:root {
  --bg-top: #d6ecff;
  --bg-bottom: #acc89d;
  --ink: #182019;
  --panel-bg: rgba(240, 248, 242, 0.82);
  --panel-border: rgba(31, 45, 35, 0.22);
  --accent: #2f7547;
  --accent-strong: #205735;
  --danger: #b64e3a;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: "Avenir Next", "Trebuchet MS", "Gill Sans", sans-serif;
  color: var(--ink);
  background: linear-gradient(180deg, var(--bg-top), var(--bg-bottom));
}

#gameCanvas {
  display: block;
  width: 100vw;
  height: 100vh;
}

#ui {
  position: fixed;
  inset: 0;
  pointer-events: none;
}

.glass {
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  box-shadow: 0 14px 40px rgba(20, 31, 22, 0.14);
  backdrop-filter: blur(5px);
}

#topBar {
  pointer-events: auto;
  position: absolute;
  top: 12px;
  left: 12px;
  right: 12px;
  border-radius: 14px;
  padding: 10px 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.stat {
  display: flex;
  flex-direction: column;
  min-width: 110px;
}

.label {
  font-size: 11px;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  opacity: 0.7;
}

.value {
  font-size: 18px;
  font-weight: 700;
}

.zoomControls {
  margin-left: auto;
  display: flex;
  gap: 6px;
}

.tinyBtn {
  pointer-events: auto;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  border: 1px solid rgba(24, 40, 30, 0.35);
  background: #f8fdf8;
  color: var(--ink);
  font-size: 20px;
  font-weight: 700;
  cursor: pointer;
}

.tinyBtn.tinyWide {
  width: auto;
  min-width: 110px;
  padding: 0 10px;
  font-size: 12px;
}

.tinyBtn:hover {
  background: #eaf6eb;
}

.toolBtn:disabled,
.tinyBtn:disabled {
  opacity: 0.6;
  cursor: default;
}

#buildPanel {
  pointer-events: auto;
  position: absolute;
  right: 12px;
  top: 76px;
  bottom: 12px;
  width: 360px;
  border-radius: 16px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow: auto;
}

#buildPanel h1 {
  margin: 0;
  font-size: 22px;
  line-height: 1.15;
}

#buildPanel h2 {
  margin: 0 0 8px;
  font-size: 15px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.sub {
  margin: 0;
  font-size: 13px;
  opacity: 0.8;
}

.toolGrid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

.menuTabs {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
}

.menuBtn {
  border: 1px solid rgba(20, 45, 30, 0.28);
  background: #edf6ee;
  color: var(--ink);
  border-radius: 10px;
  padding: 8px 6px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

.menuBtn.active {
  background: linear-gradient(180deg, #2f7547, #205735);
  color: #effff0;
}

.toolBtn {
  width: 100%;
  border: 1px solid rgba(20, 45, 30, 0.32);
  background: #f4fff6;
  color: var(--ink);
  border-radius: 11px;
  padding: 10px 10px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  text-align: left;
}

.toolBtn:hover {
  background: #dff4e3;
}

.toolBtn.active {
  background: linear-gradient(180deg, var(--accent), var(--accent-strong));
  color: #effff0;
  border-color: rgba(18, 34, 22, 0.4);
}

.section {
  border: 1px solid rgba(28, 47, 35, 0.18);
  border-radius: 12px;
  padding: 10px;
  background: rgba(255, 255, 255, 0.52);
}

.row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  padding: 2px 0;
}

#statusText {
  margin: 0;
  font-size: 13px;
  min-height: 18px;
}

#eventLog {
  margin: 0;
  padding-left: 18px;
  font-size: 12px;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

#eventLog li {
  line-height: 1.3;
}

#eventLog li.warning {
  color: var(--danger);
  font-weight: 700;
}

#eventLog li.feedback {
  color: #255c7c;
  font-weight: 700;
}

@media (max-width: 980px) {
  #buildPanel {
    width: min(94vw, 420px);
    max-height: 54vh;
    top: auto;
    left: 12px;
    right: 12px;
    bottom: 12px;
  }

  .value {
    font-size: 16px;
  }

  #topBar {
    right: 12px;
  }
}
