/* JOB_TH2_17 (PQ-71) — layer roots owned by Engine.tienHiepNavigation. */
[data-theme="tien_hiep"] .th-navigation-scene-root,
[data-theme="tien_hiep"] .th-navigation-modal-root {
  position: fixed;
  inset: 0;
  pointer-events: none;
}

[data-theme="tien_hiep"] .th-navigation-scene-root { z-index: 300; }
[data-theme="tien_hiep"] .th-navigation-modal-root { z-index: 400; }

[data-theme="tien_hiep"] .th-navigation-scene-root > *,
[data-theme="tien_hiep"] .th-navigation-modal-root > * { pointer-events: auto; }

/* JOB_TH2_23: feature Scene chrome.  Individual renderers retain their
   native content and business UI; only the app-level viewport is shared. */
[data-theme="tien_hiep"] .th-major-scene {
  position: fixed; inset: 0; display: flex; align-items: center; justify-content: center;
  /* Scene là một hộp chức năng nổi trên Sảnh Chính: giữ rõ phong cảnh/HUD
     phía dưới, không phủ dim hoặc blur như Modal xác nhận. */
  padding: 20px; background: transparent;
  backdrop-filter: none; animation: thPopupFadeIn .18s var(--ease);
}
[data-theme="tien_hiep"] .th-major-scene-shell {
  width: min(1080px, 96vw); height: min(860px, 94vh); display: flex; flex-direction: column;
  overflow: hidden; border: 1px solid var(--border-strong); border-radius: var(--radius-lg);
  background: var(--surface); box-shadow: var(--shadow-lg);
}
[data-theme="tien_hiep"] .th-major-scene-head { display:flex; align-items:center; justify-content:space-between; min-height:52px; padding:8px 14px 8px 18px; background:var(--grad-primary); color:var(--on-primary); }
[data-theme="tien_hiep"] .th-major-scene-head h2 { margin:0; font-size:17px; }
[data-theme="tien_hiep"] .th-major-scene-close { width:34px; height:34px; border:0; border-radius:50%; color:var(--on-primary); background:color-mix(in srgb,var(--on-primary) 16%,transparent); cursor:pointer; }
[data-theme="tien_hiep"] .th-major-scene-body, [data-theme="tien_hiep"] .th-major-scroll-body { min-height:0; overflow:auto; overscroll-behavior:contain; }
[data-theme="tien_hiep"] .th-major-scene-body { flex:1; padding:18px; }
[data-theme="tien_hiep"] .th-major-tabs { margin:0 0 16px; }
[data-theme="tien_hiep"] .th-major-scene-empty, [data-theme="tien_hiep"] .th-major-scene-loading { padding:32px; text-align:center; color:var(--text-muted); }
[data-theme="tien_hiep"] .th-major-leaderboard-scene .th-major-scene-body {
  display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:16px; align-items:start;
}
[data-theme="tien_hiep"] .th-major-leaderboard-scene .th-lb-section { min-width:0; margin:0; }
[data-theme="tien_hiep"] .th-major-leaderboard-scene .th-lb-section h3 { margin:0 0 8px; }
[data-theme="tien_hiep"] .th-major-village-scene[data-village-mounted] > .th-major-scene-shell { display:none; }
[data-theme="tien_hiep"] .th-major-village-scene .village-modal-overlay { position:absolute; inset:0; z-index:1; padding:0; background:transparent; backdrop-filter:none; }
[data-theme="tien_hiep"] .th-major-village-scene .village-modal {
  width:min(1080px,96vw); height:min(860px,94vh); min-height:0; max-width:none; max-height:94vh;
}
[data-theme="tien_hiep"] .th-major-village-scene .village-modal-body { min-height:0; }
@media (max-width:720px) {
  [data-theme="tien_hiep"] .th-major-scene { padding:0; }
  [data-theme="tien_hiep"] .th-major-scene-shell { width:100vw; height:100dvh; border-radius:0; border-width:0; }
  [data-theme="tien_hiep"] .th-major-leaderboard-scene .th-major-scene-body { grid-template-columns:1fr; }
  [data-theme="tien_hiep"] .th-major-leaderboard-scene .th-lb-section { margin:0 0 18px; }
  [data-theme="tien_hiep"] .th-major-village-scene .village-modal { width:100vw; height:100dvh; max-height:100dvh; border-radius:0; }
}

/* JOB_TH2_20: legacy pages live inside a full-screen Scene.  The iframe is
   deliberately a child of the Scene so every navigation close path removes
   the document rather than merely hiding it. */
[data-theme="tien_hiep"] .th-frame-scene {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: thPopupFadeIn .18s var(--ease);
}

[data-theme="tien_hiep"] .th-frame-scene-shell {
  width: min(1280px, 96vw);
  height: min(840px, 94vh);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-lg);
}

[data-theme="tien_hiep"] .th-frame-scene-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 46px;
  padding: 8px 14px 8px 18px;
  background: var(--grad-primary);
  color: var(--on-primary);
}

[data-theme="tien_hiep"] .th-frame-scene-title { font-weight: 700; }

[data-theme="tien_hiep"] .th-frame-scene-close {
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 50%;
  color: var(--on-primary);
  background: color-mix(in srgb, var(--on-primary) 16%, transparent);
  cursor: pointer;
}

[data-theme="tien_hiep"] .th-frame-scene-iframe {
  width: 100%;
  height: 100%;
  min-height: 0;
  border: 0;
  display: block;
  background: #000;
}

[data-theme="tien_hiep"] .th-frame-scene-recovery {
  flex: 1 1 auto;
  place-content: center;
  gap: 14px;
  padding: 32px;
  text-align: center;
  color: var(--text);
  background: var(--surface);
}

[data-theme="tien_hiep"] .th-frame-scene-recovery:not([hidden]) { display: grid; }

[data-theme="tien_hiep"] .th-frame-scene-recovery p { margin: 0; }

@media (max-width: 720px) {
  [data-theme="tien_hiep"] .th-frame-scene { padding: 0; }
  [data-theme="tien_hiep"] .th-frame-scene-shell { width: 100vw; height: 100dvh; border-radius: 0; border-width: 0; }
}

/* ---- Thông Báo Hệ Thống (theme Tiên Hiệp, Owner 2026-09-19) ----
   Khung log cố định góc trái dưới, mặc định mở. z-index 320: trên Scene (300),
   dưới widget Tổ Đội/Chat nổi (340+) và Modal root (400). */
.th-syslog{position:fixed;left:8px;bottom:6px;z-index:320;width:min(370px,calc(100vw - 16px));display:flex;flex-direction:column;background:rgba(5,11,15,.62);border:1px solid rgba(242,218,139,.38);border-radius:10px;backdrop-filter:blur(3px);box-shadow:0 6px 18px rgba(0,0,0,.45);font:12px/1.45 var(--font-body,sans-serif);color:#f2ead0;pointer-events:auto;}
.th-syslog-head{display:flex;align-items:center;gap:4px;padding:3px 4px;border-bottom:1px solid rgba(242,218,139,.22);}
.th-syslog-tabs{display:flex;flex:1;gap:2px;min-width:0;overflow:hidden;}
.th-syslog-tab{border:0;background:transparent;color:#cfc7ad;font:700 11px var(--font-body,sans-serif);padding:3px 7px;border-radius:5px;cursor:pointer;white-space:nowrap;text-shadow:0 1px 2px #000;}
.th-syslog-tab:hover{background:rgba(255,255,255,.08);}
.th-syslog-tab.is-active{background:rgba(242,218,139,.22);color:#ffe9a8;}
.th-syslog-toggle{border:0;background:transparent;color:#ffe9a8;font-size:13px;cursor:pointer;padding:2px 6px;}
.th-syslog-clear{border:0;background:transparent;color:#ffe9a8;font-size:12px;cursor:pointer;padding:2px 6px;opacity:.75;}
.th-syslog-clear:hover{opacity:1;}
.th-syslog-badge{min-width:16px;padding:0 4px;border-radius:8px;background:#c0392b;color:#fff;font:800 10px/16px var(--font-body,sans-serif);text-align:center;}
.th-syslog-list{height:118px;overflow-y:auto;padding:4px 8px 6px;scrollbar-width:thin;scrollbar-color:rgba(242,218,139,.4) transparent;}
.th-syslog.is-collapsed .th-syslog-pane{display:none;}
.th-syslog-line{padding:1px 0;text-shadow:0 1px 2px #000,0 0 4px #000;word-break:break-word;}
.th-syslog-time{opacity:.6;font-size:10.5px;}
.th-syslog-ch{font-weight:800;}
.th-syslog-line.is-error .th-syslog-text{color:#ff9d9d;font-weight:700;}
@media (max-width:560px){.th-syslog{width:min(300px,calc(100vw - 12px));}.th-syslog-list{height:88px;}}
/* Chat là khung NỔI mở khi cần: luôn nằm trên khung thông báo. */
[data-theme="tien_hiep"] #chatPanel{z-index:340;}
/* Owner 2026-09-23: Chat đã tích hợp vào khung Thông Báo Hệ Thống (tab "Nhắn Tin")
   — nút nổi #chatFab gốc (chat.js tự dựng, không theo icon HUD nào) giờ trùng lặp
   lối vào, ẩn hẳn cho theme này. chat.js vẫn chạy nguyên vẹn cho theme kid/pro. */
[data-theme="tien_hiep"] #chatFab{display:none;}

/* ---- Nhắn Tin lồng trong Thông Báo Hệ Thống (Owner 2026-09-23) ----
   Tab lồng ngoài cùng (💬 Nhắn Tin / 🔔 Thông Báo) đứng NGANG với 2 nút cũ
   trong .th-syslog-head; mỗi pane (.th-syslog-pane) tự chứa 1 hàng tab con +
   1 khung nội dung — dùng lại NGUYÊN cỡ chữ/khung .th-syslog-list, .th-syslog-tab
   để "y hệt thông báo hệ thống hiện tại" đúng yêu cầu Owner, không tạo ngôn ngữ
   thị giác mới. */
.th-syslog-outer-tabs{display:flex;gap:2px;flex:1;min-width:0;}
.th-syslog-outer-tab{position:relative;border:0;background:transparent;color:#cfc7ad;font:800 11px var(--font-body,sans-serif);padding:3px 7px;border-radius:5px;cursor:pointer;white-space:nowrap;text-shadow:0 1px 2px #000;}
/* Owner 2026-09-29: báo có tin nhắn Riêng mới chưa đọc — hiện ngay trên tab
   "Nhắn Tin" kể cả khi đang xem Thông Báo hoặc khung đang thu gọn (chỉ
   header bị ẩn nội dung, không ẩn hàng tab, xem .th-syslog.is-collapsed). */
.th-syslog-dm-badge{position:absolute;top:-4px;right:-2px;min-width:15px;height:15px;padding:0 3px;border-radius:8px;background:#c0392b;color:#fff;font:800 9.5px/15px var(--font-body,sans-serif);text-align:center;box-shadow:0 0 0 1.5px #06191a;}
.th-syslog-outer-tab:hover{background:rgba(255,255,255,.08);}
.th-syslog-outer-tab.is-active{background:rgba(127,227,255,.22);color:#c7f5ff;}
.th-syslog-pane{display:flex;flex-direction:column;min-height:0;}
.th-syslog-pane[hidden]{display:none;}
.th-syslog-chat-back{border:0;background:transparent;color:#ffe9a8;font:700 12px var(--font-body,sans-serif);padding:3px 6px;cursor:pointer;}
.th-syslog-chat-list{display:flex;flex-direction:column;}
.th-syslog-chat-empty{margin:auto;padding:8px 0;font-size:11.5px;opacity:.7;text-align:center;}
/* Owner 2026-09-23 ("gọn hơn, bỏ avatar để đỡ lag"): mỗi tin nhắn 1 dòng phẳng
   "giờ **Tên**: nội dung", đúng khuôn .th-syslog-line của Thông Báo — không còn
   avatar/khối bong bóng/cột riêng cho từng tin. */
.th-syslog-chat-msg{padding:1px 0;text-shadow:0 1px 2px #000,0 0 4px #000;word-break:break-word;font-size:12px;}
.th-syslog-chat-time{opacity:.6;font-size:10.5px;}
.th-syslog-chat-name{color:#ffe9a8;font-weight:800;}
.th-syslog-chat-name.is-clickable{cursor:pointer;}
.th-syslog-chat-name.is-clickable:hover{text-decoration:underline;}
.th-syslog-chat-text{word-break:break-word;}
/* Owner 2026-09-29: thẻ chia sẻ Thần Thú dùng luôn CSS gốc .pet-share-compact
   (đã nạp toàn site qua footer.php); fallback chữ (script chưa kịp nạp) chỉ
   cần style tối thiểu để bấm được, cùng tông màu tím như bản gốc chat.js. */
.th-syslog-chat-petshare-fallback{display:block;margin-top:4px;color:#818cf8;font-weight:700;cursor:pointer;}
.th-syslog-chat-petshare-fallback:hover{text-decoration:underline;}
/* Owner 2026-10-23: thẻ Thần Thú trong khung Nhắn Tin gọn như thẻ Trang Bị — viên thuốc 2 dòng, viền/tên theo màu phẩm chất,
   bỏ vạch màu bên trái + dải kỹ năng (xem đầy đủ khi bấm). Chỉ áp trong .th-syslog-chat-msg, chat cũ không đổi. */
.th-syslog-chat-msg .pet-share-compact{display:inline-block;width:auto;max-width:100%;margin-top:2px;padding:2px 12px;vertical-align:middle;
  border:1px solid var(--pet-rarity-color,#6366f1);border-radius:999px;background:rgba(8,14,20,.55);transform:none;}
.th-syslog-chat-msg .pet-share-compact:hover{background:rgba(30,24,10,.7);transform:none;}
.th-syslog-chat-msg .pet-share-compact::before{display:none;}
.th-syslog-chat-msg .pet-share-compact-skills{display:none;}
.th-syslog-chat-msg .pet-share-compact-row1{justify-content:flex-start;gap:6px;}
.th-syslog-chat-msg .pet-share-compact-name{font-size:12.5px;color:var(--pet-rarity-color,#f8fafc);}
.th-syslog-chat-msg .pet-share-compact-rarity{background:none !important;border:0 !important;padding:0;font-size:10.5px;font-weight:600;text-transform:none;}
.th-syslog-chat-msg .pet-share-compact-row2{font-size:10.5px;color:#cfc8b2;}
/* Avatar chỉ còn dùng cho danh sách hội thoại Riêng (renderDmList) — không còn dùng cho
   từng dòng tin nhắn. */
.th-syslog-chat-avatar{flex:0 0 auto;width:22px;height:22px;border-radius:50%;overflow:hidden;background:rgba(255,255,255,.08);display:flex;align-items:center;justify-content:center;font-size:13px;line-height:1;}
.th-syslog-chat-avatar img{width:100%;height:100%;object-fit:cover;display:block;}
.th-syslog-chat-dm-row{display:flex;align-items:center;gap:6px;width:100%;border:0;background:transparent;color:#f2ead0;padding:4px 2px;border-radius:6px;cursor:pointer;text-align:left;font:inherit;}
.th-syslog-chat-dm-row:hover{background:rgba(255,255,255,.08);}
.th-syslog-chat-dm-name{flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size:12px;}
.th-syslog-chat-dm-badge{min-width:16px;padding:0 4px;border-radius:8px;background:#c0392b;color:#fff;font:800 10px/16px var(--font-body,sans-serif);text-align:center;}
.th-syslog-chat-input-row{display:flex;align-items:center;gap:4px;padding:4px 6px 6px;border-top:1px solid rgba(242,218,139,.18);}
.th-syslog-chat-input-row[hidden]{display:none;}
.th-syslog-chat-input{flex:1;min-width:0;background:rgba(255,255,255,.06);border:1px solid rgba(242,218,139,.28);border-radius:999px;padding:5px 10px;color:#f2ead0;font:12px var(--font-body,sans-serif);}
.th-syslog-chat-input::placeholder{color:#9a927a;}
.th-syslog-chat-input:focus{outline:none;border-color:rgba(255,214,102,.7);}
.th-syslog-chat-map-btn[hidden]{display:none;}
.th-syslog-chat-map-btn,.th-syslog-chat-emoji-btn,.th-syslog-chat-send-btn{border:0;background:transparent;font-size:16px;line-height:1;cursor:pointer;padding:4px;border-radius:50%;}
.th-syslog-chat-map-btn:hover,.th-syslog-chat-emoji-btn:hover,.th-syslog-chat-send-btn:hover{background:rgba(255,255,255,.1);}
@media (max-width:560px){.th-syslog-outer-tab{font-size:10.5px;padding:3px 5px;}}

/* Owner 2026-09-24 — Cửa Hàng trên mobile: gọn hơn để thấy nhiều vật phẩm.
   4 cột, icon nhỏ lại, ẩn tên (đã có tooltip), 3 tab tiền tệ sát tiêu đề. Chỉ ảnh hưởng Cửa Hàng (.th-major-shop-scene) ≤560px. */
@media (max-width:560px){
  [data-theme="tien_hiep"] .th-major-shop-scene{--item-slot-max:52px;}
  /* Owner 2026-10-03: điện thoại — Scene Cửa Hàng chừa khoảng trống dưới đáy (không sát mép) và thêm đệm cuối danh sách để dòng giá/vật phẩm
     dưới cùng cuộn lên khỏi bảng thông báo hệ thống (.th-syslog cao ~175px, cố định góc trái-dưới) → luôn bấm mua được. */
  [data-theme="tien_hiep"] .th-major-shop-scene{align-items:flex-start;}
  [data-theme="tien_hiep"] .th-major-shop-scene .th-major-scene-shell{height:calc(100dvh - 56px);}
  [data-theme="tien_hiep"] .th-major-shop-scene .th-major-scene-body{padding:2px 10px 130px;}
  [data-theme="tien_hiep"] .th-major-shop-scene #shopCurrencyTabBar{margin-bottom:8px;}
  [data-theme="tien_hiep"] .th-major-shop-scene #shopCurrencyTabBar .sub-tab{padding:6px 12px;min-height:34px;}
  [data-theme="tien_hiep"] .th-major-shop-scene .item-slot-grid{grid-template-columns:repeat(4,minmax(0,1fr));gap:8px 6px;justify-items:center;}
  [data-theme="tien_hiep"] .th-major-shop-scene .inv-slot-wrap{gap:3px !important;width:100%;}
  [data-theme="tien_hiep"] .th-major-shop-scene .inv-slot-wrap .item-slot-name{display:none;}
  [data-theme="tien_hiep"] .th-major-shop-scene .inv-slot-wrap .item-slot,
  [data-theme="tien_hiep"] .th-major-shop-scene .inv-slot-wrap .th-shop-equip-tooltip{width:52px !important;height:52px !important;}
  [data-theme="tien_hiep"] .th-major-shop-scene .inv-slot-wrap .shop-buy-btn,
  [data-theme="tien_hiep"] .th-major-shop-scene .inv-slot-wrap .br-buy-btn,
  [data-theme="tien_hiep"] .th-major-shop-scene .inv-slot-wrap .consumable-buy-btn,
  [data-theme="tien_hiep"] .th-major-shop-scene .inv-slot-wrap button.btn{width:min(100%,66px) !important;min-height:24px !important;padding:0 4px !important;font-size:10px !important;}
}


/* ===== Thẻ chia sẻ Trang Bị / Vật Phẩm / Bản Đồ trong khung chat (Owner 2026-10-06) ===== */
.th-syslog-share-card{--th-share-color:#B8B8B8;display:inline-flex;align-items:center;gap:6px;max-width:100%;margin-top:2px;padding:2px 10px 2px 3px;
  border:1px solid var(--th-share-color);border-radius:999px;background:rgba(8,14,20,.55);color:#f4f1e5;font:inherit;text-align:left;cursor:pointer;vertical-align:middle;}
.th-syslog-share-card:hover{background:rgba(30,24,10,.7);}
.th-syslog-share-card.is-map{--th-share-color:#e6c27a;}
.th-syslog-share-icon{flex:0 0 26px;width:26px;height:26px;display:inline-flex;align-items:center;justify-content:center;font-size:18px;line-height:1;}
.th-syslog-share-icon img{width:26px;height:26px;object-fit:contain;}
.th-syslog-share-text{display:flex;flex-direction:column;min-width:0;font-weight:700;color:var(--th-share-color);font-size:12.5px;line-height:1.2;}
.th-syslog-share-text small{font-weight:400;font-size:10.5px;color:#cfc8b2;}

/* Loa chia sẻ vào chat — nhỏ gọn ở góc bảng vật phẩm (Owner 2026-10-23). Icon AI vẽ sẽ thay 📢 sau (đặt làm background-image). */
.th-share-speaker{flex:0 0 auto;width:26px;height:26px;padding:0;margin:0 6px 0 auto;border:0;background:transparent center/contain no-repeat;color:inherit;font-size:17px;line-height:26px;text-align:center;cursor:pointer;filter:drop-shadow(0 1px 2px rgba(0,0,0,.55));opacity:.9;}
.th-share-speaker:hover{opacity:1;transform:scale(1.12);}
.th-share-speaker:disabled{opacity:.4;cursor:default;}
.th-share-speaker[hidden]{display:none;}
.th-equip-detail-share{position:absolute;top:8px;right:42px;margin:0;}
.th-ingot-share{position:absolute;top:4px;right:4px;margin:0;width:22px;height:22px;font-size:14px;line-height:22px;}
.th-popup-corner-share{position:absolute;top:0;right:0;margin:0;}
.th-dokiepdan-popup,.th-holyflame-card{position:relative;}
