@font-face {
  font-family: "BatHoangInk";
  src: url("/assets/ui/thuy-mac/NotoSerif-Regular.ttf") format("truetype");
  font-display: swap;
}
@font-face {
  font-family: "BatHoangThuPhap";
  src: url("/assets/fonts/BatHoangThuPhap.woff2") format("woff2");
  font-style: normal;
  font-weight: 400 900;
  font-display: swap;
}

:root {
  --ink: #1e2723;
  --ink-muted: #525d55;
  --paper: #efe6d2;
  --paper-bright: #f7f0df;
  --paper-card: rgba(244, 237, 221, 0.94);
  --jade: #2c5749;
  --seal: #8f2d24;
  --gold: #9a7432;
  --slate-blue: #365666;
  --line: #8f846e;
  --lacquer: #162421;
  --timber: #5c4632;
  --slate-tile: #4f5d57;
  --mystic: #6e446b;
  --lantern: #e0822d;
  --font-main: "BatHoangInk", "Noto Serif", Georgia, serif;
}

* { box-sizing: border-box; user-select: none; }
::-webkit-scrollbar { width: 7px; height: 7px; }
::-webkit-scrollbar-track { background: #e4dac2; border-radius: 4px; }
::-webkit-scrollbar-thumb { background: #8f846e; border-radius: 4px; border: 1px solid #efe6d2; }
::-webkit-scrollbar-thumb:hover { background: #5c5342; }

html, body {
  margin: 0; padding: 0; width: 100%; height: 100%; overflow: hidden;
  background: #d8d1be; font-family: var(--font-main); color: var(--ink);
}

#world-canvas {
  display: block; width: 100vw; height: 100vh; cursor: crosshair;
}

.hidden { display: none !important; }

.bh-card {
  background: var(--paper-card) url("/assets/ui/thuy-mac/giay-do.png") center/cover;
  border: 1.5px solid #6e6757;
  border-radius: 4px;
  box-shadow: 0 8px 24px rgba(20, 24, 20, 0.34), inset 0 0 0 2px rgba(252, 247, 233, 0.80), inset 0 0 0 3px rgba(130, 120, 98, 0.35);
  pointer-events: auto;
}

.bh-panel {
  position: relative;
  background: var(--paper) url("/assets/ui/thuy-mac/giay-do.png") center/cover;
  border: 2px solid #5c5342;
  border-radius: 4px;
  box-shadow: 0 22px 54px rgba(16, 22, 18, 0.65), inset 0 0 0 5px #f8f2e2, inset 0 0 0 7px #8e836d;
}

.bh-btn {
  font-family: var(--font-main); color: var(--ink); font-size: 13px; font-weight: 600;
  background: linear-gradient(180deg, #fbf6ea 0%, #ebe0c6 100%);
  border: 1.5px solid #8a7b5d; border-radius: 4px; padding: 6px 12px; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 5px;
  line-height: 1.25; box-shadow: inset 0 1px 0 rgba(255, 253, 246, 0.9), 0 1px 2px rgba(20, 24, 20, 0.14);
  text-shadow: 0 1px 0 rgba(255, 250, 236, 0.75);
  transition: filter 0.14s ease, transform 0.1s ease;
}
.bh-btn:hover { filter: brightness(0.96) drop-shadow(0 2px 4px rgba(143, 45, 36, 0.25)); }
.bh-btn:active { transform: translateY(1px); }
.bh-btn:disabled { opacity: 0.55; cursor: not-allowed; }
.bh-btn img { width: 15px; height: 15px; object-fit: contain; flex-shrink: 0; }
.bh-btn.primary {
  background: linear-gradient(180deg, #356b59 0%, #22473b 100%);
  color: #fbf6e8; border-color: #163329; text-shadow: 0 1px 1px rgba(0, 0, 0, 0.5);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.16), 0 1px 3px rgba(20, 24, 20, 0.24);
}
.bh-btn.seal {
  background: linear-gradient(180deg, #a6372d 0%, #7c2018 100%);
  color: #fff8eb; border-color: #54140e; text-shadow: 0 1px 1px rgba(0, 0, 0, 0.5);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.16), 0 1px 3px rgba(20, 24, 20, 0.24);
}
.bh-btn.gold { background: linear-gradient(180deg, #f8e9c1 0%, #e1c685 100%); color: #4d300a; border-color: #9a7432; text-shadow: none; }
.bh-btn.mini { background: linear-gradient(180deg, #fbf6ea 0%, #ede3ca 100%); padding: 4px 9px; font-size: 11px; line-height: 1.25; border: 1.5px solid #968769; min-height: 24px; max-width: 100%; white-space: normal; text-align: center; }
.bh-btn.mini.seal { background: linear-gradient(180deg, #a6372d 0%, #7c2018 100%); color: #fff8eb; border-color: #54140e; text-shadow: 0 1px 1px rgba(0, 0, 0, 0.5); }
.bh-btn.mini.primary { background: linear-gradient(180deg, #356b59 0%, #22473b 100%); color: #fbf6e8; border-color: #163329; text-shadow: 0 1px 1px rgba(0, 0, 0, 0.5); }
.bh-btn.mini.gold { background: linear-gradient(180deg, #f8e9c1 0%, #e1c685 100%); color: #4d300a; border-color: #9a7432; text-shadow: none; }
.bh-btn.small { padding: 5px 11px; font-size: 12px; line-height: 1.25; }
.bh-btn.large { padding: 11px 20px; font-size: 15px; width: 100%; }

.bh-overlay {
  position: fixed; inset: 0; z-index: 40;
  background:
    radial-gradient(ellipse at 50% 25%, rgba(62, 74, 68, 0.45), rgba(18, 24, 21, 0.86)),
    linear-gradient(180deg, rgba(44, 54, 49, 0.72) 0%, rgba(22, 28, 25, 0.90) 100%);
  backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center; padding: 16px;
}
#screen-create.bh-overlay {
  background:
    radial-gradient(ellipse at 50% 35%, rgba(239, 230, 210, 0.22), rgba(24, 31, 27, 0.58)),
    url("/assets/ui/thuy-mac/nen-dang-nhap-son-thuy.webp") center/cover no-repeat;
}

/* ---- CHARACTER CREATION SCREEN (THỦY MẶC CỔ PHONG) ---- */
.create-box { width: min(1140px, 96vw); max-height: 92vh; overflow-y: auto; padding: 22px 26px; }
.create-header { display: flex; align-items: center; gap: 14px; border-bottom: 2px solid #8f846e; padding-bottom: 12px; margin-bottom: 16px; }
.seal-stamp {
  width: 54px; height: 54px; border: 2.5px solid var(--seal); border-radius: 3px; color: var(--seal);
  display: flex; align-items: center; justify-content: center; text-align: center; font-weight: 700; font-size: 15px; line-height: 1.15;
  background: radial-gradient(circle, rgba(143, 45, 36, 0.14), rgba(143, 45, 36, 0.04));
  box-shadow: inset 0 0 0 1px rgba(143, 45, 36, 0.4);
  transform: rotate(-2deg);
}
.create-header h1 { margin: 0; font-size: 25px; letter-spacing: 0.06em; color: var(--ink); text-shadow: 0 1px 0 #fffaf0; }
.subtitle { margin: 2px 0 0; font-size: 12.5px; color: var(--ink-muted); letter-spacing: 0.02em; }

.create-grid { display: grid; grid-template-columns: 1.05fr 1.15fr 1fr; gap: 16px; }
.create-col { background: rgba(250, 244, 230, 0.72); border: 1.5px solid #968b74; border-radius: 4px; padding: 12px; display: flex; flex-direction: column; gap: 10px; box-shadow: inset 0 0 12px rgba(140, 125, 96, 0.14); }
.create-col h3 { margin: 0; font-size: 14px; border-bottom: 1px dashed #9d927b; padding-bottom: 6px; color: var(--seal); letter-spacing: 0.02em; }
.col-head-flex { display: flex; justify-content: space-between; align-items: center; border-bottom: 1px dashed #9d927b; padding-bottom: 6px; }
.col-head-flex h3 { border: 0; padding: 0; }

.hero-preview-row { display: flex; gap: 10px; align-items: flex-start; }
#create-preview { background: radial-gradient(circle, #f6f0e1, #d8cfba); border: 1.5px solid #7d735f; border-radius: 4px; flex-shrink: 0; }
.hero-list { display: grid; grid-template-columns: repeat(2, 1fr); gap: 4px; max-height: 150px; overflow-y: auto; flex: 1; }
.hero-chip {
  font-size: 11px; padding: 4px 6px; border: 1px solid #9b9079; background: #f8f2e2; border-radius: 3px; cursor: pointer; text-align: left; color: var(--ink);
}
.hero-chip.active { background: #d2dece; border-color: var(--jade); font-weight: 700; color: #16382b; box-shadow: inset 2px 0 var(--seal); }

.field-row label { display: block; font-size: 12px; color: var(--ink-muted); margin-bottom: 6px; }
.field-row input {
  width: 100%; margin-top: 3px; padding: 7px 9px; font-family: var(--font-main); font-size: 13px;
  background: #fbf6ea; color: var(--ink); border: 1.5px solid #8a7f69; border-radius: 3px;
}

.school-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px; max-height: 295px; overflow-y: auto; }
.school-card {
  display: flex; align-items: center; gap: 8px; padding: 6px; border: 1px solid #9b9079;
  background: #f8f2e2; border-radius: 3px; cursor: pointer; text-align: left; color: var(--ink);
}
.school-card.active { background: #d4e0cf; border-color: var(--jade); box-shadow: inset 3px 0 var(--seal); }
.school-card img { width: 30px; height: 30px; object-fit: contain; flex-shrink: 0; }
.school-card b { display: block; font-size: 12px; }
.school-card small { font-size: 10px; color: var(--ink-muted); }

.destiny-list { display: flex; flex-direction: column; gap: 8px; flex: 1; }
.destiny-card { padding: 8px 10px; border: 1px solid #9c917a; border-left: 3px solid var(--gold); background: #f8f2e2; border-radius: 3px; }
.destiny-card b { font-size: 12.5px; color: var(--seal); }
.destiny-card p { margin: 2px 0 0; font-size: 11px; color: var(--ink-muted); }
.create-actions { display: flex; flex-direction: column; gap: 8px; margin-top: auto; }

/* ---- LIVE HUD (THỦY MẶC CỔ PHONG) ---- */
#hud-layer { position: fixed; inset: 0; z-index: 10; pointer-events: none; }

#hud-left-col { position: absolute; left: 10px; top: 10px; width: 262px; display: flex; flex-direction: column; gap: 6px; pointer-events: none; z-index: 4; }
#hud-left-col > * { pointer-events: auto; }
#hud-profile { position: relative; width: 100%; padding: 12px 13px 14px; background: url("/assets/ui/thuy-mac/hud_char_panel_bg.png") center/100% 100% no-repeat; border: none; box-shadow: 0 8px 24px rgba(20, 24, 20, 0.34); }
.prof-top { display: flex; align-items: center; gap: 8px; margin-bottom: 7px; }
.hud-avatar-wrap { position: relative; width: 56px; height: 56px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.hud-avatar-wrap::after { content: ""; position: absolute; inset: -3px; background: url("/assets/ui/thuy-mac/hud_avatar_frame.png") center/100% 100% no-repeat; pointer-events: none; z-index: 2; }
#hud-avatar { border: none; border-radius: 6px; background: #e3dac4; flex-shrink: 0; }
.prof-info { flex: 1; min-width: 0; }
.prof-name-row { display: flex; flex-direction: column; align-items: flex-start; gap: 3px; }
.prof-name-row strong { font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.prof-meta-row { display: flex; align-items: center; gap: 5px; flex-wrap: wrap; }
.realm-tag { font-size: 10px; background: url("/assets/ui/thuy-mac/hud_realm_badge.png") center/100% 100% no-repeat; border: none; color: #3b2611; font-weight: 700; padding: 2px 10px; border-radius: 3px; white-space: nowrap; }
.prof-sub { font-size: 11px; color: var(--ink-muted); }
.stone-pill { font-size: 11px; font-weight: 700; color: var(--seal); background: #ece3cc; border: 1px solid #a19273; padding: 2px 6px; border-radius: 3px; }

.stat-bars { display: flex; flex-direction: column; gap: 4px; }
.sbar { position: relative; height: 15px; background: rgba(24, 30, 26, 0.34); border: none; border-radius: 2px; overflow: hidden; }
.sbar::after { content: ""; position: absolute; inset: 0; background: url("/assets/ui/thuy-mac/hud_bar_frame.png") center/100% 100% no-repeat; pointer-events: none; z-index: 2; }
.sfill { height: 100%; width: 100%; transition: width 0.15s; }
.sfill.hp { background: url("/assets/ui/thuy-mac/hud_bar_hp_fill.png") center/100% 100% no-repeat; }
.sfill.mp { background: url("/assets/ui/thuy-mac/hud_bar_mp_fill.png") center/100% 100% no-repeat; }
.sfill.exp { background: url("/assets/ui/thuy-mac/hud_bar_exp_fill.png") center/100% 100% no-repeat; }
.sbar span { position: absolute; inset: 0; z-index: 3; text-align: center; font-size: 10px; line-height: 15px; color: #fcf8eb; text-shadow: 0 1px 2px #161c18; }
.prof-quick-row { display: flex; gap: 6px; margin-top: 7px; }
.prof-quick-row button { flex: 1; }

#hud-squad { position: relative; width: 100%; padding: 11px 12px; background: url("/assets/ui/thuy-mac/hud_squad_card_bg.png") center/100% 100% no-repeat; border: none; }
.squad-head { display: flex; justify-content: space-between; font-size: 11.5px; font-weight: 700; margin-bottom: 6px; border-bottom: 1px solid #bcc3b1; padding-bottom: 3px; }
.squad-slots { display: flex; flex-direction: column; gap: 4px; }
.sq-row { display: flex; align-items: center; gap: 6px; padding: 3px 5px; background: rgba(255,252,243,0.72); border: 1px solid #b5bda9; border-radius: 3px; font-size: 11px; cursor: pointer; }
.sq-row.empty { opacity: 0.55; justify-content: center; border-style: dashed; }
.sq-row img { width: 22px; height: 22px; object-fit: cover; border-radius: 2px; }
.sq-meta { flex: 1; min-width: 0; }
.sq-hp { height: 4px; background: #cfd5c6; margin-top: 2px; }
.sq-hp > i { display: block; height: 100%; background: #4f8564; }

#hud-calendar { position: absolute; top: 10px; left: 50%; transform: translateX(-50%); max-width: min(640px, calc(100vw - 505px)); min-width: 240px; padding: 10px 18px; display: flex; flex-direction: column; align-items: center; gap: 4px; z-index: 5; background: url("/assets/ui/thuy-mac/panel_calendar_plaque.png") center/100% 100% no-repeat; border: none; }
.cal-main { display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 3px 6px; font-size: 11px; max-width: 100%; }
#hud-region { max-width: 240px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: inline-block; }
.cal-date { font-weight: 700; color: var(--seal); flex-shrink: 0; }
.cal-sep { color: #a7b09d; flex-shrink: 0; }
.cal-btns { display: flex; gap: 4px; flex-wrap: wrap; justify-content: center; }
.cal-more-menu { display: flex; flex-wrap: wrap; gap: 5px; justify-content: center; margin-top: 4px; padding: 6px 8px; background: rgba(247, 240, 223, 0.97); border: 1.5px solid #8a7f6a; border-radius: 5px; box-shadow: 0 6px 16px rgba(18, 24, 20, 0.25); width: 100%; }
.cal-more-menu.hidden { display: none; }
.hud-goal-pill { font-family: var(--font-main); font-size: 10.5px; font-weight: 700; color: #5c3a14; background: linear-gradient(90deg, #f8edd1, #efe0b8); border: 1px solid #b59454; border-radius: 4px; padding: 2px 9px; cursor: pointer; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; transition: background 0.14s, border-color 0.14s; }
.hud-goal-pill:hover { border-color: var(--seal); background: #fff4d6; }
.hud-goal-pill.ready { color: #1b4332; background: linear-gradient(90deg, #dcefe2, #c7e4d0); border-color: #2e6b4f; }
.hud-goal-pill.hidden { display: none; }

#hud-minimap-box { position: absolute; right: 10px; top: 10px; width: 212px; padding: 11px 11px 13px; background: url("/assets/ui/thuy-mac/panel_minimap_frame.png") center/100% 100% no-repeat; border: none; }
.mini-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 4px; font-size: 11px; font-weight: 700; }
#mini-canvas { display: block; width: 100%; height: 136px; border: 1px solid #7d897b; background: #d4dccb; }
.sys-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 5px; margin-top: 7px; }
.bh-btn.sys { padding: 5px 6px; font-size: 11px; justify-content: flex-start; }
.bh-btn.sys img { width: 16px; height: 16px; object-fit: contain; }
.hud-right-dock { position: absolute; right: 8px; top: 214px; z-index: 15; display: flex; flex-direction: column; align-items: center; gap: 4px; pointer-events: auto; }
.right-dock-toggle { padding: 3px 8px; font-size: 10.5px; font-weight: 700; border-radius: 999px; background: rgba(24, 30, 26, 0.62) !important; border: 1px solid rgba(251, 246, 232, 0.45) !important; color: #fbf6e8 !important; text-shadow: 0 1px 2px rgba(0,0,0,0.85) !important; box-shadow: 0 2px 6px rgba(0,0,0,0.28) !important; white-space: nowrap; }
.right-dock-list { display: flex; flex-direction: column; gap: 6px; align-items: center; width: 66px; padding: 2px 0; background: none !important; border: none !important; box-shadow: none !important; max-height: calc(100vh - 280px); overflow-y: auto; scrollbar-width: none; }
.right-dock-list::-webkit-scrollbar { display: none; }
.hud-right-dock.sys-collapsed .right-dock-list { display: none; }
.bh-btn.dock-item { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; width: 64px; padding: 2px 2px; background: none !important; border: none !important; box-shadow: none !important; border-radius: 0; text-align: center; }
.bh-btn.dock-item:hover { filter: brightness(1.12); transform: scale(1.04); }
.bh-btn.dock-item img { width: 30px; height: 30px; object-fit: contain; flex-shrink: 0; filter: drop-shadow(0 2px 4px rgba(10, 14, 12, 0.72)); }
.bh-btn.dock-item span { font-size: 10.5px; font-weight: 700; line-height: 1.15; color: #fff8e8; white-space: nowrap; text-shadow: 0 1px 3px rgba(12, 16, 14, 0.96), 0 0 4px rgba(12, 16, 14, 0.9), 1px 0 2px rgba(12, 16, 14, 0.85), -1px 0 2px rgba(12, 16, 14, 0.85); }
.bh-btn.dock-item .hk { display: none; }
.bh-btn.dock-item.has-notif::after { top: 0; right: 10px; }
.placement-bar { position: absolute; top: 138px; left: 50%; transform: translateX(-50%); z-index: 18; display: flex; align-items: center; gap: 8px; padding: 8px 14px; background: rgba(247, 240, 223, 0.96); border: 2px solid var(--seal); border-radius: 6px; box-shadow: 0 8px 22px rgba(18, 24, 20, 0.34); font-size: 12px; font-weight: 700; pointer-events: auto; max-width: 90vw; flex-wrap: wrap; justify-content: center; }
.placement-bar.hidden { display: none; }

#arena-hud { position: absolute; top: 96px; left: 50%; transform: translateX(-50%); padding: 6px 14px; display: flex; align-items: center; gap: 12px; border: 2px solid var(--seal); z-index: 14; }
.arena-score { font-weight: 700; font-size: 13px; color: var(--seal); }

#hud-log { position: absolute; left: 14px; bottom: 14px; width: 274px; padding: 11px 13px; background: url("/assets/ui/thuy-mac/panel_quest_log_bg.png") center/100% 100% no-repeat; border: none; }
.log-feed { height: 96px; overflow-y: auto; font-size: 11px; line-height: 1.45; display: flex; flex-direction: column; gap: 3px; padding-right: 4px; }
.log-line.imp { color: var(--seal); font-weight: 600; }
.log-line.chat { color: #1c4e6b; }
.chat-row { display: flex; gap: 5px; margin-top: 6px; }
.chat-row input { flex: 1; min-width: 0; font-family: var(--font-main); font-size: 11px; padding: 4px 6px; background: #fffdf6; border: 1px solid #9da692; border-radius: 3px; }

#hud-skills { position: absolute; bottom: 12px; left: 50%; transform: translateX(-50%); padding: 5px 7px; display: flex; gap: 4px; max-width: 98vw; overflow-x: auto; z-index: 6; }
.skill-slot {
  position: relative; width: 58px; height: 54px; padding: 4px 4px; border: none;
  background: rgba(250, 246, 234, 0.78) url("/assets/ui/thuy-mac/slot_skill_frame.png") center/100% 100% no-repeat;
  border-radius: 4px; cursor: pointer; display: flex; flex-direction: column; align-items: center; justify-content: space-between; overflow: hidden; flex-shrink: 0;
}
.skill-slot.basic { width: 62px; }
.skill-slot.act-slot img { width: 22px; height: 22px; object-fit: contain; border-radius: 2px; background: rgba(25,30,28,0.08); }
.skill-slot.syn-active { box-shadow: 0 0 8px rgba(212, 160, 23, 0.72); }
.skill-slot:hover { filter: brightness(0.95); }
.skey { font-size: 9px; color: var(--ink-muted); font-weight: 700; align-self: flex-start; line-height: 1; }
.sinfo { position: absolute; right: 2px; top: 1px; font-size: 9.5px; line-height: 1; color: #3c6e5c; opacity: 0.72; padding: 1px 2px; border-radius: 3px; cursor: help; }
.sinfo:hover { opacity: 1; background: rgba(60,110,92,0.18); }
.skill-slot strong { font-size: 9.5px; line-height: 1.05; width: 100%; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.scd {
  position: absolute; inset: 0; background: rgba(30, 44, 38, 0.72); color: #fff;
  display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 13px;
}
.scd:empty { display: none; }

/* ---- MODAL WINDOWS ---- */
.modal-window { width: min(1040px, 95vw); max-height: 92vh; display: flex; flex-direction: column; padding: 66px 70px 58px; overflow: hidden; background: url("/assets/ui/thuy-mac/panel_scroll_modal.png") center/100% 100% no-repeat; border: none; box-shadow: 0 22px 54px rgba(16, 22, 18, 0.65); }
.modal-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; border-bottom: 1.5px solid #96896e; padding: 2px 4px 8px; flex-shrink: 0; }
.modal-head h2 { margin: 0; font-size: 18px; line-height: 1.25; color: #241911; text-shadow: 0 1px 0 rgba(255, 250, 236, 0.92); min-width: 0; overflow-wrap: anywhere; }
.close-x { padding: 4px; width: 34px; height: 34px; flex-shrink: 0; background: url("/assets/ui/thuy-mac/btn_circle_seal.png") center/100% 100% no-repeat !important; border: none !important; box-shadow: none !important; }
.close-x img { width: 16px; height: 16px; }

.modal-tabs { display: flex; gap: 6px; padding: 8px 2px; border-bottom: 1.5px solid #b5aa91; flex-wrap: wrap; flex-shrink: 0; }
.mtab { padding: 6px 11px; min-height: 30px; line-height: 1.2; font-size: 12px; font-weight: 700; color: #261d14; background: linear-gradient(180deg, #faf4e6 0%, #eae0c9 100%); border: 1.5px solid #8f8064; border-radius: 4px; text-shadow: none; white-space: nowrap; }
.mtab.active { background: linear-gradient(180deg, #9d352b 0%, #782018 100%); border-color: #54140e; color: #fff8eb; filter: none; box-shadow: 0 2px 6px rgba(143, 45, 36, 0.30); }

.modal-body { flex: 1; min-height: 0; overflow-y: auto; overflow-x: hidden; padding: 10px 6px 4px; }
.modal-body select, .modal-body input { max-width: 100%; font-family: var(--font-main); }

.grid-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; }
.danger-pill { display: inline-block; max-width: 100%; font-size: 10.5px; font-weight: 700; line-height: 1.3; padding: 2px 7px; border-radius: 3px; border: 1px solid #968b74; background: #e6f3ec; color: #2d6a4f; overflow-wrap: anywhere; }
.sub-card { background: rgba(255, 252, 244, 0.84); border: 1.5px solid #abb4a1; border-radius: 5px; padding: 9px 10px; display: flex; flex-direction: column; gap: 5px; min-width: 0; overflow-wrap: anywhere; word-break: break-word; }
.sub-card > .tier-pill, .sub-card > .danger-pill, .sub-card > .destiny-tier { align-self: flex-start; }
.sc-line { display: block; line-height: 1.38; font-size: 12px; }
.npc-card-head { display: flex; gap: 10px; align-items: flex-start; min-width: 0; }
.npc-card-head > div { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.npc-card-head img { width: 46px; height: 68px; object-fit: contain; background: #dfe5d7; border: 1px solid #9aa491; border-radius: 3px; image-rendering: high-quality; }
.wp-icon { width: 48px; height: 48px; object-fit: contain; background: #e3e8da; border: 1px solid #9aa491; border-radius: 4px; image-rendering: high-quality; }
.btn-row { display: flex; gap: 5px; flex-wrap: wrap; margin-top: auto; }
.atlas-wrap { display: flex; gap: 14px; flex-wrap: wrap; align-items: flex-start; }
#atlas-canvas { border: 2px solid #6e7b6d; background: #d6ded0; cursor: pointer; width: 500px; height: 500px; max-width: 100%; image-rendering: high-quality; }
.atlas-sidebar { flex: 1; min-width: 260px; display: flex; flex-direction: column; gap: 8px; max-height: 510px; overflow-y: auto; }
.atlas-sidebar > * { flex-shrink: 0; }
.bh-btn.pk-on { background: #8f2222; color: #fff4e8; border-color: #5c1414; }
.tier-pill { display: inline-block; max-width: 100%; font-size: 10.5px; line-height: 1.3; padding: 2px 6px; border-radius: 3px; background: #ede6cf; border: 1px solid #b4a474; color: #5c4010; font-weight: 700; overflow-wrap: anywhere; }
.eq-bar { display: grid; grid-template-columns: repeat(auto-fit, minmax(175px, 1fr)); gap: 8px; margin-bottom: 12px; }
.bag-list { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 3px; }
.bag-tag { font-size: 10px; padding: 1px 4px; background: #eef1e4; border: 1px solid #b2bba6; border-radius: 2px; }
.slot-bar { display: flex; gap: 6px; margin-top: 4px; }
.slot-bar .bh-btn { flex: 1; }
#hud-quest-box { position: relative; width: 100%; padding: 11px 13px; background: url("/assets/ui/thuy-mac/panel_quest_log_bg.png") center/100% 100% no-repeat; border: none; }
.guide-tip { margin-top: 6px; padding: 6px; background: #faf5e2; border: 1px dashed #9d8b55; border-radius: 3px; font-size: 10px; line-height: 1.35; }
.rw-card { border: 2px solid #993b32; background: linear-gradient(180deg, #fbf4ea, #f2e5d4); padding: 12px; border-radius: 5px; display: flex; flex-direction: column; gap: 6px; }
.bh-btn.seal-btn { background: #eadbc6; border-color: #9b513f; color: #5c1914; font-weight: 700; }
.syn-banner { padding: 8px 10px; background: linear-gradient(90deg, #f6eed8, #efe4c8); border: 1px solid #b88c38; border-radius: 4px; margin-bottom: 10px; font-size: 12px; }
.skill-icon-sm { width: 34px; height: 34px; object-fit: contain; border-radius: 4px; background: #1e2422; padding: 2px; flex-shrink: 0; }

/* V6 & V7 Clean 2-Column Skills, Bag (10 Slots + Sets + Hoan My) & Inspector */
.skills-shell, .bag-shell { display: grid; grid-template-columns: minmax(0, 1fr) 295px; gap: 12px; align-items: start; }
.skills-main, .bag-main { min-width: 0; display: flex; flex-direction: column; gap: 10px; }
.skills-inspector {
  background: linear-gradient(180deg, #faf5e8, #f2ead7); border: 2px solid #8c7a5b;
  border-radius: 6px; padding: 11px; position: sticky; top: 0; display: flex; flex-direction: column; gap: 8px;
  min-width: 0; max-width: 100%; overflow-wrap: anywhere; word-break: break-word;
}
.eq10-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 6px; }
.eq10-slot {
  display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 6px 4px; text-align: center;
  border-radius: 5px; background: rgba(255,253,246,0.9); border: 2px solid #9aa491; cursor: pointer; min-height: 76px;
}
.eq10-slot:hover { background: #ecf4e9; }
.eq10-slot img { width: 38px; height: 38px; object-fit: contain; border-radius: 4px; background: #1e2422; image-rendering: high-quality; }
.eq10-slot .eq-slot-lbl { font-size: 9px; font-weight: 700; color: #475569; text-transform: uppercase; }
.eq10-slot .eq-item-nm { font-size: 9.5px; font-weight: 700; width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.eq10-slot.perfected, .item-tile.perfected { box-shadow: 0 0 8px rgba(245, 158, 11, 0.72); background: linear-gradient(180deg, #fffbeb, #fef3c7); }
.item-tile {
  position: relative; display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 7px 5px;
  border-radius: 5px; background: rgba(255,253,246,0.88) url("/assets/ui/thuy-mac/slot_item_frame.png") center/100% 100% no-repeat; border: none; cursor: pointer; text-align: center;
}
.item-tile:hover { background: #ecf4e9; }
.item-tile.inspected, .eq10-slot.inspected { box-shadow: 0 0 0 2px #993b32; }
.item-tile img { width: 42px; height: 42px; object-fit: contain; border-radius: 4px; background: #18201d; image-rendering: high-quality; }
.item-tile small { font-size: 9.5px; line-height: 1.15; width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 700; }
.it-qty { position: absolute; bottom: 20px; right: 4px; background: rgba(15,23,42,0.85); color: #fff; font-size: 9px; padding: 0 4px; border-radius: 3px; }
.hm-badge { position: absolute; top: 2px; left: 3px; font-size: 9px; color: #d97706; font-weight: 700; }
.set-chip { display: inline-block; padding: 2px 6px; border-radius: 4px; font-size: 10.5px; font-weight: 700; border: 1px solid #b4a474; background: #faf5e2; margin: 2px 4px 2px 0; }
.sk-subtabs { display: flex; gap: 6px; flex-wrap: wrap; border-bottom: 1px solid #c5bca7; padding-bottom: 8px; }
.sk-slots-strip { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
.sk-equip-box {
  display: flex; align-items: center; gap: 6px; padding: 6px; border-radius: 5px; background: #fffdf6;
  border: 2px solid #aeb5a2; cursor: pointer; transition: transform 0.08s;
}
.sk-equip-box:hover { transform: translateY(-1px); background: #f3f7ef; }
.sk-equip-box.active-sel { box-shadow: 0 0 0 2px #993b32; }
.skill-icon-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(74px, 1fr)); gap: 7px; }
.skill-tile {
  position: relative; display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 6px 4px;
  border-radius: 5px; background: rgba(255,253,246,0.9); border: 2px solid #9aa491; cursor: pointer; text-align: center;
}
.skill-tile:hover { background: #ecf4e9; }
.skill-tile.inspected { box-shadow: 0 0 0 2px #993b32; background: #fdf1e6; }
.skill-tile.locked { opacity: 0.62; }
.skill-tile img { width: 44px; height: 44px; border-radius: 5px; background: #18201d; object-fit: contain; image-rendering: high-quality; }
.skill-tile small { font-size: 9.5px; line-height: 1.15; width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 700; }
.sk-badge-lock { position: absolute; top: 2px; right: 3px; font-size: 9px; }
.sk-stat-kv { display: grid; grid-template-columns: repeat(2, 1fr); gap: 4px; font-size: 11px; background: rgba(255,255,255,0.68); padding: 7px; border-radius: 4px; border: 1px solid #c9bfa9; }

/* V6 Quy Coc Bát Hoang NPC Character Sheet Modal */
.npc-qc-shell { display: grid; grid-template-columns: 270px 1fr; gap: 14px; align-items: start; }
.npc-qc-left {
  background: linear-gradient(180deg, #faf4e6, #eee4ce); border: 2px solid #8a785c;
  border-radius: 6px; padding: 12px; display: flex; flex-direction: column; gap: 8px;
}
.npc-qc-portrait { width: 84px; height: 116px; object-fit: contain; background: #dce4d6; border: 2px solid #7d8a7a; border-radius: 5px; margin: 0 auto; display: block; }
.npc-qc-stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 5px; font-size: 11px; background: rgba(255,255,255,0.7); padding: 7px; border-radius: 4px; border: 1px solid #c5baa4; }
.lineage-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(175px, 1fr)); gap: 6px; margin-top: 4px; }
.lineage-node { background: #fffcf3; border: 1px solid #b4a474; border-radius: 5px; padding: 6px; cursor: pointer; display: flex; flex-direction: column; gap: 2px; font-size: 11px; }
.lineage-node:hover { background: #f3ecda; border-color: #993b32; }
.aff-bar { height: 10px; background: #dad5c5; border-radius: 5px; overflow: hidden; border: 1px solid #a29a84; }
.aff-bar > i { display: block; height: 100%; transition: width 0.2s; }
.npc-qc-right { min-width: 0; display: flex; flex-direction: column; gap: 8px; }

@media (max-width: 1020px), (hover: none) and (pointer: coarse) {
  .skills-shell, .bag-shell, .npc-qc-shell { grid-template-columns: minmax(0, 1fr); }
  .skills-inspector { position: static; }
  .sk-slots-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .eq10-grid { grid-template-columns: repeat(5, minmax(0, 1fr)); }
}
.touch-joystick { display: none; position: fixed; left: 26px; bottom: 28px; z-index: 20; pointer-events: auto; touch-action: none; }
.joy-ring { position: relative; width: 200px; height: 200px; border-radius: 50%; border: none; background: none; display: flex; align-items: center; justify-content: center; }
.joy-ring::before { content: ""; position: absolute; inset: 0; background: url("/assets/ui/thuy-mac/joy_base_bagua.png") center/100% 100% no-repeat; opacity: 0.6845; pointer-events: none; transition: opacity 0.12s ease; }
.touch-joystick.active-float .joy-ring::before { opacity: 0.94; }
.joy-knob { position: relative; z-index: 2; width: 84px; height: 84px; border-radius: 50%; border: none; background: url("/assets/ui/thuy-mac/joy_knob_jade.png") center/100% 100% no-repeat; opacity: 1; box-shadow: 0 3px 10px rgba(0, 0, 0, 0.38); pointer-events: none; transition: transform 0.04s linear; }
.touch-action-pad { display: none; position: fixed; right: 20px; bottom: 22px; z-index: 20; flex-direction: column; align-items: flex-end; gap: 8px; pointer-events: auto; touch-action: none; -webkit-user-select: none; user-select: none; }
.touch-action-pad button { touch-action: none; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; -webkit-tap-highlight-color: transparent; }
.tap-utils { display: flex; flex-wrap: wrap; max-width: 440px; gap: 7px; justify-content: flex-end; margin-bottom: 2px; }
.tap-mini { padding: 10px 16px; font-size: 16px; font-weight: 700; border-radius: 6px; border: none; background: url("/assets/ui/thuy-mac/btn_util_pill_bg.png") center/100% 100% no-repeat; color: #241d15; cursor: pointer; filter: drop-shadow(0 2px 5px rgba(0,0,0,0.28)); white-space: nowrap; }
.tap-combat { position: relative; width: 396px; height: 390px; display: block; }
.tap-skills-4 { display: contents; }
.tap-sk { position: absolute; width: 104px; height: 104px; border-radius: 50%; border: none; background: rgba(250, 245, 232, 0.32) url("/assets/ui/thuy-mac/btn_skill_circle_bg.png") center/100% 100% no-repeat; padding: 6px; display: flex; align-items: center; justify-content: center; overflow: hidden; cursor: pointer; filter: drop-shadow(0 4px 10px rgba(0,0,0,0.36)); transition: opacity 0.12s, transform 0.1s; }
.tap-sk:active, .tap-atk:active, .tap-atk.is-pressed, .tap-sk-page:active, .tap-mini:active { transform: scale(0.92); }
.tap-atk.is-pressed { filter: drop-shadow(0 4px 14px rgba(175, 45, 36, 0.85)) brightness(1.08); }
.tap-sk.is-empty { opacity: 0.48; }
.tap-sk.is-empty::after { content: "+"; font-size: 32px; font-weight: 700; color: #5c4d3c; }
.tap-sk-page { position: absolute; right: 192px; bottom: 10px; z-index: 3; width: 54px; height: 54px; border-radius: 50%; border: none; background: rgba(247, 240, 223, 0.78) url("/assets/ui/thuy-mac/btn_skill_circle_bg.png") center/100% 100% no-repeat; color: #2b2218; font-size: 24px; font-weight: 700; line-height: 1; display: flex; align-items: center; justify-content: center; cursor: pointer; filter: drop-shadow(0 3px 8px rgba(0,0,0,0.34)); transition: transform 0.1s, filter 0.15s; }
.tap-sk-page.is-page2 { color: #8f2d24; filter: drop-shadow(0 3px 9px rgba(143, 45, 36, 0.52)); }
#mob-sk-0 { right: 270px; bottom: 40px; }
#mob-sk-1 { right: 236px; bottom: 155px; }
#mob-sk-2 { right: 151px; bottom: 238px; }
#mob-sk-3 { right: 36px; bottom: 270px; }
.tap-sk img { width: 66px; height: 66px; object-fit: contain; border-radius: 50%; pointer-events: none; }
.tap-sk span { position: absolute; bottom: 4px; right: 8px; font-size: 16px; font-weight: 700; color: #1b211d; background: rgba(247,240,223,0.92); padding: 0 6px; border-radius: 5px; pointer-events: none; }
.tap-atk { position: absolute; right: 8px; bottom: 8px; z-index: 3; width: 152px; height: 152px; border-radius: 50%; border: none; background: url("/assets/ui/thuy-mac/btn_atk_seal.png") center/100% 100% no-repeat; color: #fbf4e4; font-weight: 700; font-size: 26px; text-shadow: 0 1px 4px rgba(0,0,0,0.85); cursor: pointer; filter: drop-shadow(0 6px 15px rgba(20, 12, 10, 0.50)); }
#world-canvas { touch-action: none; }
.mob-only-toggle { display: none !important; }
#hud-minimap-box.sys-collapsed .mini-zoom-row { display: none; }
html.bh-mobile-desktop .hk { display: none; }

@media (max-width: 1020px), (hover: none) and (pointer: coarse) {
  .create-grid { grid-template-columns: 1fr; }
  .mob-only-toggle { display: inline-flex !important; }
  .hk { display: none; }
  #hud-left-col { top: 6px; left: 6px; width: 272px; gap: 4px; }
  #hud-profile { padding: 18px 18px 20px; max-width: none; }
  .hud-avatar-wrap { width: 48px; height: 48px; }
  #hud-avatar { width: 44px !important; height: 44px !important; }
  .prof-top { gap: 8px; margin-bottom: 6px; align-items: flex-start; }
  .prof-name-row strong { font-size: 13px; }
  .prof-sub { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 10.5px; }
  .stone-pill { white-space: nowrap; flex-shrink: 0; font-size: 10px; padding: 2px 6px; }
  .sbar { height: 14px; }
  .sbar span { font-size: 9.5px; line-height: 14px; }
  .prof-quick-row .bh-btn.mini { font-size: 10.5px; padding: 4px 8px; white-space: nowrap; }
  #hud-squad { display: none; }
  #hud-calendar { top: 6px; left: 284px; right: 234px; transform: none; width: auto; max-width: none; min-width: 0; padding: 23px 34px 16px; gap: 4px; }
  .cal-main { font-size: 10.5px; gap: 2px 6px; }
  #hud-region { max-width: 190px; }
  .cal-btns { flex-wrap: wrap; overflow: visible; justify-content: center; width: 100%; gap: 4px; }
  .cal-btns .bh-btn.mini { flex-shrink: 0; padding: 4px 8px; font-size: 10.5px; white-space: nowrap; }
  #hud-boss-bar { top: 142px; min-width: 310px; max-width: 48vw; }
  #hud-target-frame { top: 142px; }
  #hud-minimap-box { top: 6px; right: 6px; width: 222px; padding: 20px 16px 18px; }
  #mini-canvas { width: 100% !important; height: 88px !important; }
  .mini-head { font-size: 10px; margin-bottom: 4px; gap: 4px; }
  .mini-zoom-row { flex-wrap: nowrap; gap: 3px; }
  .mini-zoom-row .bh-btn.mini { padding: 3px 5px; font-size: 9.5px; white-space: nowrap; }
  .hud-right-dock { right: 6px; top: 180px; }
  .right-dock-toggle { font-size: 10px; padding: 3px 8px; }
  .right-dock-list { width: 64px; gap: 6px; padding: 2px 0; max-height: calc(100vh - 540px); }
  .bh-btn.dock-item { width: 62px; padding: 2px; gap: 2px; }
  .bh-btn.dock-item img { width: 30px; height: 30px; }
  .bh-btn.dock-item span { font-size: 10.5px; }
  #hud-log { display: none; z-index: 24; width: 286px; }
  #hud-log.mobile-show { display: block; bottom: 245px; left: 10px; }
  #hud-quest-box { display: none; }
  #hud-quest-box.mobile-show { display: block; max-width: none; }
  #hud-skills { display: none; }
  .touch-joystick { display: block; }
  .touch-action-pad { display: flex; }
  .modal-window { width: 97vw; max-height: 92vh; padding: 64px 62px 54px; }
}

/* V13: 2-Step Login, 9-Pick-3 Destiny Grid, Territory Arrival Banner & Combat Regen Pill */
.create-step1-shell { padding: 12px 0; }
.hero-story-preview { font-size: 11px; background: #fffdf5; border: 1px solid #b5bdab; border-left: 3px solid var(--gold); border-radius: 4px; padding: 8px; line-height: 1.4; max-height: 150px; overflow-y: auto; }
.destiny-grid-9 { display: grid; grid-template-columns: 1fr; gap: 5px; max-height: 295px; overflow-y: auto; }
.destiny-card { cursor: pointer; transition: transform 0.08s, box-shadow 0.08s; }
.destiny-grid-9 .sub-card.destiny-card.selected, .destiny-card.selected { border: 2px solid #993b32; background: #fef3c7; box-shadow: 0 2px 8px rgba(153, 59, 50, 0.25); }
.destiny-tier { display: inline-block; font-size: 9.5px; font-weight: 700; padding: 1px 5px; border-radius: 3px; color: #fff; margin-right: 4px; }
.combat-state-pill { margin-top: 5px; font-size: 10px; font-weight: 700; text-align: center; padding: 3px 6px; border-radius: 3px; background: #e3e9d8; color: #264d3b; border: 1px solid #7d967c; }
.combat-state-pill.in-combat { background: #f2deda; color: #8f2d24; border-color: #ad594e; }
.skill-slot img.tm-slot-ic { width: 18px; height: 18px; object-fit: contain; margin: 1px auto; display: block; opacity: 0.92; }
#hud-zone-banner { position: absolute; top: 88px; left: 50%; transform: translateX(-50%); padding: 13px 68px; text-align: center; border: 1.5px solid #6e6757; border-left: 5px solid var(--seal); border-right: 5px solid var(--seal); z-index: 6; background: linear-gradient(90deg, rgba(247, 240, 223, 0.72), rgba(247, 240, 223, 0.94) 16%, rgba(247, 240, 223, 0.94) 84%, rgba(247, 240, 223, 0.72)), url("/assets/ui/thuy-mac/khung-cuon-thu-ngang.png") center/100% 100% no-repeat; box-shadow: 0 10px 26px rgba(18, 24, 20, 0.36); pointer-events: auto; min-width: 300px; max-width: min(640px, 88vw); }
#hzb-title { font-family: "BatHoangThuPhap", "BatHoangInk", serif; font-size: 16.5px; font-weight: 700; color: var(--seal); text-shadow: 0 1px 0 rgba(255, 250, 236, 0.92); }
#hzb-sub { font-size: 11.5px; color: var(--ink); font-weight: 600; text-shadow: 0 1px 0 rgba(255, 250, 236, 0.85); }
h1, #hud-zone-banner, .realm-title, .boss-name { font-family: "BatHoangThuPhap", "BatHoangInk", serif; }
.thuy-mac-event-banner { display: block; width: 100%; max-height: 175px; aspect-ratio: 16 / 9; object-fit: cover; border-radius: 4px; border: 1.5px solid #8f846e; margin-bottom: 10px; box-shadow: 0 4px 12px rgba(20, 24, 20, 0.2); }
.sect-emblem-ic { width: 34px; height: 34px; object-fit: contain; flex-shrink: 0; border-radius: 4px; background: rgba(239, 230, 210, 0.65); border: 1px solid #9b9079; padding: 2px; }
.tm-modal-ic { width: 16px; height: 16px; object-fit: contain; vertical-align: -3px; margin-right: 4px; }

/* V17: Top Target Avatar Frame + Right-Click Context Menu */
#hud-target-frame {
  position: absolute; top: 84px; left: calc(50% + 28px); transform: translateX(-50%);
  width: min(335px, 88vw); padding: 7px 10px; z-index: 9; pointer-events: auto;
  display: flex; align-items: center; gap: 10px; border-left: 3.5px solid var(--seal);
  background: rgba(244, 237, 221, 0.96); box-shadow: 0 6px 18px rgba(18, 24, 20, 0.28);
}
#hud-target-avatar {
  width: 52px; height: 52px; overflow: hidden; border-radius: 5px;
  border: 2px solid #8c7a5b; background: #e6dfd0; cursor: context-menu; flex-shrink: 0;
}
#hud-target-avatar:hover { box-shadow: 0 0 0 2px #993b32; }
.htf-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.htf-head { display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.htf-head strong { font-size: 13px; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.htf-sub { font-size: 10.5px; color: var(--ink-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.htf-hp-bar { height: 12px; margin-top: 1px; }
.htf-hp-bar span { font-size: 9.5px; line-height: 11px; }
.htf-meta { font-size: 10px; color: var(--ink-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#hud-zone-banner.has-target { top: 168px; }
#target-context-menu {
  position: fixed; z-index: 70; min-width: 196px; padding: 5px;
  display: flex; flex-direction: column; gap: 3px; border: 1.5px solid #8c7a5b;
  background: rgba(247, 240, 223, 0.98); box-shadow: 0 8px 24px rgba(15, 20, 17, 0.36);
}
.tcm-head { font-size: 11px; font-weight: 700; color: var(--seal); padding: 2px 6px 4px; border-bottom: 1px dashed #b4a474; margin-bottom: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tcm-item { justify-content: flex-start; text-align: left; width: 100%; font-size: 11.5px; padding: 5px 8px; }
.tcm-item:hover { background: #dce8d6; border-color: var(--jade); }

/* Pinned Boss HP Bar, 2-Col Equip Diff, Bag Lock, Trial Tower & Settings */
#hud-boss-bar {
  position: absolute; top: 144px; left: 50%; transform: translateX(-50%);
  width: min(440px, 84vw); padding: 7px 11px; z-index: 13; pointer-events: none;
  display: flex; align-items: center; gap: 10px;
  border: 1.5px solid #8f2d24; border-left: 5px solid #8f2d24;
  background: rgba(244, 237, 221, 0.95) url("/assets/ui/thuy-mac/hud_boss_bar_bg.png") center/100% 100% no-repeat; border: none; padding: 10px 26px; box-shadow: 0 8px 22px rgba(24, 16, 16, 0.34);
}
.boss-bar-img { width: 42px; height: 42px; border-radius: 5px; object-fit: cover; border: 1.5px solid #8f2d24; background: #e8dec8; flex-shrink: 0; }
.boss-bar-body { flex: 1; min-width: 0; }
.boss-bar-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 3px; }
.boss-bar-top strong { font-size: 13px; color: #5b1d17; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.boss-phase-tag { font-size: 9.5px; font-weight: 700; padding: 1px 6px; border-radius: 3px; background: #e5decb; color: #394a43; border: 1px solid #b4a474; flex-shrink: 0; }
.boss-phase-tag.enraged { background: #8f2d24; color: #fff8eb; border-color: #5b1d17; }
.boss-sbar { height: 14px; }
.boss-sbar span { font-size: 10px; line-height: 13px; font-weight: 700; }

.diff-box { background: #f2ece0; border: 1px solid #bdb299; border-left: 3px solid #2c5749; border-radius: 4px; padding: 6px 8px; margin: 4px 0; }
.diff-head { font-size: 10.5px; font-weight: 700; color: #2c5749; margin-bottom: 4px; }
.diff-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 3px 10px; font-size: 10.5px; }
.diff-row { display: flex; justify-content: space-between; gap: 6px; }
.diff-pos { color: #166534; font-weight: 700; }
.diff-neg { color: #b91c1c; font-weight: 700; }
.diff-eq { color: #64748b; }

.item-tile { position: relative; }
.lock-badge { position: absolute; top: 2px; left: 3px; font-size: 10px; line-height: 1; }
.tower-card { border-left: 4px solid #9a7432; }
.tower-card.cleared { border-left-color: #2c5749; background: #e8efe6; }
#hud-layer.arena-mode #hud-calendar,
#hud-layer.arena-mode #hud-target-frame,
#hud-layer.arena-mode #hud-zone-banner,
#hud-layer.arena-mode #hud-minimap-box,
#hud-layer.arena-mode #hud-right-dock { display: none !important; }
#hud-layer.arena-mode #arena-hud { top: 10px !important; z-index: 20; background: rgba(244, 237, 221, 0.96); box-shadow: 0 6px 18px rgba(10, 14, 12, 0.38); }
#hud-layer.arena-mode #hud-boss-bar { top: 58px !important; z-index: 19; }
.tower-victory-box { max-width: 520px; margin: 0 auto; text-align: center; }
.tower-reward-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin: 10px 0 14px; text-align: left; }
.settings-box { display: flex; flex-direction: column; gap: 10px; max-width: 560px; }
.settings-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; background: #f3ecdc; border: 1px solid #c5bca7; border-radius: 4px; padding: 8px 10px; }
.settings-row input[type="range"] { width: 170px; accent-color: #8f2d24; }

/* ---- REDESIGNED STEP 1 SAVE CARDS & STEP 2 2-COL CREATOR + SPIRIT ROOT ---- */
.name-input-row { display: flex; gap: 8px; align-items: center; }
.name-input-row input { flex: 1; }
.save-cards-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 4px 0; }
.save-slot-card {
  background: #f5efe0; border: 1.5px solid #968b74; border-radius: 4px; padding: 9px 10px;
  display: flex; flex-direction: column; gap: 6px; cursor: pointer; transition: border-color .14s, background .14s;
}
.save-slot-card.active { border-color: #8f2d24; background: #faf4e4; box-shadow: 0 2px 10px rgba(143, 45, 36, 0.16); }
.save-slot-card.empty { align-items: center; justify-content: center; text-align: center; min-height: 98px; border-style: dashed; }
.save-card-top { display: flex; gap: 8px; align-items: center; }
.save-card-avatar { width: 44px; height: 44px; overflow: hidden; border-radius: 4px; border: 1px solid #7d735f; background: #e8dec8; flex-shrink: 0; }
.save-card-avatar img { width: 800%; height: 400%; max-width: none; display: block; }
.save-card-title { font-size: 12.5px; font-weight: 700; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.save-card-meta { font-size: 10.5px; color: var(--ink-muted); line-height: 1.3; }
.save-card-empty-title { font-size: 12.5px; font-weight: 700; color: var(--jade); }
.save-card-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.cloud-sync-box { background: rgba(242, 234, 214, 0.72); border: 1px dashed #9d927b; border-radius: 4px; padding: 6px 10px; font-size: 12px; }
.cloud-sync-box summary { cursor: pointer; font-weight: 600; color: var(--jade); }

.creator-2col { display: grid; grid-template-columns: 320px 1fr; gap: 14px; align-items: stretch; }
.creator-stage-col { align-items: center; }
.stage-canvas-wrap { display: flex; justify-content: center; align-items: center; width: 100%; }
.creator-stage-controls { display: flex; gap: 6px; justify-content: center; flex-wrap: wrap; }
.live-stats-box { width: 100%; background: #f2ead8; border: 1px solid #968b74; border-left: 3px solid var(--jade); border-radius: 4px; padding: 8px 10px; font-size: 11.5px; }
.live-stat-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 4px; color: var(--seal); }
.live-stat-tags { display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 6px; }
.live-stat-tags span { background: #e6dcc4; border: 1px solid #b5a788; border-radius: 3px; padding: 1px 6px; font-size: 10px; }
.live-stat-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 2px 8px; font-size: 11px; }
.live-root-hint { margin-top: 6px; padding-top: 5px; border-top: 1px dashed #a89c82; font-size: 10.5px; color: #2c5749; line-height: 1.35; }

.creator-wizard-col { min-width: 0; }
.creator-tab-bar { display: flex; gap: 6px; flex-wrap: wrap; border-bottom: 1.5px solid #9d927b; padding-bottom: 8px; }
.creator-tab-btn.active { background: linear-gradient(180deg, #8f2d24, #681e17); color: #fff8ea; border-color: #4f150f; text-shadow: none; }
.creator-tab-pane { display: flex; flex-direction: column; gap: 8px; flex: 1; min-height: 360px; max-height: 455px; overflow-y: auto; padding-right: 2px; }
.creator-hero-grid { max-height: 185px; }
.creator-school-2col { grid-template-columns: repeat(2, 1fr); max-height: 390px; overflow-y: auto; }

.origin-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px; max-height: 240px; overflow-y: auto; }
.origin-card {
  text-align: left; font-family: var(--font-main); background: #f5efe2; border: 1px solid #a2957c; border-radius: 4px;
  padding: 7px 8px; cursor: pointer; display: flex; flex-direction: column; gap: 3px;
}
.origin-card:hover { border-color: var(--seal); }
.origin-card.active { border: 2px solid #8f2d24; background: #fbf4e3; box-shadow: inset 0 0 0 1px rgba(143, 45, 36, 0.2); }
.origin-head { display: flex; justify-content: space-between; align-items: center; gap: 4px; font-size: 12px; color: var(--ink); }
.origin-tag { font-size: 9.5px; background: #e3dac3; padding: 1px 5px; border-radius: 3px; color: var(--jade); }
.origin-lore { margin: 0; font-size: 10.5px; color: var(--ink-muted); line-height: 1.3; }
.origin-bonus { font-size: 10px; font-weight: 700; color: #2c5749; }

.mind-diff-block { background: #efe7d4; border: 1px solid #b5a788; border-radius: 4px; padding: 7px 9px; }
.mind-row-label { font-size: 11px; font-weight: 700; color: var(--seal); margin-bottom: 4px; }
.pill-choice-row { display: flex; gap: 5px; flex-wrap: wrap; }
.pill-choice {
  font-family: var(--font-main); font-size: 11px; padding: 3px 8px; background: #f8f2e4; border: 1px solid #968b74; border-radius: 3px; cursor: pointer;
}
.pill-choice.active { background: #2c5749; color: #fbf6e8; border-color: #1b382e; font-weight: 700; }

.destiny-top-row { display: flex; justify-content: space-between; align-items: center; gap: 4px; margin-bottom: 3px; }
.destiny-lock-btn {
  font-family: var(--font-main); font-size: 10px; padding: 1px 5px; border: 1px solid #9d927b; border-radius: 3px;
  background: #efe6d2; color: #394a43; cursor: pointer;
}
.destiny-lock-btn.active { background: #8f2d24; color: #fff8eb; border-color: #5b1d17; }
.destiny-card.locked-card { box-shadow: inset 0 0 0 1px #8f2d24; }
.destiny-picked-mark { float: right; color: #993b32; font-weight: 700; font-size: 10.5px; }

.root-badge {
  display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 3px;
  border: 1px solid #2c5749; font-size: 11.5px; font-weight: 700; margin: 2px;
}
.compat-pill-ok { background: #dcfce7; color: #166534; border: 1px solid #16a34a; border-radius: 3px; padding: 1px 6px; font-size: 10.5px; font-weight: 700; }
.compat-pill-lock { background: #fee2e2; color: #991b1b; border: 1px solid #dc2626; border-radius: 3px; padding: 1px 6px; font-size: 10.5px; font-weight: 700; }
.prologue-scroll, .awaken-altar { max-width: 640px; margin: 0 auto; text-align: center; }
.prologue-banner { font-size: 17px; font-weight: 700; color: #8f2d24; border-bottom: 1.5px dashed #9d927b; padding-bottom: 6px; margin-bottom: 8px; }
.prologue-scroll .sub-card { text-align: left; }

@media (max-width: 900px) {
  .save-cards-grid { grid-template-columns: 1fr; }
  .creator-2col { grid-template-columns: 1fr; }
  .origin-grid, .creator-school-2col { grid-template-columns: 1fr; }
}

/* ==== GÓI 1-3 VISUAL POLISH, FASHION, ACTIVITIES & 1366x768 RESPONSIVE ==== */
.status-strip { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.status-strip.hidden { display: none; }
.status-pill {
  display: inline-flex; align-items: center; gap: 3px;
  font-size: 10px; font-weight: 700; padding: 1px 6px; border-radius: 3px;
  background: #f5efe0; border: 1px solid #9a7432; color: #27342e;
}
.status-pill img { width: 14px; height: 14px; object-fit: contain; display: block; }
.bh-btn { position: relative; }
.bh-btn.has-notif::after {
  content: ""; position: absolute; top: -2px; right: -2px;
  width: 7px; height: 7px; border-radius: 50%;
  background: #c83228; border: 1px solid #fff8eb; pointer-events: none;
}
.sect-emblem-ic {
  width: 34px; height: 34px; border-radius: 50%; object-fit: cover;
  border: 1.5px solid #8c7a5b; background: #1e2723; flex-shrink: 0;
}
.log-filter-bar { display: flex; gap: 4px; margin-bottom: 4px; flex-wrap: wrap; }
.log-ft {
  font-family: var(--font-main); font-size: 10px; font-weight: 600;
  padding: 1px 7px; border-radius: 3px; cursor: pointer;
  background: rgba(240, 232, 213, 0.85); color: #394a43; border: 1px solid #b5aa91;
}
.log-ft.active { background: #2c5749; color: #fbf6e8; border-color: #1b382e; }
.gfs-preset-bar, .gfs-evo-box { margin-bottom: 6px; }
.gfs-costume-thumb { width: 64px; height: 64px; overflow: hidden; border: 1px solid #9a7432; border-radius: 5px; background: #141a18; }
@media (max-width: 1400px) and (min-width: 1021px), (max-height: 780px) and (min-width: 1021px) {
  #hud-profile { max-width: 295px; padding: 12px 13px 14px; font-size: 11px; }
  #hud-calendar { max-width: min(560px, calc(100vw - 500px)); font-size: 11px; }
  #hud-boss-bar { top: 96px; min-width: 300px; max-width: 38vw; }
  #hud-quest-box { max-width: 245px; }
  #hud-minimap-box canvas { width: 100%; height: 120px; }
  #hud-log { max-width: 310px; max-height: 148px; }
  .bh-modal { max-width: 96vw; max-height: 92vh; }
}

/* ==== KỲ ÁN & SỰ KIỆN BƯỚC NGOẶC (PARCHMENT EVENT CARD) ==== */
.story-parchment {
  position: relative; max-width: 560px; margin: 4px auto 8px;
  padding: 20px 24px 28px; border-radius: 3px;
  background: linear-gradient(180deg, #f6efe0 0%, #ede3cb 100%);
  border: 2px solid #8a7c60;
  box-shadow: inset 0 0 0 4px #f5eedc, inset 0 0 0 5.5px #a49679, 0 8px 24px rgba(20, 18, 12, 0.35);
  color: #241f18; font-family: var(--font-main);
}
.story-corner {
  position: absolute; width: 7px; height: 7px; background: #8f2d24; transform: rotate(45deg);
}
.story-corner.tl { top: 8px; left: 8px; }
.story-corner.tr { top: 8px; right: 8px; }
.story-corner.bl { bottom: 8px; left: 8px; }
.story-corner.br { bottom: 8px; right: 8px; }
.story-head { display: flex; align-items: baseline; gap: 10px; margin-bottom: 10px; flex-wrap: wrap; }
.story-title { font-size: 20px; font-weight: 800; color: #1b1812; letter-spacing: 0.2px; }
.story-loc { font-size: 13.5px; color: #6c6352; font-style: italic; }
.story-body-txt { font-size: 14px; line-height: 1.58; color: #2b241b; margin-bottom: 16px; }
.story-body-txt b { color: #17130d; font-weight: 800; }
.story-choice-list { display: flex; flex-direction: column; gap: 8px; }
.story-choice-btn {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left;
  padding: 10px 14px; border-radius: 2px; cursor: pointer;
  background: linear-gradient(180deg, #f9f4e7 0%, #eee6d1 100%);
  border: 1.5px solid #8d8064; box-shadow: inset 0 1px 0 #fffdf7;
  font-family: var(--font-main); font-size: 13.5px; font-weight: 600; color: #241f18;
  transition: border-color 0.14s, background 0.14s;
}
.story-choice-btn:hover { border-color: #8f2d24; background: linear-gradient(180deg, #fffaf0 0%, #f5ead1 100%); }
.story-choice-num { font-weight: 800; font-size: 15px; color: #8f2d24; min-width: 18px; }
.story-choice-lbl { flex: 1; }
.story-seal-badge {
  position: absolute; right: 12px; bottom: -14px; width: 38px; height: 38px; border-radius: 50%;
  background: #f5eedc; border: 2px solid #8f2d24; box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
  display: flex; align-items: center; justify-content: center; font-size: 18px;
}
.story-clue-bar {
  margin-top: 4px; padding: 3px 6px; border-radius: 3px; font-size: 11px;
  background: #f5ead2; border: 1px solid #b59a6a; color: #5b3e17;
}
.cos-frame-crop {
  width: 48px; height: 48px; flex-shrink: 0; border-radius: 5px;
  border: 1.5px solid #968b74; background-color: #141a18;
  background-repeat: no-repeat; background-size: 1400% 800%; background-position: 0% 0%;
  image-rendering: pixelated;
}
.cos-thumb-54 {
  width: 54px; height: 54px; flex-shrink: 0; border-radius: 4px;
  border: 1.5px solid var(--timber, #5c4632); background: var(--lacquer, #162421);
  object-fit: contain; image-rendering: pixelated; padding: 2px;
}
.charbag-layout {
  display: grid; grid-template-columns: minmax(340px, 43%) 1fr; gap: 12px; align-items: start;
}
.cb-left, .cb-right { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.cb-inv-scroll { max-height: 235px; overflow-y: auto; padding-right: 2px; }
#hud-skillbar .skill-slot.aiming {
  border-color: var(--seal, #8f2d24); background: rgba(143, 45, 36, 0.34);
  box-shadow: 0 0 10px rgba(224, 130, 45, 0.55), inset 0 0 6px rgba(227, 199, 124, 0.42);
  transform: translateY(-3px);
}
@media (max-width: 960px) {
  .charbag-layout { grid-template-columns: 1fr; }
}
#scene-hud {
  position: fixed; top: 10px; left: 50%; transform: translateX(-50%); z-index: 25;
  display: flex; align-items: center; gap: 12px; padding: 6px 14px; font-weight: 700;
}
#scene-hud.hidden { display: none; }

/* ===== BAN THU HUD MOBILE GON (05/12/2026) =====
   Bo ep viewport 980: HUD mobile rieng, che <25% man hinh.
   Desktop khong doi (chi ap dung <=820px). */
@media (max-width: 820px) {
  /* Avatar cum gon goc trai tren */
  #hud-left-col { top: 6px; left: 6px; width: 168px; gap: 4px; }
  #hud-profile { padding: 8px 9px 9px; }
  .hud-avatar-wrap { width: 38px; height: 38px; flex-shrink: 0; }
  #hud-avatar { width: 36px !important; height: 36px !important; }
  .prof-top { gap: 6px; margin-bottom: 4px; align-items: center; }
  .prof-name-row strong { font-size: 13px; white-space: nowrap; }
  .prof-sub, .prof-quick-row, #hud-combat-state, #hud-status-strip { display: none !important; }
  .realm-tag { font-size: 10px; padding: 1px 5px; }
  .stone-pill { font-size: 10px; padding: 1px 5px; }
  .sbar { height: 11px; margin-top: 3px; }
  .sbar span { font-size: 9px; line-height: 11px; }
  #hud-squad, #hud-quest-box, #hud-log, #hud-skills { display: none !important; }
  #hud-quest-box.mobile-show, #hud-log.mobile-show {
    display: block !important; position: fixed; left: 6px; right: 6px; width: auto;
    bottom: 248px; z-index: 30; max-height: 34dvh; overflow-y: auto; font-size: 13px;
  }

  /* Lich gon o giua tren: chi ngay + Qua Thang + Tu Danh */
  #hud-calendar { top: 6px; left: 180px; right: 108px; transform: none; width: auto;
    max-width: none; min-width: 0; padding: 6px 7px; gap: 4px; }
  .cal-main { font-size: 11px; justify-content: center; text-align: center; }
  #hud-region, #hud-danger-pill, #hud-online, .cal-sep { display: none !important; }
  .cal-btns { flex-wrap: wrap; justify-content: center; gap: 4px; width: 100%; }
  .cal-btns .bh-btn.mini { font-size: 11px; padding: 5px 7px; min-height: 34px; white-space: nowrap; }
  #btn-open-tower, #btn-cal-more { display: none !important; }
  #hud-goal-pill { font-size: 11px; padding: 5px 8px; max-width: 100%; }

  /* Minimap nho goc phai tren, cham mo ban do lon */
  #hud-minimap-box { top: 6px; right: 6px; width: 96px; padding: 6px; }
  #mini-canvas { width: 100% !important; height: 62px !important; }
  .mini-head { margin-bottom: 3px; }
  #mini-coords, .mini-zoom-row { display: none !important; }
  #btn-open-atlas { width: 100%; font-size: 11px; padding: 5px 4px; min-height: 32px; justify-content: center; }
  #btn-open-atlas img { width: 14px; height: 14px; }

  /* Dock chuc nang: thu san, mo bang nut Menu */
  .hud-right-dock { right: 6px; top: 122px; }
  .right-dock-toggle { font-size: 11px; padding: 6px 9px; min-height: 36px; min-width: 56px; }
  .right-dock-list { width: 60px; gap: 5px; max-height: 48dvh; overflow-y: auto; }
  .bh-btn.dock-item { width: 58px; min-height: 50px; padding: 3px 2px; gap: 1px; }
  .bh-btn.dock-item img { width: 25px; height: 25px; }
  .bh-btn.dock-item span { font-size: 10px; line-height: 1.15; }

  /* Banner / boss / target khong de HUD tren */
  #hud-zone-banner { top: 122px; min-width: 0; width: 86vw; padding: 8px 12px; }
  #hzb-title { font-size: 14px; }
  #hzb-sub { font-size: 11px; }
  #hud-boss-bar { top: 122px; width: 92vw; min-width: 0; max-width: 92vw; padding: 8px 10px; }
  #hud-target-frame { top: 122px; width: 92vw; }

  /* Joystick + cum danh thu theo man that */
  .touch-joystick { left: 14px; bottom: 18px; }
  .joy-ring { width: 118px; height: 118px; }
  .joy-knob { width: 52px; height: 52px; }
  .touch-action-pad { right: 10px; bottom: 14px; gap: 6px; }
  .tap-utils { max-width: 248px; gap: 5px; }
  .tap-mini { padding: 8px 10px; font-size: 12px; min-height: 36px; }
  .tap-combat { width: 218px; height: 214px; }
  .tap-atk { width: 84px; height: 84px; font-size: 17px; right: 4px; bottom: 4px; }
  .tap-sk { width: 56px; height: 56px; padding: 3px; }
  .tap-sk img { width: 36px; height: 36px; }
  .tap-sk span { font-size: 11px; bottom: 2px; right: 4px; padding: 0 4px; }
  #mob-sk-0 { right: 150px; bottom: 20px; }
  #mob-sk-1 { right: 130px; bottom: 86px; }
  #mob-sk-2 { right: 82px; bottom: 134px; }
  #mob-sk-3 { right: 16px; bottom: 156px; }
  .tap-sk-page { width: 40px; height: 40px; right: 102px; bottom: 4px; font-size: 17px; }

  /* Modal + man tao nhan vat doc duoc tren dien thoai */
  .modal-window { width: 96vw; max-height: 94dvh; padding: 14px; }
  .modal-body { font-size: 13.5px; line-height: 1.45; }
  .modal-body button, .modal-tabs button { min-height: 40px; font-size: 13px; }
  .create-box { width: 96vw; max-height: 94dvh; padding: 14px; }
  .create-header h1 { font-size: 20px; }
  .create-header .subtitle { font-size: 12px; }
  .creator-2col { grid-template-columns: 1fr; }
  .stage-canvas-wrap canvas { width: 168px !important; height: 168px !important; }
  .creator-tab-btn { min-height: 42px; font-size: 12.5px; }
  .create-actions .bh-btn.large { min-height: 50px; font-size: 15px; }
  input[type="text"], input[type="password"] { font-size: 16px; min-height: 44px; }
}

/* HUD mobile gon v2: lich khong tran chu, minimap nut duoi anh */
@media (max-width: 820px) {
  .cal-main { overflow: hidden; }
  #hud-date { font-size: 10px; line-height: 1.25; white-space: normal; word-break: break-word; }
  #btn-mob-quest, #btn-mob-log { display: none !important; }
  #hud-minimap-box { display: flex; flex-direction: column; }
  .mini-head { order: 2; margin: 3px 0 0; }
  #mini-canvas { order: 1; }
  #btn-toggle-sys-grid { min-height: 38px !important; font-size: 11px; }
  .hud-right-dock { top: 126px; }
}
@media (max-width: 820px) {
  .cal-main { display: block; }
  #hud-date { display: block; width: 100%; text-align: center; }
}

/* ===== HUD MOBILE V3: TOI GIAN, BOT KHUNG HOA VAN (user bao roi mat 05/12) ===== */
@media (max-width: 820px) {
  /* Avatar: chi ten + 3 thanh mong, nen mo trong suot */
  #hud-left-col { width: 150px; }
  #hud-profile { background: rgba(18,24,20,.55) !important; border: none !important;
    border-radius: 12px; padding: 6px 8px 7px; box-shadow: none; backdrop-filter: blur(2px); }
  .hud-avatar-wrap { width: 34px; height: 34px; }
  #hud-avatar { width: 32px !important; height: 32px !important; border-radius: 50%; }
  .prof-name-row strong { color: #fff; font-size: 12.5px; text-shadow: 0 1px 2px rgba(0,0,0,.7); }
  .prof-meta-row { display: none !important; }
  .sbar { height: 9px; margin-top: 3px; border: none; border-radius: 5px; background: rgba(0,0,0,.45); }
  .sbar span { font-size: 8.5px; line-height: 9px; color: #fff; text-shadow: 0 1px 1px rgba(0,0,0,.8); }

  /* Lich: bo khung, chi 2 nut pill nho + muc tieu */
  #hud-calendar { background: none !important; border: none !important; box-shadow: none;
    left: 162px; right: 86px; padding: 0; gap: 5px; }
  .cal-main { display: none !important; }
  .cal-btns { flex-direction: column; align-items: stretch; gap: 5px; }
  .cal-btns .bh-btn.mini, #hud-goal-pill {
    background: rgba(18,24,20,.62) !important; color: #fff !important; border: none !important;
    border-radius: 999px; font-size: 11px; font-weight: 700; min-height: 30px; padding: 4px 8px;
    box-shadow: none; text-shadow: none; }
  .cal-btns .bh-btn.mini img { display: none; }
  #hud-goal-pill { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

  /* Minimap: nho, bo nut Ban Do (cham map mo ban do lon) */
  #hud-minimap-box { width: 74px; padding: 3px; background: rgba(18,24,20,.55) !important;
    border: none !important; border-radius: 12px; box-shadow: none; }
  #mini-canvas { height: 52px !important; border-radius: 9px; }
  .mini-head { display: none !important; }

  /* Menu chuc nang: 1 nut pill, mo ra la bang luoi noi, khong de nut danh */
  .hud-right-dock { top: 72px; right: 6px; z-index: 40; }
  #btn-toggle-sys-grid { background: rgba(18,24,20,.62) !important; color: #fff !important;
    border: none !important; border-radius: 999px; min-height: 34px !important;
    font-size: 11px; font-weight: 700; padding: 5px 11px; box-shadow: none; }
  .hud-right-dock:not(.sys-collapsed) .right-dock-list {
    display: grid !important; grid-template-columns: repeat(3, 54px); gap: 4px; width: auto;
    max-height: none; overflow: visible; margin-top: 6px; padding: 8px;
    background: rgba(247,240,223,.97); border-radius: 14px;
    box-shadow: 0 10px 28px rgba(15,20,17,.4); }
  .bh-btn.dock-item { width: 54px; min-height: 52px; background: none !important; border: none !important; box-shadow: none; }

  /* Nut phu + cum danh + joystick nho lai */
  .tap-mini { background: rgba(18,24,20,.55) !important; color: #fff; border-radius: 999px;
    padding: 6px 9px; font-size: 11px; min-height: 32px; filter: none; }
  .touch-joystick { left: 10px; bottom: 14px; opacity: .92; }
  .joy-ring { width: 104px; height: 104px; }
  .joy-knob { width: 46px; height: 46px; }
  .touch-action-pad { right: 8px; bottom: 12px; }
  .tap-combat { width: 196px; height: 192px; }
  .tap-atk { width: 76px; height: 76px; font-size: 15px; }
  .tap-sk { width: 50px; height: 50px; }
  .tap-sk img { width: 32px; height: 32px; }
  #mob-sk-0 { right: 134px; bottom: 18px; }
  #mob-sk-1 { right: 116px; bottom: 78px; }
  #mob-sk-2 { right: 72px; bottom: 122px; }
  #mob-sk-3 { right: 14px; bottom: 142px; }
  .tap-sk-page { width: 36px; height: 36px; right: 90px; bottom: 4px; font-size: 15px; }

  #hud-zone-banner { top: 86px; width: 78vw; padding: 6px 10px; }
  #hzb-title { font-size: 13px; }
  #hzb-sub { font-size: 10.5px; }
}

/* ===== HUD DOC V4: HOC BO CUC TUTIENPIXEL, ICON ASSET CO SAN ===== */
@media (max-width: 820px) {
  /* Tren trai: khung nhan vat nau dam vien vang */
  #hud-left-col { width: 172px; top: 6px; left: 6px; }
  #hud-profile { background: linear-gradient(180deg, rgba(43,32,20,.92), rgba(28,21,14,.92)) !important;
    border: 1.5px solid #b08a4a !important; border-radius: 8px; padding: 7px 8px 8px;
    box-shadow: 0 4px 14px rgba(20,14,8,.45); backdrop-filter: none; }
  .hud-avatar-wrap { width: 36px; height: 36px; }
  #hud-avatar { width: 34px !important; height: 34px !important; border-radius: 6px; }
  .prof-name-row strong { color: #f3d9a4; font-size: 13px; text-shadow: none; }
  .prof-meta-row { display: flex !important; gap: 4px; margin-top: 2px; }
  .realm-tag, .stone-pill { background: rgba(0,0,0,.4); color: #e8d9b8; border: 1px solid rgba(176,138,74,.6);
    font-size: 9.5px; padding: 1px 5px; border-radius: 999px; }
  .sbar { height: 12px; margin-top: 3px; border: 1px solid rgba(0,0,0,.6); border-radius: 3px; background: rgba(0,0,0,.55); }
  .sbar span { font-size: 9px; line-height: 12px; color: #fff; }

  /* Duoi khung nhan vat: hang icon tinh nang vuong, khong chu */
  .hud-right-dock { top: 148px; left: 6px; right: auto; z-index: 30; }
  #btn-toggle-sys-grid { display: none !important; }
  .hud-right-dock .right-dock-list, .hud-right-dock:not(.sys-collapsed) .right-dock-list {
    display: grid !important; grid-template-columns: repeat(5, 37px); gap: 4px; width: auto;
    max-height: none; overflow: visible; margin: 0; padding: 0; background: none; box-shadow: none; }
  .bh-btn.dock-item { width: 37px; min-height: 37px; height: 37px; padding: 4px;
    background: linear-gradient(180deg, rgba(43,32,20,.9), rgba(28,21,14,.9)) !important;
    border: 1.5px solid #b08a4a !important; border-radius: 7px; box-shadow: 0 3px 8px rgba(20,14,8,.4); }
  .bh-btn.dock-item img { width: 25px; height: 25px; }
  .bh-btn.dock-item span { display: none !important; }

  /* Tren phai: minimap khung vang + nut Ban Do */
  #hud-minimap-box { width: 130px; top: 6px; right: 6px; padding: 4px;
    background: linear-gradient(180deg, rgba(43,32,20,.92), rgba(28,21,14,.92)) !important;
    border: 1.5px solid #b08a4a !important; border-radius: 8px; box-shadow: 0 4px 14px rgba(20,14,8,.45); }
  #mini-canvas { height: 76px !important; border-radius: 4px; }
  .mini-head { display: block !important; order: 2; margin: 4px 0 0; }
  #btn-open-atlas { background: rgba(0,0,0,.35) !important; color: #f3d9a4 !important;
    border: 1px solid rgba(176,138,74,.7) !important; border-radius: 6px;
    font-size: 11px; font-weight: 700; min-height: 30px; padding: 4px; box-shadow: none; }

  /* Duoi minimap: Qua Thang / Tu Danh / muc tieu */
  #hud-calendar { top: 152px; left: auto; right: 6px; width: 130px; gap: 4px; }
  .cal-btns { flex-direction: column; gap: 4px; }
  .cal-btns .bh-btn.mini, #hud-goal-pill {
    background: linear-gradient(180deg, rgba(43,32,20,.9), rgba(28,21,14,.9)) !important;
    color: #f3d9a4 !important; border: 1.5px solid #b08a4a !important; border-radius: 7px;
    font-size: 11px; font-weight: 700; min-height: 34px; padding: 4px 6px; box-shadow: none; }
  .cal-btns .bh-btn.mini img { display: inline-block; width: 17px; height: 17px; vertical-align: -3px; }

  /* Duoi trai: joystick lon trong suot */
  .touch-joystick { left: 12px; bottom: 16px; opacity: .95; }
  .joy-ring { width: 132px; height: 132px; }
  .joy-knob { width: 54px; height: 54px; }

  /* Duoi phai: nut Danh lon + ky nang vong cung */
  .touch-action-pad { right: 8px; bottom: 14px; }
  .tap-utils { max-width: 260px; }
  .tap-mini { background: linear-gradient(180deg, rgba(43,32,20,.88), rgba(28,21,14,.88)) !important;
    color: #f3d9a4; border: 1px solid #b08a4a; border-radius: 999px;
    padding: 6px 10px; font-size: 11px; min-height: 32px; }
  .tap-combat { width: 212px; height: 208px; }
  .tap-atk { width: 92px; height: 92px; font-size: 17px; }
  .tap-sk { width: 54px; height: 54px; }
  .tap-sk img { width: 36px; height: 36px; }
  #mob-sk-0 { right: 146px; bottom: 20px; }
  #mob-sk-1 { right: 126px; bottom: 86px; }
  #mob-sk-2 { right: 80px; bottom: 134px; }
  #mob-sk-3 { right: 16px; bottom: 156px; }
  .tap-sk-page { width: 38px; height: 38px; right: 98px; bottom: 4px; }

  #hud-zone-banner { top: 236px; width: 80vw; }
}
