:root {
  --game-bg: #0a0c10;
  --panel: #12151c;
  --grid-line: rgba(255, 255, 255, 0.06);
  --text: #e8eaef;
  --muted: #7d8596;
  --accent: #5ee0d0;
  --font: "DM Sans", system-ui, sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  background: var(--game-bg);
  color: var(--text);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 1.25rem 1rem 2rem;
}

.back {
  align-self: flex-start;
  max-width: 920px;
  width: 100%;
  margin-bottom: 1rem;
}

.back a {
  color: var(--accent);
  text-decoration: none;
  font-size: 0.9rem;
}

.back a:hover {
  text-decoration: underline;
}

.layout {
  display: flex;
  flex-wrap: wrap;
  gap: 1.5rem;
  align-items: flex-start;
  justify-content: center;
  max-width: 920px;
}

.board-wrap {
  padding: 12px;
  background: var(--panel);
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

canvas#board {
  display: block;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  background: #07080b;
  border-radius: 8px;
}

.side {
  min-width: 200px;
  max-width: 260px;
}

.side h1 {
  font-size: 1.35rem;
  font-weight: 700;
  margin: 0 0 0.5rem;
  letter-spacing: -0.02em;
}

.side .sub {
  font-size: 0.85rem;
  color: var(--muted);
  margin: 0 0 1.25rem;
  line-height: 1.5;
}

.stats {
  background: var(--panel);
  border-radius: 12px;
  padding: 1rem 1.125rem;
  border: 1px solid rgba(255, 255, 255, 0.08);
  margin-bottom: 1rem;
}

.stats dl {
  margin: 0;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.35rem 1rem;
  font-size: 0.9rem;
}

.stats dt {
  color: var(--muted);
  margin: 0;
}

.stats dd {
  margin: 0;
  font-weight: 600;
  text-align: right;
}

.controls {
  font-size: 0.8rem;
  color: var(--muted);
  line-height: 1.65;
}

.controls kbd {
  display: inline-block;
  padding: 0.1em 0.45em;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  font-size: 0.85em;
  font-family: inherit;
}

.status {
  margin-top: 1rem;
  font-size: 0.85rem;
  min-height: 1.25em;
}

.status.gameover {
  color: #ff8a80;
  font-weight: 600;
}

@media (max-width: 720px) {
  .layout {
    flex-direction: column;
    align-items: center;
  }

  .side {
    max-width: none;
    width: 100%;
    text-align: center;
  }

  .stats dl {
    max-width: 280px;
    margin: 0 auto;
  }
}
