/* 宗门领地·全域势力争夺系统  UI（9:16 竖屏） */
#territory-panel {
    position: fixed; left: 0; top: 0; right: 0; bottom: 0;
    z-index: 9999;
    background: linear-gradient(180deg, #0c0c1a 0%, #141428 60%, #1b1430 100%);
    color: #e8e8f4;
    display: flex; flex-direction: column;
    overflow: hidden;
}
#territory-panel.hidden { display: none !important; }

.terr-wrap {
    width: 100%; max-width: 480px; margin: 0 auto;
    height: 100%; display: flex; flex-direction: column;
    box-sizing: border-box;
}

/* 顶部总览 */
.terr-top {
    padding: 14px 16px 10px;
    background: linear-gradient(180deg, rgba(60,40,110,0.55), rgba(20,20,40,0.2));
    border-bottom: 1px solid rgba(150,120,220,0.25);
}
.terr-top-row { display: flex; align-items: center; justify-content: space-between; }
.terr-title { font-size: 18px; font-weight: 800; color: #f0e6ff; letter-spacing: 1px; }
.terr-close {
    width: 32px; height: 32px; border-radius: 50%;
    background: rgba(255,255,255,0.08); color: #fff;
    border: 1px solid rgba(255,255,255,0.2); font-size: 18px; cursor: pointer;
}
.terr-stats { display: flex; gap: 10px; margin-top: 10px; }
.terr-stat {
    flex: 1; background: rgba(255,255,255,0.05); border: 1px solid rgba(150,120,220,0.2);
    border-radius: 10px; padding: 8px 10px; text-align: center;
}
.terr-stat .v { font-size: 17px; font-weight: 800; color: #ffd98a; }
.terr-stat .k { font-size: 11px; color: #a9a9c8; margin-top: 2px; }

/* 分类标签 */
.terr-tabs {
    display: flex; gap: 8px; overflow-x: auto; padding: 10px 14px;
    border-bottom: 1px solid rgba(150,120,220,0.18); scrollbar-width: none;
}
.terr-tabs::-webkit-scrollbar { display: none; }
.terr-tab {
    flex: 0 0 auto; padding: 7px 14px; border-radius: 18px; cursor: pointer;
    background: rgba(255,255,255,0.06); border: 1px solid rgba(255,255,255,0.12);
    font-size: 13px; color: #c9c9e6; white-space: nowrap;
}
.terr-tab.active { background: linear-gradient(90deg,#7b4bd6,#a45bff); color: #fff; font-weight: 700; border-color: transparent; }

/* 卡片列表 */
.terr-body { flex: 1; overflow-y: auto; padding: 14px; -webkit-overflow-scrolling: touch; }
.terr-card {
    background: rgba(255,255,255,0.05); border: 1px solid rgba(150,120,220,0.22);
    border-radius: 14px; padding: 12px; margin-bottom: 12px; cursor: pointer;
    transition: transform .08s, border-color .15s;
}
.terr-card:active { transform: scale(0.99); }
.terr-card.owned-self { border-color: #4fd6a0; box-shadow: 0 0 0 1px rgba(79,214,160,0.4) inset; }
.terr-card.owned-enemy { border-color: #ff7a7a; }
.terr-card-head { display: flex; align-items: center; justify-content: space-between; }
.terr-name { font-size: 16px; font-weight: 800; color: #fff; }
.terr-stars { color: #ffd98a; font-size: 13px; letter-spacing: 1px; }
.terr-owner {
    display: inline-block; margin-top: 6px; font-size: 12px; padding: 2px 8px; border-radius: 8px;
}
.terr-owner.npc { background: rgba(160,160,180,0.18); color: #cfcfe6; }
.terr-owner.self { background: rgba(79,214,160,0.18); color: #7df0c0; }
.terr-owner.enemy { background: rgba(255,122,122,0.18); color: #ff9d9d; }
.terr-meta { display: flex; gap: 12px; margin-top: 8px; font-size: 12px; color: #b9b9d6; }
.terr-meta b { color: #ffd98a; font-weight: 700; }
.terr-protect {
    margin-top: 6px; font-size: 11px; color: #ffb86b;
}
.terr-income {
    margin-top: 6px; font-size: 11px; color: #9fe0ff;
}

/* 详情 / 弹窗共用 */
.terr-overlay {
    position: fixed; left: 0; top: 0; right: 0; bottom: 0; z-index: 10000;
    background: rgba(0,0,0,0.6); display: flex; align-items: flex-end; justify-content: center;
}
.terr-overlay.hidden { display: none !important; }
.terr-sheet {
    width: 100%; max-width: 480px; max-height: 88%; overflow-y: auto;
    background: linear-gradient(180deg, #1a1830, #12121f);
    border-top-left-radius: 18px; border-top-right-radius: 18px;
    border: 1px solid rgba(150,120,220,0.3);
    padding: 16px 16px 22px; box-sizing: border-box;
}
.terr-sheet-title { font-size: 18px; font-weight: 800; color: #fff; display: flex; justify-content: space-between; align-items: center; }
.terr-sheet-close { font-size: 22px; color: #aaa; cursor: pointer; background: none; border: none; }
.terr-sec-title { font-size: 13px; color: #b9a9ff; margin: 14px 0 8px; font-weight: 700; }
.terr-def-row {
    display: flex; align-items: center; justify-content: space-between;
    padding: 8px 10px; background: rgba(255,255,255,0.04); border-radius: 10px; margin-bottom: 6px;
}
.terr-def-name { font-size: 13px; color: #e8e8f4; }
.terr-def-sub { font-size: 11px; color: #9a9ac0; margin-top: 2px; }
.terr-def-pow { font-size: 13px; color: #ffd98a; font-weight: 700; }
.terr-trib-row { display: flex; justify-content: space-between; font-size: 13px; padding: 5px 2px; border-bottom: 1px dashed rgba(255,255,255,0.08); }
.terr-trib-row .v { color: #9fe0ff; font-weight: 700; }

.terr-btn {
    display: block; width: 100%; padding: 13px; margin-top: 12px; border: none; border-radius: 12px;
    font-size: 15px; font-weight: 800; cursor: pointer; color: #fff;
    background: linear-gradient(90deg, #7b4bd6, #a45bff);
}
.terr-btn:disabled { background: rgba(255,255,255,0.1); color: #888; cursor: not-allowed; }
.terr-btn.danger { background: linear-gradient(90deg, #d64b6b, #ff5b7b); }
.terr-btn.ghost { background: rgba(255,255,255,0.08); color: #ddd; }

/* 成员选择 */
.terr-sel-hint { font-size: 12px; color: #b9b9d6; margin-bottom: 8px; }
.terr-sel-list { max-height: 46vh; overflow-y: auto; }
.terr-sel-item {
    display: flex; align-items: center; gap: 10px; padding: 9px 10px;
    background: rgba(255,255,255,0.04); border-radius: 10px; margin-bottom: 6px; cursor: pointer;
    border: 1px solid transparent;
}
.terr-sel-item.on { border-color: #a45bff; background: rgba(164,91,255,0.14); }
.terr-sel-item input { width: 18px; height: 18px; accent-color: #a45bff; }
.terr-sel-info { flex: 1; }
.terr-sel-name { font-size: 14px; color: #fff; }
.terr-sel-sub { font-size: 11px; color: #9a9ac0; margin-top: 2px; }
.terr-sel-pow { font-size: 13px; color: #ffd98a; font-weight: 700; }
.terr-sel-count { font-size: 12px; color: #ffd98a; text-align: right; margin-top: 6px; }
.terr-empty { text-align: center; color: #888; padding: 30px 0; font-size: 13px; }
