/* 小小都市 - 城市建造模拟 */
* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { width: 100%; height: 100%; overflow: hidden; }
body {
  font-family: "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  background: #0b0e13;
  color: #dfe6ee;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}
#game { position: fixed; inset: 0; display: block; touch-action: none; }
.hidden { display: none !important; }
.hidden-ui { display: none; }
body.playing .hidden-ui { display: flex; }

/* ---------- 顶部数据栏 ---------- */
#topbar {
  position: fixed; top: 0; left: 0; right: 0;
  align-items: center; gap: 6px; flex-wrap: wrap;
  padding: 6px 8px;
  background: rgba(13, 18, 26, 0.88);
  border-bottom: 1px solid #232c3a;
  z-index: 20;
  backdrop-filter: blur(4px);
}
.chip {
  font-size: 12px; line-height: 1;
  padding: 6px 9px;
  background: #1a2230;
  border: 1px solid #2a3648;
  border-radius: 20px;
  white-space: nowrap;
}
.chip.gold { color: #ffd964; }
.chip.bad { color: #ff7a7a; border-color: #6e2f2f; }
.chip.good { color: #7fe08a; }
.spacer { flex: 1; }
.btngroup { display: inline-flex; }
.tbtn {
  min-width: 34px; height: 30px;
  padding: 0 8px;
  background: #1a2230; color: #dfe6ee;
  border: 1px solid #2a3648;
  border-radius: 6px;
  font-size: 13px; font-weight: 600;
  cursor: pointer;
  margin-left: 4px;
}
.btngroup .tbtn { margin-left: 0; border-radius: 0; }
.btngroup .tbtn:first-child { border-radius: 6px 0 0 6px; }
.btngroup .tbtn:last-child { border-radius: 0 6px 6px 0; }
.tbtn:hover { background: #253047; }
.tbtn.sel { background: #3560a8; border-color: #4a7bd0; color: #fff; }

/* ---------- 建造工具栏 ---------- */
#toolbar {
  position: fixed; left: 8px; top: 52px; bottom: 8px;
  flex-direction: column; gap: 6px;
  overflow-y: auto;
  z-index: 15;
  padding-right: 2px;
  scrollbar-width: thin;
}
.toolbtn {
  width: 76px;
  display: flex; flex-direction: column; align-items: center;
  gap: 3px;
  padding: 7px 4px 6px;
  background: rgba(20, 27, 38, 0.92);
  border: 1px solid #2a3648;
  border-radius: 10px;
  color: #dfe6ee;
  cursor: pointer;
  font-family: inherit;
}
.toolbtn:hover { background: #253047; }
.toolbtn.sel { border-color: #ffd964; box-shadow: 0 0 0 1px #ffd964 inset; }
.toolbtn.cant .cost { color: #ff7a7a; }
.toolbtn .tchip {
  width: 30px; height: 30px;
  border-radius: 7px;
  display: flex; align-items: center; justify-content: center;
  font-size: 15px; font-weight: 700; color: #10151d;
}
.toolbtn .tname { font-size: 12px; }
.toolbtn .cost { font-size: 11px; color: #ffd964; }
#tool-desc {
  position: fixed; left: 94px; bottom: 10px;
  max-width: 300px;
  font-size: 12px; line-height: 1.5;
  padding: 8px 10px;
  background: rgba(13, 18, 26, 0.85);
  border: 1px solid #2a3648;
  border-radius: 8px;
  z-index: 14;
  pointer-events: none;
}

/* ---------- 侧面板 ---------- */
#panel-toggle {
  position: fixed; right: 8px; top: 52px;
  z-index: 16;
  padding: 7px 12px;
  background: rgba(20, 27, 38, 0.92);
  color: #dfe6ee;
  border: 1px solid #2a3648;
  border-radius: 8px;
  font-size: 13px;
  cursor: pointer;
}
#panel {
  position: fixed; right: 8px; top: 92px; bottom: 8px;
  width: 272px;
  flex-direction: column;
  background: rgba(15, 21, 30, 0.94);
  border: 1px solid #2a3648;
  border-radius: 12px;
  z-index: 15;
  overflow: hidden;
}
#tab-btns { display: flex; border-bottom: 1px solid #232c3a; }
.tabbtn {
  flex: 1; padding: 10px 0;
  background: none; border: none;
  color: #8fa0b5; font-size: 13px; font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}
.tabbtn.sel { color: #ffd964; border-bottom: 2px solid #ffd964; }
#panel-body { flex: 1; overflow-y: auto; padding: 10px 12px; font-size: 13px; }
.stat-row {
  display: flex; justify-content: space-between;
  padding: 6px 2px;
  border-bottom: 1px dashed #232c3a;
}
.stat-row .k { color: #8fa0b5; }
.stat-row .v { font-weight: 600; }
.stat-row .v.bad { color: #ff7a7a; }
.stat-row .v.good { color: #7fe08a; }
.panel-h { font-size: 12px; color: #6b7c93; margin: 10px 0 4px; }
.panel-note { font-size: 12px; color: #6b7c93; line-height: 1.6; margin-top: 8px; }
input[type=range] { width: 100%; accent-color: #ffd964; }
select {
  width: 100%; padding: 6px;
  background: #1a2230; color: #dfe6ee;
  border: 1px solid #2a3648; border-radius: 6px;
  font-family: inherit;
}
.mission {
  padding: 8px; margin-bottom: 8px;
  background: #182130;
  border: 1px solid #2a3648;
  border-radius: 8px;
}
.mission.done { opacity: 0.55; border-color: #2f6e3f; }
.mission .mname { font-weight: 700; font-size: 13px; }
.mission .mdesc { font-size: 12px; color: #8fa0b5; margin: 2px 0 6px; }
.mission .mreward { font-size: 11px; color: #ffd964; }
.mbar { height: 6px; background: #0d1320; border-radius: 3px; overflow: hidden; margin-top: 4px; }
.mbar > i { display: block; height: 100%; background: #4a9eff; }
.mission.done .mbar > i { background: #4caf50; }
.bigbtn.small { padding: 8px 10px; font-size: 13px; margin-top: 8px; }

/* ---------- 提示消息 ---------- */
#toasts {
  position: fixed; bottom: 14px; left: 50%;
  transform: translateX(-50%);
  display: flex; flex-direction: column; align-items: center;
  gap: 6px; z-index: 40; pointer-events: none;
}
.toast {
  padding: 8px 14px;
  background: rgba(20, 27, 38, 0.95);
  border: 1px solid #2a3648;
  border-radius: 20px;
  font-size: 13px;
  animation: toast-in 0.25s ease-out;
  max-width: 82vw;
  text-align: center;
}
.toast.good { border-color: #2f6e3f; color: #9fe6a8; }
.toast.bad { border-color: #6e2f2f; color: #ff9d9d; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; } }

/* ---------- 开始 / 结算界面 ---------- */
#start-overlay, #end-overlay {
  position: fixed; inset: 0; z-index: 50;
  display: flex; align-items: center; justify-content: center;
  background: radial-gradient(ellipse at 50% 30%, #16233a 0%, #0b0e13 75%);
  padding: 16px;
}
.start-box {
  width: 100%; max-width: 460px;
  max-height: 92vh; overflow-y: auto;
  background: rgba(17, 24, 35, 0.96);
  border: 1px solid #2a3648;
  border-radius: 16px;
  padding: 28px 26px;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}
.start-box h1 {
  font-size: 40px; letter-spacing: 6px;
  color: #ffd964;
  text-shadow: 0 3px 0 #7a5b12, 0 6px 18px rgba(0, 0, 0, 0.6);
}
.subtitle { color: #8fa0b5; font-size: 13px; margin: 10px 0 20px; }
.start-btns { display: flex; flex-direction: column; gap: 10px; }
.bigbtn {
  padding: 13px;
  font-size: 16px; font-weight: 700;
  color: #10151d;
  background: linear-gradient(180deg, #ffe27a, #f5b93c);
  border: none; border-radius: 10px;
  cursor: pointer;
  font-family: inherit;
}
.bigbtn:hover { filter: brightness(1.08); }
.bigbtn:disabled { filter: grayscale(0.9) brightness(0.6); cursor: not-allowed; }
.bigbtn.ghost { background: #1a2230; color: #dfe6ee; border: 1px solid #2a3648; }
#help-box {
  margin-top: 16px; text-align: left;
  font-size: 12.5px; line-height: 1.7; color: #b8c4d4;
  background: #121a28;
  border: 1px solid #2a3648;
  border-radius: 10px;
  padding: 12px 14px;
}
#help-box p { margin-bottom: 8px; }
.foot { margin-top: 18px; font-size: 11px; color: #55637a; }
#end-stats {
  margin: 4px 0 18px;
  font-size: 14px; line-height: 2;
  color: #b8c4d4;
}
#end-stats b { color: #ffd964; }

/* ---------- 手机端 ---------- */
@media (max-width: 760px) {
  #topbar { gap: 4px; padding: 4px 6px; }
  .chip { font-size: 11px; padding: 5px 7px; }
  .tbtn { min-width: 32px; height: 32px; }
  #toolbar {
    left: 0; right: 0; top: auto; bottom: 0;
    flex-direction: row;
    padding: 6px;
    background: rgba(13, 18, 26, 0.9);
    border-top: 1px solid #232c3a;
  }
  .toolbtn { width: 64px; flex-shrink: 0; }
  .toolbtn .tchip { width: 28px; height: 28px; font-size: 14px; }
  #tool-desc { display: none !important; }
  #panel-toggle { top: auto; bottom: 96px; right: 8px; }
  #panel {
    top: auto; left: 0; right: 0; bottom: 0;
    width: 100%; max-height: 55vh;
    border-radius: 14px 14px 0 0;
  }
  .start-box h1 { font-size: 32px; }
}
