/* 冰火纪元 - 全局样式 */
* { margin: 0; padding: 0; box-sizing: border-box; }
body {
  background: #0a0a1a; color: #e0e0e0; font-family: 'Courier New', monospace;
  overflow: hidden; width: 100vw; height: 100vh;
}
#game-container { width: 100vw; height: 100vh; position: relative; }
#game-container canvas { display: block; width: 100% !important; height: 100% !important; }

/* ========== HUD顶部(资源+天气合并) ========== */
#hud-top {
  position: fixed; top: 0; left: 0; right: 0; z-index: 100;
  display: flex; flex-direction: column; align-items: center;
  padding: 4px 8px;
  background: rgba(10,10,30,0.88); border-bottom: 1px solid rgba(100,160,255,0.3);
  backdrop-filter: blur(4px); pointer-events: none;
  font-size: 13px;
}
#hud-res-row {
  display: flex; justify-content: center; align-items: center;
  gap: 10px; flex-wrap: wrap; width: 100%;
}
#hud-info-row {
  display: flex; justify-content: center; align-items: center;
  gap: 14px; margin-top: 2px; font-size: 12px; color: #8ac;
}
#hud-top span { white-space: nowrap; text-shadow: 0 0 6px rgba(100,180,255,0.5); }
.res { min-width: 55px; text-align: center; pointer-events: auto; }

/* ========== 面板通用 ========== */
.panel {
  position: fixed; z-index: 200; background: rgba(15,15,40,0.95);
  border: 1px solid rgba(100,160,255,0.4); border-radius: 6px;
  min-width: 260px; max-height: 70vh; overflow-y: auto;
  backdrop-filter: blur(6px); box-shadow: 0 4px 20px rgba(0,0,0,0.6);
  touch-action: manipulation; max-width: calc(100vw - 20px);
}
.panel-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 8px 12px; border-bottom: 1px solid rgba(100,160,255,0.2);
  font-size: 15px; font-weight: bold; color: #8cf;
}
.btn-close {
  background: none; border: none; color: #f66; font-size: 18px;
  cursor: pointer; line-height: 1;
}
.btn-close:hover { color: #f99; }
.panel-tabs { display: flex; border-bottom: 1px solid rgba(100,160,255,0.15); }
.tab {
  flex: 1; padding: 6px 8px; background: none; border: none;
  color: #8ac; font-size: 13px; cursor: pointer; font-family: inherit;
}
.tab.active { color: #fff; background: rgba(100,160,255,0.15); }
.tab:hover { background: rgba(100,160,255,0.1); }
.panel-body { padding: 8px; }

/* ========== 建造面板 ========== */
#build-panel { left: 10px; top: 50%; transform: translateY(-50%); width: 240px; }
.build-item {
  display: flex; align-items: center; gap: 8px; padding: 8px;
  border-bottom: 1px solid rgba(255,255,255,0.05); cursor: pointer;
  transition: background 0.15s;
}
.build-item:hover { background: rgba(100,160,255,0.1); }
.build-item .icon { font-size: 22px; }
.build-item .info { flex: 1; }
.build-item .name { font-size: 13px; color: #cdf; }
.build-item .cost { font-size: 11px; color: #8a8; }
.build-item.locked { opacity: 0.4; pointer-events: none; }

/* ========== 建筑信息面板 ========== */
#building-info { right: 10px; top: 50%; transform: translateY(-50%); width: 260px; }
#binfo-body { font-size: 13px; line-height: 1.6; }
.binfo-row { display: flex; justify-content: space-between; padding: 2px 0; }
.binfo-label { color: #8ac; }
.binfo-val { color: #cdf; }
.btn-upgrade {
  display: block; width: 100%; margin-top: 8px; padding: 8px;
  background: rgba(80,180,100,0.3); border: 1px solid rgba(80,180,100,0.5);
  color: #8f8; font-size: 13px; cursor: pointer; border-radius: 4px;
  font-family: inherit;
}
.btn-upgrade:hover { background: rgba(80,180,100,0.5); }
.btn-upgrade:disabled { opacity: 0.4; cursor: not-allowed; }

/* 拆除按钮 */
.btn-demolish {
  display: block; width: 100%; margin-top: 6px; padding: 8px;
  background: rgba(200,60,60,0.3); border: 1px solid rgba(200,60,60,0.5);
  color: #f88; font-size: 13px; cursor: pointer; border-radius: 4px;
  font-family: inherit;
}
.btn-demolish:hover { background: rgba(200,60,60,0.5); }

/* ========== 菜单场景 ========== */
.menu-btn {
  display: block; width: 200px; margin: 10px auto; padding: 12px;
  background: rgba(40,60,120,0.6); border: 2px solid rgba(100,160,255,0.5);
  color: #adf; font-size: 16px; cursor: pointer; border-radius: 4px;
  font-family: inherit; text-align: center; transition: all 0.2s;
}
.menu-btn:hover { background: rgba(60,100,200,0.6); border-color: #8cf; color: #fff; }

/* ========== 加载进度条 ========== */
#boot-overlay {
  position: fixed; inset: 0; z-index: 999; background: #0a0a1a;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
}
#boot-overlay .title { font-size: 28px; color: #8cf; margin-bottom: 20px; letter-spacing: 4px; }
#boot-bar-bg {
  width: 300px; height: 12px; background: rgba(255,255,255,0.1);
  border-radius: 6px; overflow: hidden;
}
#boot-bar {
  width: 0%; height: 100%; background: linear-gradient(90deg, #4af, #8cf);
  transition: width 0.3s;
}
#boot-text { margin-top: 10px; font-size: 12px; color: #68a; }

/* ========== 科技/探索/幸存者面板 ========== */
#tech-panel { right: 10px; top: 50%; transform: translateY(-50%); width: 280px; }
#explore-panel { right: 10px; top: 50%; transform: translateY(-50%); width: 320px; }
#survivor-panel { left: 10px; top: 50%; transform: translateY(-50%); width: 300px; }

.tech-tab {
  flex: 1; padding: 6px 8px; background: none; border: none;
  color: #8ac; font-size: 13px; cursor: pointer; font-family: inherit;
}
.tech-tab.active { color: #fff; background: rgba(100,160,255,0.15); }
.tech-tab:hover { background: rgba(100,160,255,0.1); }
.tech-item {
  padding: 8px; border-bottom: 1px solid rgba(255,255,255,0.05);
  transition: background 0.15s;
}
.tech-item.done { opacity: 0.6; background: rgba(80,180,100,0.1); }
.tech-item.available { background: rgba(100,160,255,0.05); }
.tech-name { font-size: 13px; color: #cdf; }
.tech-effect { font-size: 11px; color: #8cf; margin: 2px 0; }
.tech-cost { font-size: 11px; color: #8a8; }
.btn-research {
  margin-top: 4px; padding: 4px 12px;
  background: rgba(80,180,100,0.3); border: 1px solid rgba(80,180,100,0.5);
  color: #8f8; font-size: 12px; cursor: pointer; border-radius: 3px; font-family: inherit;
}
.btn-research:hover { background: rgba(80,180,100,0.5); }
.btn-research:disabled { opacity: 0.4; cursor: not-allowed; }

/* 探索区域 */
.explore-section-title {
  font-size: 13px; color: #8cf; padding: 6px 0; font-weight: bold;
  border-bottom: 1px solid rgba(100,160,255,0.15);
}
.explore-zone { padding: 8px; border-bottom: 1px solid rgba(255,255,255,0.05); }
.explore-zone.locked { opacity: 0.4; }
.zone-name { font-size: 13px; color: #cdf; }
.zone-desc { font-size: 11px; color: #999; margin: 2px 0; }
.zone-info { font-size: 11px; color: #8a8; }
.explore-mission {
  padding: 6px 8px; font-size: 12px; color: #fa4;
  border-bottom: 1px solid rgba(255,255,255,0.03);
}
.btn-dispatch {
  margin-top: 4px; padding: 4px 12px;
  background: rgba(100,160,255,0.3); border: 1px solid rgba(100,160,255,0.5);
  color: #8cf; font-size: 12px; cursor: pointer; border-radius: 3px; font-family: inherit;
}
.btn-dispatch:hover { background: rgba(100,160,255,0.5); }
.dispatch-row {
  display: flex; align-items: center; gap: 8px; padding: 4px 8px;
  font-size: 12px; color: #ccc;
}
.dispatch-row input[type="checkbox"] { accent-color: #4af; }

/* ========== 幸存者卡片 ========== */
.survivor-card {
  padding: 8px; margin-bottom: 6px; border-radius: 4px;
  background: rgba(255,255,255,0.03); border: 1px solid rgba(255,255,255,0.06);
}
.survivor-card.sick { border-color: rgba(255,180,0,0.4); }
.survivor-card.frost { border-color: rgba(100,180,255,0.4); }
.sv-header { display: flex; justify-content: space-between; margin-bottom: 4px; }
.sv-name { font-size: 13px; color: #cdf; font-weight: bold; }
.sv-trait { font-size: 11px; color: #f8a; }
.sv-bar-row { display: flex; align-items: center; gap: 4px; margin: 2px 0; }
.sv-bar-label { font-size: 10px; color: #888; width: 28px; }
.sv-bar-bg {
  flex: 1; height: 6px; background: rgba(255,255,255,0.1); border-radius: 3px; overflow: hidden;
}
.sv-bar-fill { height: 100%; border-radius: 3px; transition: width 0.3s; }
.sv-tags { display: flex; gap: 4px; margin-top: 4px; }
.sv-tag {
  font-size: 10px; padding: 1px 6px; border-radius: 3px;
  background: rgba(100,100,100,0.3); color: #aaa;
}
.sv-tag.sick { background: rgba(255,180,0,0.3); color: #fa4; }
.sv-tag.frost { background: rgba(100,180,255,0.3); color: #8cf; }
.sv-tag.job { background: rgba(80,180,100,0.3); color: #8f8; }
.sv-actions { display: flex; gap: 4px; margin-top: 4px; }
.sv-btn {
  padding: 2px 8px; font-size: 11px;
  background: rgba(100,160,255,0.2); border: 1px solid rgba(100,160,255,0.3);
  color: #8cf; cursor: pointer; border-radius: 3px; font-family: inherit;
}
.sv-btn:hover { background: rgba(100,160,255,0.4); }

/* ========== 事件弹窗 ========== */
.event-overlay {
  position: fixed; inset: 0; z-index: 500;
  background: rgba(0,0,0,0.7); display: flex; align-items: center; justify-content: center;
}
.event-box {
  background: rgba(15,15,40,0.98); border: 2px solid rgba(100,160,255,0.5);
  border-radius: 8px; padding: 20px; max-width: 360px; width: 90%;
  box-shadow: 0 8px 40px rgba(0,0,0,0.8);
}
.event-title { font-size: 18px; color: #8cf; margin-bottom: 10px; text-align: center; }
.event-desc {
  font-size: 13px; color: #ccc; line-height: 1.6; margin-bottom: 16px;
  white-space: pre-line;
}
.event-choices { display: flex; flex-direction: column; gap: 8px; }
.event-btn {
  padding: 10px; background: rgba(40,60,120,0.6); border: 1px solid rgba(100,160,255,0.4);
  color: #adf; font-size: 14px; cursor: pointer; border-radius: 4px; font-family: inherit;
}
.event-btn:hover { background: rgba(60,100,200,0.6); color: #fff; }

/* ========== 功能按钮栏 ========== */
.action-bar {
  position: fixed; right: 10px; bottom: 20px; z-index: 150;
  display: flex; flex-direction: column; gap: 8px;
}
.action-btn {
  width: 48px; height: 48px; border-radius: 50%;
  background: rgba(15,15,40,0.9); border: 1px solid rgba(100,160,255,0.4);
  font-size: 18px; cursor: pointer; display: flex; align-items: center; justify-content: center;
  transition: all 0.2s; touch-action: manipulation;
}
.action-btn:hover { background: rgba(40,60,120,0.8); border-color: #8cf; }

/* ========== 动画 ========== */
@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* ========== 新手引导 ========== */
#tutorial-overlay {
  position: fixed; inset: 0; z-index: 300;
  background: rgba(0,0,0,0.6); display: flex;
  align-items: center; justify-content: center;
}
.tutorial-box {
  background: rgba(15,15,40,0.98); border: 2px solid rgba(100,200,255,0.6);
  border-radius: 10px; padding: 24px; max-width: 340px; width: 90%;
  text-align: center; box-shadow: 0 8px 40px rgba(0,0,0,0.8);
}
.tutorial-step { font-size: 14px; color: #ccc; line-height: 1.8; margin-bottom: 16px; }
.tutorial-btn {
  padding: 10px 24px; background: rgba(60,120,200,0.6);
  border: 1px solid rgba(100,160,255,0.5); color: #fff;
  font-size: 15px; cursor: pointer; border-radius: 6px; font-family: inherit;
}
.tutorial-btn:hover { background: rgba(80,140,220,0.8); }

/* 火炉熄灭警告 */
#furnace-warning {
  position: fixed; top: 56px; left: 50%; transform: translateX(-50%);
  z-index: 250; background: rgba(200,40,40,0.9); color: #fff;
  padding: 6px 16px; border-radius: 4px; font-size: 14px;
  animation: blink 0.8s infinite;
}

/* ========== 手机端适配 ========== */
@media (max-width: 480px) {
  #hud-top { padding: 3px 4px; }
  #hud-res-row { gap: 4px; }
  #hud-info-row { gap: 8px; font-size: 11px; }
  .res { min-width: 44px; font-size: 10px; }
  #build-panel {
    left: 0; right: 0; bottom: 0; top: auto;
    transform: none; width: 100%; max-height: 50vh;
    border-radius: 8px 8px 0 0;
  }
  #survivor-panel, #tech-panel, #explore-panel, #building-info {
    left: 5px; right: 5px; top: auto; bottom: 40px;
    transform: none; width: auto; max-height: 50vh;
  }
}

/* ========== #1 工人分配UI ========== */
.binfo-workers { border-top: 1px solid rgba(100,160,255,0.2); margin-top: 8px; padding-top: 4px; }
.worker-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 4px 8px; margin: 2px 0; background: rgba(40,60,100,0.3); border-radius: 4px;
  font-size: 12px;
}
.btn-worker-remove {
  background: rgba(200,80,80,0.6); color: #fff; border: none; border-radius: 4px;
  padding: 2px 8px; font-size: 11px; cursor: pointer;
}
.btn-worker-remove:hover { background: rgba(200,80,80,0.9); }
.btn-assign {
  display: block; width: 100%; margin-top: 6px; padding: 6px;
  background: rgba(60,120,200,0.5); color: #cdf; border: 1px solid rgba(100,160,255,0.4);
  border-radius: 6px; font-size: 12px; cursor: pointer; text-align: center;
}
.btn-assign:hover { background: rgba(60,120,200,0.8); }
.worker-pick-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 8px; margin: 3px 0; background: rgba(40,60,100,0.3); border-radius: 6px;
  cursor: pointer; font-size: 13px;
}
.worker-pick-row:hover { background: rgba(60,100,180,0.5); }

/* 动画 */
@keyframes fadeIn {
  from { opacity: 0; transform: translate(-50%, -50%) scale(0.9); }
  to { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}
