:root {
  color-scheme: light dark;
  --bg: Canvas;
  --ink: CanvasText;
  --muted: #625f58;
  --line: #d7d2c8;
  --panel: #efede5;
  --pixel-on: #18372a;
  --pixel-off: #dff2e7;
  --accent: #208c5a;
}

@media (prefers-color-scheme: dark) {
  :root {
    --muted: #a7a196;
    --line: #34362f;
    --panel: #1b1d19;
    --pixel-on: #8fe8bd;
    --pixel-off: #26352e;
    --accent: #77d9ad;
  }
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100svh;
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

button {
  color: inherit;
  font: inherit;
}

.shell {
  width: min(100% - 32px, 920px);
  min-height: 100svh;
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: clamp(18px, 4vw, 42px);
  align-items: center;
  margin: 0 auto;
  padding: clamp(20px, 5vw, 56px) 0;
}

.mast {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 14px;
}

h1,
p {
  margin: 0;
}

h1 {
  font-size: clamp(2.1rem, 7vw, 5.6rem);
  line-height: 0.92;
  font-weight: 720;
}

.note {
  color: var(--muted);
  font-size: clamp(0.82rem, 2vw, 1rem);
  text-transform: uppercase;
}

.stage {
  display: grid;
  grid-template-columns: minmax(112px, 190px) minmax(260px, 520px);
  gap: clamp(16px, 5vw, 48px);
  align-items: center;
  justify-content: center;
}

.target {
  width: min(100%, 190px);
  aspect-ratio: 1;
  padding: 10px;
  border: 1px solid var(--line);
  background: var(--panel);
}

.board-button {
  width: min(100%, 520px);
  aspect-ratio: 1;
  display: block;
  padding: 0;
  border: 1px solid var(--ink);
  background: transparent;
  cursor: crosshair;
}

.board-button:focus-visible,
.controls button:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 4px;
}

canvas {
  width: 100%;
  height: 100%;
  display: block;
  image-rendering: pixelated;
}

.footer-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 18px;
  align-items: end;
  border-top: 1px solid var(--line);
  padding-top: 14px;
}

.facts,
.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.facts span,
.controls button,
.controls output {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  padding: 0 10px;
  background: var(--panel);
  font-size: 0.86rem;
}

.controls button {
  cursor: pointer;
}

.controls output {
  min-width: 84px;
  border-color: var(--ink);
}

:root[data-solved="true"] .board-button,
:root[data-solved="true"] .controls output {
  border-color: var(--accent);
}

@media (max-width: 680px) {
  .shell {
    width: min(100% - 24px, 520px);
    justify-items: stretch;
  }

  .mast,
  .footer-row {
    align-items: start;
    grid-template-columns: 1fr;
  }

  .mast {
    display: grid;
  }

  .stage {
    grid-template-columns: 1fr;
    justify-items: center;
  }

  .target {
    width: min(42vw, 150px);
  }

  .board-button {
    width: min(100%, 430px);
  }
}
