* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; user-select: none; }
html, body {
  margin: 0; padding: 0; width: 100%; height: 100%;
  background: #14100d; overflow: hidden;
  font-family: 'Trebuchet MS', 'Segoe UI', sans-serif;
  touch-action: none;
}
#game {
  position: fixed; inset: 0;
  display: flex; flex-direction: column;
}
#hud {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 12px;
  background: linear-gradient(#1c1611, #14100d);
  border-bottom: 2px solid #3a2c1e;
  color: #e8dfd0;
  font-size: 14px;
  z-index: 5;
}
#hud .stat { display: flex; align-items: center; gap: 6px; }
#hud .stat b { color: #e8a33d; font-size: 15px; }
#canvasWrap { flex: 1; position: relative; overflow: hidden; background: #0d0a08; }
canvas { display: block; touch-action: none; }
#toolbar {
  position: absolute; top: 10px; right: 10px; z-index: 15;
  display: flex; flex-direction: column; gap: 6px;
}
#toolbar button {
  width: 46px; height: 46px; border-radius: 10px;
  background: rgba(28,22,17,0.9); border: 2px solid #3a2c1e;
  color: #cbb999; font-size: 20px; display: flex; align-items: center; justify-content: center;
  font-family: inherit; padding: 0;
}
#toolbar button .lbl { display: none; }
#toolbar button.active {
  border-color: #e8a33d; background: #3a2c1e; color: #e8a33d;
  box-shadow: 0 0 8px rgba(232,163,61,0.5);
}
#buildMenu {
  position: absolute; top: 10px; left: 10px; z-index: 15;
}
#buildToggle {
  width: 46px; height: 46px; border-radius: 10px;
  background: rgba(28,22,17,0.9); border: 2px solid #3a2c1e;
  color: #cbb999; font-size: 20px; display: flex; align-items: center; justify-content: center;
  font-family: inherit; padding: 0;
}
#buildToggle.active { border-color: #e8a33d; color: #e8a33d; }
#buildPanel {
  display: none; margin-top: 6px; background: rgba(28,22,17,0.95);
  border: 2px solid #3a2c1e; border-radius: 10px; padding: 6px; min-width: 120px;
}
#buildPanel.open { display: block; }
#buildPanel button {
  display: flex; align-items: center; gap: 8px; width: 100%;
  background: none; border: none; color: #e8dfd0; font-family: inherit;
  padding: 8px 6px; font-size: 13px; border-radius: 6px;
}
#buildPanel button:active { background: #3a2c1e; }
#buildPanel button .ic { font-size: 18px; }
#toast {
  position: absolute; top: 10px; left: 50%; transform: translateX(-50%);
  background: rgba(20,16,13,0.95); border: 1px solid #e8a33d; color: #e8dfd0;
  padding: 8px 16px; border-radius: 6px; font-size: 13px;
  opacity: 0; transition: opacity 0.25s; pointer-events: none; z-index: 20;
  white-space: nowrap;
}
#toast.show { opacity: 1; }
#nav {
  display: flex; border-top: 2px solid #3a2c1e; background: #1c1611;
}
#nav button {
  flex: 1; padding: 12px 4px; background: none; border: none; color: #cbb999;
  font-size: 13px; font-weight: bold; border-right: 1px solid #3a2c1e;
  font-family: inherit;
}
#nav button:last-child { border-right: none; }
#nav button:active { background: #2a2018; color: #e8a33d; }
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,0.6);
  display: none; align-items: flex-end; justify-content: center; z-index: 30;
}
.modal-backdrop.open { display: flex; }
.modal {
  background: #1c1611; width: 100%; max-height: 78vh; overflow-y: auto;
  border-top: 3px solid #e8a33d; border-radius: 14px 14px 0 0;
  padding: 14px 14px 24px;
  color: #e8dfd0;
}
.modal h2 {
  margin: 0 0 12px; font-size: 18px; color: #e8a33d;
  display: flex; justify-content: space-between; align-items: center;
}
.modal h2 .close { font-size: 20px; color: #cbb999; padding: 0 6px; }
.row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 8px; border-bottom: 1px solid #2a2018; gap: 8px;
}
.row:last-child { border-bottom: none; }
.swatch { width: 22px; height: 22px; border-radius: 4px; flex-shrink: 0; border: 1px solid rgba(255,255,255,0.15); }
.rowInfo { flex: 1; min-width: 0; }
.rowInfo .name { font-size: 14px; font-weight: bold; }
.rowInfo .sub { font-size: 12px; color: #a3927a; }
.btnSmall {
  background: #3a2c1e; color: #e8dfd0; border: 1px solid #e8a33d33;
  border-radius: 6px; padding: 8px 10px; font-size: 12px; font-family: inherit;
  white-space: nowrap;
}
.btnSmall:active { background: #e8a33d; color: #1c1611; }
.btnSmall:disabled { opacity: 0.35; }
.empty { text-align: center; color: #6b5c48; padding: 20px 0; font-size: 13px; }
progress { width: 60px; height: 8px; }
