:root {
  --bg: #ffffff;
  --fg: #1f2328;
  --muted: #59636e;
  --link: #0969da;
  --pill: rgba(255, 255, 255, 0.92);
  --pill-border: #d1d9e0;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d1117;
    --fg: #f0f6fc;
    --muted: #9198a1;
    --link: #4493f8;
    --pill: rgba(13, 17, 23, 0.92);
    --pill-border: #3d444d;
    color-scheme: dark;
  }
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  overscroll-behavior: none;
}

body {
  font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans", Helvetica, Arial, sans-serif;
}

main {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
  max-width: 944px;
  margin: 0 auto;
  padding: 24px 16px;
  padding-left: max(16px, env(safe-area-inset-left));
  padding-right: max(16px, env(safe-area-inset-right));
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
}

header {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px 16px;
  margin-bottom: 16px;
}

a {
  color: var(--link);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

.stats {
  display: flex;
  gap: 16px;
  margin: 0;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.stats b {
  color: var(--fg);
  font-weight: 600;
}

.board {
  position: relative;
  display: flex;
  justify-content: center;
}

canvas {
  display: block;
}

/* A board not being played shows a play icon instead of a focus ring
   around the one that is. */
.board {
  outline: none;
}

/* The games share the page from the header down, spread evenly. */
.games {
  position: relative;
  display: flex;
  flex: 1;
  flex-direction: column;
  justify-content: space-evenly;
  gap: 24px;
}

.game + .game {
  padding-top: 20px;
  border-top: 1px solid var(--pill-border);
}

/* On a phone, the boards not being played shrink to one row. */
.compact .caption {
  display: none;
}

.games.merged .game {
  visibility: hidden;
}

/* The final spreads wider than the page column when there is room. */
.final {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: min(calc(100vw - 32px), 1240px);
  transform: translateX(-50%);
}

.pitch {
  position: relative;
  flex: 1;
  min-height: 0;
}

.pitch canvas {
  position: absolute;
  inset: 0;
}

.final .hint {
  margin: 0;
}

.finale {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  pointer-events: none;
}

.finale-art {
  flex: none;
}

.finale-score {
  margin: 0;
  padding: 4px 14px;
  border: 1px solid var(--pill-border);
  border-radius: 999px;
  background: var(--pill);
  font-weight: 600;
}

.finale-score:empty {
  display: none;
}

/* Play again: a circular arrow drawn with cells. */
.replay {
  display: grid;
  grid-template-columns: repeat(7, 6px);
  gap: 2px;
  padding: 10px;
  border: 1px solid var(--pill-border);
  border-radius: 12px;
  background: var(--pill);
  cursor: pointer;
  pointer-events: auto;
}

.replay[hidden] {
  display: none;
}

.replay i {
  width: 6px;
  height: 6px;
  border-radius: 1.5px;
}

.replay i.on {
  background: var(--icon, var(--fg));
}

.replay:hover {
  border-color: var(--muted);
}

.lockline,
.runline {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 16px;
  margin: 12px 0 0;
  color: var(--muted);
}

.lockline {
  justify-content: center;
}

.runline {
  justify-content: space-between;
}

.bar {
  display: inline-flex;
  gap: 3px;
}

.bar i {
  width: 9px;
  height: 9px;
  border-radius: 2px;
  background: var(--pill-border);
}

.bar i.on {
  background: var(--cell-on, var(--link));
}

#fx {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 1;
}

.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 8px;
  pointer-events: none;
}

.status {
  margin: 0;
  padding: 6px 12px;
  border: 1px solid var(--pill-border);
  border-radius: 999px;
  background: var(--pill);
  text-align: center;
  pointer-events: none;
}

.status:empty {
  display: none;
}

.hint {
  margin: 16px 0 0;
  color: var(--muted);
}

.touch {
  display: none;
}

@media (pointer: coarse) {
  .keys {
    display: none;
  }

  .touch {
    display: inline;
  }
}
