:root {
  color-scheme: dark;
  --bg: #0a0a0a;
  --panel: #111111;
  --panel-2: #1a1a1a;
  --border: #2a2a2a;
  --text: #f5f5f5;
  --muted: #888888;
  --accent: #ffffff;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100dvh;
  overflow: hidden;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  display: flex;
  justify-content: center;
  padding: 1rem;
}

main {
  width: 100%;
  max-width: 1100px;
  height: 100%;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.masthead {
  margin-bottom: 0.75rem;
}

.mark {
  display: inline-block;
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: #ffffff;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.2rem 0.65rem;
  margin-bottom: 0.5rem;
}

h1 {
  font-family: "Fraunces", Georgia, serif;
  font-size: 2rem;
  font-weight: 700;
  margin: 0 0 0.1rem;
  color: #ffffff;
}

.subtitle {
  color: var(--muted);
  margin: 0;
  line-height: 1.45;
  font-size: 0.85rem;
  max-width: 62ch;
}

.layout {
  flex: 1;
  min-height: 0;
  display: flex;
  gap: 1rem;
}

.panel {
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.75rem;
}

.board-panel {
  flex: 1 1 0;
}

.stats-panel {
  flex: 0 0 320px;
  overflow-y: auto;
}

.board {
  position: relative;
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background: var(--bg);
  border-radius: 8px;
}

canvas {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 1 / 1;
  background: var(--bg);
}

.controls {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.75rem;
  flex-wrap: wrap;
}

button {
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.45rem 0.8rem;
  font: inherit;
  font-size: 0.9rem;
  cursor: pointer;
}

button:hover {
  border-color: #ffffff;
  color: #ffffff;
}

button.primary {
  background: #ffffff;
  color: #000000;
  font-weight: 700;
  border-color: #ffffff;
}

button.primary:hover {
  background: #e0e0e0;
  color: #000000;
}

.speed {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-left: auto;
  color: var(--muted);
  font-size: 0.85rem;
}

select {
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.35rem;
  font: inherit;
}

.hint {
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.45;
  margin: 0.6rem 0 0;
}

.panel-title {
  font-family: "Fraunces", Georgia, serif;
  font-size: 1.15rem;
  font-weight: 700;
  margin: 0 0 0.75rem;
  color: #ffffff;
}

.stat-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.stat {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.5rem 0.7rem;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.stat-label {
  color: var(--muted);
  font-size: 0.66rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.stat-value {
  color: #ffffff;
  font-weight: 600;
  font-size: 1.05rem;
  font-variant-numeric: tabular-nums;
}

@media (max-width: 760px) {
  .stats-panel {
    flex: 0 0 190px;
    padding: 0.75rem;
  }

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

  .subtitle,
  .hint {
    display: none;
  }

  h1 {
    font-size: 1.4rem;
  }

  body {
    padding: 0.5rem;
  }
}
