/* === 白色背景 · 黑色文字 主题 === */
* {
    box-sizing: border-box;
    user-select: none;
}

body {
    background: #f5f7fa;                /* 柔和浅灰背景 */
    font-family: 'Segoe UI', 'Roboto', sans-serif;
    margin: 0;
    padding: 20px;
    color: #1e1e2a;                     /* 深色文字 */
}

.game-container {
    max-width: 95%;
    margin: 0 auto;
    background: #ffffff;                /* 纯白容器 */
    border-radius: 1rem;
    padding: 1.5rem;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.05);
    border: 1px solid #e9ecef;
    color: #1a1e2b;
}

h2 {
    margin-top: 0;
    border-left: 5px solid #2a7faa;     /* 稳重蓝色点缀 */
    padding-left: 0.8rem;
    color: #0b1c2c;
    font-weight: 600;
}

/* 左右布局 */
.main-layout {
    display: flex;
    gap: 1.5rem;
}

.sidebar {
    flex: 0 0 300px;
    display: flex;
    flex-direction: column;
    gap: 1.2rem;
}

.main-content {
    flex: 1;
}

/* 资源栏 */
.resource-bar {
    background: #f8fafc;
    border-radius: 1rem;
    padding: 0.6rem 0.4rem;
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    border: 1px solid #dee2e6;
    box-shadow: inset 0 1px 3px rgba(0,0,0,0.02);
}

.resource-item {
    background: #ffffff;
    padding: 0.2rem 0.4rem;
    border-radius: 1.5rem;
    cursor: default;
    text-align: center;
    font-weight: 500;
    font-size: 0.85rem;  
    color: #1e293b;
    border: 1px solid #e2e8f0;
    transition: none;
    position: relative;
    overflow: hidden;
}
.resource-item:hover {
    background: #ffffff;
    border-color: #e2e8f0; 
}
/* 行动面板 */
.actions-panel {
    background: #f8fafc;
    border-radius: 1rem;
    padding: 0.6rem 0.4rem;
    border: 1px solid #dee2e6;
}

.actions-panel h3 {
    margin: 0 0 0.8rem 0;
    font-size: 1.0rem;
    border-left: 4px solid #2a7faa;
    padding-left: 0.6rem;
    color: #1e2a3a;
}

.action-buttons {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.action-btn {
    background: #ffffff;
    border: 1px solid #cfdde9;
    border-radius: 0.4rem;
    padding: 0.4rem 0.6rem;
    font-size: 0.90rem;
    font-weight: 500;
    cursor: pointer;
    transition: 0.1s;
    color: #1f2a3c;
    box-shadow: 0 1px 2px rgba(0,0,0,0.02);
    text-align: left;
}
.action-btn:hover {
    background: #e6f0fa;
    border-color: #2a7faa;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.05);
}

/* 选项卡 */
.tabs {
    display: flex;
    gap: 0.3rem;
    margin-bottom: 0.5rem;
    flex-wrap: wrap;
    border-bottom: 2px solid #e9ecef;
}

.tab-btn {
    background: #f1f5f9;
    border: none;
    color: #2c3e50;
    padding: 0.6rem 1.2rem;
    border-radius: 0.75rem 0.75rem 0 0;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.9rem;
    transition: all 0.1s;
    border: 1px solid transparent;
    border-bottom: none;
}
.tab-btn:hover {
    background: #e2e8f0;
}
.tab-btn.active {
    background: #ffffff;
    color: #0a3144;
    border: 1px solid #dee2e6;
    border-bottom: 2px solid #2a7faa;
    font-weight: 700;
    box-shadow: 0 -2px 6px rgba(0,0,0,0.02);
}

.panel {
    background: #ffffff;
    border-radius: 0 1rem 1rem 1rem;
    padding: 1.2rem;
    border: 1px solid #e2e8f0;
    min-height: 700px;
    max-height: 700px;
    overflow-y: auto;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.01);
    color: #1e1e2a;
}

/* 建筑网格 */
.building-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.8rem;
}

.building-card {
    background: #fbfdff;
    border-radius: 0.5rem;
    padding: 0.5rem 0.4rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: default;
    border: 1px solid #d7e0e8;
    font-size: 1.0rem;
    box-shadow: 0 2px 4px rgba(0,0,0,0.02);
    transition: border 0.1s;
}
.building-card:hover {
    border-color: #a0bbd0;
    background: #ffffff;
}
.building-card-info {
    font-weight: 600;
    color: #1f2a3c;
}
.building-card-info small {
    font-weight: 400;
    color: #5e6f82;
}

.btn-group {
    display: flex;
    gap: 0.4rem;
}

.btn-square {
    background: #ffffff;
    border: 1px solid #bcccd9;
    color: #1e2e42;
    width: 34px;
    height: 34px;
    border-radius: 0.5rem;
    cursor: pointer;
    font-weight: bold;
    font-size: 1rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.03);
    transition: all 0.1s;
}
.btn-square:hover {
    background: #e1ebf5;
    border-color: #2a7faa;
}
.btn-square:active {
    background: #cbdde9;
}

/* 通用卡片列表 */
.grid-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.8rem;
}

.card-btn {
    background: #f9fcff;
    border: 0.8px solid #cbd5e1;
    border-radius: 0.7rem;
    padding: 0.6rem 0.8rem;
    cursor: pointer;
    text-align: left;
    min-width: 180px;
    transition: all 0.1s;
    color: #1e2a3a;
    font-weight: 500;
    box-shadow: 0 1px 3px rgba(0,0,0,0.02);
}
.card-btn:hover {
    background: #e6f0fa;
    border-color: #2a7faa;
    box-shadow: 0 4px 8px rgba(0,0,0,0.05);
}

.researched-item {
    background: #e2f0e6 !important;
    border-color: #7fa98c !important;
    color: #1c3b2a;
}

.btn-rect {
    background: #ffffff;
    border: 1px solid #bcccd9;
    color: #1e2e42;
    padding: 0.4rem 0.6rem;
    border-radius: 0.5rem;
    cursor: pointer;
    font-weight: 500;
    box-shadow: 0 1px 2px rgba(0,0,0,0.02);
    transition: 0.1s;
}
.btn-rect:hover {
    background: #e3ecf5;
    border-color: #2a7faa;
}

/* 政策 */
.policy-group {
    margin-bottom: 1.2rem;
    background: #fafdff;
    padding: 0.8rem;
    border-radius: 0.8rem;
    border: 1px solid #e9edf2;
}
.policy-title {
    font-weight: 700;
    border-left: 5px solid #2a7faa;
    padding-left: 0.8rem;
    margin-bottom: 0.8rem;
    color: #1e384b;
}
.radio-label {
    display: block;
    margin: 0.5rem 0;
    color: #1f2e40;
    font-weight: 500;
}

.reset-area {
    display: flex;
    flex-wrap: wrap;
    gap: 0.8rem;
    margin-bottom: 1rem;
}

.footer-bar {
    margin-top: 1.5rem;
    display: flex;
    justify-content: space-between;
    font-size: 0.85rem;
    color: #4a5c6e;
    border-top: 1px solid #dee2e6;
    padding-top: 1rem;
}

/* 模态框 */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.3);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    backdrop-filter: blur(2px);
}
.modal-content {
    background: #ffffff;
    border: 1px solid #cbd5e1;
    border-radius: 1.5rem;
    padding: 2rem;
    min-width: 400px;
    max-width: 90%;
    box-shadow: 0 20px 40px rgba(0,0,0,0.15);
    color: #1e1e2a;
}
.modal-close {
    float: right;
    font-size: 1.8rem;
    cursor: pointer;
    color: #5e6f82;
}
.modal-close:hover {
    color: #1e1e2a;
}
.modal-buttons {
    margin-top: 1.5rem;
    display: flex;
    gap: 1rem;
    justify-content: flex-end;
}

#import-text {
    width: 100%;
    background: #f8fafc;
    color: #1a1e2b;
    border: 1px solid #cbd5e1;
    border-radius: 0.7rem;
    padding: 0.8rem;
    font-family: 'SF Mono', 'Menlo', monospace;
    resize: vertical;
}

/* 提示框 */
.tooltip {
    position: fixed;
    background: #ffffff;
    color: #1e293b;
    padding: 0.5rem 0.9rem;
    border-radius: 0.6rem;
    font-size: 0.8rem;
    z-index: 2000;
    pointer-events: none;
    white-space: pre-line;
    max-width: 320px;
    border: 1px solid #bdd3e8;
    box-shadow: 0 8px 20px rgba(0,0,0,0.12);
    line-height: 1.5;
    font-weight: 450;
}

/* 贸易面板 */
.trade-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
}
.trade-card {
    background: #f9fcff;
    border-radius: 0.8rem;
    padding: 0.8rem;
    border: 1px solid #d2dfea;
    color: #1e2a3a;
}
.trade-name {
    margin-bottom: 0.6rem;
    text-align: center;
    font-weight: 600;
}
.trade-buttons {
    display: flex;
    gap: 0.6rem;
    justify-content: center;
}
.trade-buy-btn, .trade-sell-btn {
    background: #ffffff;
    border: 1px solid #b8cadc;
    border-radius: 0.5rem;
    padding: 0.4rem 0.6rem;
    cursor: pointer;
    color: #1f2e42;
    font-size: 0.85rem;
    font-weight: 500;
    flex: 1;
    box-shadow: 0 1px 2px rgba(0,0,0,0.02);
    transition: 0.1s;
}
.trade-buy-btn:hover {
    background: #d9ebf7;
    border-color: #2a7faa;
}
.trade-sell-btn:hover {
    background: #fce4e4;
    border-color: #b85c5c;
}

/* 保持红色提示 (买不起) 依旧醒目 */
.btn-square.buy-btn[style*="color: red"],
.buy-btn[style*="color: red"] {
    color: #c52828 !important;
    border-color: #e0a1a1;
}

/* 其他细节 */
h3 {
    color: #1e384b;
    margin-top: 0.5rem;
}

p {
    color: #2d3f53;
}

/* 美化滚动条 (可选) */
.panel::-webkit-scrollbar {
    width: 8px;
}
.panel::-webkit-scrollbar-track {
    background: #f1f5f9;
    border-radius: 10px;
}
.panel::-webkit-scrollbar-thumb {
    background: #b9c7d4;
    border-radius: 10px;
}
#happiness-display {
    background: #f8fafc;
    border-radius: 2rem;
    padding: 0.5rem 0.5rem;
    display: inline-block;
    margin: 0.5 auto;
    border: 1px solid #dee2e6;
    box-shadow: 0 2px 4px rgba(0,0,0,0.02);
}
/* 右侧日志面板 */
.log-panel {
    flex: 0 0 280px;
    background: #f8fafc;
    border-radius: 1rem;
    border: 1px solid #dee2e6;
    display: flex;
    flex-direction: column;
    margin-left: 1rem;
    overflow: hidden;
}
.log-header {
    padding: 0.8rem;
    background: #ffffff;
    border-bottom: 1px solid #e2e8f0;
    font-weight: bold;
    color: #1e384b;
}
.event-log-list {
    flex: 1;
    overflow-y: auto;
    padding: 0.5rem;
    display: flex;
    flex-direction: column; 
}
.log-entry {
    background: #ffffff;
    border-left: 3px solid #2a7faa;
    margin-bottom: 0.5rem;
    padding: 0.4rem 0.6rem;
    border-radius: 0.5rem;
    font-size: 0.8rem;
    box-shadow: 0 1px 2px rgba(0,0,0,0.02);
    color: #2d3f53;
}
.log-date {
    font-weight: bold;
    color: #2a7faa;
    margin-right: 0.5rem;
}
/* 晶体面板样式 */
.crystal-slots {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 1.5rem;
}
.crystal-slot {
    flex: 1;
    min-width: 200px;
}
.crystal-card {
    background: #f9fcff;
    border: 1px solid #cbd5e1;
    border-radius: 0.8rem;
    padding: 0.8rem;
    text-align: center;
}
.crystal-card.empty {
    background: #f1f5f9;
    color: #6c7a8a;
    font-style: italic;
}
.crystal-name {
    font-weight: bold;
    font-size: 1.1rem;
    margin-bottom: 0.5rem;
}
.crystal-effects {
    font-size: 0.8rem;
    margin: 0.5rem 0;
    color: #2d3f53;
}
.crystal-buttons {
    display: flex;
    gap: 0.5rem;
    justify-content: center;
    margin-top: 0.5rem;
}
/* 资源卡片进度条样式 */
.resource-item {
    position: relative;
    overflow: hidden;
}

.resource-progress {
    position: absolute;
    left: 0;
    top: 0;
    width: 0%;
    height: 100%;
    background: #b8d9ff; 
    border-radius: inherit;
    z-index: 1;
    transition: width 0.1s ease;
}

.resource-text {
    position: relative;
    z-index: 2;
    text-align: center;
    width: 100%;
    display: block;
}
/* 在 style.css 末尾或合适位置添加 */
.building-card {
    position: relative; /* 确保齿轮绝对定位相对于卡片 */
}

.mode-gear-btn {
    position: absolute;
    top: 4px;
    left: 4px;
    background: transparent;
    border: none;
    font-size: 1rem;
    cursor: pointer;
    opacity: 0.6;
    padding: 0;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: opacity 0.2s, background 0.2s;
    z-index: 5;
}
.mode-gear-btn:hover {
    opacity: 1;
    background: rgba(0,0,0,0.05);
}

.mode-indicator {
    font-size: 0.75rem;
    color: #2a7faa;
    margin-left: 4px;
}
/* 买不起时建筑名称变红 */
.unaffordable-name {
    color: #c52828 !important;
}

/* 建筑卡片交互 */
.building-card {
    cursor: pointer;
    transition: background 0.1s, border-color 0.1s;
}
.building-card:active {
    background: #eef3f8;
}

/* 在原有样式基础上添加/修改 */

/* 买不起但上限够：灰色 */
.insufficient-name {
    color: #6c757d !important; /* 灰色 */
}

/* 上限不够：红色 */
.unaffordable-name {
    color: #c52828 !important;
}

/* 齿轮按钮位置调整（更靠左上角） */
.mode-gear-btn {
    position: absolute;
    top: 0px;        /* 原来可能是4px，现在调为0或2px */
    left: 0px;
    background: transparent;
    border: none;
    font-size: 1rem;
    cursor: pointer;
    opacity: 0.6;
    padding: 0;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: opacity 0.2s, background 0.2s;
    z-index: 5;
}

/* 模式指示文字样式 */
.mode-indicator {
    font-size: 0.75rem;
    color: #2a7faa;
    margin-left: 4px;
}
.population-info {
    background: #f8fafc;
    border-radius: 1rem;
    padding: 0.2rem;
    text-align: center;
    font-weight: bold;
    margin-bottom: 0.2rem;
    border: 1px solid #dee2e6;
}