:root {
  color-scheme: dark;
  --bg: #0c111c;
  --surface: #121927;
  --surface-2: #1a2334;
  --border: #263248;
  --text: #e8ebf2;
  --muted: #9aa3b5;
  --accent: #f5b942;
  --accent-text: #1a1305;
  --radius: 10px;
  --font: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --mono: ui-monospace, 'SF Mono', 'Cascadia Code', Consolas, monospace;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
}

body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--accent);
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Project page: header, stage that holds the canvas, optional controls */

.project {
  display: grid;
  grid-template-rows: auto 1fr auto;
  height: 100dvh;
  overflow: hidden;
}

.topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 16px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.back {
  color: var(--muted);
  font-size: 14px;
  text-decoration: none;
  white-space: nowrap;
}

.back:hover {
  color: var(--text);
}

.topbar h1 {
  margin: 0;
  font-size: 17px;
  font-weight: 650;
  letter-spacing: -0.01em;
}

.hint {
  margin: 0 0 0 auto;
  color: var(--muted);
  font-size: 13px;
}

kbd {
  padding: 1px 6px;
  border: 1px solid var(--border);
  border-bottom-width: 2px;
  border-radius: 5px;
  background: var(--surface-2);
  font: 12px var(--mono);
}

.stage {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 0;
  overflow: hidden;
}

.stage canvas {
  display: block;
  touch-action: none;
}

.stage.padded {
  padding: 16px;
}

.stage.padded canvas {
  outline: 1px solid var(--border);
  border-radius: 6px;
  box-shadow: 0 10px 40px rgb(0 0 0 / 0.5);
}

.controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 10px 20px;
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  background: var(--surface);
}

.controls label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 14px;
}

.stat {
  color: var(--muted);
  font-size: 14px;
}

.stat output,
.stat strong {
  color: var(--text);
  font: 600 14px var(--mono);
}

/* Form controls */

button,
select,
input[type='text'],
input[type='number'] {
  min-height: 36px;
  padding: 6px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
  font-size: 14px;
}

button {
  cursor: pointer;
  font-weight: 600;
}

button:hover,
select:hover {
  border-color: var(--muted);
}

button.primary {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--accent-text);
}

button.primary:hover {
  filter: brightness(1.08);
}

input[type='number'] {
  width: 5.5em;
}

input[type='range'],
input[type='checkbox'] {
  accent-color: var(--accent);
}

input[type='range'] {
  width: 140px;
}

input[type='checkbox'] {
  width: 18px;
  height: 18px;
}

/* Overlay message on top of the stage (game over, start screen) */

.overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  gap: 12px;
  background: rgb(12 17 28 / 0.72);
  text-align: center;
}

.overlay[hidden] {
  display: none;
}

.overlay h2 {
  margin: 0;
  font-size: clamp(28px, 6vw, 44px);
  letter-spacing: -0.02em;
}

.overlay p {
  margin: 0;
  color: var(--muted);
}

@media (max-width: 640px) {
  input[type='range'] {
    width: 110px;
  }

  .hint {
    flex-basis: 100%;
    margin: 0;
  }
}

/* Canvas sizing scripts set an inline size; until then the canvas stays hidden so it doesn't jump on load */
.stage canvas:not([style]) {
  visibility: hidden;
}
