/* === 建造菜单 HTML 版 — PC/手机统一 === */

#build-menu {
    display: none;
    flex-direction: column;
    position: fixed;
    top: 0; left: 50%;
    transform: translateX(-50%);
    width: 100%; height: 100%;
    max-width: calc(100vh * 3 / 2); /* 跟随 canvas 的 aspect-ratio 3:2 */
    background: linear-gradient(180deg, #1a0f05 0%, #2a1a0e 100%);
    z-index: 20;
    font-family: 'Segoe UI', 'Microsoft YaHei', sans-serif;
    color: #f4d98c;
}
#build-menu.active { display: flex; }

/* 自定义滚动条 */
#build-menu ::-webkit-scrollbar {
    width: 6px;
}
#build-menu ::-webkit-scrollbar-track {
    background: transparent;
}
#build-menu ::-webkit-scrollbar-thumb {
    background: rgba(139,105,20,0.3);
    border-radius: 3px;
}
#build-menu ::-webkit-scrollbar-thumb:hover {
    background: rgba(139,105,20,0.5);
}
#build-menu {
    scrollbar-width: thin;
    scrollbar-color: rgba(139,105,20,0.3) transparent;
}

/* ==================== 顶部状态栏 ==================== */
.bm-header {
    background: rgba(0,0,0,0.6);
    padding: 10px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
    border-bottom: 1px solid #3a2a10;
    max-width: 980px;
    margin: 0 auto;
    width: 100%;
}
.bm-player-name {
    font-size: 18px;
    font-weight: bold;
}
.bm-header-left {
    display: flex;
    align-items: center;
    gap: 14px;
}
.bm-resources {
    display: flex;
    gap: 20px;
    font-size: 18px;
    font-weight: bold;
}
.bm-header-right {
    display: flex;
    align-items: center;
    gap: 16px;
}
.bm-gold { color: #ffd700; }
.bm-crystal { color: #00bfff; }
.bm-turn {
    font-size: 15px;
    color: #c9a84c;
}
.bm-ai-status {
    font-size: 13px;
    font-weight: bold;
}
.bm-intel-btn {
    padding: 6px 16px;
    font-size: 13px;
    font-family: inherit;
    background: rgba(100,80,40,0.4);
    color: #c9a84c;
    border: 1px solid #6a5a24;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.15s;
}
.bm-intel-btn:hover {
    background: rgba(139,105,20,0.5);
    border-color: #8b6914;
}

/* === 情报面板 === */
#intel-modal {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    z-index: 30;
    display: flex;
    justify-content: center;
    align-items: center;
}
.intel-backdrop {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(0,0,0,0.6);
}
.intel-panel {
    position: relative;
    background: linear-gradient(180deg, #2a1a0e, #1a0f05);
    border: 2px solid #6a5a24;
    border-radius: 8px;
    padding: 20px 24px;
    max-width: 560px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 8px 40px rgba(0,0,0,0.6);
}
.intel-header {
    font-size: 20px;
    font-weight: bold;
    color: #f4d98c;
    text-align: center;
    margin-bottom: 16px;
    padding-bottom: 10px;
    border-bottom: 1px solid rgba(139,105,20,0.3);
}
.intel-columns {
    display: flex;
    gap: 0;
}
.intel-col {
    flex: 1;
    min-width: 0;
}
.intel-divider {
    width: 1px;
    background: rgba(139,105,20,0.3);
    margin: 0 16px;
}
.intel-col-title {
    font-size: 15px;
    font-weight: bold;
    margin-bottom: 10px;
}
.intel-section {
    font-size: 12px;
    color: #888;
    margin-top: 10px;
    margin-bottom: 4px;
    text-transform: uppercase;
    letter-spacing: 0.1em;
}
.intel-item {
    display: flex;
    justify-content: space-between;
    font-size: 14px;
    color: #ccc;
    padding: 3px 0;
}
.intel-close {
    display: block;
    margin: 16px auto 0;
    padding: 8px 32px;
    font-size: 14px;
    font-family: inherit;
    background: rgba(100,80,40,0.4);
    color: #c9a84c;
    border: 1px solid #6a5a24;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.15s;
}
.intel-close:hover {
    background: rgba(139,105,20,0.5);
}

/* ==================== 主内容区 ==================== */
.bm-content {
    flex: 1;
    display: flex;
    overflow: hidden;
}

/* --- PC: 左侧卡片列表 + 右侧建造记录 --- */
.bm-cards {
    flex: 1;
    overflow-y: auto;
    padding: 12px 20px;
    -webkit-overflow-scrolling: touch;
}
.bm-sidebar {
    width: 280px;
    flex-shrink: 0;
    background: rgba(0,0,0,0.4);
    border-left: 1px solid #3a2a10;
    padding: 16px;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

/* --- 分类标题 --- */
.bm-section-title {
    font-size: 14px;
    font-weight: bold;
    padding: 10px 0 6px;
    border-bottom: 1px solid rgba(139,105,20,0.3);
    margin-bottom: 6px;
    display: flex;
    align-items: center;
    gap: 8px;
}
.bm-section-title .dot {
    width: 8px; height: 8px;
    border-radius: 50%;
    display: inline-block;
}
.dot-eco { background: #ffd700; }
.dot-melee { background: #e74c3c; }
.dot-ranged { background: #2ecc71; }
.dot-magic { background: #9b59b6; }

/* --- 建筑卡片 --- */
.bm-card {
    background: rgba(60,50,30,0.5);
    border: 1px solid #4a3a14;
    border-radius: 6px;
    padding: 10px 12px;
    margin-bottom: 6px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
    min-height: 52px;
}
.bm-card:active {
    background: rgba(100,80,30,0.6);
    border-color: #8b6914;
}
.bm-card.affordable {
    border-color: #6a5a24;
}
.bm-card.affordable:hover {
    background: rgba(100,80,30,0.6);
    border-color: #8b6914;
}
.bm-card.disabled {
    opacity: 0.4;
    cursor: default;
}
.bm-card.maxed {
    opacity: 0.35;
    cursor: default;
}

/* 左侧类别色条 */
.bm-card::before {
    content: '';
    width: 3px;
    align-self: stretch;
    border-radius: 2px;
    margin-right: 10px;
    flex-shrink: 0;
}
.bm-card.cat-eco::before { background: #ffd700; }
.bm-card.cat-melee::before { background: #e74c3c; }
.bm-card.cat-ranged::before { background: #2ecc71; }
.bm-card.cat-magic::before { background: #9b59b6; }

.bm-card-left {
    display: flex;
    flex-direction: column;
    gap: 3px;
    flex: 1;
    min-width: 0;
}
.bm-card-name {
    font-size: 15px;
    font-weight: bold;
    color: #f4d98c;
}
.bm-card-desc {
    font-size: 12px;
    color: #aaa;
}
.bm-card-stats {
    font-size: 12px;
    color: #999;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}
.bm-card-stats span {
    white-space: nowrap;
}
.bm-card-cost {
    font-size: 14px;
    color: #ccc;
    text-align: right;
    white-space: nowrap;
    margin-left: 12px;
    flex-shrink: 0;
}
.bm-card-cost .cost-gold { color: #ffd700; }
.bm-card-cost .cost-crystal { color: #00bfff; }

/* ==================== 右侧边栏（PC：建造记录） ==================== */
.bm-sidebar-title {
    color: #e8a040;
    font-weight: bold;
    font-size: 14px;
    margin-bottom: 10px;
}
.bm-sidebar-empty {
    color: #666;
    font-size: 13px;
    font-style: italic;
}
.bm-sidebar-item {
    padding: 6px 10px;
    margin-bottom: 4px;
    background: rgba(60,60,80,0.4);
    border: 1px solid rgba(139,105,20,0.3);
    border-radius: 4px;
    font-size: 13px;
    color: #e8d8b0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    transition: background 0.15s;
}
.bm-sidebar-item:hover {
    background: rgba(139,105,20,0.25);
}
.bm-sidebar-item .cancel-x {
    color: #ff6b6b;
    font-weight: bold;
    margin-left: 12px;
    font-size: 15px;
}

/* ==================== 底部操作栏 ==================== */
.bm-footer {
    background: rgba(0,0,0,0.7);
    padding: 12px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
    border-top: 1px solid #3a2a10;
    gap: 16px;
}
.bm-footer-info {
    display: flex;
    align-items: center;
    gap: 20px;
    font-size: 13px;
    color: #aaa;
}
.bm-footer-barracks {
    color: #ccc;
}
.bm-footer-buttons {
    display: flex;
    gap: 10px;
    align-items: center;
}
.bm-footer .bm-intel-btn,
.bm-footer .bm-confirm-btn {
    flex: 1;
}
.bm-footer .bm-intel-btn {
    padding: 12px 24px;
    font-size: 16px;
    font-weight: bold;
}
.bm-confirm-btn {
    padding: 12px 32px;
    font-size: 16px;
    font-weight: bold;
    font-family: inherit;
    background: linear-gradient(180deg, #7a6a1a, #5a4a14);
    color: #f4d98c;
    border: 2px solid #8b6914;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
    flex-shrink: 0;
}
.bm-confirm-btn:hover {
    background: linear-gradient(180deg, #9a8a2a, #7a6a1a);
    box-shadow: 0 0 15px rgba(139,105,20,0.3);
}
.bm-confirm-btn:active {
    transform: scale(0.97);
}

/* ==================== PC 布局（>=1001px） ==================== */
@media (min-width: 1001px) {
    .bm-cards {
        max-width: 700px;
        padding: 16px 24px;
    }
    .bm-content {
        justify-content: center;
    }
    /* 手机底部建造列表在PC端隐藏，用侧边栏代替 */
    .bm-footer-builds-mobile { display: none; }
}

/* ==================== 手机布局（<=1000px） ==================== */
@media (max-width: 1000px) {
    .bm-header {
        padding: 10px 12px;
        flex-wrap: wrap;
        gap: 6px;
    }
    .bm-header-left {
        gap: 10px;
    }

    /* 手机：无侧边栏，全屏卡片列表 */
    .bm-content {
        flex-direction: column;
    }
    .bm-sidebar {
        display: none;
    }
    .bm-cards {
        padding: 10px 12px;
    }

    .bm-card {
        padding: 12px 10px;
        min-height: 56px;
    }
    .bm-card-name {
        font-size: 16px;
    }
    .bm-card-stats {
        font-size: 13px;
    }
    .bm-card-cost {
        font-size: 15px;
    }

    /* 手机底部栏 */
    .bm-footer {
        padding: 10px 12px;
        flex-wrap: wrap;
    }
    .bm-footer-builds-mobile {
        width: 100%;
        font-size: 12px;
        color: #aaa;
        margin-bottom: 6px;
        padding-bottom: 6px;
        border-bottom: 1px solid #3a2a10;
        max-height: 30vh;
        overflow-y: auto;
    }
    .bm-footer-builds-mobile .bm-sidebar-title {
        font-size: 12px;
        margin-bottom: 4px;
    }
    .bm-footer-builds-mobile .bm-sidebar-item {
        font-size: 12px;
        padding: 4px 6px;
    }
    .bm-footer-buttons {
        width: 100%;
        gap: 8px;
    }
    .bm-footer .bm-intel-btn {
        padding: 14px 20px;
        font-size: 16px;
    }
    .bm-confirm-btn {
        flex: 1;
        padding: 14px 24px;
        font-size: 18px;
        text-align: center;
    }
}
