:root {
  --bg: #000;
  --ink: #fff;
  --muted: #b8b8b8;
  --line: #fff;
  --panel: #111;
  --panel-2: #1b1b1b;
  --pressed: #ddd;
  --cell: 58px;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 600px;
  height: 600px;
  margin: 0;
  overflow: hidden;
  background: var(--bg);
  color: var(--ink);
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button {
  font: inherit;
  color: inherit;
}

.app {
  position: relative;
  width: 600px;
  height: 600px;
  padding: 8px;
}

.topbar {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  height: 58px;
}

.control {
  height: 58px;
  border: 3px solid var(--line);
  border-radius: 0;
  background: var(--panel);
  color: var(--ink);
  font-size: 17px;
  font-weight: 750;
  letter-spacing: 0;
  text-transform: uppercase;
  transition:
    transform 180ms cubic-bezier(0.4, 0.04, 0.5, 1),
    background 180ms cubic-bezier(0.4, 0.04, 0.5, 1),
    color 180ms cubic-bezier(0.4, 0.04, 0.5, 1);
}

.control.is-focused {
  transform: scale(1.08);
  background: var(--ink);
  color: #000;
}

.control.is-pressed {
  transform: scale(0.92);
  background: var(--pressed);
  color: #000;
}

.status-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 42px;
  padding: 0 6px;
  color: var(--ink);
  font-size: 16px;
  font-weight: 700;
}

#game-state {
  color: var(--muted);
  font-weight: 650;
}

.board {
  position: relative;
  display: grid;
  grid-template-columns: repeat(8, var(--cell));
  grid-template-rows: repeat(8, var(--cell));
  gap: 0;
  width: calc(var(--cell) * 8);
  height: calc(var(--cell) * 8);
  margin: 4px auto 0;
  border: 4px solid var(--line);
  background: var(--line);
}

.cell {
  position: relative;
  width: var(--cell);
  height: var(--cell);
  border: 1px solid var(--line);
  border-radius: 0;
  background: #050505;
  color: var(--ink);
  display: grid;
  place-items: center;
  padding: 0;
  overflow: hidden;
  transition:
    transform 150ms cubic-bezier(0.4, 0.04, 0.5, 1),
    background 150ms cubic-bezier(0.4, 0.04, 0.5, 1),
    color 150ms cubic-bezier(0.4, 0.04, 0.5, 1);
}

.cell.dark {
  background: #161616;
}

.cell.light {
  background: #262626;
}

.cell.is-focused {
  z-index: 2;
  transform: scale(1.12);
  background: var(--ink);
  color: #000;
  border-width: 3px;
}

.cell.is-selected {
  outline: 5px solid var(--ink);
  outline-offset: -10px;
}

.cell.is-kept {
  outline: 4px double var(--ink);
  outline-offset: -9px;
}

.cell.is-target::after {
  content: "";
  width: 18px;
  height: 18px;
  border: 3px solid currentColor;
  position: absolute;
  inset: 50% auto auto 50%;
  transform: translate(-50%, -50%);
}

.cell.is-last::before {
  content: "";
  position: absolute;
  inset: 7px;
  border: 2px solid var(--muted);
  pointer-events: none;
}

.piece {
  position: relative;
  z-index: 1;
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  transform: translateZ(0);
  transition: transform 180ms cubic-bezier(0.68, 0, 0.29, 1);
}

.piece-icon {
  display: block;
  width: 48px;
  height: 48px;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 4.3;
}

.piece-icon.white {
  fill: var(--ink);
  stroke: #050505;
}

.piece-icon.black {
  fill: #050505;
  stroke: var(--ink);
}

.cell.is-focused .piece,
.cell.is-selected .piece,
.cell.is-kept .piece {
  transform: scale(1.12);
}

.cell.is-focused .piece-icon.white {
  fill: #050505;
  stroke: var(--ink);
}

.cell.is-focused .piece-icon.black {
  fill: #050505;
  stroke: var(--ink);
}

.cell.is-arriving > .piece {
  visibility: hidden;
}

.piece-ghost {
  position: fixed;
  z-index: 30;
  display: grid;
  place-items: center;
  pointer-events: none;
  will-change: transform, opacity;
}

.piece-ghost .piece {
  transform: none;
}

.footer {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 18px;
  height: 28px;
  margin-top: 4px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 650;
}

.version {
  position: absolute;
  right: 10px;
  bottom: 7px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.game-over .board {
  opacity: 0.78;
}

.game-over #game-state {
  color: var(--ink);
}
