/* styles.css — 移动优先 UI */
* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  width: 100%; height: 100%; overflow: hidden;
  font-family: -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
  background: #cfeaff;
  touch-action: none; overscroll-behavior: none;
  user-select: none; -webkit-user-select: none;
}
#game { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }

/* ---------- 顶部 HUD ---------- */
#hud {
  position: fixed; top: 0; left: 0; right: 0;
  padding: calc(6px + env(safe-area-inset-top)) 10px 6px;
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  pointer-events: none; z-index: 10;
}
.hud-chip {
  background: rgba(255,255,255,0.92); border-radius: 14px;
  padding: 5px 12px; font-size: 13px; font-weight: 600; color: #2c3e50;
  box-shadow: 0 2px 8px rgba(50,80,120,0.15);
  pointer-events: auto; display: flex; align-items: center; gap: 5px;
  white-space: nowrap;
}
.hud-chip.warn { color: #e74c3c; animation: pulse 1.2s infinite; }
@keyframes pulse { 50% { opacity: 0.55; } }
.hud-chip .ico { font-size: 14px; }
#chip-date { font-weight: 500; color: #7f8c8d; font-size: 12px; }
#speed-btn { cursor: pointer; }

/* RCI 需求条 */
#rci { display: flex; gap: 3px; align-items: flex-end; height: 26px; padding: 4px 10px; }
.rci-bar { width: 9px; border-radius: 3px; min-height: 3px; transition: height .4s; }
.rci-R { background: #ff9950; } .rci-C { background: #3f8fe8; } .rci-I { background: #b478c2; }

/* ---------- 底部工具栏 ---------- */
#toolbar {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(10px + env(safe-area-inset-bottom));
  display: flex; gap: 6px; z-index: 20;
  background: rgba(255,255,255,0.95); border-radius: 20px; padding: 7px;
  box-shadow: 0 4px 20px rgba(50,80,120,0.25);
}
.tb-btn {
  min-width: 56px; height: 56px; border: none; border-radius: 15px;
  background: transparent; font-size: 11px; color: #57687a; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
}
.tb-btn .ico { font-size: 22px; line-height: 1; }
.tb-btn.active { background: #2bb6c9; color: #fff; }
.tb-btn:active { transform: scale(0.93); }

/* ---------- 上滑面板 ---------- */
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  background: #fff; border-radius: 22px 22px 0 0;
  box-shadow: 0 -6px 30px rgba(50,80,120,0.3);
  padding: 10px 14px calc(16px + env(safe-area-inset-bottom));
  transform: translateY(105%); transition: transform .28s cubic-bezier(.2,.9,.3,1);
  max-height: 62vh; overflow-y: auto; touch-action: pan-y;
}
.sheet.open { transform: translateY(0); }
.sheet-handle { width: 40px; height: 4px; background: #dfe6ec; border-radius: 2px; margin: 2px auto 10px; }
.sheet h3 { font-size: 15px; color: #2c3e50; margin-bottom: 8px; }
.sheet .close-x {
  position: absolute; top: 10px; right: 14px; width: 30px; height: 30px;
  border: none; border-radius: 50%; background: #f0f3f6; color: #7f8c8d;
  font-size: 15px; cursor: pointer;
}

/* 建造网格 */
.cat-tabs { display: flex; gap: 6px; margin-bottom: 10px; flex-wrap: wrap; }
.cat-tab {
  border: none; background: #f0f3f6; color: #57687a; border-radius: 12px;
  padding: 7px 14px; font-size: 13px; font-weight: 600; cursor: pointer;
}
.cat-tab.active { background: #2bb6c9; color: #fff; }
.build-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; }
.build-item {
  border: 2px solid #eef2f5; border-radius: 14px; padding: 10px 6px;
  text-align: center; cursor: pointer; background: #fbfdfe;
}
.build-item.selected { border-color: #2bb6c9; background: #e8f9fb; }
.build-item.locked { opacity: 0.45; }
.build-item .b-ico { font-size: 26px; }
.build-item .b-name { font-size: 12px; font-weight: 600; color: #2c3e50; margin-top: 3px; }
.build-item .b-cost { font-size: 11px; color: #e67e22; margin-top: 1px; }
.build-item .b-desc { font-size: 10px; color: #95a5a6; margin-top: 1px; }

/* 查询卡片 */
#inspect-card {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(84px + env(safe-area-inset-bottom)); z-index: 15;
  background: rgba(255,255,255,0.97); border-radius: 16px; padding: 12px 16px;
  box-shadow: 0 4px 20px rgba(50,80,120,0.25);
  min-width: 220px; max-width: 90vw; display: none;
}
#inspect-card.show { display: block; }
#inspect-card h4 { font-size: 14px; color: #2c3e50; margin-bottom: 5px; }
#inspect-card p { font-size: 12px; color: #57687a; line-height: 1.55; }
#inspect-card .tag { display: inline-block; padding: 1px 8px; border-radius: 8px; font-size: 11px; margin-right: 4px; }
.tag.ok { background: #d5f5e3; color: #1e8449; }
.tag.bad { background: #fdedec; color: #c0392b; }

/* 税率滑块 */
.tax-row { display: flex; align-items: center; gap: 10px; margin: 10px 0; }
.tax-row label { width: 56px; font-size: 13px; font-weight: 600; color: #2c3e50; }
.tax-row input[type=range] { flex: 1; }
.tax-row .tax-val { width: 42px; font-size: 13px; color: #e67e22; text-align: right; }
.budget-line { display: flex; justify-content: space-between; font-size: 13px; color: #57687a; padding: 4px 0; }
.budget-line b { color: #2c3e50; }

/* 存档槽 */
.save-slot { display: flex; align-items: center; gap: 8px; padding: 8px 0; border-bottom: 1px solid #f0f3f6; }
.save-slot .s-name { flex: 1; font-size: 13px; color: #2c3e50; }
.save-slot button {
  border: none; border-radius: 10px; padding: 7px 12px; font-size: 12px;
  cursor: pointer; background: #eef2f5; color: #57687a;
}
.save-slot button.primary { background: #2bb6c9; color: #fff; }

/* Toast */
#toast {
  position: fixed; top: calc(58px + env(safe-area-inset-top)); left: 50%;
  transform: translateX(-50%) translateY(-16px); z-index: 50;
  background: rgba(44,62,80,0.94); color: #fff; border-radius: 12px;
  padding: 9px 18px; font-size: 13px; opacity: 0; transition: all .3s;
  pointer-events: none; max-width: 86vw; text-align: center;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* 游戏结束 */
#gameover {
  position: fixed; inset: 0; z-index: 100; display: none;
  align-items: center; justify-content: center; background: rgba(30,40,60,0.75);
}
#gameover.show { display: flex; }
.go-card { background: #fff; border-radius: 22px; padding: 28px 32px; text-align: center; max-width: 320px; }
.go-card h2 { color: #c0392b; font-size: 20px; margin-bottom: 8px; }
.go-card p { color: #57687a; font-size: 13px; line-height: 1.6; margin-bottom: 16px; }
.go-card button {
  border: none; background: #2bb6c9; color: #fff; border-radius: 14px;
  padding: 12px 28px; font-size: 15px; font-weight: 600; cursor: pointer;
}

/* 数据视图指示 */
#overlay-badge {
  position: fixed; top: calc(52px + env(safe-area-inset-top)); right: 10px; z-index: 12;
  background: rgba(44,62,80,0.85); color: #fff; font-size: 12px;
  border-radius: 10px; padding: 5px 12px; display: none;
}
#overlay-badge.show { display: block; }

@media (min-width: 768px) {
  .tb-btn { min-width: 64px; }
  .sheet { left: 50%; right: auto; transform: translateX(-50%) translateY(105%); width: 520px; border-radius: 22px; bottom: 12px; }
  .sheet.open { transform: translateX(-50%) translateY(0); }
}
