* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    color: #fff;
    min-height: 100vh;
    overflow: hidden;
}

#game-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    padding: 10px;
}

/* 顶部资源条 */
#resource-bar {
    display: flex;
    justify-content: space-around;
    background: rgba(0, 0, 0, 0.5);
    border-radius: 10px;
    padding: 10px;
    margin-bottom: 10px;
    flex-wrap: wrap;
    gap: 10px;
}

.resource-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    background: rgba(255, 255, 255, 0.1);
    padding: 8px 15px;
    border-radius: 8px;
    min-width: 80px;
    transition: transform 0.2s, background 0.2s;
}

.resource-item:hover {
    transform: scale(1.05);
    background: rgba(255, 255, 255, 0.2);
}

.resource-icon {
    font-size: 24px;
    margin-bottom: 5px;
}

.resource-name {
    font-size: 12px;
    color: #aaa;
    margin-bottom: 3px;
}

.resource-value {
    font-size: 16px;
    font-weight: bold;
    color: #4ecdc4;
}

/* 游戏控制面板 */
#control-panel {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 15px;
    background: rgba(0, 0, 0, 0.5);
    border-radius: 10px;
    padding: 10px;
    margin-bottom: 10px;
}

#control-panel button {
    background: linear-gradient(135deg, #4ecdc4 0%, #44a08d 100%);
    border: none;
    padding: 8px 15px;
    border-radius: 5px;
    color: white;
    font-weight: bold;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

#control-panel button:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
}

#control-panel button:active {
    transform: translateY(0);
}

#speed-display, #time-display {
    font-size: 14px;
    color: #aaa;
}

/* 建筑选择面板 */
#building-panel {
    position: absolute;
    left: 10px;
    top: 150px;
    width: 150px;
    max-height: calc(100vh - 180px);
    overflow-y: auto;
    background: rgba(0, 0, 0, 0.7);
    border-radius: 10px;
    padding: 10px;
    z-index: 100;
}

#building-panel h3 {
    text-align: center;
    margin-bottom: 10px;
    color: #4ecdc4;
    font-size: 16px;
    position: sticky;
    top: 0;
    background: rgba(0, 0, 0, 0.9);
    padding: 5px 0;
    border-radius: 5px;
}

#building-panel::-webkit-scrollbar {
    width: 6px;
}

#building-panel::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.3);
    border-radius: 3px;
}

#building-panel::-webkit-scrollbar-thumb {
    background: #4ecdc4;
    border-radius: 3px;
}

.building-option {
    display: flex;
    flex-direction: column;
    align-items: center;
    background: rgba(255, 255, 255, 0.1);
    padding: 6px;
    border-radius: 8px;
    margin-bottom: 6px;
    cursor: pointer;
    transition: transform 0.2s, background 0.2s;
    border: 2px solid transparent;
}

.building-option:hover {
    transform: scale(1.05);
    background: rgba(255, 255, 255, 0.2);
}

.building-option.selected {
    border-color: #4ecdc4;
    background: rgba(78, 205, 196, 0.3);
}

.building-icon {
    font-size: 24px;
    margin-bottom: 2px;
}

.building-name {
    font-size: 14px;
    font-weight: bold;
    margin-bottom: 3px;
}

.building-cost {
    font-size: 10px;
    color: #aaa;
}

/* 中央建筑区域 */
#building-area {
    flex: 1;
    position: relative;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 10px;
    overflow: hidden;
}

#game-canvas {
    width: 100%;
    height: 100%;
    display: block;
}

/* 信息面板 */
#info-panel {
    position: absolute;
    right: 10px;
    top: 150px;
    width: 200px;
    background: rgba(0, 0, 0, 0.7);
    border-radius: 10px;
    padding: 10px;
    z-index: 100;
}

#info-panel h3 {
    text-align: center;
    margin-bottom: 10px;
    color: #4ecdc4;
    font-size: 16px;
}

#info-content {
    font-size: 12px;
    line-height: 1.5;
    color: #ccc;
}

#info-content p {
    margin-bottom: 8px;
}

#info-content .desc {
    color: #aaa;
    font-size: 11px;
    line-height: 1.4;
    padding: 5px;
    background: rgba(255,255,255,0.05);
    border-radius: 4px;
    border-left: 3px solid #4ecdc4;
}

/* 建筑操作按钮 */
#building-actions {
    display: flex;
    gap: 8px;
    justify-content: center;
}

.action-btn {
    flex: 1;
    background: linear-gradient(135deg, #4ecdc4 0%, #44a08d 100%);
    border: none;
    padding: 8px 6px;
    border-radius: 5px;
    color: white;
    font-weight: bold;
    font-size: 12px;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

.action-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
}

.action-btn.demolish {
    background: linear-gradient(135deg, #e74c3c 0%, #c0392b 100%);
}

/* 资源接近上限警告 */
.resource-item.near-limit {
    border: 2px solid #e74c3c;
    animation: pulse 0.8s infinite;
}

/* 建筑信息提示 */
.building-tooltip {
    position: absolute;
    background: rgba(0, 0, 0, 0.9);
    border: 1px solid #4ecdc4;
    border-radius: 8px;
    padding: 10px;
    font-size: 12px;
    z-index: 200;
    pointer-events: none;
    max-width: 200px;
}

.building-tooltip h4 {
    color: #4ecdc4;
    margin-bottom: 5px;
}

.building-tooltip p {
    margin-bottom: 3px;
    color: #ccc;
}

/* 资源流向箭头动画 */
.resource-flow {
    position: absolute;
    pointer-events: none;
    z-index: 50;
}

/* 动画效果 */
@keyframes fadeInOut {
    0% { opacity: 0; transform: translateX(-50%) translateY(-20px); }
    20% { opacity: 1; transform: translateX(-50%) translateY(0); }
    80% { opacity: 1; transform: translateX(-50%) translateY(0); }
    100% { opacity: 0; transform: translateX(-50%) translateY(-20px); }
}

@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

@keyframes glow {
    0% { box-shadow: 0 0 5px rgba(78, 205, 196, 0.5); }
    50% { box-shadow: 0 0 20px rgba(78, 205, 196, 0.8); }
    100% { box-shadow: 0 0 5px rgba(78, 205, 196, 0.5); }
}

.resource-item {
    animation: pulse 2s infinite;
}

.building-option.selected {
    animation: glow 1.5s infinite;
}

/* 资源变化动画 */
.resource-value.increasing {
    color: #2ecc71;
    animation: pulse 0.5s;
}

.resource-value.decreasing {
    color: #e74c3c;
    animation: pulse 0.5s;
}

/* 建筑工作状态指示 */
.building-active {
    position: relative;
}

.building-active::after {
    content: '';
    position: absolute;
    top: -5px;
    right: -5px;
    width: 10px;
    height: 10px;
    background: #2ecc71;
    border-radius: 50%;
    animation: pulse 1s infinite;
}

/* 响应式设计 */
@media (max-width: 768px) {
    #building-panel {
        width: 120px;
        top: 200px;
    }
    
    #info-panel {
        width: 150px;
        top: 200px;
    }
    
    .resource-item {
        min-width: 60px;
        padding: 5px 10px;
    }
    
    .resource-icon {
        font-size: 18px;
    }
    
    .resource-name {
        font-size: 10px;
    }
    
    .resource-value {
        font-size: 14px;
    }
}
