:root {
  color-scheme: dark;
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #12151c;
  color: #eef2ff;
}

* { box-sizing: border-box; }
html { min-width: 320px; }
body { margin: 0; min-height: 100vh; overflow-x: hidden; }
main { width: min(100%, 1240px); margin: 0 auto; padding: clamp(10px, 3vw, 22px); }
header { margin-bottom: 16px; }
h1 { margin: 0 0 4px; font-size: clamp(24px, 7vw, 30px); }
p { color: #b7c0d8; margin: 0; }

.controls {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  align-items: end;
  min-width: 0;
  background: #1b2130;
  border: 1px solid #30394f;
  border-radius: 14px;
  padding: 12px;
  margin-bottom: 14px;
}

label {
  min-width: 0;
  color: #cbd5f3;
  font-size: 13px;
  display: grid;
  gap: 5px;
}
.controls > label:nth-child(1),
.controls > label:nth-child(2),
.controls > label:nth-child(4),
.controls > .checkbox-label { grid-column: 1 / -1; }
.checkbox-label {
  min-height: 44px;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 10px;
  border: 1px solid #3a4560;
  border-radius: 9px;
  background: #101520;
  font-size: 15px;
  line-height: 1.2;
}
.checkbox-label input { flex: 0 0 auto; width: 20px; height: 20px; accent-color: #60a5fa; }
select, input:not([type="checkbox"]), button {
  width: 100%;
  min-width: 0;
  max-width: 100%;
  border-radius: 9px;
  border: 1px solid #3a4560;
  background: #101520;
  color: #f8fbff;
  min-height: 44px;
  padding: 9px 10px;
  font: inherit;
  font-size: 16px;
}
select {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
button { cursor: pointer; background: #263556; touch-action: manipulation; }
button:hover { background: #31436c; }

.board-wrap {
  display: grid;
  grid-template-columns: minmax(0, 720px) minmax(280px, 1fr);
  gap: 18px;
  align-items: start;
}
canvas {
  width: 100%;
  max-width: 720px;
  min-width: 0;
  aspect-ratio: 1 / 1;
  height: auto;
  display: block;
  background: #090b10;
  border: 1px solid #30394f;
  border-radius: 12px;
  touch-action: manipulation;
}
aside {
  min-width: 0;
  background: #1b2130;
  border: 1px solid #30394f;
  border-radius: 14px;
  padding: 14px;
}
h2 { margin: 0 0 8px; font-size: 18px; }
ol, ul { padding-left: 20px; color: #cbd5f3; }
.rules { display: grid; gap: 8px; margin-top: 8px; }
.rules li { line-height: 1.35; overflow-wrap: anywhere; }
code { color: #bfdbfe; background: #101520; border: 1px solid #30394f; border-radius: 5px; padding: 1px 4px; }
.legend { margin-top: 12px; font-size: 13px; line-height: 1.35; }
.supply-dot { display: inline-block; width: 10px; height: 10px; border-radius: 999px; background: rgba(255,255,255,.55); margin-right: 5px; vertical-align: -1px; }
#status {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  color: #dbeafe;
  line-height: 1.5;
}

@media (min-width: 700px) {
  .controls { grid-template-columns: repeat(6, minmax(0, 1fr)); }
  .controls > label:nth-child(1),
  .controls > label:nth-child(2) { grid-column: span 3; }
  .controls > label:nth-child(3),
  .controls > label:nth-child(4),
  .controls > .checkbox-label,
  .controls > button { grid-column: span 2; }
}

@media (min-width: 1020px) {
  .controls { grid-template-columns: repeat(12, minmax(0, 1fr)); }
  .controls > label:nth-child(1),
  .controls > label:nth-child(2) { grid-column: span 4; }
  .controls > label:nth-child(3),
  .controls > label:nth-child(4) { grid-column: span 2; }
  .controls > .checkbox-label,
  .controls > button { grid-column: span 2; }
}

@media (max-width: 1019px) {
  .board-wrap { grid-template-columns: 1fr; }
  canvas { max-width: min(720px, 100%); justify-self: center; }
}

@media (max-width: 560px) {
  main { padding: 8px; }
  header { margin-bottom: 10px; }
  .controls { gap: 8px; padding: 10px; }
  .board-wrap { gap: 10px; }
  aside { padding: 12px; }
  ol, ul { margin: 8px 0 0; }
  .rules { gap: 10px; }
}
