* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0; width: 100%; height: 100%; overflow: hidden;
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: #dff1ff;
}
#scene { display: block; width: 100vw; height: 100vh; touch-action: none; cursor: grab; }
#scene:active { cursor: grabbing; }

#hud {
  position: fixed; top: 16px; left: 16px; z-index: 10;
  display: flex; flex-direction: column; gap: 4px;
  background: rgba(255,255,255,0.88); backdrop-filter: blur(8px);
  padding: 8px 14px; border-radius: 16px;
  box-shadow: 0 6px 18px rgba(40,60,90,0.18);
  font-weight: 700; font-size: 14px; color: #33475b;
}
.hud-row { display: flex; gap: 10px; align-items: center; }
#coins { color: #a8710f; }
#income { color: #2e8b4f; font-size: 12.5px; font-weight: 600; }
#houses { color: #33475b; }
#population { color: #3d7ab8; font-size: 12.5px; font-weight: 600; }

#toolbar {
  position: fixed; left: 50%; bottom: 18px; transform: translateX(-50%);
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  z-index: 10; max-width: 96vw;
}

.tool-group {
  display: flex; gap: 6px; background: rgba(255,255,255,0.85);
  backdrop-filter: blur(8px); padding: 8px; border-radius: 16px;
  box-shadow: 0 6px 20px rgba(40,60,90,0.18); flex-wrap: wrap; justify-content: center;
}
.tool-group.secondary { padding: 6px; }

button.tool, .tool-group.secondary button, #btn-import-label {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  border: none; background: #f4f7fb; border-radius: 12px;
  padding: 8px 12px; cursor: pointer; font-size: 20px;
  color: #33475b; transition: transform 0.08s ease, background 0.15s ease;
  min-width: 56px;
}
button.tool span, .tool-group.secondary button span, #btn-import-label span {
  font-size: 10.5px; font-weight: 600; letter-spacing: 0.2px;
}
button.tool:hover, .tool-group.secondary button:hover, #btn-import-label:hover {
  background: #e6edf5; transform: translateY(-2px);
}
button.tool.active {
  background: #ffd98a; box-shadow: inset 0 0 0 2px #e8a93b;
}
.tool-group.secondary button { font-size: 17px; padding: 7px 10px; }

#btn-import-label { position: relative; }
#file-import { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; height: 100%; }

.sub-panel {
  display: none; flex-wrap: wrap; justify-content: center; gap: 6px;
  background: rgba(255,255,255,0.85); backdrop-filter: blur(8px);
  padding: 6px; border-radius: 14px; max-width: 480px;
  box-shadow: 0 4px 14px rgba(40,60,90,0.14);
}
.sub-panel.visible { display: flex; }

.chip {
  border: none; background: #f4f7fb; color: #33475b;
  padding: 7px 14px; border-radius: 999px; font-size: 13px; font-weight: 600;
  cursor: pointer; transition: background 0.15s ease, opacity 0.15s ease;
}
.chip:hover { background: #e6edf5; }
.chip.active { background: #9fe0b0; box-shadow: inset 0 0 0 2px #4caf6f; }
.chip .cost { font-weight: 700; opacity: 0.65; margin-left: 4px; font-size: 11.5px; }
.chip.locked { background: #eee3f2; color: #6b4c7a; }
.chip.locked .cost { opacity: 0.8; }
.chip.unaffordable { opacity: 0.45; }

#help {
  display: none; position: fixed; top: 16px; right: 16px; z-index: 20;
  background: rgba(255,255,255,0.95); border-radius: 16px; padding: 18px 22px;
  max-width: 320px; box-shadow: 0 8px 26px rgba(40,60,90,0.24);
  color: #2c3e50; font-size: 13.5px; line-height: 1.5;
}
#help.visible { display: block; }
#help h2 { margin: 0 0 8px; font-size: 17px; }
#help p { margin: 6px 0; }
#help button {
  margin-top: 10px; border: none; background: #ffd98a; color: #5a4013;
  font-weight: 700; padding: 7px 14px; border-radius: 10px; cursor: pointer;
}

#toast {
  position: fixed; top: 18px; left: 50%; transform: translateX(-50%) translateY(-10px);
  background: rgba(30,40,55,0.88); color: #fff; padding: 8px 18px; border-radius: 999px;
  font-size: 13px; font-weight: 600; opacity: 0; pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease; z-index: 30;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

@media (max-width: 640px) {
  button.tool, .tool-group.secondary button, #btn-import-label { min-width: 46px; padding: 6px 8px; font-size: 17px; }
  #help { left: 12px; right: 12px; max-width: none; }
}
