/* =====================================================================
 * HOAN LẠC TRẤN — giao diện trấn + combat + quest (Phase 1 Gameplay UI)
 * Tone: u tối pha dân gian Việt. Prefix class: wx-
 * ===================================================================== */

/* --- khung game --- */
.wx-game {
  position: fixed;
  inset: 0;
  z-index: 900;
  background: #0d0a07;
  color: #e8dcc4;
  font-family: "Noto Serif", "Times New Roman", serif;
  overflow-y: auto;
}
.wx-game-inner {
  max-width: 720px;
  margin: 0 auto;
  padding: 16px 16px 40px;
}

/* --- title screen (Q91a) --- */
#wx-boot {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background: #0a0806;
}
#wx-boot.wx-hidden,
#wx-boot .wx-hidden { display: none; }
.wx-boot-bg {
  position: absolute;
  inset: 0;
  background: url("../assets/runtime/forge/map/tran_van_ha/preview.webp") center/cover no-repeat;
  image-rendering: pixelated;
  filter: brightness(0.45) saturate(0.9);
}
.wx-boot-bg::after {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at 50% 70%, transparent 30%, rgba(10, 8, 6, 0.85) 100%);
}
.wx-boot-content {
  position: relative;
  text-align: center;
  padding: 0 24px;
  max-width: 520px;
}
.wx-boot-kicker {
  font-size: 12px;
  letter-spacing: 6px;
  color: #a89468;
  margin-bottom: 12px;
}
#wx-boot h1 {
  font-size: 44px;
  letter-spacing: 8px;
  color: #f0e4c8;
  margin: 0 0 8px;
  text-shadow: 0 2px 20px rgba(0, 0, 0, 0.8);
  font-family: "Noto Serif", serif;
}
#wx-boot .wx-sub {
  font-size: 13px;
  letter-spacing: 4px;
  color: #c9a86a;
  margin-bottom: 16px;
}
#wx-boot .wx-desc {
  font-size: 14px;
  line-height: 1.7;
  color: #cbb98f;
  margin-bottom: 24px;
}
#wx-boot button {
  display: block;
  width: 100%;
  max-width: 300px;
  margin: 10px auto;
  background: linear-gradient(180deg, #3a2f22, #2a2118);
  border: 1px solid #a89468;
  color: #f0e4c8;
  border-radius: 10px;
  padding: 14px;
  font-size: 16px;
  font-family: inherit;
  cursor: pointer;
  letter-spacing: 1px;
}
#wx-boot button:hover { border-color: #ffd76a; }
#wx-boot button.wx-secondary {
  background: transparent;
  border-color: #4a3b28;
  color: #a89468;
}

/* --- tutorial (Q92a) --- */
.wx-tut-wrap {
  position: fixed;
  inset: 0;
  z-index: 990;
  background: rgba(0, 0, 0, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.wx-tut-box {
  background: #14100b;
  border: 1px solid #ffd76a;
  border-radius: 12px;
  padding: 20px;
  max-width: 400px;
  color: #e8dcc4;
}
.wx-tut-step { font-size: 11px; color: #a89468; letter-spacing: 2px; }
.wx-tut-title { font-size: 18px; color: #ffd76a; margin: 6px 0 10px; }
.wx-tut-box p { font-size: 14px; line-height: 1.6; margin: 0 0 14px; }
.wx-tut-btns { display: flex; gap: 8px; }
.wx-tut-btns button {
  flex: 1;
  background: #2a2118;
  border: 1px solid #a89468;
  color: #f0e4c8;
  border-radius: 8px;
  padding: 10px;
  font-family: inherit;
  font-size: 13px;
  cursor: pointer;
}
.wx-tut-btns button.wx-secondary {
  background: transparent;
  border-color: #4a3b28;
  color: #a89468;
}

/* --- trấn --- */
.wx-town-img {
  width: 100%;
  border-radius: 8px;
  border: 1px solid #3a2f22;
  display: block;
}
.wx-town-title {
  font-size: 24px;
  letter-spacing: 4px;
  color: #f0e4c8;
  margin: 14px 0 4px;
  text-align: center;
}
.wx-town-day {
  text-align: center;
  color: #a89468;
  font-size: 13px;
  margin-bottom: 14px;
}
.wx-menu {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 12px;
}
.wx-menu-btn {
  background: #1c1610;
  border: 1px solid #4a3b28;
  color: #e8dcc4;
  border-radius: 8px;
  padding: 14px 8px;
  font-size: 15px;
  font-family: inherit;
  cursor: pointer;
  text-align: center;
}
.wx-menu-btn:hover { background: #2a2118; border-color: #a89468; }
.wx-menu-btn small {
  display: block;
  font-size: 12px;
  color: #a89468;
  margin-top: 4px;
}
.wx-menu-btn:disabled { opacity: 0.4; cursor: default; }

/* --- HUD gắn trên --- */
.wx-game-hud {
  background: #14100b;
  border: 1px solid #3a2f22;
  border-radius: 8px;
  padding: 10px 12px;
  margin-bottom: 12px;
  font-size: 13px;
}
.wx-game-hud .row { display: flex; justify-content: space-between; margin: 2px 0; }
.wx-bar { height: 8px; background: #2a2118; border-radius: 4px; overflow: hidden; margin: 3px 0 7px; }
.wx-bar > div { height: 100%; border-radius: 4px; }
.wx-bar-hp > div { background: #b04040; }
.wx-bar-nl > div { background: #4a7ab0; }
.wx-bar-tl > div { background: #7ab04a; }

/* --- combat --- */
.wx-combat-arena {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  margin: 12px 0;
  gap: 8px;
}
.wx-fighter { flex: 1; text-align: center; }
.wx-fighter img {
  width: 110px; height: 110px;
  object-fit: cover; border-radius: 8px;
  border: 1px solid #4a3b28;
  background: #14100b;
}
.wx-fighter .nm { font-size: 14px; margin: 6px 0 2px; color: #f0e4c8; }
.wx-vs { font-size: 20px; color: #a89468; padding-bottom: 60px; }
.wx-combat-log {
  background: #14100b;
  border: 1px solid #3a2f22;
  border-radius: 8px;
  height: 150px;
  overflow-y: auto;
  padding: 8px 10px;
  font-size: 13px;
  margin: 10px 0;
}
.wx-combat-log p { margin: 3px 0; color: #cbb98f; }
.wx-moves { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.wx-move-btn {
  background: #1c1610;
  border: 1px solid #4a3b28;
  color: #e8dcc4;
  border-radius: 8px;
  padding: 10px 6px;
  font-family: inherit;
  font-size: 14px;
  cursor: pointer;
}
.wx-move-btn:hover:not(:disabled) { background: #2a2118; border-color: #a89468; }
.wx-move-btn:disabled { opacity: 0.35; cursor: default; }
.wx-move-btn small { display: block; font-size: 11px; color: #a89468; }

/* --- quest dialogue --- */
.wx-quest-lines { margin: 10px 0; }
.wx-quest-lines p { margin: 8px 0; font-size: 15px; line-height: 1.6; }
.wx-quest-lines .sp { color: #a89468; font-size: 13px; }
.wx-spk-img {
  width: 64px; height: 64px;
  object-fit: contain; border-radius: 6px;
  border: 1px solid #4a3b28;
  vertical-align: middle;
  margin-right: 8px;
  background: #14100b;
}
.wx-quest-choices { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.wx-choice-btn {
  background: #1c1610;
  border: 1px solid #4a3b28;
  color: #e8dcc4;
  border-radius: 8px;
  padding: 12px;
  font-family: inherit;
  font-size: 14px;
  cursor: pointer;
  text-align: left;
}
.wx-choice-btn:hover { background: #2a2118; border-color: #a89468; }
.wx-choice-btn small { display: block; color: #a89468; font-size: 12px; margin-top: 3px; }

/* --- hiệu ứng FX --- */
.wx-fx-flash {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 950;
  opacity: 0;
  transition: opacity 0.25s;
}
.wx-fx-flash.show { opacity: 0.35; }

/* --- nút chung --- */
.wx-btn {
  background: #2a2118;
  border: 1px solid #a89468;
  color: #f0e4c8;
  border-radius: 8px;
  padding: 10px 18px;
  font-family: inherit;
  font-size: 14px;
  cursor: pointer;
  margin-top: 12px;
}
.wx-btn:hover { background: #3a2f22; }
.wx-back { text-align: center; }
/* --- bản đồ đi lại --- */
.wx-map-dlg {
  position: fixed;
  left: 12px; right: 12px; bottom: 110px;
  z-index: 960;
}
.wx-map-dlg.wx-hidden { display: none; }
.wx-map-dlg-box {
  max-width: 520px;
  margin: 0 auto;
  background: rgba(20, 16, 11, 0.95);
  border: 1px solid #a89468;
  border-radius: 10px;
  padding: 12px 14px;
  color: #e8dcc4;
  font-size: 14px;
}
.wx-map-dlg-name {
  color: #ffd76a;
  font-weight: bold;
  margin-bottom: 6px;
}
.wx-map-dlg-box p { margin: 6px 0; line-height: 1.5; }
.wx-map-dlg-btns { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.wx-map-dlg-btns button {
  background: #2a2118;
  border: 1px solid #a89468;
  color: #f0e4c8;
  border-radius: 8px;
  padding: 8px 14px;
  font-family: inherit;
  font-size: 13px;
  cursor: pointer;
}
.wx-map-toast {
  position: fixed;
  top: 70px; left: 50%;
  transform: translateX(-50%) translateY(-10px);
  background: rgba(20, 16, 11, 0.95);
  border: 1px solid #a89468;
  color: #ffd76a;
  border-radius: 8px;
  padding: 8px 16px;
  font-size: 13px;
  z-index: 970;
  opacity: 0;
  transition: all 0.3s;
  pointer-events: none;
}
.wx-map-toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* --- panels --- */
.wx-panel-wrap {
  position: fixed;
  inset: 0;
  z-index: 980;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.wx-panel {
  background: #14100b;
  border: 1px solid #a89468;
  border-radius: 12px;
  width: 100%;
  max-width: 440px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  color: #e8dcc4;
}
.wx-panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid #3a2f22;
  font-size: 17px;
  letter-spacing: 2px;
  color: #f0e4c8;
}
.wx-panel-x {
  background: none;
  border: none;
  color: #a89468;
  font-size: 18px;
  cursor: pointer;
}
.wx-panel-body {
  padding: 12px 16px;
  overflow-y: auto;
}
.wx-equip-stats { margin-bottom: 10px; color: #c9b98f; font-size: 13px; }
.wx-equip-doll {
  display: grid;
  grid-template-columns: repeat(4, minmax(72px, 1fr));
  grid-template-rows: repeat(5, auto);
  gap: 8px;
  margin-bottom: 12px;
}
.wx-equip-slot {
  min-height: 72px;
  padding: 6px;
  border: 1px solid #6a5230;
  border-radius: 6px;
  background: #1a140c;
  color: #e8dcc0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  font-size: 11px;
}
.wx-equip-slot.pick { border-color: #ffd76a; box-shadow: 0 0 6px rgba(255, 215, 106, 0.35); }
.wx-equip-slot img { width: 36px; height: 36px; object-fit: contain; }
.wx-equip-slot .lb { color: #9a8a66; font-size: 10px; }
.wx-equip-slot .empty { opacity: 0.45; }
.wx-skill-slots-8 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }

.wx-tabs { display: flex; gap: 8px; margin-bottom: 10px; }
.wx-tabs button {
  flex: 1;
  background: #1c1610;
  border: 1px solid #4a3b28;
  color: #a89468;
  border-radius: 8px;
  padding: 8px;
  font-family: inherit;
  cursor: pointer;
}
.wx-tabs button.on {
  background: #2a2118;
  color: #f0e4c8;
  border-color: #a89468;
}
.wx-inv-item.equipped { border-color: #ffd76a; }
.wx-char-preview-wrap {
  display: flex;
  justify-content: center;
  margin: 8px 0 12px;
  padding: 10px;
  background: radial-gradient(ellipse at center, #2a2418 0%, #120e0a 70%);
  border: 1px solid #3a3020;
  border-radius: 10px;
}
.wx-char-preview {
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  width: 96px;
  height: 192px;
}
.wx-char-info .row {
  display: flex;
  justify-content: space-between;
  padding: 6px 0;
  border-bottom: 1px solid #2a2118;
  font-size: 14px;
}
.wx-char-info .row span { color: #a89468; }
.wx-char-info .row small { color: #8a7a5c; font-weight: normal; }
.wx-bonus-box {
  background: #1c2a14;
  border: 1px solid #5a7a3a;
  border-radius: 8px;
  padding: 10px;
  margin-top: 12px;
}
.wx-bonus-box .t { font-size: 13px; color: #ffd76a; margin-bottom: 8px; }
.wx-bonus-box button, .wx-char-info button {
  background: #2a2118;
  border: 1px solid #a89468;
  color: #f0e4c8;
  border-radius: 8px;
  padding: 8px 12px;
  margin: 4px 4px 0 0;
  font-family: inherit;
  font-size: 13px;
  cursor: pointer;
}
.wx-skill { padding: 8px 0; border-bottom: 1px solid #2a2118; }
.wx-skill .nm { font-size: 14px; color: #f0e4c8; }
.wx-skill .nm small { color: #8a7a5c; }
.wx-skill .desc { font-size: 12px; color: #a89468; margin-top: 2px; }
.wx-skill.locked { opacity: 0.5; }
.wx-skill-slots {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.wx-skill-slot {
  background: #1c1610;
  border: 1px dashed #4a3b28;
  border-radius: 8px;
  padding: 10px 6px;
  text-align: center;
  cursor: pointer;
}
.wx-skill-slot .nm { font-size: 13px; color: #f0e4c8; }

/* --- túi đồ --- */
.wx-inv-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-top: 12px;
}
.wx-inv-item {
  background: #1c1610;
  border: 1px solid #3a2f22;
  border-radius: 8px;
  padding: 10px 6px;
  text-align: center;
}
.wx-inv-item img {
  width: 48px; height: 48px;
  object-fit: contain;
  image-rendering: pixelated;
}
.wx-inv-item .nm { font-size: 13px; color: #f0e4c8; margin-top: 4px; }
.wx-inv-item .qty { font-size: 12px; color: #a89468; }
.wx-inv-item .desc { font-size: 11px; color: #8a7a5c; margin-top: 2px; }
.wx-rewards {
  background: #1c2a14;
  border: 1px solid #5a7a3a;
  border-radius: 8px;
  padding: 10px 14px;
  margin: 10px 0;
  font-size: 14px;
}

/* Mobile safe areas, readable controls, status and accessible alternatives. */
.wx-safe-probe { position:fixed; visibility:hidden; pointer-events:none; padding:env(safe-area-inset-top,0px) env(safe-area-inset-right,0px) env(safe-area-inset-bottom,0px) env(safe-area-inset-left,0px); }
.wx-save-status { position:fixed; right:max(12px,env(safe-area-inset-right)); bottom:max(4px,env(safe-area-inset-bottom)); z-index:905; color:#cabd9f; font:12px sans-serif; pointer-events:none; }
.wx-save-error { color:#ffbaad; background:#24170f; max-width:65%; padding:4px; }
.wx-panel-wrap { padding:max(12px,env(safe-area-inset-top)) max(12px,env(safe-area-inset-right)) max(12px,env(safe-area-inset-bottom)) max(12px,env(safe-area-inset-left)); box-sizing:border-box; }
.wx-panel button, .wx-tut-box button, .wx-map-dlg button, .wx-game-inner button { min-height:44px; }
.wx-panel a { color:#f1d896; }
.wx-game-inner { padding-top:max(16px,env(safe-area-inset-top)); padding-bottom:max(40px,env(safe-area-inset-bottom)); }
.wx-tut-practice { inset:auto; top:max(154px,env(safe-area-inset-top)); left:max(10px,env(safe-area-inset-left)); right:auto; width:min(270px,70vw); padding:0; background:none; display:block; pointer-events:none; z-index:980; }
.wx-tut-practice .wx-tut-box { pointer-events:auto; padding:12px; font-size:14px; }
.wx-tut-practice p { margin:8px 0; }
.wx-access-controls { position:absolute; width:1px; height:1px; overflow:hidden; clip-path:inset(50%); }
.wx-journey-open { position:fixed; top:max(150px,env(safe-area-inset-top)); right:10px; z-index:100; min-height:44px; padding:8px 12px; }
.wx-journey-nav { display:flex; flex-wrap:wrap; gap:8px; }
.wx-journey-nav button { margin:0; min-height:44px; padding-left:14px; padding-right:14px; }
.wx-journey-nav [aria-pressed="true"] { outline:2px solid #7ab04a; }
.wx-journey-content { min-width:0; }
.wx-journey-content h2 { font-size:20px; }
.wx-journey-content h3 { font-size:17px; }
.wx-journey-row { padding:16px 0; border-bottom:1px solid #665b48; }
.wx-journey-content button { margin:6px 6px 6px 0; max-width:100%; white-space:normal; }
.wx-journey-content label { display:flex; flex-wrap:wrap; gap:8px; align-items:center; margin:12px 0; }
.wx-journey-content input { max-width:100%; min-width:0; min-height:44px; box-sizing:border-box; background:#201c18; color:#e8dcc4; border:1px solid #665b48; border-radius:4px; padding:8px; font:inherit; }
.wx-journey-content p,.wx-journey-content li { overflow-wrap:anywhere; }
.wx-journey-nav button,.wx-journey-content h2,.wx-journey-content h3,.wx-journey-open { letter-spacing:0; }
.wx-journey-content button:disabled { opacity:0.5; cursor:default; }
.wx-access-controls:focus-within { position:fixed; top:max(150px,env(safe-area-inset-top)); left:10px; width:auto; height:auto; clip-path:none; display:flex; flex-wrap:wrap; max-width:90vw; z-index:989; background:#21190e; }
:focus-visible { outline:3px solid #ffe49f; outline-offset:3px; }
.wx-reduced-motion *, .wx-reduced-motion *::before, .wx-reduced-motion *::after { animation:none!important; transition:none!important; scroll-behavior:auto!important; }
@media (prefers-reduced-motion:reduce) { .wx-fx-flash { display:none; } * { scroll-behavior:auto!important; } }
@media (max-height:500px) { .wx-tut-practice { top:10px; left:230px; width:min(300px,45vw); } .wx-panel { max-height:90dvh; } }

/* Asset WuxiaForge là pixel-art: phóng to bằng nearest-neighbour ở mọi <img> trong UI. */
img[src*="/forge/"], img[src*="/items/wx_icon_"], img[src*="/weapons/"] {
  image-rendering: pixelated;
}

/* Chân dung 64×64 pixel-art: chỉ phóng số nguyên (2× = 128 px; 1× trên màn hẹp) để nét sắc. */
.wx-fighter-portrait img { width: 128px; height: 128px; object-fit: contain; image-rendering: pixelated; }
.wx-map-dlg-box.has-portrait { display: flex; gap: 12px; align-items: flex-start; }
.wx-map-dlg-portrait { width: 128px; height: 128px; flex: none; image-rendering: pixelated; background: #14100b; border: 1px solid #4a3b28; border-radius: 8px; }
.wx-map-dlg-text { min-width: 0; flex: 1; }
@media (max-width: 600px) {
  .wx-fighter-portrait img { width: 64px; height: 64px; }
  .wx-map-dlg-portrait { width: 64px; height: 64px; }
}
.wx-spk-line { display: flex; gap: 10px; align-items: flex-start; }
.wx-spk-line .wx-spk-img { flex: none; margin-right: 0; }

/* Liên kết cẩm nang ở màn khởi động */
#wx-boot a.wx-boot-info {
  display: block;
  margin-top: 14px;
  color: #b9a888;
  font-size: 13px;
  letter-spacing: 1px;
  text-align: center;
  text-decoration: underline;
  text-underline-offset: 3px;
}
#wx-boot a.wx-boot-info:hover, #wx-boot a.wx-boot-info:focus-visible { color: #e8dcc0; }

/* Kết cục nhiệm vụ */
.wx-quest-ending { margin: 12px 0; padding: 12px 14px; border-left: 3px solid #8a6f45; background: rgba(36, 28, 18, 0.7); }
.wx-quest-ending h2 { margin: 0 0 8px; font-size: 17px; color: #d8b46a; letter-spacing: 1px; }
.wx-quest-ending p { margin: 0; font-size: 15px; line-height: 1.7; color: #e8dcc0; }
