/* Giả Kim Thoa: màn chơi toàn cửa sổ, ưu tiên điện thoại xoay ngang. Thế giới vẽ trên canvas, mọi bảng là lớp DOM nổi trên. */
:root {
  --lacquer: #120508; --panel: #24090e; --panel-2: #2f1218; --gold: #e2b866; --gold-soft: #f3d797;
  --paper: #f7ecd6; --muted: #d9c3a2; --dim: #a88f74; --crimson: #b1303f; --alarm: #ff6b7a; --jade: #7fe0b0; --lilac: #c9b8ff;
  --display: 'Cormorant Garamond', 'Songti SC', Georgia, serif; --body: 'Be Vietnam Pro', system-ui, sans-serif;
  --safe-l: max(12px, env(safe-area-inset-left, 0px)); --safe-r: max(12px, env(safe-area-inset-right, 0px));
  --safe-t: max(8px, env(safe-area-inset-top, 0px)); --safe-b: max(10px, env(safe-area-inset-bottom, 0px));
  color-scheme: dark;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; }
body { background: var(--lacquer); color: var(--paper); font: 14px/1.45 var(--body); overflow: hidden; touch-action: none;
  -webkit-user-select: none; user-select: none; -webkit-tap-highlight-color: transparent; -webkit-touch-callout: none; }
/* Giữ ngón trên nút/ảnh: không bật menu ảnh của trình duyệt (Sao chép ảnh, Tải xuống…). */
img, canvas { -webkit-touch-callout: none; -webkit-user-drag: none; user-drag: none; }
button img { pointer-events: none; }
button { font: inherit; color: inherit; cursor: pointer; }
button:focus-visible { outline: 3px solid var(--gold-soft); outline-offset: 2px; }
#game { position: fixed; inset: 0; overflow: hidden; }
canvas#view { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }

.round { width: 44px; height: 44px; border-radius: 50%; border: 1px solid rgba(226, 184, 102, .5); background: rgba(20, 8, 10, .85);
  color: var(--gold-soft); font: 700 15px 'Songti SC', 'Noto Serif SC', serif; display: grid; place-items: center; padding: 0; }
.primary { min-height: 46px; padding: 0 22px; border-radius: 999px; border: 0; background: linear-gradient(180deg, #e0525f, #8e1f2e);
  color: #fff4dc; font-weight: 700; box-shadow: 0 6px 18px rgba(0, 0, 0, .35); }
.ghost { min-height: 44px; padding: 0 18px; border-radius: 999px; border: 1px solid rgba(226, 184, 102, .5); background: rgba(20, 8, 10, .6); color: var(--gold-soft); font-weight: 600; }

/* ---------- Thanh trên ---------- */
#hud { position: absolute; top: var(--safe-t); left: var(--safe-l); right: var(--safe-r); display: grid; grid-template-columns: auto minmax(0, 1fr) auto auto;
  gap: 10px; align-items: start; pointer-events: none; z-index: 5; }
#hud > * { pointer-events: auto; }
.hud-when { display: flex; flex-direction: column; padding: 6px 12px; border-radius: 12px; background: rgba(20, 8, 10, .82); border: 1px solid rgba(226, 184, 102, .3); }
.hud-when b { font: 700 17px/1.1 var(--display); color: var(--gold-soft); white-space: nowrap; }
.hud-when small { font-size: 11px; color: var(--muted); white-space: nowrap; }
.hud-mid { display: flex; flex-direction: column; align-items: center; gap: 4px; min-width: 0; }
.money { padding: 4px 14px; border-radius: 999px; background: rgba(20, 8, 10, .82); border: 1px solid rgba(226, 184, 102, .35); font-weight: 700; color: var(--gold-soft); font-variant-numeric: tabular-nums; }
.goal { max-width: 100%; padding: 4px 12px; border-radius: 10px; border: 1px solid rgba(226, 184, 102, .25); background: rgba(20, 8, 10, .7); font-size: 12px; color: var(--paper);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.goal::before { content: '◆ '; color: var(--gold); }
.hud-bars { display: grid; gap: 4px; padding: 6px 10px; border-radius: 12px; background: rgba(20, 8, 10, .82); border: 1px solid rgba(226, 184, 102, .3); width: 168px; color: inherit; font: inherit; text-align: left; cursor: pointer; }
.bar-row { display: grid; gap: 2px; font-size: 11px; }
.bar-name { display: flex; justify-content: space-between; }
.bar-name b { font-weight: 700; }
.bar-row.low .bar i { animation: lowBlink 1s ease-in-out infinite; }
@keyframes lowBlink { 50% { opacity: .35; } }
.bar-name.mom { color: #ff9aa6; } .bar-name.sta { color: var(--jade); }
.bar { height: 7px; border-radius: 4px; background: rgba(255, 255, 255, .14); overflow: hidden; }
.bar i { display: block; height: 100%; width: 50%; transition: width .3s; }
#barMom { background: var(--alarm); } #barSta { background: #5fa38a; }

/* ---------- Cần gạt nổi và nút ---------- */
#stick { position: absolute; width: 112px; height: 112px; margin: -56px 0 0 -56px; border-radius: 50%; border: 2px solid rgba(255, 255, 255, .45);
  background: rgba(255, 255, 255, .07); pointer-events: none; opacity: 0; transition: opacity .12s; z-index: 4; }
#stick.on { opacity: 1; }
#knob { position: absolute; left: 50%; top: 50%; width: 46px; height: 46px; margin: -23px 0 0 -23px; border-radius: 50%; background: rgba(243, 215, 151, .8); box-shadow: 0 0 12px rgba(243, 215, 151, .5); }
#ctrl { position: absolute; right: var(--safe-r); bottom: var(--safe-b); width: 190px; height: 170px; z-index: 5; pointer-events: none; }
#ctrl > * { pointer-events: auto; position: absolute; }
#actBtn { right: 0; bottom: 0; width: 92px; height: 92px; border-radius: 50%; border: 3px solid var(--gold-soft); color: #fff4dc;
  background: radial-gradient(circle at 40% 35%, #c85a1a, #7a2a10); font-weight: 700; font-size: 12.5px; line-height: 1.2; padding: 6px; touch-action: none; }
#actBtn.idle { background: rgba(20, 8, 10, .7); border-color: rgba(226, 184, 102, .35); color: var(--dim); }
#actBtn.hold { background: radial-gradient(circle at 40% 35%, #8a7ad0, #3a2a70); }
#actBtn.pressed { transform: scale(.94); }
#bagBtn { right: 104px; bottom: 6px; width: 50px; height: 50px; }
#pathBtn { right: 100px; bottom: 66px; width: 50px; height: 50px; border-color: var(--gold-soft); color: var(--gold-soft); }
#gestBtn { right: 14px; bottom: 106px; width: 46px; height: 46px; }
#gestures { right: 70px; bottom: 100px; display: flex; gap: 8px; }
#gestures button { min-width: 74px; min-height: 52px; padding: 4px 10px; border-radius: 14px; border: 2px solid var(--lilac); background: rgba(36, 22, 60, .9);
  color: #f1ecff; font-weight: 700; font-size: 13px; display: flex; flex-direction: column; align-items: center; justify-content: center; touch-action: none; }
#gestures button small { font-size: 10px; font-weight: 500; opacity: .8; }
#gestures button.held { background: #5a4aa0; }

/* ---------- Thông báo nhỏ ---------- */
#toasts { position: absolute; left: 50%; top: calc(var(--safe-t) + 96px); transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: 6px; z-index: 20; pointer-events: none; }
.toast { padding: 6px 14px; border-radius: 999px; background: rgba(20, 8, 10, .9); border: 1px solid rgba(226, 184, 102, .45); font-size: 13px; font-weight: 600; color: var(--gold-soft);
  animation: toast 2.6s forwards; white-space: nowrap; }
.toast.bad { color: #ffb3bc; border-color: rgba(255, 107, 122, .6); }
.toast.warn { color: #ffd59a; border-color: rgba(255, 196, 107, .6); }
.toast.good { color: #b8f0d2; border-color: rgba(127, 224, 176, .6); }
@keyframes toast { 0% { opacity: 0; transform: translateY(6px); } 10%, 80% { opacity: 1; transform: none; } 100% { opacity: 0; } }

/* ---------- Hộp thoại ---------- */
#dialog { position: absolute; inset: 0; z-index: 8; background: linear-gradient(0deg, rgba(10, 3, 5, .75), rgba(10, 3, 5, .15) 60%); }
.portrait { position: absolute; bottom: 70px; width: 34%; height: min(78%, calc(100% - 150px)); display: flex; align-items: flex-end; justify-content: center; transition: opacity .2s; }
.portrait.left { left: 0; } .portrait.right { right: 0; }
.portrait.dim { opacity: .45; }
.portrait img { max-height: 100%; max-width: 100%; object-fit: contain; }
.px-portrait { width: min(70%, 220px); aspect-ratio: 1; image-rendering: pixelated; filter: drop-shadow(0 6px 12px rgba(0,0,0,.5)); }
.ph-portrait { width: min(62%, 170px); height: min(92%, 230px); border-radius: 40% 40% 12px 12px; display: grid; place-items: center; font: 700 64px var(--display); color: rgba(255, 255, 255, .85);
  border: 3px solid rgba(255, 255, 255, .25); box-shadow: inset 0 -30px 60px rgba(0, 0, 0, .35); }
.dbox { position: absolute; left: var(--safe-l); right: var(--safe-r); bottom: var(--safe-b); padding: 12px 18px 22px; border-radius: 16px;
  background: rgba(28, 9, 13, .96); border: 1px solid rgba(226, 184, 102, .55); min-height: 96px; }
#dialog.choosing .dbox { right: calc(var(--safe-r) + 270px); }
#dName { font: 700 19px var(--display); color: var(--gold-soft); }
#dText { margin: 4px 0 0; font-size: 15px; line-height: 1.5; }
.dnext { position: absolute; right: 14px; bottom: 6px; font-size: 11px; color: var(--dim); }
#choices { position: absolute; right: var(--safe-r); bottom: var(--safe-b); width: 258px; display: flex; flex-direction: column; gap: 8px; }
#choices button { text-align: left; padding: 10px 12px; border-radius: 12px; border: 1px solid rgba(226, 184, 102, .5); background: #2a1015; font-size: 13.5px; line-height: 1.35; }
#choices button small { display: block; font-size: 11px; color: var(--jade); margin-top: 2px; }
#choices button:disabled { opacity: .45; cursor: default; } /* lựa chọn không đủ điều kiện (thiếu tiền, thiếu đồ): mờ đi, không giống nút bấm được */

/* ---------- Danh sách việc ---------- */
#sheet { position: absolute; left: 50%; bottom: var(--safe-b); transform: translateX(-50%); width: min(460px, 70vw); z-index: 7; padding: 12px 14px; border-radius: 16px;
  background: rgba(28, 9, 13, .96); border: 1px solid rgba(226, 184, 102, .55); display: flex; flex-direction: column; gap: 8px; }
#sheetTitle { font: 700 19px var(--display); color: var(--gold-soft); }
#sheetList { display: flex; flex-direction: column; gap: 6px; max-height: 52vh; overflow-y: auto; }
#sheetList button { display: flex; justify-content: space-between; align-items: center; gap: 10px; min-height: 46px; padding: 6px 12px; border-radius: 12px;
  border: 1px solid rgba(226, 184, 102, .4); background: #2a1015; text-align: left; }
#sheetList button small { color: var(--muted); font-size: 11.5px; }
#sheetList button:disabled { opacity: .45; cursor: default; }
#sheetClose { align-self: flex-end; }

/* ---------- Trò nghề ---------- */
#mg { position: absolute; inset: 0; z-index: 9; background: rgba(12, 4, 6, .96); display: flex; flex-direction: column; padding: var(--safe-t) var(--safe-r) var(--safe-b) var(--safe-l); gap: 8px; }
.mg-head { display: flex; align-items: center; gap: 12px; }
#mgTitle { font: 700 22px var(--display); color: var(--gold-soft); flex: 1; }
#mgTimer { font: 700 22px var(--display); color: var(--gold-soft); font-variant-numeric: tabular-nums; }
.mg-body { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(0, 1fr) 190px; gap: 12px; }
#mgStage { position: relative; min-height: 0; border-radius: 14px; overflow: hidden; background: #24140c; touch-action: none; }
#mgStage canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
#mgSide { display: flex; flex-direction: column; gap: 8px; min-height: 0; overflow-y: auto; }
.side-card { padding: 9px 10px; border-radius: 10px; background: rgba(36, 9, 15, .9); border: 1px solid rgba(226, 184, 102, .3); font-size: 12px; line-height: 1.45; }
.side-card b { color: var(--gold-soft); }
.side-big { font: 700 26px var(--display); color: var(--gold-soft); }
.mg-btn { min-height: 48px; border-radius: 12px; border: 1px solid rgba(226, 184, 102, .5); background: #2a1015; font-weight: 700; }
.mg-btn.go { background: linear-gradient(180deg, #e0525f, #8e1f2e); border: 0; color: #fff4dc; }
/* Nút bị khoá (vd số tiền lớn hơn tiền đang mang, Lấy ra khi chỗ giấu trống): mờ đi để người chơi thấy không bấm được (QA 27/10). */
.mg-btn:disabled { opacity: .38; filter: grayscale(.6); cursor: default; }

/* ---------- Bảng túi, tài năng ---------- */
#panel { position: absolute; inset: 0; z-index: 9; background: rgba(12, 4, 6, .96); display: grid; grid-template-columns: 112px minmax(0, 1fr); padding: var(--safe-t) var(--safe-r) var(--safe-b) var(--safe-l); gap: 12px; }
#panelTabs { display: flex; flex-direction: column; gap: 6px; padding-top: 4px; }
#panelTabs button { min-height: 54px; border-radius: 10px; border: 1px solid rgba(226, 184, 102, .3); background: #2a1015; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; font-size: 11.5px; }
#panelTabs button b { font: 700 17px 'Songti SC', serif; color: var(--gold-soft); }
#panelTabs button.on { background: #4a1820; border: 2px solid var(--gold-soft); }
#panelBody { min-height: 0; overflow-y: auto; padding: 4px 4px 60px; }
#panelBody h3 { margin: 0 0 8px; font: 700 22px var(--display); color: var(--gold-soft); }
#panelClose { position: absolute; right: var(--safe-r); bottom: var(--safe-b); }
.grid-items { display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: 8px; }
.item { position: relative; aspect-ratio: 1; border-radius: 10px; background: #2a1015; border: 1px solid rgba(226, 184, 102, .3); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; padding: 4px; text-align: center; }
.item b { font: 700 22px/1 'Songti SC', serif; color: var(--gold-soft); }
.item small { font-size: 10.5px; line-height: 1.2; }
.item i { position: absolute; right: 5px; top: 3px; font-style: normal; font-size: 11px; color: var(--gold-soft); font-weight: 700; }
.rows { display: flex; flex-direction: column; gap: 6px; }
.row { display: grid; grid-template-columns: 130px minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 8px 12px; border-radius: 10px; background: #2a1015; border: 1px solid rgba(226, 184, 102, .25); font-size: 12.5px; }
.row b { color: var(--gold-soft); }
.lvl { display: flex; gap: 3px; }
.lvl i { width: 12px; height: 8px; border-radius: 2px; background: rgba(255, 255, 255, .15); }
.lvl i.on { background: var(--jade); }
.note { padding: 8px 12px; border-radius: 10px; background: #2a1015; border-left: 3px solid var(--gold); font-size: 12.5px; margin-bottom: 6px; }

/* ---------- Thẻ chương, tổng kết ---------- */
#card, #pause, #slots, #shop, #howto { position: absolute; inset: 0; z-index: 10; background: rgba(8, 2, 4, .86); display: grid; place-items: center; padding: var(--safe-t) var(--safe-r) var(--safe-b) var(--safe-l); }
.card-box { width: min(620px, 92vw); max-height: 92vh; overflow-y: auto; padding: 20px 24px; border-radius: 20px; background: linear-gradient(180deg, #2a1015, #1c090d); border: 1px solid rgba(226, 184, 102, .5);
  display: flex; flex-direction: column; gap: 10px; }
#cardKicker { font-size: 11px; letter-spacing: .2em; text-transform: uppercase; color: var(--gold); }
.card-box h2 { margin: 0; font: 700 30px/1.1 var(--display); color: var(--gold-soft); }
#cardBody { font-size: 14px; line-height: 1.55; display: flex; flex-direction: column; gap: 6px; }
#cardBody .kv { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
#cardBody .kv div { padding: 6px 10px; border-radius: 10px; background: rgba(0, 0, 0, .25); font-size: 12.5px; }
#cardBody .kv b { display: block; font-size: 16px; color: var(--gold-soft); }
#cardBody ul { margin: 0; padding-left: 18px; }
#cardBtns, .pause-btns { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; margin-top: 4px; }
#pauseInfo, #slotsInfo { margin: 0; color: var(--muted); font-size: 13px; }
#slots { z-index: 14; } /* trên cả màn chính: Tiếp tục mở danh sách bản lưu ngay ở màn chính */
#howto { z-index: 12; }
.howto-kicker { letter-spacing: .2em; text-transform: uppercase; color: var(--gold); font-size: 11px; }
.howto-goal { margin: 0; font-size: 16px; font-weight: 700; color: var(--gold-soft); }
.howto-steps { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 4px; font-size: 14px; }
.howto-win { margin: 0; font-size: 13px; color: var(--jade); }
.shop-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; }
#shopMoney { color: var(--gold-soft); font-weight: 700; }
.shop-tabs { display: flex; gap: 6px; }
.shop-tabs button { flex: 1; padding: 8px; border-radius: 10px; border: 1px solid rgba(226, 184, 102, .35); background: rgba(0, 0, 0, .25); color: var(--muted); font: inherit; font-weight: 700; cursor: pointer; }
.shop-tabs button.on { background: rgba(226, 184, 102, .2); color: var(--gold-soft); }
.shop-list { display: flex; flex-direction: column; gap: 6px; }
.shop-row { display: grid; grid-template-columns: 36px 1fr auto auto; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 12px; background: rgba(0, 0, 0, .25); }
.shop-row.off { opacity: .5; }
.shop-row > b, .shop-row > .ic { width: 32px; height: 32px; display: grid; place-items: center; font: 700 20px "Songti SC", serif; color: var(--gold-soft); object-fit: contain; }
.shop-name { display: flex; flex-direction: column; min-width: 0; }
.shop-name small, .shop-empty { color: var(--muted); font-size: 12px; }
.shop-step { display: flex; align-items: center; gap: 6px; }
.shop-step button { width: 28px; height: 28px; border-radius: 8px; border: 1px solid rgba(226, 184, 102, .35); background: transparent; color: inherit; font: inherit; cursor: pointer; }
.shop-step i { min-width: 18px; text-align: center; font-style: normal; }
.shop-row > button.primary { padding: 6px 14px; min-height: 34px; }
.bag-tabs { display: flex; gap: 6px; margin: 6px 0; flex-wrap: wrap; }
.bag-tabs button { padding: 5px 12px; border-radius: 10px; border: 1px solid rgba(226, 184, 102, .35); background: rgba(0, 0, 0, .25); color: var(--muted); font: inherit; font-size: 13px; cursor: pointer; }
.bag-tabs button.on { color: var(--gold-soft); background: rgba(226, 184, 102, .2); }
.bag-detail { margin-top: 8px; padding: 10px 12px; border-radius: 12px; background: rgba(0, 0, 0, .25); font-size: 13px; display: flex; flex-direction: column; gap: 6px; }
.bag-detail small { color: var(--muted); }
.grid-items .item.sel { outline: 2px solid var(--gold-soft); }
.slot-list { display: flex; flex-direction: column; gap: 8px; }
.slot { display: grid; grid-template-columns: auto 1fr; gap: 2px 12px; align-items: center; width: 100%; text-align: left; padding: 10px 14px; border-radius: 12px; background: rgba(0, 0, 0, .25); border: 1px solid rgba(226, 184, 102, .35); color: inherit; font: inherit; cursor: pointer; }
.slot b { grid-row: span 2; font: 700 20px var(--display); color: var(--gold-soft); min-width: 64px; }
.slot span { font-size: 14px; }
.slot small { color: var(--muted); font-size: 12px; }
.slot:disabled, .slot.locked { opacity: .45; cursor: default; }
.slot.sure { border-color: var(--gold-soft); box-shadow: 0 0 0 2px rgba(226, 184, 102, .5); }
.slot.sure small { color: var(--gold-soft); }

/* ---------- Màn đen ---------- */
#blackout { position: absolute; inset: 0; z-index: 11; background: #000; display: grid; place-items: center; padding: 30px 60px; }
#blackText { max-width: 640px; margin: 0; font: 600 19px/1.6 var(--display); color: #efe2c8; text-align: center; white-space: pre-line; }
#blackout .dnext { position: absolute; bottom: var(--safe-b); right: var(--safe-r); }
#fade { position: absolute; inset: 0; z-index: 7; background: #000; opacity: 0; pointer-events: none; transition: opacity .5s; }
#fade.on { opacity: 1; }

/* ---------- Màn chính ---------- */
#title { position: absolute; inset: 0; z-index: 13; display: grid; grid-template-columns: 1.3fr 1fr; grid-template-rows: 1fr auto; align-items: center; gap: 24px;
  padding: var(--safe-t) max(28px, var(--safe-r)) var(--safe-b) max(28px, var(--safe-l));
  background: radial-gradient(800px 500px at 30% 40%, #3a1219, #120508 70%); background-size: cover; background-position: center; }
.title-logo { display: flex; flex-direction: column; gap: 8px; text-shadow: 0 2px 18px rgba(0, 0, 0, .7); }
.title-logo > small { letter-spacing: .26em; text-transform: uppercase; color: var(--gold); font-size: 12px; }
.title-logo h1 { margin: 0; font: 700 clamp(44px, 9vw, 76px)/1 var(--display); color: var(--gold-soft); }
.press-start { grid-column: 1 / -1; justify-self: center; align-self: end; margin-bottom: 8vh; background: none; border: 0; color: var(--gold-soft);
  font: 600 18px var(--display); letter-spacing: .12em; cursor: pointer; animation: pressBlink 1.8s ease-in-out infinite; }
@keyframes pressBlink { 50% { opacity: .35; } }
.title-menu { display: flex; flex-direction: column; gap: 8px; align-items: stretch; justify-self: end; width: min(260px, 40vw); }
.title-menu button { min-height: 42px; padding: 0 18px; border-radius: 12px; border: 1px solid rgba(226, 184, 102, .35); background: rgba(20, 8, 10, .72);
  color: var(--gold-soft); font: 600 16px var(--display); letter-spacing: .04em; text-align: left; cursor: pointer; }
.title-menu button:hover, .title-menu button:focus-visible { background: rgba(122, 42, 16, .85); border-color: var(--gold-soft); }
#title.ready .press-start { display: none; }
#settings { position: absolute; inset: 0; z-index: 14; background: rgba(8, 2, 4, .86); display: grid; place-items: center; }
.set-rows { display: flex; flex-direction: column; gap: 8px; }
.set-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 6px 0; border-bottom: 1px solid rgba(226, 184, 102, .15); }
.set-row button { min-height: 34px; min-width: 110px; }
.set-row input[type=range] { width: 160px; accent-color: var(--gold-soft); }
.done-note { margin: 0; font-size: 12.5px; color: var(--jade); }
.warn { margin: 0; font-size: 11.5px; color: var(--dim); max-width: 420px; }

/* Màn mời xoay ngang (giống Ta là Quân Đại): chỉ hiện khi điện thoại cầm dọc, nằm trên mọi thứ kể cả màn Đang tải. */
#rotate { display: none; }
@media (pointer: coarse) and (orientation: portrait) {
  html body #rotate { display: grid; position: fixed; inset: 0; z-index: 1000; place-items: center; text-align: center; padding: 24px; background: #000; color: #f6ead0; }
  #rotate .rot-box { display: grid; gap: 18px; justify-items: center; max-width: 300px; }
  #rotate svg { width: 96px; height: 96px; color: #f3d797; animation: rotPhone 2.4s ease-in-out infinite; }
  #rotate p { margin: 0; font: 700 22px/1.3 var(--display); color: #f3d797; }
  #rotate small { color: #c4ab8a; font-size: 14px; }
  @keyframes rotPhone { 0%, 30% { transform: rotate(0); } 60%, 100% { transform: rotate(-90deg); } }
}
@media (pointer: coarse) and (orientation: portrait) and (prefers-reduced-motion: reduce) { #rotate svg { animation: none; } }

@media (max-height: 420px) {
  .hud-bars { width: 150px; }
  .dbox { min-height: 84px; padding: 10px 14px 20px; }
  #dText { font-size: 14px; }
  .card-box { padding: 14px 18px; }
  .card-box h2 { font-size: 24px; }
}
@media (prefers-reduced-motion: reduce) { .toast { animation-duration: .01s; } #fade { transition: none; } }
/* Thẻ Bản đồ trong túi */







/* Bản đồ nhỏ góc trái trên, bản đồ lớn phủ màn hình */
#minimap { position: absolute; left: var(--safe-l); top: calc(var(--safe-t) + 58px); width: 136px; height: 92px; border-radius: 10px; z-index: 5; cursor: pointer; touch-action: none; }
#bigmap { position: absolute; inset: 0; z-index: 9; background: rgba(8, 2, 4, .9); padding: var(--safe-t) var(--safe-r) var(--safe-b) var(--safe-l); }
#bigmapCv { width: 100%; height: 100%; display: block; }
#bigmapClose { position: absolute; right: var(--safe-r); bottom: var(--safe-b); }
.bag-map { width: 100%; height: min(46vh, 460px); display: block; border-radius: 12px; }

/* Ảnh minh hoạ kể chuyện (intro, mở chương). Ảnh 16:9 phủ kín màn; chữ nằm trên dải tối ở đáy. */
#slides { position: absolute; inset: 0; z-index: 12; background: #0b0406; overflow: hidden; }
#slideImg { position: absolute; inset: 0; background: radial-gradient(ellipse at 50% 40%, #3a1a20, #0b0406 70%) center / cover no-repeat; transition: opacity .5s; }
#slideImg.has { background-size: cover; }
#slideImg .ph { position: absolute; inset: 0; display: grid; place-items: center; font: 700 clamp(48px, 12vw, 120px) var(--display); color: rgba(243, 215, 151, .12); }
.slide-cap { position: absolute; left: 0; right: 0; bottom: 0; padding: 40px max(24px, var(--safe-r)) max(18px, var(--safe-b)) max(24px, var(--safe-l)); background: linear-gradient(180deg, transparent, rgba(8, 2, 4, .88) 45%); }
.slide-cap small { display: block; font: 700 12px var(--ui, 'Be Vietnam Pro', sans-serif); letter-spacing: .18em; color: var(--gold, #e2b866); text-transform: uppercase; margin-bottom: 4px; }
.slide-cap p { margin: 0; max-width: 760px; font: 600 clamp(15px, 2.2vw, 20px)/1.5 var(--ui, 'Be Vietnam Pro', sans-serif); color: #f7ecd6; }
#slideSkip { position: absolute; top: max(12px, var(--safe-t)); right: max(12px, var(--safe-r)); }
#slides .dnext { position: absolute; bottom: max(10px, var(--safe-b)); right: max(16px, var(--safe-r)); color: #c4ab8a; font-size: 12px; }
.card-img { width: 100%; aspect-ratio: 16 / 9; object-fit: cover; border-radius: 12px; margin-bottom: 10px; display: block; }
/* Icon Codex (art/codex/icons): thay chữ trên nút khi đã có ảnh. */
img.ic { width: 1.6em; height: 1.6em; object-fit: contain; image-rendering: auto; vertical-align: middle; }
.round > img.ic { width: 70%; height: 70%; }
#actBtn img.ic { width: 1.4em; height: 1.4em; margin-right: 4px; }

/* ---------- Bố cục màn chơi kiểu MOBA (đè theme.css nhờ độ ưu tiên #a #b) ----------
   Thanh trên: không có dải nền chạy ngang; mỗi cụm (tuổi, tiền, mục tiêu, hai thanh, tạm dừng) là một thẻ nổi riêng.
   Nút bên phải: nút chính tròn to ở góc; các nút phụ xếp vòng cung quanh nó (Túi trái, Cử chỉ chéo, Con đường trên);
   bấm Cử chỉ thì các cử chỉ bung ra thành vòng ngoài. Màu, viền, icon vẫn theo theme.css của Codex. */
body #hud { background: none; border: 0; box-shadow: none; padding: 0; }
body #ctrl { width: 300px; height: 300px; }
#ctrl #actBtn { right: 10px; bottom: 10px; width: 104px; height: 104px; border-radius: 50%; padding: 8px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: 2px; overflow: hidden; }
#ctrl #actBtn img.ic { width: 44px; height: 44px; margin: 0; }
#ctrl #actBtn #actLabel { display: block; font-size: 12px; line-height: 1.15; max-width: 84px; }
/* Tâm nút chính cách góc 62px; nút phụ 58px nằm trên vòng bán kính 122px. */
#ctrl #bagBtn, #ctrl #gestBtn, #ctrl #pathBtn { width: 58px; height: 58px; border-radius: 50%; }
#ctrl #bagBtn  { right: 155px; bottom: 33px; }   /* 180° */
#ctrl #gestBtn { right: 119px; bottom: 119px; }  /* 135° */
#ctrl #pathBtn { right: 33px; bottom: 155px; }   /* 90° */
/* Cử chỉ: vòng ngoài bán kính 205px. */
#ctrl #gestures { inset: 0; display: block; pointer-events: none; }
#ctrl #gestures[hidden] { display: none; }
#ctrl #gestures button { position: absolute; width: 66px; height: 66px; min-width: 0; min-height: 0; padding: 4px; border-radius: 50%;
  font-size: 11px; line-height: 1.1; gap: 0; pointer-events: auto; }
#ctrl #gestures button img.ic { width: 30px; height: 30px; margin: 0; }
#ctrl #gestures button small { font-size: 9px; }
#ctrl #gestures [data-gest="bow"]   { right: 232px; bottom: 109px; }  /* 157° */
#ctrl #gestures [data-gest="shout"] { right: 109px; bottom: 232px; }  /* 113° */
#ctrl #gestures [data-gest="mud"]   { right: 178px; bottom: 178px; }  /* 135° */
@media (max-height: 380px) {
  body #ctrl { transform: scale(.85); transform-origin: right bottom; }
}

/* ---------- Mini game: cùng bố cục màn chơi ---------- */
#mg { padding: 0; display: block; background: #0c0406; }
#mgStage { position: absolute; inset: 0; border-radius: 0; }
#mgStage.dom > div { padding: calc(var(--safe-t) + 64px) calc(var(--safe-r) + 228px) calc(var(--safe-b) + 12px) calc(var(--safe-l) + 12px) !important; }
#mg .mg-head { position: absolute; top: calc(var(--safe-t) + 6px); left: calc(var(--safe-l) + 6px); max-width: calc(28% - var(--safe-l) - 10px); z-index: 2; gap: 8px; }
/* Thẻ tên trò chỉ chiếm phần trái (≤ 28% bề ngang, trừ nút ✕), thẻ giữa (luật/mục tiêu) chiếm 28–72%, cột phải ≤ 28%:
   tên dài thì xuống dòng chứ không đè lên bảng luật (QA 23/10). */
#mg .mg-name { min-width: 0; display: flex; flex-direction: column; padding: 6px 12px; border-radius: 12px; background: rgba(20, 8, 10, .82); border: 1px solid rgba(226, 184, 102, .3); }
#mg #mgTitle { font: 700 16px/1.15 var(--display); flex: none; }
#mg #mgTimer { font: 600 12px var(--body, inherit); color: var(--muted); }
#mgGoal { position: absolute; top: calc(var(--safe-t) + 6px); left: 50%; transform: translateX(-50%); max-width: min(44%, 380px); z-index: 2; }
#mgGoal:empty { display: none; }
#mgGoal .side-card { font-size: 12px; text-align: center; }
#mg #mgSide { position: absolute; top: calc(var(--safe-t) + 6px); right: calc(var(--safe-r) + 6px); width: min(200px, calc(28% - 12px)); box-sizing: border-box; max-height: calc(100% - 240px); overflow: auto; z-index: 2; gap: 6px; }
#mg .side-card { background: rgba(20, 8, 10, .82); padding: 7px 10px; }
#mg .side-big { font-size: 20px; }
/* Cụm nút: giống #ctrl ngoài màn chơi. */
#mgActs { position: absolute; right: var(--safe-r); bottom: var(--safe-b); width: 300px; height: 300px; z-index: 2; pointer-events: none; }
#mgActs > button { position: absolute; pointer-events: auto; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  text-align: center; font-weight: 700; line-height: 1.1; touch-action: none; padding: 4px; overflow: visible; overflow-wrap: anywhere; }
/* QA 27/10: nhãn dài ("Xé giấy tờ đấy", "Chặt xấp") bị cắt trong nút tròn 64px: cho tràn ra mép, có viền chữ cho dễ đọc. */
#mgActs .act-sub { text-shadow: 0 1px 2px #000, 0 0 4px #000; }
#mgActs > button img.ic { width: 40%; height: 40%; margin: 0; }
#mgActs .act-main { right: 10px; bottom: 10px; width: 104px; height: 104px; border-radius: 50%; font-size: 13px; color: #fff4dc; }
#mgActs .act-sub { width: 64px; height: 64px; border-radius: 50%; font-size: 10.5px; color: var(--gold-soft); }
#mgActs .act-sub.s0 { right: 152px; bottom: 30px; } #mgActs .act-sub.s1 { right: 116px; bottom: 116px; } #mgActs .act-sub.s2 { right: 30px; bottom: 152px; }
#mgActs > button:disabled { opacity: .45; }
#mgActs > button.pressed { transform: scale(.94); }
/* Cần gạt nổi trong mini game: giống #stick. */
.mg-stick { position: absolute; width: 112px; height: 112px; margin: -56px 0 0 -56px; border-radius: 50%; border: 2px solid rgba(255, 255, 255, .45);
  background: rgba(255, 255, 255, .07); pointer-events: none; opacity: 0; transition: opacity .12s; z-index: 3; }
.mg-stick.on { opacity: 1; }
.mg-stick i { position: absolute; left: 50%; top: 50%; width: 46px; height: 46px; margin: -23px 0 0 -23px; border-radius: 50%; background: rgba(243, 215, 151, .8); box-shadow: 0 0 12px rgba(243, 215, 151, .5); }
@media (max-height: 380px) { #mgActs { transform: scale(.85); transform-origin: right bottom; } }

/* ---------- Nút kiểu kỹ năng (Tốc chiến): cả nút là hình, viền mảnh, không nền màu, không chữ ---------- */
#ctrl #actBtn, #mgActs .act-main { width: 84px; height: 84px; }
#ctrl #bagBtn, #ctrl #gestBtn, #ctrl #pathBtn, #mgActs .act-sub { width: 54px; height: 54px; }
#ctrl #bagBtn { right: 112px; bottom: 18px; } #ctrl #gestBtn { right: 92px; bottom: 92px; } #ctrl #pathBtn { right: 18px; bottom: 112px; }
#mgActs .act-main { right: 12px; bottom: 12px; }
#mgActs .act-sub.s0 { right: 112px; bottom: 18px; } #mgActs .act-sub.s1 { right: 92px; bottom: 92px; } #mgActs .act-sub.s2 { right: 18px; bottom: 112px; }
#ctrl #gestures [data-gest="bow"] { right: 176px; bottom: 60px; } #ctrl #gestures [data-gest="shout"] { right: 60px; bottom: 176px; } #ctrl #gestures [data-gest="mud"] { right: 140px; bottom: 140px; }
#ctrl #gestures button { width: 54px; height: 54px; }
body .skill, body #ctrl #actBtn.skill, body #mgActs > button.skill { background: radial-gradient(circle, rgba(40, 26, 16, .78), rgba(8, 5, 4, .7)); border: 2px solid rgba(226, 184, 102, .8); padding: 0; overflow: hidden;
  box-shadow: 0 2px 10px rgba(0, 0, 0, .55), inset 0 0 0 1px rgba(0, 0, 0, .4); color: transparent; }
body .skill img.ic, body #actBtn.skill img.ic { width: 100%; height: 100%; margin: 0; object-fit: contain; border-radius: 50%; display: block; }
body #actBtn.skill #actLabel { display: block; width: 100%; height: 100%; }
body #actBtn.idle { opacity: .5; }
body .skill.pressed, body #actBtn.skill.pressed { transform: scale(.92); filter: brightness(1.25); }
body .skill:disabled { opacity: .35; filter: grayscale(.8); }
/* Lựa chọn trả lời trong mini game: như lựa chọn hội thoại. */
#mgActs .mg-choices { position: absolute; right: 12px; bottom: 12px; display: flex; flex-direction: column; gap: 6px; align-items: stretch; pointer-events: auto; width: 210px; }
#mgActs .mg-choices button { min-height: 40px; padding: 6px 14px; border-radius: 10px; border: 1px solid rgba(226, 184, 102, .55); background: rgba(20, 8, 10, .88); color: #fff4dc; font-weight: 600; font-size: 13px; text-align: left; }

/* ---------- HUD chuẩn RPG (story/GIAODIEN.md mục 5): thanh trên chỉ có chỉ số A Sửu; nhiệm vụ ở góc trái ---------- */
#hudGoal { display: none !important; } /* dòng mục tiêu cũ: nay là bước kế tiếp trong bảng nhiệm vụ */
#areaName { position: absolute; left: var(--safe-l); top: calc(var(--safe-t) + 152px); width: 136px; z-index: 5; pointer-events: none;
  font: 700 12px/1.2 var(--display); color: var(--gold-soft); text-align: center; text-shadow: 0 1px 3px #000, 0 0 8px #000; }
#areaName.flash { animation: areaIn 1.6s ease-out; }
@keyframes areaIn { 0% { opacity: 0; transform: translateY(-4px); letter-spacing: .2em; } 30% { opacity: 1; } 100% { opacity: 1; transform: none; letter-spacing: 0; } }
#questTrack { position: absolute; left: var(--safe-l); top: calc(var(--safe-t) + 172px); width: 220px; z-index: 5; display: flex; flex-direction: column; gap: 6px;
  padding: 0; background: none; border: 0; text-align: left; color: var(--paper); cursor: pointer; }
#questTrack[hidden] { display: none; }
.qt-item { padding: 6px 9px; border-radius: 8px; background: linear-gradient(90deg, rgba(14, 8, 6, .82), rgba(14, 8, 6, .45)); border-left: 3px solid var(--gold); }
.qt-item.ngay { border-left-color: #e88a9a; } .qt-item.phu { border-left-color: #7fc8e0; }
.qt-head { display: flex; align-items: baseline; gap: 6px; flex-wrap: wrap; }
.qt-head b { font-size: 12px; color: var(--gold-soft); }
.qt-kind { font-style: normal; font-size: 9.5px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.qt-step { font-size: 11.5px; line-height: 1.35; margin-top: 2px; color: #f3e9d2; }
.qt-step::before { content: '▸ '; color: var(--gold); }
.qt-status { font-size: 10.5px; padding: 0 6px; border-radius: 999px; background: rgba(255, 255, 255, .1); }
.qt-status.ok { color: #9ee0b8; } .qt-status.warn { color: #f3d797; } .qt-status.bad { color: #ff9aa6; animation: lowBlink 1.2s ease-in-out infinite; }
/* Thẻ Nhiệm vụ trong menu. */
.ql { display: flex; flex-direction: column; gap: 8px; }
.ql h3 { margin: 6px 0 0; }
.ql-card { padding: 10px 12px; border-radius: 10px; background: rgba(20, 8, 10, .55); border: 1px solid rgba(226, 184, 102, .25); }
.ql-card.done { opacity: .55; }
.ql-card p { margin: 4px 0 6px; font-size: 12.5px; color: #e5dfcb; }
.ql-card ul { margin: 0; padding-left: 18px; font-size: 12.5px; }
.ql-card li.done { text-decoration: line-through; color: var(--muted); } .ql-card li.now { color: var(--gold-soft); font-weight: 700; }
.ql-tag { font-size: 10px; padding: 0 6px; border-radius: 999px; border: 1px solid rgba(255, 154, 166, .5); color: #ff9aa6; }
.ql-tag.ok { border-color: rgba(127, 224, 176, .5); color: #9ee0b8; }
/* Gợi ý chỉ vào nút. */
.hint-pulse { animation: hintPulse 0.9s ease-in-out infinite; }
@keyframes hintPulse { 50% { box-shadow: 0 0 0 6px rgba(243, 215, 151, .55), 0 0 18px rgba(243, 215, 151, .8); } }
.hint-bubble { position: fixed; z-index: 30; padding: 6px 12px; border-radius: 10px; background: rgba(255, 248, 232, .96); color: #3a1410; font-size: 13px; font-weight: 700;
  box-shadow: 0 4px 14px rgba(0, 0, 0, .5); pointer-events: none; }
/* Thông báo ngắn: dải nhỏ ngay dưới thanh trên, không chiếm giữa màn. */
#toasts { top: calc(var(--safe-t) + 48px); }
.toast { font-size: 12px; padding: 4px 12px; }

/* ---------- HUD màn ngang (bản 2): góc dưới hai bên để trống cho hai ngón cái ---------- */
/* Trái trên: bản đồ nhỏ (tên khu ở mép dưới), dưới nó một dòng tuổi · ngày · buổi.
   Cạnh bản đồ nhỏ: nhiệm vụ đang theo dõi (tối đa 2 dòng). Phải trên: Sức A Sửu, tạm dừng.
   Tiền không nằm trên màn chính: xem trong Túi. */
body #hud { display: block; inset: auto; top: 0; left: 0; right: 0; height: 0; z-index: 6; }
body #hud .hud-mid { display: none; }
body #hud .hud-when { position: absolute; left: var(--safe-l); top: calc(var(--safe-t) + 90px); width: 124px; padding: 2px 6px; border: 0; border-radius: 6px;
  background: rgba(14, 8, 6, .7); flex-direction: row; gap: 4px; align-items: baseline; justify-content: center; }
body #hud .hud-when b { font: 700 11px/1.3 var(--body, inherit); color: var(--gold-soft); }
body #hud .hud-when small { font-size: 10.5px; }
body #hud .hud-bars { position: absolute; right: calc(var(--safe-r) + 52px); top: var(--safe-t); width: 150px; padding: 5px 9px; }
body #hud #pauseBtn { position: absolute; right: var(--safe-r); top: var(--safe-t); }
body #minimap { top: var(--safe-t); width: 124px; height: 86px; }
/* Tên map: góc trên trái bản đồ nhỏ, chữ nhỏ, dài thì "…". Buổi: icon mặt trời/trăng góc trên phải bản đồ nhỏ. */
body #areaName { top: calc(var(--safe-t) + 3px); left: calc(var(--safe-l) + 4px); width: auto; max-width: 92px; padding: 1px 5px; border-radius: 5px;
  background: rgba(14, 8, 6, .62); font: 600 10px/1.3 var(--body, inherit); text-align: left; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
body #areaName.flash { animation: none; }
body #hud .hud-part { position: absolute; left: calc(var(--safe-l) + 124px - 23px); top: calc(var(--safe-t) + 3px); width: 20px; height: 20px; z-index: 6;
  display: grid; place-items: center; border-radius: 50%; background: rgba(14, 8, 6, .62); pointer-events: auto; }
body #hud .hud-part[hidden] { display: none; }
body #questTrack { top: var(--safe-t); left: calc(var(--safe-l) + 132px); width: min(270px, 34vw); gap: 4px; }
.qt-item { padding: 5px 9px; }
.qt-item.chinh .qt-title { display: block; font-size: 11.5px; color: var(--gold-soft); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.qt-item .qt-step { font-size: 11.5px; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 1px; }
.qt-item.urgent { display: flex; gap: 6px; align-items: center; border-left-color: #e88a9a; }
.qt-item.urgent .qt-step { margin: 0; }
#toasts { top: calc(var(--safe-t) + 56px); left: 56%; }
/* Nút đóng: tròn, chỉ có icon, ở góc phải trên của bảng. */
.close-btn, body #panelClose, body #bigmapClose { position: absolute; top: calc(var(--safe-t) + 6px); right: calc(var(--safe-r) + 6px); bottom: auto; width: 44px; height: 44px; min-height: 0; padding: 0; font-size: 18px; z-index: 3; }
body #panelBody { padding-right: 56px; }
.qt-item.urgent .qt-status { white-space: nowrap; flex: none; }

/* Bảng theo dõi: một nhiệm vụ đang làm. */
body #questTrack .qt-item { padding: 5px 10px; }
body #questTrack .qt-head { flex-wrap: nowrap; }
body #questTrack .qt-title { white-space: normal; overflow: visible; min-width: 0; font-size: 11.5px; color: var(--gold-soft); }
/* Ô nhiệm vụ: chữ "Nhiệm vụ" một dòng, tên nhiệm vụ hiện đủ (xuống dòng nếu dài). */
body #questTrack .qt-kind { white-space: nowrap; flex: none; }
body #questTrack .qt-head { align-items: baseline; gap: 6px; }
.ql-track { min-height: 32px; margin-top: 6px; padding: 0 12px; font-size: 12px; }
body #hud .hud-when { width: auto; max-width: 160px; justify-content: flex-start; white-space: nowrap; }

/* Bản đồ lớn: cảnh đang đứng (trái) + sơ đồ kinh thành và đi nhanh (phải). */
body #bigmap { display: grid; grid-template-columns: minmax(0, 1fr) 260px; gap: 12px; padding: calc(var(--safe-t) + 8px) calc(var(--safe-r) + 60px) calc(var(--safe-b) + 8px) calc(var(--safe-l) + 8px); }
body #bigmap[hidden] { display: none; }
#bigmap .bm-main { display: flex; flex-direction: column; min-height: 0; gap: 6px; }
#bigmapTitle { font: 700 18px var(--display); color: var(--gold-soft); }
body #bigmapCv { flex: 1; min-height: 0; width: 100%; height: auto; }
#bigmapSide { overflow-y: auto; min-height: 0; display: flex; flex-direction: column; gap: 8px; }
#bigmapSide h3 { margin: 0; font: 700 16px var(--display); color: var(--gold-soft); }

.ql-reward { display: flex; flex-wrap: wrap; gap: 6px 12px; align-items: center; margin: 6px 0 2px; font-size: 12px; color: #f3e9d2; }
.ql-reward i { font-style: normal; font-size: 10.5px; letter-spacing: .06em; text-transform: uppercase; color: var(--gold); }
.ql-reward span { display: inline-flex; align-items: center; gap: 4px; }
.ql-reward img { width: 22px; height: 22px; object-fit: contain; }
body #bigmap { grid-template-columns: minmax(0, 1fr); }

/* Intro tự chạy: khung phủ cả màn, trên mọi thứ. */
#introFilm { position: fixed; inset: 0; width: 100%; height: 100%; border: 0; z-index: 50; background: #000; }
#sheetList button.has-ic { display: grid; grid-template-columns: 40px minmax(0,1fr); column-gap: 10px; align-items: center; }
#sheetList button.has-ic small { grid-column: 2; }
.sheet-ic { width: 40px; height: 40px; border-radius: 50%; grid-row: span 2; }
#sheet { position: relative; }

/* ---------- Thẻ mở chương: ảnh tràn màn, chữ vàng kim trên ảnh (như intro) ---------- */
body #card.full { background: #000 center/cover no-repeat; place-items: end start; padding: 0; }
body #card.full::before { content: ''; position: absolute; inset: 0; background: linear-gradient(90deg, rgba(0,0,0,.72) 0%, rgba(0,0,0,.35) 38%, rgba(0,0,0,0) 62%), linear-gradient(0deg, rgba(0,0,0,.55), rgba(0,0,0,0) 45%); pointer-events: none; }
body #card.full .card-box { position: relative; width: min(560px, 62vw); max-height: 100%; overflow-x: hidden; overflow-y: auto; background: none; /* thẻ dài (Hết Hồi: nhiều dòng mang sang) cuộn được, nút không rơi khỏi màn 390 px */ border: 0; box-shadow: none; border-radius: 0;
  padding: 0 0 calc(var(--safe-b) + 22px) calc(var(--safe-l) + 34px); gap: 6px; }
body #card.full #cardKicker { font: 600 13px var(--body); letter-spacing: .32em; color: #e8c983; text-shadow: 0 1px 6px #000; }
body #card.full .card-box h2 { font: 700 clamp(40px, 7.5vw, 64px)/1.02 var(--display);
  background: linear-gradient(180deg, #fff1c4 0%, #f0cf7a 45%, #b8862e 100%); -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 2px 6px rgba(0,0,0,.85)); }
body #card.full #cardBody { font: 500 15px/1.6 var(--body); color: #f6ead0; text-shadow: 0 1px 5px #000, 0 0 14px #000; max-width: 52ch; }
body #card.full #cardBtns { justify-content: flex-start; margin-top: 10px; }
body #card.full #cardBtns .primary { background: linear-gradient(180deg, rgba(240,207,122,.95), rgba(184,134,46,.95)); color: #2a1408; border: 0; }

/* ---------- Nền và khung giao diện bằng ảnh Codex (art/codex/ui/, story/GIAODIEN.md mục 0) ----------
   Không dùng nền màu phẳng (kể cả nền xanh của theme.css). Có ảnh thì dùng ảnh; chưa có thì tạm là lớp tối trong mờ
   cho thấy cảnh phía sau, cho tới khi Codex giao. Khung: border-image 9 mảnh, viền 32 px không kéo giãn. */
html body #panel { background: rgba(10, 6, 4, .78); backdrop-filter: blur(6px); }
html.ui-bg-menu body #panel { background: var(--ui-bg-menu) center/cover no-repeat; backdrop-filter: none; }
html body #card:not(.full), html body #pause, html body #settings, html body #slots, html body #howto, html body #shop { background: rgba(6, 4, 3, .55); backdrop-filter: blur(5px); }
html body .card-box, html body .dbox, html body #sheet { background: rgba(14, 9, 6, .9); border: 1px solid rgba(226, 184, 102, .35); box-shadow: 0 10px 30px rgba(0,0,0,.6); }
html.ui-frame-popup body #card:not(.full) .card-box, html.ui-frame-popup body #pause .card-box, html.ui-frame-popup body #settings .card-box,
html.ui-frame-popup body #slots .card-box, html.ui-frame-popup body #howto .card-box { background: none; border: 32px solid transparent; border-image: var(--ui-frame-popup) 32 fill / 32px stretch; box-shadow: none; padding: 4px 8px; }
html.ui-bg-shop body #shop .card-box { background: var(--ui-bg-shop) center/cover no-repeat; border: 0; }
/* Gánh hàng rong ngoài phố: nền gánh hàng dưới hiên chợ, không phải trong tiệm (QA 26/10). */
/* theme.css (Codex) ép nền tiệm cho mọi #shop bằng !important: chọn cụ thể hơn để gánh hàng dùng nền phố chợ. */
html.ui-bg-ganh-hang body #game #shop[data-shop="ganh_hang"] { background-image: var(--ui-bg-ganh-hang) !important; }
/* Ngoài trời đang mưa: nền gánh hàng tối lại, có vệt mưa (ảnh nền chỉ có bản trời nắng). */
html body #game #shop[data-shop="ganh_hang"][data-weather="rain"]::after { content: ''; position: absolute; inset: 0; pointer-events: none; z-index: 0;
  background: repeating-linear-gradient(105deg, rgba(200, 215, 230, .16) 0 1px, transparent 1px 9px), rgba(20, 30, 45, .45); }
html body #game #shop[data-shop="ganh_hang"][data-weather="rain"] .card-box { position: relative; z-index: 1; }
html.ui-frame-dialog body .dbox { background: none; border: 28px solid transparent; border-image: var(--ui-frame-dialog) 28 fill / 28px stretch; box-shadow: none; }
html.ui-frame-sheet body #sheet { background: none; border: 28px solid transparent; border-image: var(--ui-frame-sheet) 28 fill / 28px stretch; box-shadow: none; }
/* Thẻ nhỏ (thanh trên, nhiệm vụ đang làm, số liệu mini game, thông báo) và dòng danh sách. */
html body .hud-when, html body .hud-bars, html body .qt-item, html body #mg .side-card, html body #mg .mg-name, html body .toast { background: rgba(14, 9, 6, .78); }
html.ui-frame-chip body .hud-when, html.ui-frame-chip body .hud-bars, html.ui-frame-chip body .qt-item, html.ui-frame-chip body #mg .side-card, html.ui-frame-chip body #mg .mg-name, html.ui-frame-chip body .toast
  { background: none; border: 12px solid transparent; border-image: var(--ui-frame-chip) 16 fill / 12px stretch; }
html body .shop-row, html body .bag-row, html body .slot-row, html body #sheetList button, html body .ql-card, html body #panelTabs button { background: rgba(28, 18, 12, .82); }
html.ui-frame-row body .shop-row, html.ui-frame-row body .bag-row, html.ui-frame-row body .slot-row, html.ui-frame-row body #sheetList button, html.ui-frame-row body .ql-card, html.ui-frame-row body #panelTabs button
  { background: none; border: 14px solid transparent; border-image: var(--ui-frame-row) 18 fill / 14px stretch; }
html.ui-btn-primary body .primary:not(.skill) { background: none; border: 14px solid transparent; border-image: var(--ui-btn-primary) 18 fill / 14px stretch; }
html.ui-btn-secondary body .ghost:not(.skill) { background: none; border: 14px solid transparent; border-image: var(--ui-btn-secondary) 18 fill / 14px stretch; }

/* Cử chỉ mở ra: cùng kiểu nút kỹ năng (đè nền xanh #gestures button của theme.css). */
html body #ctrl #gestures button.skill { background: rgba(8, 5, 4, .28); border: 2px solid rgba(226, 184, 102, .8); padding: 0; overflow: hidden; }
html body #ctrl #gestures button.skill img.ic { width: 100%; height: 100%; border-radius: 50%; }
html body #ctrl #actBtn.idle.skill { opacity: .55; filter: grayscale(.5); }
html body #ctrl #actBtn.skill { padding: 0; }
html body #ctrl #actBtn.skill #actLabel { display: block; width: 100%; height: 100%; max-width: none; }
html body #ctrl #actBtn.skill img.ic { width: 100%; height: 100%; margin: 0; border-radius: 50%; object-fit: cover; }
html body #ctrl #actBtn.idle.skill { opacity: .72; filter: grayscale(.35); }

/* Nút đóng của bảng danh sách: nằm trên dòng tiêu đề, góc phải, không đè lên các dòng. */
body #sheet #sheetTitle { display: block; min-height: 34px; line-height: 34px; padding-right: 44px; }
body #sheet #sheetClose { top: 0; right: 0; width: 34px; height: 34px; }
/* Bảng menu và bản đồ lớn: nút đóng ở góc phải trên màn, lùi khỏi nội dung. */
body #panel #panelClose, body #bigmap #bigmapClose { top: calc(var(--safe-t) + 10px); right: calc(var(--safe-r) + 10px); width: 40px; height: 40px; }

/* Tiền: số + icon tiền đồng thay cho chữ "đồng" (engine/i18n.js coinify). */
.coin { display: inline-flex; align-items: center; gap: 2px; white-space: nowrap; }
.coin img { height: 1.5em; width: auto; vertical-align: -0.25em; filter: drop-shadow(0 1px 1px rgba(0,0,0,.6)); }

/* ---------- Màn tiêu đề: tên game viết thư pháp, vàng kim như chữ trên thẻ chương; một câu của A Sửu bên dưới ---------- */
#title .title-logo { gap: 2px; text-shadow: none; }
.title-han { font: 400 clamp(26px, 4.6vw, 40px)/1 'Ma Shan Zheng', 'Kaiti SC', 'STKaiti', serif; letter-spacing: .32em; padding-left: .3em;
  background: linear-gradient(180deg, #fff1c4 0%, #f0cf7a 45%, #b8862e 100%); -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 2px 5px rgba(0,0,0,.85)); opacity: .92; }
#title .title-logo h1 { font: 400 clamp(44px, 8.4vw, 96px)/1.1 'Water Brush', 'Charm', 'Ma Shan Zheng', var(--display); white-space: nowrap; padding: .04em .12em .1em 0; margin-left: -.04em;
  background: linear-gradient(180deg, #fff3cc 0%, #f3d27e 40%, #d4a24a 70%, #9c6b22 100%); -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 3px 8px rgba(0,0,0,.9)) drop-shadow(0 0 22px rgba(240,190,90,.18)); }
html[lang="th"] #title .title-logo h1 { font-family: 'Charm', var(--display); font-weight: 700; font-size: clamp(44px, 8vw, 80px); line-height: 1.35; padding-top: .3em; }
html[lang="zh"] #title .title-logo h1 { font-family: 'Ma Shan Zheng', 'Kaiti SC', serif; letter-spacing: .12em; }
html[lang="zh"] .title-han { display: none; }
.title-quote { margin: 14px 0 0; max-width: 42ch; padding-left: 14px; border-left: 2px solid rgba(226, 184, 102, .55); }
.title-quote p { margin: 0; font: italic 500 clamp(14px, 1.9vw, 17px)/1.5 'Cormorant Garamond', var(--display); color: #f1e2c0; text-shadow: 0 1px 6px #000, 0 0 16px #000; }
.title-quote cite { display: block; margin-top: 4px; font: 600 11px var(--body); letter-spacing: .24em; text-transform: uppercase; font-style: normal; color: var(--gold); }
.title-quote cite::before { content: '— '; }
/* Tên game thư pháp: cỡ chữ theo bề rộng cột logo (luôn nằm gọn một dòng ở mọi màn ngang), và chừa lề quanh chữ để
   nét đuôi (đuôi chữ G, chữ T) không bị cắt: chữ vàng dùng background-clip nên phần nằm ngoài khung sẽ mất. */
#title .title-logo { container-type: inline-size; min-width: 0; }
#title .title-logo h1 { font-size: min(14.5cqi, 17vh, 96px); padding: .12em .3em .32em .3em; margin: -.12em -.3em -.1em -.3em; }
html[lang="th"] #title .title-logo h1 { font-size: min(19cqi, 19vh, 80px); padding-top: .4em; margin-top: -.05em; }
html[lang="zh"] #title .title-logo h1 { font-size: min(22cqi, 24vh, 110px); }
.title-han { font-size: min(8cqi, 9vh, 40px); }

#title:not(.ready) { cursor: pointer; }

/* ---------- Màn Đang tải (lúc mở / F5) ---------- */
/* Nền là ảnh tiêu đề (tải đầu tiên vì nằm ngay trong CSS), làm tối; chưa có ảnh thì tạm nền tối. */
#boot { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center;
  background: linear-gradient(rgba(10,4,6,.72), rgba(10,4,6,.9)), url("art/codex/cg/title.webp") center / cover no-repeat, #0b0406; transition: opacity .4s; }
#boot.done { opacity: 0; pointer-events: none; }
.boot-box { display: flex; flex-direction: column; align-items: center; gap: 14px; width: min(320px, 60vw); }
.boot-han { font: 400 clamp(34px, 7vw, 54px)/1 'Ma Shan Zheng', 'Kaiti SC', 'STKaiti', serif; letter-spacing: .3em; padding-left: .3em;
  background: linear-gradient(180deg, #fff1c4 0%, #f0cf7a 45%, #b8862e 100%); -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 2px 6px rgba(0,0,0,.85)); }
.boot-bar { position: relative; width: 100%; height: 4px; border-radius: 2px; background: rgba(226, 184, 102, .18); overflow: hidden; }
.boot-bar i { position: absolute; inset: 0 auto 0 0; width: 2%; background: linear-gradient(90deg, #b8862e, #f3d27e, #fff1c4); box-shadow: 0 0 10px rgba(240,200,110,.6); transition: width .25s; }
#bootText { font: 500 12px var(--body); letter-spacing: .18em; color: #d9c08c; }
/* Màn tiêu đề giữ nguyên bố cục khi chuyển từ "Chạm để bắt đầu" sang menu: dòng chạm nằm ngoài lưới (ghim đáy màn),
   nên tên game và câu trích không bị đẩy lên / tụt xuống khi dòng đó ẩn đi. */
#title { grid-template-rows: 1fr; }
#title .press-start { position: absolute; left: 50%; bottom: calc(var(--safe-b) + 8vh); transform: translateX(-50%); margin: 0; white-space: nowrap; }

/* Ảnh nền cho hội thoại khi chưa có bản đồ (ui.backdrop), và cụm nút ẩn khi chưa có bản đồ. */
#backdrop { position: absolute; inset: 0; background: #0b0406 center / cover no-repeat; pointer-events: none; }
#backdrop::after { content: ''; position: absolute; inset: 0; background: linear-gradient(0deg, rgba(0,0,0,.55), rgba(0,0,0,0) 45%); }
#ctrl.nomap { display: none !important; }

/* Tên chương / tên hồi trên thẻ ảnh tràn màn: cùng kiểu thư pháp vàng kim với tên game ở màn tiêu đề.
   Chừa lề quanh chữ để nét đuôi không bị cắt (chữ vàng dùng background-clip). */
body #card.full .card-box h2 { font: 400 clamp(46px, 8.6vw, 92px)/1.12 'Water Brush', 'Charm', 'Ma Shan Zheng', var(--display);
  background: linear-gradient(180deg, #fff3cc 0%, #f3d27e 40%, #d4a24a 70%, #9c6b22 100%); -webkit-background-clip: text; background-clip: text; color: transparent;
  padding: .1em .3em .3em .3em; margin: -.1em -.3em -.2em -.3em; text-wrap: balance;
  filter: drop-shadow(0 3px 8px rgba(0,0,0,.9)) drop-shadow(0 0 22px rgba(240,190,90,.18)); }
html[lang="th"] body #card.full .card-box h2 { font-family: 'Charm', var(--display); font-weight: 700; font-size: clamp(40px, 7vw, 72px); line-height: 1.4; padding-top: .35em; }
html[lang="zh"] body #card.full .card-box h2 { font-family: 'Ma Shan Zheng', 'Kaiti SC', serif; letter-spacing: .06em; }
/* Gradient vàng lặp lại theo từng dòng (tên dài xuống dòng thì dòng nào cũng vàng kim như nhau). */
body #card.full .card-box h2 { background-size: 100% 1.12em; background-repeat: repeat-y; background-position: 0 .1em; }
html[lang="th"] body #card.full .card-box h2 { background-size: 100% 1.4em; background-position: 0 .35em; }
/* Màn mở hồi: dòng phụ dưới tên hồi. */
body #card.full .act-sub { margin: 0; font: italic 500 clamp(18px, 2.6vw, 26px)/1.4 'Cormorant Garamond', var(--display); letter-spacing: .04em; color: #f3e2bd; text-shadow: 0 1px 6px #000, 0 0 18px #000; }
/* Trên ảnh sáng, vàng nhạt trông như màu kem: dùng dải vàng đậm hơn cho tên chương / tên hồi. */
body #card.full .card-box h2 { background-image: linear-gradient(180deg, #fff0b8 0%, #f2c964 32%, #d39a3c 62%, #8f5c17 100%); }
/* art/codex/theme.css (Codex, nạp sau) đặt tên chương màu phẳng: người chơi yêu cầu tên chương vàng kim thư pháp như tên game,
   nên ghi đè bằng bộ chọn mạnh hơn (không sửa tệp của Codex). */
html body #game #card.full .card-box h2#cardTitle {
  background-image: linear-gradient(180deg, #fff0b8 0%, #f2c964 32%, #d39a3c 62%, #8f5c17 100%);
  background-size: 100% 1.12em; background-repeat: repeat-y; background-position: 0 .1em;
  -webkit-background-clip: text; background-clip: text; color: transparent; -webkit-text-fill-color: transparent; }
html[lang="th"] body #game #card.full .card-box h2#cardTitle { background-size: 100% 1.4em; background-position: 0 .35em; }

/* ---------- Thẻ tiêu đề tự chạy (mở hồi, mở chương): không nút, hiện dần rồi tự chuyển ---------- */
body #card.auto { opacity: 0; transition: opacity .6s ease; cursor: pointer; }
body #card.auto.in { opacity: 1; }
body #card.auto.out { opacity: 0; }
body #card.auto #cardBtns { display: none; }
body #card.auto .card-box { transition: opacity .6s ease, transform .9s ease; }
body #card.auto:not(.in) .card-box { transform: translateY(10px); }
/* Dòng chuyển cảnh ("Ba năm sau…"): giữa màn, trên ảnh làm tối và mờ; xong thì ảnh rõ dần và tên chương hiện. */
body #card .card-lead { position: absolute; inset: 0; display: grid; place-items: center; padding: 0 8vw; text-align: center; pointer-events: none;
  font: italic 500 clamp(24px, 4.2vw, 40px)/1.3 'Cormorant Garamond', var(--display); letter-spacing: .06em; color: #f3e2bd;
  text-shadow: 0 2px 12px #000; opacity: 0; transition: opacity .6s ease; }
body #card.auto.leading .card-lead { opacity: 1; }
body #card.auto.leading .card-box { opacity: 0; }
body #card.auto::after { content: ''; position: absolute; inset: 0; pointer-events: none; background: rgba(6, 3, 2, .72); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); opacity: 0; transition: opacity .8s ease; }
body #card.auto.leading::after { opacity: 1; }
body #card .card-lead { z-index: 2; }
/* Thẻ tự chạy: "Chương N: tên" nằm một dòng (khung chữ rộng hơn, cỡ chữ theo bề ngang màn). */
body #card.full.auto .card-box { width: min(980px, 90vw); }
html body #game #card.full.auto .card-box h2#cardTitle { font-size: clamp(36px, 6.4vw, 82px); }
html[lang="th"] body #game #card.full.auto .card-box h2#cardTitle { font-size: clamp(32px, 5.6vw, 66px); }
/* Ảnh sáng (chương ban ngày): tối góc dưới trái sau tên chương cho chữ vàng nổi. */
body #card.full.auto::before { background: radial-gradient(ellipse 70% 55% at 22% 82%, rgba(0,0,0,.78), rgba(0,0,0,.35) 55%, rgba(0,0,0,0) 80%), linear-gradient(0deg, rgba(0,0,0,.45), rgba(0,0,0,0) 40%); }
html body #game #card.full.auto .card-box h2#cardTitle { filter: drop-shadow(0 2px 3px rgba(0,0,0,.95)) drop-shadow(0 0 14px rgba(0,0,0,.8)); }

/* ---------- Chữ vàng nhũ (gold foil): dùng chung cho tên game, 假金钗, tên hồi / chương ----------
   Kim loại thật có dải sáng tối xen nhau (không phải một màu vàng chuyển nhẹ): các dải đồng tối, vàng sậm, ánh trắng.
   Lớp hạt nhũ (nhiễu SVG) phủ lên làm mặt chữ lấp lánh; viền nâu tối mảnh + quầng tối để chữ tách khỏi ảnh sáng. */
:root {
  --foil-bands: linear-gradient(176deg, #6e4a12 0%, #b8862e 14%, #f6dc8c 30%, #fff7d6 38%, #e2b85a 48%, #9a6a1c 60%, #d9ab4c 72%, #ffe9a8 84%, #a87526 100%);
  --foil-grain: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='160' height='160'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='1.1' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 1  0 0 0 0 0.93  0 0 0 0 0.7  0 0 0 1.6 -0.55'/></filter><rect width='160' height='160' filter='url(%23n)' opacity='.55'/></svg>");
  --foil-edge: drop-shadow(0 0 .6px #2a1405) drop-shadow(0 0 .6px #2a1405) drop-shadow(0 2px 2px rgba(0,0,0,.9)) drop-shadow(0 0 16px rgba(0,0,0,.75));
}
#title .title-logo h1, .title-han, .boot-han, html body #game #card.full .card-box h2#cardTitle {
  background-image: var(--foil-grain), var(--foil-bands) !important;
  -webkit-background-clip: text !important; background-clip: text !important; color: transparent !important; -webkit-text-fill-color: transparent !important;
  filter: var(--foil-edge) !important; }
#title .title-logo h1, .title-han, .boot-han { background-size: 160px 160px, 100% 100% !important; background-repeat: repeat, no-repeat !important; }
html body #game #card.full .card-box h2#cardTitle { background-size: 160px 160px, 100% 1.12em !important; background-repeat: repeat, repeat-y !important; background-position: 0 0, 0 .1em !important; }
html[lang="th"] body #game #card.full .card-box h2#cardTitle { background-size: 160px 160px, 100% 1.4em !important; background-position: 0 0, 0 .35em !important; }
/* Ánh lướt qua chữ như lá vàng bắt sáng (chậm, nhẹ; tắt khi người dùng chọn giảm chuyển động). */
@keyframes foilSheen { 0%, 70% { background-position: 0 0, -40% 0; } 100% { background-position: 0 0, 140% 0; } }
/* Mảng mực mờ sau tên chương (chỉ quanh chữ, không phủ cả ảnh): ảnh sáng hay rối cỡ nào chữ vàng nhũ vẫn đọc rõ. */
body #card.full.auto .card-box { isolation: isolate; }
body #card.full.auto .card-box::before { content: ''; position: absolute; z-index: -1; left: -8vw; right: 18%; top: -10vh; bottom: -6vh; pointer-events: none;
  background: radial-gradient(ellipse 60% 62% at 34% 58%, rgba(10, 5, 2, .86) 0%, rgba(10, 5, 2, .62) 45%, rgba(10, 5, 2, 0) 78%); filter: blur(6px); }

/* Chuyển màn liền mạch (không lộ nền menu): thẻ tự chạy luôn đặc, có nền đen; lớp màn đen phủ trên rồi mờ đi khi vào,
   hiện lại khi ra. Thay cho cách cũ làm mờ cả thẻ (mờ cả thẻ thì thấy nền menu của trang phía sau). */
body #card.auto, body #card.auto.in, body #card.auto.out { opacity: 1; background-color: #000; }
body #card .card-curtain { position: absolute; inset: 0; z-index: 5; background: #000; pointer-events: none; opacity: 1; transition: opacity .7s ease; }
body #card:not(.auto) .card-curtain { display: none; }
body #card.auto.in .card-curtain { opacity: 0; }
body #card.auto.out .card-curtain { opacity: 1; }
/* Lời dẫn dưới tên chương trên thẻ tự chạy. */
body #card.full.auto #cardBody { max-width: 56ch; }
body #card.full.auto #cardBody p { font: 500 clamp(14px, 1.9vw, 17px)/1.6 var(--body); color: #f6ead0; text-shadow: 0 1px 4px #000, 0 0 14px #000; }
/* Khi có ảnh nền hội thoại (đoạn mở đầu chưa có bản đồ): không có gì để bấm, ẩn cụm nút. */
#backdrop ~ #ctrl { display: none !important; }
/* Nền trang khi chưa vào cảnh (giữa intro và thẻ chương): đen, không dùng nền menu. */
html body.in-game { background: #000 !important; }

/* ---------- Hướng dẫn từng bước (ui.tour) ---------- */
#tour { position: fixed; inset: 0; z-index: 40; cursor: pointer; }
#tour .tour-hole { position: absolute; border-radius: 16px; box-shadow: 0 0 0 9999px rgba(6, 3, 2, .74); border: 2px solid rgba(240, 200, 110, .9);
  transition: all .35s ease; pointer-events: none; animation: tourPulse 1.6s ease-in-out infinite; }
#tour.nohole .tour-hole { left: 50% !important; top: 50% !important; width: 0 !important; height: 0 !important; border: 0; animation: none; }
@keyframes tourPulse { 50% { border-color: rgba(255, 236, 170, .45); } }
#tour .tour-tip { position: absolute; width: min(320px, 44vw); padding: 14px 16px 10px; border-radius: 12px; background: rgba(20, 12, 7, .94);
  border: 1px solid rgba(226, 184, 102, .6); box-shadow: 0 10px 30px rgba(0,0,0,.6); transition: all .35s ease; }
html.ui-frame-popup #tour .tour-tip { background: none; border: 26px solid transparent; border-image: var(--ui-frame-popup) 32 fill / 26px stretch; padding: 2px 4px; box-shadow: none; width: min(360px, 48vw); }
#tour .tour-tip p { margin: 0 0 8px; font: 500 14px/1.55 var(--body); color: #f6ead0; }
#tour .tour-foot { display: flex; justify-content: space-between; align-items: center; font-size: 11.5px; color: var(--gold); letter-spacing: .06em; }
#tour .tour-next { color: #d9c08c; }
/* Đáy giữa màn: góc trên phải là nút Túi, Tạm dừng mà hướng dẫn đang chỉ, đặt ở đó thì che mất. */
#tour .tour-skip { position: absolute; left: 50%; transform: translateX(-50%); bottom: calc(var(--safe-b, 0px) + 14px); min-height: 34px; padding: 0 14px; font-size: 12.5px; }

/* "chạm để tiếp" luôn nằm dòng riêng dưới lời thoại, không đè lên chữ khi câu dài. */
html body #dialog .dbox .dnext, html body #blackout .dnext { position: static; display: block; text-align: right; margin-top: 4px; line-height: 1.2; }
html body #blackout .dnext { margin-top: 18px; }

/* Thiếp đi / mê man (ui.dreamy): cảnh nhoè và mờ sáng dần rồi chìm vào tối. */
#dreamFx { position: fixed; inset: 0; z-index: 30; pointer-events: none; opacity: 0;
  background: radial-gradient(ellipse at 50% 55%, rgba(255, 240, 210, .0) 0%, rgba(30, 18, 12, .55) 55%, #000 100%);
  backdrop-filter: blur(0); -webkit-backdrop-filter: blur(0); transition: opacity var(--dream-ms, 2600ms) ease-in, backdrop-filter var(--dream-ms, 2600ms) ease-in; }
#dreamFx.on { opacity: 1; backdrop-filter: blur(10px) brightness(.55); -webkit-backdrop-filter: blur(10px) brightness(.55); animation: dreamSway 2.2s ease-in-out infinite; }
#dreamFx:not(.on) { transition-duration: .9s; }
@keyframes dreamSway { 50% { background-position: 0 6px; filter: brightness(1.15); } }

/* Nhiệm vụ mới / bước mới: bảng theo dõi nháy sáng viền vàng (thay cho dòng chữ giữa màn hình). */
#questTrack.flash .qt-item { animation: qtFlash 1.6s ease-out 1; }
@keyframes qtFlash { 0%, 40% { box-shadow: 0 0 0 2px rgba(255, 220, 140, .95), 0 0 18px rgba(255, 200, 100, .8); } 100% { box-shadow: none; } }

/* Chân dung: phần cắt ngang ở ngực nằm khuất sau khung thoại (không lơ lửng, không hở nền giữa ảnh và khung). */
html body #dialog .portrait { bottom: calc(var(--safe-b) + 6px); height: min(82%, calc(100% - 90px)); z-index: 0; }
html body #dialog .dbox { z-index: 1; }

/* Cần gạt: chỉ là vòng mảnh mờ và nút tròn mờ, không có nền. */
/* (theme.css của Codex phủ ảnh khung lên cần gạt: ghi đè bằng bộ chọn mạnh hơn, không sửa tệp của Codex.) */
html body #game #stick#stick, html body .mg-stick { overflow: visible !important; border: 1.5px solid rgba(255, 245, 225, .28) !important; background: none !important; box-shadow: none !important; }
html body #game #knob#knob, html body .mg-stick i { background: rgba(255, 245, 225, .32) !important; box-shadow: none !important; border: 1px solid rgba(255, 245, 225, .4) !important; }

/* Thẻ luồng nhiệm vụ (engine/flow.js): mục tiêu, khi nào không đạt, lời kết. */
.flow-card p { margin: 0 0 8px; }
.flow-card .flow-fail { color: #e7a58c; font-size: .92em; }
.flow-note { margin: 8px 0 0; color: #d9c3a2; }

/* Huy hiệu được thêm (+10 đồng, +1 củi khô): viên vàng nhỏ nổi lên rồi mờ (ui.gain). */
html body #game #toasts .toast.gain, html body #toasts .toast.gain { background: linear-gradient(180deg, #f6d98a, #c9952f) !important; color: #3a1d08 !important; font-weight: 700; font-size: 15px !important; border: 1px solid #fff2c4 !important; border-image: none !important; border-radius: 999px !important; padding: 4px 14px !important; box-shadow: 0 2px 10px rgba(0,0,0,.35) !important; text-shadow: none !important; animation: gainUp 2.4s ease-out forwards; }
@keyframes gainUp { 0% { opacity: 0; transform: translateY(10px) scale(.9); } 12% { opacity: 1; transform: translateY(0) scale(1.05); } 20% { transform: scale(1); } 80% { opacity: 1; } 100% { opacity: 0; transform: translateY(-14px); } }

/* Thẻ chữ Hán trong trò viết chữ (engine/hanzi.js). */
.hz-card { display: flex; flex-direction: column; align-items: center; gap: 2px; text-align: center; }
.hz-card .hz-big { font: 700 44px/1.1 "Noto Serif SC", "Songti SC", serif; color: #f3d797; }
.hz-card .hz-py { font-size: 16px; font-weight: 700; color: #ffe9b8; letter-spacing: .04em; }
.hz-card .hz-line { font-size: 13px; color: #e9d9bf; }
.hz-card .hz-line b { color: #fff3d2; }
.hz-card .hz-n { color: #c4ab8a; font-size: 12px; }

/* Thế đánh trên bản đồ (đoạn đóng vai A, trận Hỗ Thác): Đỡ, Né thay chỗ Túi, Cử chỉ; nút lớn là Chém. */
#ctrl #doBtn, #ctrl #neBtn { width: 54px; height: 54px; border-radius: 50%; font-weight: 800; font-size: 15px;
  border: 3px solid var(--gold-soft); color: #fff4dc; background: radial-gradient(circle at 40% 35%, #3a6a9a, #1a2f52); touch-action: none; }
#ctrl #doBtn { right: 112px; bottom: 18px; }
#ctrl #neBtn { right: 92px; bottom: 92px; background: radial-gradient(circle at 40% 35%, #4a8a5a, #1d4228); }
#ctrl #doBtn.pressed, #ctrl #neBtn.pressed { transform: scale(.92); filter: brightness(1.3); }
#ctrl #doBtn, #ctrl #neBtn { display: none; align-items: center; justify-content: center; }
#ctrl.fighting #doBtn, #ctrl.fighting #neBtn { display: flex; }
/* Chưa có icon Codex: nền màu để đọc được chữ (theme.css làm trong suốt mọi nút tròn). */
html body #game #ctrl.fighting button.fight:not(:has(img.ic)) { background: radial-gradient(circle at 40% 35%, #3a6a9a, #1a2f52) !important; border: 3px solid #e2b866 !important; color: #fff4dc; }
html body #game #ctrl.fighting button#neBtn.fight:not(:has(img.ic)) { background: radial-gradient(circle at 40% 35%, #4a8a5a, #1d4228) !important; }
html body #game #ctrl.fighting #actBtn:not(.skill) { background: radial-gradient(circle at 40% 35%, #c85a1a, #7a2a10) !important; border: 3px solid #e2b866 !important; color: #fff4dc; font-size: 16px; font-weight: 800; }
/* Nút ở chế độ giữ (nín thở, cúi đầu…): #ctrl #actBtn ghi đè mất nền, chỉ còn chữ trôi trên map. */
html body #ctrl #actBtn.hold:not(.skill) { background: radial-gradient(circle at 40% 35%, #8a7ad0, #3a2a70) !important; border: 3px solid #e2b866 !important; color: #fff4dc; font-weight: 700; }
/* Đang nhập vai người khác: túi đồ, cử chỉ, con đường là của A Sửu, ẩn đi. */
body.roleplay #ctrl #bagBtn, body.roleplay #ctrl #gestBtn, body.roleplay #ctrl #pathBtn, body.roleplay #ctrl #gestures { display: none !important; }
#ctrl.fighting #bagBtn, #ctrl.fighting #gestBtn, #ctrl.fighting #pathBtn, #ctrl.fighting #gestures { display: none; }
#fightHud { position: fixed; left: 50%; bottom: max(14px, env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 40; pointer-events: none;
  display: flex; flex-direction: column; align-items: center; gap: 4px; color: #fff4dc; text-shadow: 0 1px 3px #000; font-weight: 700; }
#fightHud .goal { font-size: 14px; background: rgba(20, 8, 10, .72); padding: 4px 12px; border-radius: 12px; border: 1px solid rgba(226, 184, 102, .45); }
#fightHud .hp { width: 220px; height: 12px; border-radius: 6px; background: rgba(0, 0, 0, .6); border: 1px solid rgba(226, 184, 102, .6); overflow: hidden; }
#fightHud .hp i { display: block; height: 100%; width: 100%; background: linear-gradient(90deg, #b8321e, #e2763a); transition: width .15s; }
#fightHud.poison .hp i { background: linear-gradient(90deg, #3f7a2a, #8fbf3a); }
#fightHud .hint { font-size: 12px; opacity: .9; background: rgba(20, 8, 10, .6); padding: 3px 10px; border-radius: 10px; }
#fightFx { position: fixed; inset: 0; pointer-events: none; z-index: 39; }
#fightFx.hit { background: radial-gradient(ellipse at center, transparent 45%, rgba(190, 20, 10, .55)); }
#fightFx.poison { background: radial-gradient(ellipse at center, transparent 50%, rgba(40, 120, 30, .38)); }
/* Nhập vai Lục Trạc trúng tên độc: thanh sức đổi màu độc. */
html body #game #rowSta.poison #barSta { background-image: none !important; background-color: #6fa83a !important; }

/* Hôm đụng xe, đêm trước ngộ độc (actions.js cartJob): màn hình chao đảo, mờ nhoè theo nhịp. */
body.dizzy #view { animation: dizzy 3.4s ease-in-out infinite; transform-origin: 50% 55%; }
@keyframes dizzy {
  0%, 100% { transform: rotate(0) scale(1.03); filter: blur(0); }
  30% { transform: rotate(.7deg) scale(1.05); filter: blur(1.4px); }
  65% { transform: rotate(-.5deg) scale(1.04); filter: blur(.6px); }
}
@media (prefers-reduced-motion: reduce) { body.dizzy #view { animation: none; filter: blur(.8px); } }
/* Câu chuyển cảnh ("Cùng lúc đó", "5 ngày trước", "Hiện tại"…): nền ĐEN đặc, chữ trắng giữa màn, không ảnh. */
html body #game #card.full.black, html body #card.full.black { background: #000 !important; place-items: center; }
/* Thẻ hồi/chương chưa có ảnh nền: nền tối tạm, toàn màn hình (không lộ map phía sau). */
html body #game #card.full.dark, html body #card.full.dark { background: radial-gradient(ellipse at 30% 60%, #2a170c, #0b0604 70%) !important; }
html body #card.full.black::before { display: none; }
/* QA 27/10: vệt tối sau chữ của thẻ chương (đặt lệch trái trên ảnh) hiện thành một dải lệch ở câu chuyển cảnh nền đen chữ giữa. */
html body #card.full.black .card-box::before { display: none; }
html body #game #card.full.black .card-box { text-align: center; padding: 0 !important; }
html body #card.full.black #cardKicker, html body #card.full.black #cardBody, html body #card.full.black .card-lead { color: #fff; }
/* Lời dẫn (max-width 52ch) hẹp hơn hộp: canh giữa cả khối, không thì tiêu đề giữa mà đoạn chữ lệch trái. */
html body #card.full.black #cardBody { margin: 0 auto; }
html body #game #card.full.black .card-box h2#cardTitle, html body #game #card.full.black .card-box h2 { background: none !important; -webkit-text-fill-color: #fff !important; color: #fff !important; font-size: clamp(30px, 5vw, 52px); }

/* Chân dung hai bên (ui.js stage): người đang nói trồi lên trước, sáng; người kia lùi sau, tối và thấp xuống. */
html body #dialog .portrait { transform-origin: 50% 100%; transition: transform .22s ease-out, filter .22s ease-out, opacity .22s ease-out; }
html body #dialog .portrait.empty { opacity: 0; }
html body #dialog .portrait.front { transform: translateY(0) scale(1.04); filter: none; opacity: 1; z-index: 0; }
html body #dialog .portrait.back { transform: translateY(7%) scale(.93); filter: brightness(.45) saturate(.7); opacity: .85; z-index: -1; }
html body #dialog .portrait img.flip { transform: scaleX(-1); }
html body #dialog #dName { display: block; }
html body #dialog.spk-right #dName { text-align: right; }
@media (prefers-reduced-motion: reduce) { html body #dialog .portrait { transition: none; } }
/* Chân dung nằm trong mép khung thoại hai bên; chân thân khuất sau khung (kể cả khi lùi xuống), không lòi ra mép. */
html body #dialog .portrait { bottom: calc(var(--safe-b) + 44px); overflow: hidden; }
html body #dialog .portrait.left { left: var(--safe-l); }
html body #dialog .portrait.right { right: var(--safe-r); }
html body #dialog .portrait img { object-position: 50% 0; }

/* Lựa chọn: hộp thoại giữ nguyên cả bề ngang, câu vừa nói ở dưới; các nút xếp dọc ngay phía trên hộp, giữa khung.
   Lúc đang chọn, chân dung lùi mờ để nút không che người nói. Nút điều khiển (#ctrl) ẩn khi hộp thoại mở. */
html body #dialog.choosing .dbox { right: var(--safe-r); }
html body #dialog #choices { left: calc(var(--safe-l) + 16px); right: auto; transform: none; width: min(300px, calc(100% - var(--safe-l) - var(--safe-r) - 24px));
  bottom: var(--choices-b, calc(var(--safe-b) + 110px)); z-index: 2; max-height: calc(100% - var(--choices-b, 120px) - 76px); overflow-y: auto; } /* chừa HUD trên (bản đồ nhỏ, ô nhiệm vụ) */
/* Đang chọn = A Sửu sắp nói: chân dung A Sửu (bên phải) sáng, ở trước; chân dung NPC (bên trái, chỗ đặt lựa chọn) ẩn. */
html body #dialog.choosing .portrait.right { filter: none; opacity: 1; transform: none; z-index: 1; }
html body #dialog.choosing .portrait.left { opacity: 0; }
html body #dialog #choices button { padding: 6px 10px; font-size: 12.5px; line-height: 1.3; }
html body #dialog.choosing .dnext { visibility: hidden; }
html body #game:has(#dialog:not([hidden])) #ctrl, html body:has(#dialog:not([hidden])) #ctrl { visibility: hidden; }

/* Ô nhiệm vụ: đã bỏ thanh sức góc phải nên kéo dài ra, tên nhiệm vụ một dòng (22/10). */
html body #questTrack { width: min(560px, calc(100vw - var(--safe-l) - 132px - 90px)); }
html body #questTrack .qt-title { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* Bỏ nhãn "Chương N · tên" / "N tuổi" dưới minimap: ô nhiệm vụ đã thể hiện chương (22/10). */
html body #hud .hud-when { display: none !important; }

/* ---------- Giải đố (src/engine/puzzle.js): ghép suy luận, khoá. Khung thật Codex vẽ: art/codex/ui/frame-puzzle.webp ---------- */
.puzzle { position: absolute; inset: 0; z-index: 11; background: rgba(8, 2, 4, .86); display: grid; place-items: center; padding: var(--safe-t) var(--safe-r) var(--safe-b) var(--safe-l); }
.puzzle-kicker { font-size: 11px; letter-spacing: .2em; text-transform: uppercase; color: var(--gold); }
.puzzle-claim { margin: 0; font: 600 18px/1.4 var(--display); color: var(--gold-soft); }
.puzzle-ask { margin: 0; color: var(--muted); font-size: 13px; }
.puzzle-list { display: flex; flex-direction: column; gap: 6px; max-height: 42vh; overflow-y: auto; }
.puzzle-clue { text-align: left; display: flex; flex-direction: column; gap: 2px; padding: 8px 12px; border-radius: 10px; background: #2a1015; border: 1px solid transparent; border-left: 3px solid var(--gold); color: inherit; font-size: 13px; }
.puzzle-clue small { color: #a88f74; font-size: 11px; }
.puzzle-clue.on, .puzzle-opt.on { border-color: var(--gold); background: #4a2418; }
.puzzle-slot { display: flex; justify-content: center; gap: 10px; }
.puzzle-slot b { width: 54px; height: 54px; border-radius: 10px; border: 1px dashed rgba(226, 184, 102, .6); display: grid; place-items: center; font: 700 30px var(--display); color: var(--gold-soft); }
.puzzle-slot b.on { border-style: solid; background: rgba(0, 0, 0, .3); }
.puzzle-opts { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.puzzle-opt { min-width: 56px; min-height: 56px; border-radius: 12px; border: 1px solid rgba(226, 184, 102, .5); background: rgba(28, 18, 12, .82); color: var(--gold-soft); font: 700 28px var(--display); }
.puzzle-long .puzzle-box { max-height: 96vh; overflow-y: auto; }
.puzzle-long .puzzle-slot { flex-direction: column; align-items: stretch; gap: 4px; }
.puzzle-long .puzzle-slot b { width: auto; height: auto; min-height: 30px; padding: 4px 12px; place-items: center start; font: 600 14.5px/1.35 var(--body, inherit); text-align: left; }
.puzzle-long .puzzle-slot b:not(.on) { color: var(--muted); }
.puzzle-long .puzzle-opts { gap: 6px; }
.puzzle-long .puzzle-opt { min-height: 0; padding: 6px 12px; font: 600 14.5px/1.35 var(--body, inherit); text-align: left; flex: 1 1 calc(50% - 6px); }
.puzzle-opt.digit { font-size: 22px; min-width: 48px; min-height: 48px; }
.puzzle-opt.wide { flex: 1 1 100%; font: 600 15px var(--body, inherit); text-align: left; padding: 8px 14px; display: flex; flex-direction: column; }
.puzzle-opt.wide small { color: var(--muted); font-size: 11.5px; font-weight: 400; }
.puzzle-opt:disabled, .puzzle-clue:disabled { cursor: default; }
.puzzle-hint { padding: 8px 12px; border-radius: 10px; background: rgba(0, 0, 0, .3); font-style: italic; font-size: 13.5px; line-height: 1.5; }
.puzzle-hint b { display: block; font-style: normal; font-size: 11.5px; color: var(--gold); }
.puzzle-hint.flash { animation: puzzleFlash .5s ease-out; }
@keyframes puzzleFlash { from { background: rgba(226, 184, 102, .35); } }
.puzzle-btns { display: flex; justify-content: flex-end; gap: 8px; }
/* Ngồi nghĩ (think): thẻ dữ kiện, thẻ ý nghĩ (chữ ngọc), thẻ ký ức mờ. */
.puzzle-think .puzzle-box { max-width: min(760px, 96vw); max-height: 96vh; overflow-y: auto; }
/* Màn thấp (640px): khung ghép thẻ phải cuộn; nút Đứng dậy dính đáy khung, không bị cuộn khuất dưới viền. */
.puzzle-think .puzzle-btns { position: sticky; bottom: 0; padding-top: 6px; }
.puzzle-think h2 { font-style: italic; }
.think-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 8px; }
.think-card { text-align: left; display: flex; flex-direction: column; gap: 3px; padding: 9px 12px; border-radius: 10px; background: #2a1015; border: 1px solid rgba(226, 184, 102, .25); color: inherit; font-size: 13.5px; line-height: 1.4; }
.think-card small { color: #a88f74; font-size: 11px; }
.think-card.dim { opacity: .55; font-style: italic; }
.think-card.thought { background: #12261f; border-color: rgba(111, 179, 154, .5); color: #bfe6d6; font-style: italic; }
.think-card.thought small { color: #6fb39a; }
.think-card.think-goal { border-color: var(--gold); box-shadow: 0 0 0 1px var(--gold), 0 0 18px rgba(226, 184, 102, .35); color: var(--gold-soft); }
.think-card.on { border-color: var(--gold); background: #4a2418; }
.think-card.thought.on { background: #1f4234; }
.think-card.fresh { animation: thinkIn .7s ease-out; }
@keyframes thinkIn { from { transform: scale(.9); opacity: 0; } }
.think-said { padding: 8px 12px; border-radius: 10px; background: rgba(0, 0, 0, .3); font-style: italic; font-size: 14px; }
.think-said b { display: block; font-style: normal; font-size: 11.5px; color: var(--gold); }
.think-said.thought span { color: #bfe6d6; }
.think-said.flash { animation: puzzleFlash .5s ease-out; }
.note.thought { border-left-color: #6fb39a; font-style: italic; }
.note.clue { border-left-color: var(--jade, #6fb39a); }
.note-group { margin: 10px 0 6px; font: 700 14px var(--display); color: var(--gold); letter-spacing: .08em; }
html.ui-frame-puzzle body .puzzle-box { background: none; border: 28px solid transparent; border-image: var(--ui-frame-puzzle) 28 fill / 28px stretch; box-shadow: none; }

/* ---------- Ván cờ, Sổ lời đã nói (engine/vanco.js) ---------- */
body.vc-slow canvas#view { filter: saturate(.35) brightness(.72); transition: filter .5s; }
.vc-cham { position: absolute; z-index: 9; top: calc(var(--safe-t, 0px) + 12px); right: calc(var(--safe-r, 0px) + 64px); width: min(400px, 46vw); pointer-events: none;
  padding: 8px 16px; border-radius: 12px; background: rgba(10, 3, 5, .78); border: 1px solid rgba(226, 184, 102, .45); text-align: center; animation: vcIn .5s ease-out; }
.vc-cham small { letter-spacing: .2em; text-transform: uppercase; color: var(--gold); font-size: 11px; }
.vc-cham p { margin: 4px 0 0; color: var(--gold-soft); font-size: 14px; font-style: italic; }
.vc-cham p.vc-canh { color: #bfe6d6; font-size: 13px; }
body.vc-slow #toasts { top: calc(var(--safe-t, 0px) + 150px); } /* thông báo Sổ không đè dải Chậm lại */
@keyframes vcIn { from { opacity: 0; transform: translateY(-6px); } }
.note.noi { border-left-color: #c9704f; }
.note.hua { border-left-color: #8fa8d6; }
.note.hua.doi { opacity: .6; }
.note.ngoac { border-left-color: #b49ad6; font-style: italic; }

/* Nhiều lựa chọn (≥3): xếp hai cột trong khoảng trống giữa màn, khỏi phải cuộn hay đè HUD. */
html body #dialog #choices:has(> button:nth-child(3)) { display: grid; grid-template-columns: 1fr 1fr; width: min(560px, calc(100% - var(--safe-l) - var(--safe-r) - 290px)); align-items: stretch; }

/* HUD 25/10: túi đồ thu nhỏ, đứng ngay bên trái nút tạm dừng ở góc trên phải; cụm phải dưới chỉ còn MỘT nút hành động chính
   (nút 道 gộp vào bảng chọn của nút chính; nút 礼 chỉ hiện khi có cử chỉ tự chọn được, vd Bôi bùn). */
html body #hud #bagBtn { position: absolute; right: calc(var(--safe-r) + 50px); top: calc(var(--safe-t) + 4px); width: 36px; height: 36px; min-width: 0; min-height: 0; padding: 0; border-radius: 50%; z-index: 6; }
html body #hud #bagBtn img.ic { width: 100%; height: 100%; margin: 0; object-fit: contain; border-radius: 50%; }
html body #hud .hud-bars { right: calc(var(--safe-r) + 94px); }
html body #ctrl #pathBtn { display: none !important; }
html body #ctrl #gestBtn[hidden] { display: none; }
body.roleplay #hud #bagBtn { display: none !important; }
/* Mini game: nút phụ chỉ có chữ (chưa có icon Codex) phải nhìn rõ: khung tròn, nền tối, chữ sáng (QA Hồi 7, 25/10). */
html body #game #mgActs > button.act-sub:not(.skill) { background: radial-gradient(circle, rgba(92, 52, 24, .95), rgba(30, 14, 8, .92)) !important; border: 2px solid rgba(232, 192, 110, .95) !important; color: #fff4dc !important; font: 700 14px 'Be Vietnam Pro', sans-serif !important; box-shadow: 0 0 0 2px rgba(0, 0, 0, .5), 0 2px 10px rgba(0, 0, 0, .7) !important; }
/* Lựa chọn trong mini game không đè khung bên (sổ, thông tin): nút rộng hơn để chữ một dòng, khung bên ngắn lại khi có lựa chọn. */
#mgActs .mg-choices { width: 270px; }
#mg:has(.mg-choices) #mgSide { max-height: calc(100% - 255px); }

/* Tên động tác dưới nút tròn mini game (Bước, Cúi, Dâng trà…): luật nhịp ghi theo tên nên nút phải có chữ. */
#mgActs button.skill .ic-label { position: absolute; left: 50%; bottom: 5px; transform: translateX(-50%); padding: 1px 6px; border-radius: 8px; background: rgba(10, 6, 4, .72); font: 700 10px "Be Vietnam Pro", sans-serif; line-height: 1.3; color: #f3d797; white-space: nowrap; pointer-events: none; }
