/* Cổ Thành — bản đồ lớn (tien-hiep-cothanh.js). Chỉ hiệu lực khi JS đặt data-co-thanh="1" lên .hero-tienhiep.
   Tiền tố riêng .th-cothanh* (KHÔNG dùng .th-cotran*). Đặc tả: mdMeta/TIEN_HIEP/CoThanh/CT01, CT02. */
.hero-tienhiep .th-cothanh{display:none;position:absolute;inset:0;overflow:hidden;z-index:0;background:#0a1822;touch-action:none;user-select:none;-webkit-user-select:none;}
.hero-tienhiep[data-co-thanh="1"]:not(.is-equip-view) .th-cothanh{display:block;}
.hero-tienhiep[data-co-thanh="1"] .th-cotran{display:none !important;}   /* Cổ Trấn có thể đã dựng sẵn: ẩn khi Cổ Thành đang chạy */
.hero-tienhiep[data-co-thanh="1"]:not(.is-equip-view) .stage,
.hero-tienhiep[data-co-thanh="1"]:not(.is-equip-view) .l4-roof,
.hero-tienhiep[data-co-thanh="1"]:not(.is-equip-view) .l4-railing,
.hero-tienhiep[data-co-thanh="1"]:not(.is-equip-view) .l4-lantern,
.hero-tienhiep[data-co-thanh="1"]:not(.is-equip-view) .char-home-platform,
.hero-tienhiep[data-co-thanh="1"]:not(.is-equip-view) .char-home-portrait,
.hero-tienhiep[data-co-thanh="1"]:not(.is-equip-view) .th-char-shadow,
.hero-tienhiep[data-co-thanh="1"]:not(.is-equip-view) .th-char-nameplate,
.hero-tienhiep[data-co-thanh="1"]:not(.is-equip-view) .th-equip-weapon-float,
.hero-tienhiep[data-co-thanh="1"]:not(.is-equip-view) .th-equip-mount-float,
.hero-tienhiep[data-co-thanh="1"]:not(.is-equip-view) .th-mount-shadow,
.hero-tienhiep[data-co-thanh="1"]:not(.is-equip-view) .th-equip-phikiem-float{display:none !important;}

.th-cothanh-ground{position:absolute;left:0;top:0;width:100%;height:100%;display:block;z-index:0;}
/* world: gốc (0,0) ở góc trên-trái, đơn vị = rpx; JS đặt transform translate+scale theo camera */
.th-cothanh-world{position:absolute;left:0;top:0;width:0;height:0;transform-origin:0 0;will-change:transform;z-index:1;}
.th-cothanh-decals,.th-cothanh-sorted{position:absolute;left:0;top:0;width:0;height:0;}
.th-cothanh-decals{z-index:1;}
.th-cothanh-sorted{z-index:2;}
.th-cothanh-tag{position:absolute;display:none;pointer-events:none;white-space:nowrap;font:700 15px/1.25 system-ui,sans-serif;color:#ffe9b0;background:rgba(18,14,8,.8);border:1px solid rgba(225,195,110,.75);border-radius:999px;padding:2px 12px;text-shadow:0 1px 2px #000;scale:var(--inv,1)}
.th-cothanh-tag .ts{display:none}.th-cothanh-world.show-tags .th-cothanh-tag{display:block}
.th-cothanh-world.show-shoptags .th-cothanh-tag[data-act="tap_hoa"]{display:block}
.th-cothanh-world.show-shoptags:not(.show-tags) .th-cothanh-tag[data-act="tap_hoa"] .ta{display:none}.th-cothanh-world.show-shoptags:not(.show-tags) .th-cothanh-tag[data-act="tap_hoa"] .ts{display:inline}
.th-cothanh-tag[data-pos="bottom"]{transform:translate(-50%,0);transform-origin:50% 0}.th-cothanh-tag[data-pos="top"]{transform:translate(-50%,-100%);transform-origin:50% 100%}
.th-cothanh-tag[data-pos="left"]{transform:translate(-100%,-50%);transform-origin:100% 50%}.th-cothanh-tag[data-pos="right"]{transform:translate(0,-50%);transform-origin:0 50%}
.th-cothanh-obj{position:absolute;pointer-events:none;transform-origin:var(--fx,50%) var(--fy,100%);}
.th-cothanh-obj img{position:absolute;inset:0;width:100%;height:100%;display:block;opacity:0;transition:opacity .7s ease;user-select:none;-webkit-user-drag:none;pointer-events:none;}
.th-cothanh-obj[data-p="ngay"] img.is-ngay.is-ready,.th-cothanh-obj[data-p="dem"] img.is-dem.is-ready{opacity:1;}

.th-cothanh-glow{position:absolute;aspect-ratio:1/1;transform:translate(-50%,-50%);border-radius:50%;pointer-events:none;opacity:0;transition:opacity .7s ease;mix-blend-mode:screen;background:radial-gradient(circle,rgba(255,206,110,.5) 0%,rgba(255,170,70,.2) 38%,rgba(255,150,50,0) 70%);}
.th-cothanh-obj.has-img[data-p="dem"] .th-cothanh-glow{opacity:1;animation:th-cothanh-flick 4s ease-in-out infinite;}
@keyframes th-cothanh-flick{0%,100%{opacity:1;}45%{opacity:.78;}70%{opacity:.92;}}
@media (prefers-reduced-motion:reduce){.th-cothanh-obj.has-img[data-p="dem"] .th-cothanh-glow{animation:none;}}
.th-cothanh-walker{position:absolute;left:0;top:0;pointer-events:none;will-change:transform;}
.th-cothanh-walker-sprite{position:absolute;left:0;top:0;display:block;background-repeat:no-repeat;transform-origin:50% 50%;}
.th-cothanh-walker-shadow{position:absolute;display:block;border-radius:50%;background:radial-gradient(ellipse at center,rgba(0,0,0,.42),rgba(0,0,0,0) 70%);}
.th-cothanh-walker-tag{position:absolute;transform:translate(-50%,-100%) scale(var(--inv,1));transform-origin:50% 100%;white-space:nowrap;pointer-events:none;}
.th-cothanh-walker-name{font-family:"Noto Serif","Playfair Display",Georgia,serif;font-size:12px;font-weight:700;line-height:1.1;color:#fff4d6;text-shadow:0 1px 2px #000,0 0 3px #000,1px 0 2px #000,-1px 0 2px #000;}
.th-cothanh-ring{position:absolute;width:44px;height:20px;margin:-10px 0 0 -22px;border:3px solid rgba(255,242,200,.95);border-radius:50%;opacity:0;pointer-events:none;z-index:60000;}
.th-cothanh-ring.is-go{animation:th-cothanh-ring .9s ease-out;}
@keyframes th-cothanh-ring{0%{opacity:.95;transform:scale(.4);}100%{opacity:0;transform:scale(1.5);}}
.th-cothanh-maskdbg{position:absolute;left:0;top:0;opacity:.3;pointer-events:none;image-rendering:pixelated;z-index:59999;}
.th-cothanh-debug{position:absolute;left:8px;top:8px;z-index:9999;font:11px/1.35 monospace;color:#9fffe0;background:rgba(0,0,0,.62);padding:5px 8px;border-radius:5px;white-space:pre;pointer-events:none;}
@media (prefers-reduced-motion:reduce){.th-cothanh-obj img{transition:none;}}

/* ---- Bày Trí Cổ Thành (tien-hiep-cothanh-arranger.js; Admin, ?co_thanh_arrange=1) ---- */
.th-cothanh-ar-cv{position:absolute;left:0;top:0;width:100%;height:100%;pointer-events:none;display:block;}
.th-cothanh-ar-under{z-index:0;}
.th-cothanh-ar-over{z-index:6;}
.th-cothanh .th-cothanh-sorted,.th-cothanh .th-cothanh-decals{pointer-events:none;}
body.is-th-cothanh-arranging .th-cothanh{cursor:crosshair;}
.th-cothanh-ar{position:fixed;z-index:2700;right:12px;top:92px;width:min(340px,calc(100vw - 24px));max-height:calc(100vh - 108px);overflow:auto;display:flex;flex-direction:column;gap:6px;padding:10px;border:1px solid #d4a847;border-radius:10px;background:rgba(18,30,42,.96);color:#f1e7c9;font:12px/1.35 system-ui,sans-serif;box-shadow:0 8px 28px rgba(0,0,0,.55);}
.th-cothanh-ar header{display:flex;justify-content:space-between;gap:8px;align-items:baseline;font-size:14px;}
.th-cothanh-ar-info{color:#9fb3c2;font-size:11px;}
.th-cothanh-ar-status{padding:4px 6px;border-radius:5px;background:rgba(255,255,255,.06);min-height:18px;}
.th-cothanh-ar-status.ok{color:#8ff0b5;}.th-cothanh-ar-status.err{color:#ff9a9a;}
.th-cothanh-ar button,.th-cothanh-ar select,.th-cothanh-ar input,.th-cothanh-ar a{font:inherit;color:#f6e7b6;background:#1b3141;border:1px solid #b7953c;border-radius:6px;padding:4px 7px;}
.th-cothanh-ar button{cursor:pointer;font-weight:600;}.th-cothanh-ar button.is-on{background:#6a5316;}
.th-cothanh-ar-main{background:#7a5a00 !important;}
.th-cothanh-ar a{text-decoration:none;display:inline-block;}
.th-cothanh-ar-row{display:flex;gap:5px;flex-wrap:wrap;align-items:center;}
.th-cothanh-ar-tabs{display:flex;gap:5px;}.th-cothanh-ar-tabs button{flex:1;}
.th-cothanh-ar section{display:flex;flex-direction:column;gap:6px;}
.th-cothanh-ar [hidden]{display:none !important;}
.th-cothanh-ar-lib,.th-cothanh-ar-list{max-height:34vh;overflow:auto;}
.th-cothanh-ar-lib h4{margin:6px 0 3px;font-size:12px;color:#d9c27c;}
.th-cothanh-ar-grid{display:grid;grid-template-columns:repeat(3,1fr);gap:5px;}
.th-cothanh-ar-grid button{display:flex;flex-direction:column;align-items:center;gap:2px;padding:3px;font-size:10px;min-width:0;}
.th-cothanh-ar-grid img{width:100%;height:52px;object-fit:contain;display:block;background:rgba(255,255,255,.05);border-radius:4px;}
.th-cothanh-ar-grid span{max-width:100%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;}
.th-cothanh-ar-list button{display:block;width:100%;text-align:left;margin-bottom:3px;}
.th-cothanh-ar-expand{display:grid;grid-template-columns:1fr 1fr;gap:5px;}
.th-cothanh-ar-chk{display:flex;gap:6px;align-items:center;}
.th-cothanh-ar-insp{display:flex;flex-direction:column;gap:5px;border-top:1px solid rgba(212,168,71,.3);padding-top:6px;}
.th-cothanh-ar-insp label{display:grid;grid-template-columns:44px 1fr 48px;gap:6px;align-items:center;}
.th-cothanh-ar-insp input[type=number],.th-cothanh-ar-insp input[type=text]{width:100%;grid-column:2 / 4;}
.th-cothanh-ar-insp input[type=range]{grid-column:2;padding:0;}
.th-cothanh-ar-del{border-color:#c0504d !important;}
.th-cothanh-ar-hint{color:#9fb3c2;margin:2px 0;}
@media (max-width:720px){.th-cothanh-ar{top:auto;bottom:8px;right:8px;width:min(360px,calc(100vw - 16px));max-height:50vh;}}

/* Sinh vật / hạt Cổ Thành (tien-hiep-cothanh-ambient.js) */
.th-cothanh-obj.is-anim img{opacity:0 !important;}
.th-cothanh-fx{transition:opacity .3s linear;}
@media (prefers-reduced-motion:reduce){.th-cothanh-fx-leaf,.th-cothanh-fx-butterfly{display:none;}}
/* Phi Kiếm trong Cổ Thành (như Cổ Trấn): thanh phi kiếm dưới chân nhân vật + nút tròn Phi Kiếm góc phải-dưới */
.th-cothanh-walker-pk{position:absolute;display:block;background-repeat:no-repeat;pointer-events:none;}
.hero-tienhiep:not([data-co-thanh="1"]) .th-combat-kit.th-cothanh-kit,.hero-tienhiep.is-equip-view .th-combat-kit.th-cothanh-kit{display:none;}
.hero-tienhiep .th-combat-kit.th-cothanh-kit{z-index:30;inset:0;}

/* Khung dựng riêng (hoạt động như Bách Quỷ Dạ Hành): hiện luôn, phủ kín khung chứa. */
.th-cothanh.th-cothanh-standalone{display:block;position:absolute;inset:0;overflow:hidden;z-index:0;background:#0a1822;touch-action:none;user-select:none;-webkit-user-select:none;}

/* Renderer ngoài (PixiJS, Bách Quỷ) vẽ công trình: ảnh DOM vẫn nạp (depthAt/bộ nhớ) nhưng ẩn; quầng sáng/nhãn vẫn là DOM. */
.th-cothanh-ext .th-cothanh-obj > img{visibility:hidden}
