:root {
  color-scheme: dark;
  --bg: #151713;
  --panel: #20241c;
  --panel-2: #2a2f25;
  --line: #3f4637;
  --text: #f3efe3;
  --muted: #b9b09d;
  --accent: #d8a33f;
  --accent-2: #7cc0a2;
  --danger: #d86f5d;
  --blue: #79a9d8;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: radial-gradient(circle at 40% 20%, #283122 0, #151713 36%, #10110f 100%);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  overflow-x: hidden;
}

button,
input {
  font: inherit;
}

button {
  min-height: 38px;
  border: 1px solid #5a604b;
  border-radius: 6px;
  background: #343a2e;
  color: var(--text);
  cursor: pointer;
  transition: background 120ms ease, border-color 120ms ease, transform 120ms ease;
}

button:hover {
  background: #424936;
  border-color: #777e63;
}

button:active {
  transform: translateY(1px);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.shell {
  width: min(1540px, 100vw);
  min-height: 100vh;
  margin: 0 auto;
  padding: 16px;
}

.topbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 12px;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(1.5rem, 2.8vw, 2.4rem);
  line-height: 1;
  letter-spacing: 0;
}

h2 {
  font-size: 0.92rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
  color: #f4d58f;
}

.topbar p,
.metric-grid span,
.actions span,
.log,
.toggle {
  color: var(--muted);
}

.status-strip {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.status-strip span {
  min-width: 86px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(32, 36, 28, 0.82);
  text-align: center;
  white-space: nowrap;
}

.top-button {
  min-width: 92px;
  padding: 8px 10px;
  border-color: rgba(216, 163, 63, 0.58);
  background: #473a20;
}

.game {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 352px;
  gap: 12px;
  align-items: stretch;
}

.field-wrap {
  position: relative;
  min-height: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: #182014;
}

canvas {
  display: block;
  width: 100%;
  max-width: 100%;
  height: calc(100vh - 112px);
  min-height: 520px;
}

.toast {
  position: absolute;
  left: 14px;
  bottom: 14px;
  max-width: min(520px, calc(100% - 28px));
  padding: 9px 12px;
  border: 1px solid rgba(244, 213, 143, 0.45);
  border-radius: 6px;
  background: rgba(20, 22, 18, 0.86);
  color: #f4d58f;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 160ms ease, transform 160ms ease;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
}

.band {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(32, 36, 28, 0.9);
  padding: 12px;
}

.band h2 {
  margin-bottom: 10px;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 12px;
}

.metric-grid div {
  min-height: 62px;
  border: 1px solid #3c4234;
  border-radius: 6px;
  background: #272c22;
  padding: 9px;
}

.metric-grid b {
  display: block;
  font-size: 1.25rem;
  line-height: 1.1;
}

.metric-grid span {
  display: block;
  margin-top: 4px;
  font-size: 0.82rem;
}

.policy {
  display: grid;
  gap: 8px;
}

.policy label {
  display: grid;
  grid-template-columns: 54px 1fr;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 0.92rem;
}

input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
}

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

.allocation span {
  min-width: 0;
  padding: 7px 4px;
  border: 1px solid #3c4234;
  border-radius: 6px;
  background: #272c22;
  color: var(--muted);
  font-size: 0.75rem;
  text-align: center;
}

.allocation b {
  display: block;
  color: var(--text);
  font-size: 1rem;
}

.row,
.orders {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-top: 10px;
}

.orders {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.actions {
  display: grid;
  gap: 8px;
}

.actions button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 10px;
  text-align: left;
}

.actions span {
  flex: 0 0 auto;
  font-size: 0.8rem;
}

.toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
  font-size: 0.92rem;
}

.toggle input {
  accent-color: var(--accent-2);
}

.log {
  height: 74px;
  margin-top: 10px;
  overflow: hidden;
  font-size: 0.84rem;
  line-height: 1.4;
}

.log div {
  padding: 3px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

@media (max-width: 1040px) {
  .topbar {
    align-items: start;
    flex-direction: column;
  }

  .status-strip {
    justify-content: start;
  }

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

  canvas {
    height: 62vh;
    min-height: 390px;
  }

  .panel {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 720px) {
  .shell {
    padding: 10px;
  }

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

  .status-strip span {
    min-width: 74px;
    padding: 7px 8px;
    font-size: 0.86rem;
  }

  canvas {
    min-height: 330px;
  }
}
