:root {
  color-scheme: dark;
  --bg: #121316;
  --panel: #1d2025;
  --panel-2: #272b31;
  --line: #3b4148;
  --text: #f0f5ef;
  --muted: #aeb8af;
  --accent: #46d7a7;
  --accent-2: #f0bc5e;
  --danger: #f26d65;
  --blue: #6ea8ff;
  --shadow: rgba(0, 0, 0, 0.34);
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  background:
    radial-gradient(circle at 22% 12%, rgba(70, 215, 167, 0.14), transparent 28rem),
    linear-gradient(135deg, #101214, #1a1717 48%, #101417);
  color: var(--text);
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button {
  font: inherit;
}

.app-shell {
  min-height: 100vh;
  padding: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.game-surface {
  width: min(1180px, 100%);
  background: rgba(18, 19, 22, 0.92);
  border: 1px solid rgba(240, 245, 239, 0.12);
  border-radius: 8px;
  box-shadow: 0 22px 80px var(--shadow);
  overflow: hidden;
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  padding: 18px 20px;
  border-bottom: 1px solid rgba(240, 245, 239, 0.1);
  background: rgba(29, 32, 37, 0.82);
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 1.6rem;
  line-height: 1;
  letter-spacing: 0;
}

#objective {
  margin-top: 8px;
  max-width: 820px;
  color: var(--muted);
  line-height: 1.45;
  font-size: 0.98rem;
}

.quiet-button,
.wide-action,
.build-button,
.segmented button {
  min-height: 44px;
  border-radius: 7px;
  border: 1px solid rgba(240, 245, 239, 0.16);
  color: var(--text);
  background: var(--panel-2);
  cursor: pointer;
  transition: border-color 140ms ease, background 140ms ease, transform 140ms ease;
}

.quiet-button {
  padding: 0 16px;
  white-space: nowrap;
}

.quiet-button:hover,
.wide-action:hover,
.build-button:hover,
.segmented button:hover {
  background: #30353b;
  border-color: rgba(70, 215, 167, 0.56);
}

.quiet-button:active,
.wide-action:active,
.build-button:active,
.segmented button:active {
  transform: translateY(1px);
}

.play-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 286px;
  min-height: 610px;
}

.canvas-wrap {
  padding: 18px;
  min-width: 0;
}

#gameCanvas {
  display: block;
  width: 100%;
  height: min(66vh, 620px);
  min-height: 460px;
  background: #15181d;
  border: 1px solid rgba(240, 245, 239, 0.12);
  border-radius: 8px;
}

.control-panel {
  padding: 18px;
  border-left: 1px solid rgba(240, 245, 239, 0.1);
  background: rgba(29, 32, 37, 0.9);
}

.status-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.status-grid div {
  min-height: 70px;
  padding: 12px;
  border: 1px solid rgba(240, 245, 239, 0.1);
  border-radius: 8px;
  background: rgba(39, 43, 49, 0.72);
}

.status-grid span,
.build-button b,
.wide-action b {
  color: var(--muted);
  font-size: 0.78rem;
  text-transform: uppercase;
}

.status-grid strong {
  display: block;
  margin-top: 6px;
  color: var(--text);
  font-size: 1.35rem;
  line-height: 1;
}

.panel-block {
  margin-top: 18px;
}

.panel-block h2 {
  margin-bottom: 10px;
  font-size: 0.88rem;
  color: var(--muted);
  font-weight: 700;
  text-transform: uppercase;
}

.button-stack {
  display: grid;
  gap: 9px;
}

.build-button {
  width: 100%;
  padding: 11px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.build-button span {
  font-weight: 800;
}

.build-button.is-selected,
.segmented button.is-selected {
  color: #07110d;
  border-color: rgba(70, 215, 167, 0.9);
  background: var(--accent);
}

.build-button:disabled,
.wide-action:disabled {
  opacity: 0.46;
  cursor: not-allowed;
}

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

.segmented button {
  padding: 0 10px;
  font-weight: 750;
}

.wide-action {
  width: 100%;
  padding: 0 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-weight: 800;
}

.message {
  margin-top: 12px;
  min-height: 3.4em;
  color: var(--muted);
  line-height: 1.35;
  font-size: 0.92rem;
}

@media (max-width: 900px) {
  .app-shell {
    padding: 10px;
    align-items: flex-start;
  }

  .topbar {
    flex-direction: column;
  }

  .play-layout {
    grid-template-columns: 1fr;
  }

  .control-panel {
    border-left: 0;
    border-top: 1px solid rgba(240, 245, 239, 0.1);
  }

  #gameCanvas {
    height: 58vh;
    min-height: 360px;
  }

  .segmented {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (max-width: 560px) {
  .topbar,
  .canvas-wrap,
  .control-panel {
    padding: 12px;
  }

  #objective {
    font-size: 0.9rem;
  }

  .status-grid {
    grid-template-columns: 1fr 1fr;
  }

  .segmented {
    grid-template-columns: 1fr;
  }
}
