:root {
  --bg: #0d0e10;
  --panel: #17191c;
  --line: #23262a;
  --text: #e8e8ea;
  --muted: #7d838c;
  --accent: #4f8ef7;
  --black-disc: #08090a;
  --black-ring: #2c2f34;
  --white-disc: #e8e8ea;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  justify-content: center;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}

main {
  width: min(92vw, 560px);
  padding: 40px 0 56px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

main.arena-page {
  width: min(94vw, 900px);
}

.tabs {
  display: flex;
  gap: 4px;
  margin-bottom: -4px;
}

.tab {
  color: var(--muted);
  text-decoration: none;
  font-size: 13px;
  padding: 6px 12px;
  border-radius: 4px;
  border: 1px solid transparent;
}

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

.tab.active {
  color: var(--text);
  border-color: var(--line);
  background: var(--panel);
}

.tab.back {
  margin-right: 8px;
  padding-right: 12px;
  border-right: 1px solid var(--line);
  border-radius: 0;
}

header h1 {
  margin: 0;
  font-size: 19px;
  font-weight: 600;
  letter-spacing: 0.01em;
}

.sub {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

.score {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.side {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  transition: border-color 0.15s ease, color 0.15s ease;
}

.side.active {
  border-color: var(--accent);
  color: var(--text);
}

.side .count {
  font-variant-numeric: tabular-nums;
  min-width: 2ch;
  text-align: center;
}

.side .disc {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  flex-shrink: 0;
}

.side-text {
  display: flex;
  flex-direction: column;
  line-height: 1.25;
}

.side .name {
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
}

.side.active .name {
  color: var(--text);
}

.disc.black {
  background: var(--black-disc);
  box-shadow: inset 0 0 0 1px var(--black-ring);
}

.disc.white {
  background: var(--white-disc);
}

.status {
  flex: 1;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
}

.spinner {
  display: inline-block;
  width: 11px;
  height: 11px;
  border: 1.5px solid var(--line);
  border-top-color: var(--accent);
  border-radius: 50%;
  vertical-align: -1px;
  animation: spin 0.7s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.board {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  grid-template-rows: repeat(8, 1fr);
  gap: 1px;
  padding: 1px;
  background: var(--line);
  border: 1px solid var(--line);
  border-radius: 4px;
  aspect-ratio: 1;
  width: 100%;
}

.cell {
  position: relative;
  background: var(--panel);
  border: 0;
  padding: 0;
  cursor: default;
  display: grid;
  place-items: center;
}

.cell.legal {
  cursor: pointer;
}

.cell.legal::after {
  content: "";
  width: 18%;
  height: 18%;
  border-radius: 50%;
  background: var(--accent);
  opacity: 0.28;
  transition: opacity 0.15s ease;
}

.cell.legal:hover::after {
  opacity: 0.65;
}

.cell.last {
  outline: 1px solid var(--accent);
  outline-offset: -1px;
}

.stone {
  width: 78%;
  height: 78%;
  border-radius: 50%;
  animation: place 0.14s ease-out;
}

.stone.black {
  background: var(--black-disc);
  box-shadow: inset 0 0 0 1px var(--black-ring);
}

.stone.white {
  background: var(--white-disc);
}

@keyframes place {
  from {
    transform: scale(0.7);
    opacity: 0.4;
  }
}

.stone.flip-to-black,
.stone.flip-to-white {
  animation-duration: 0.26s;
  animation-timing-function: ease-in-out;
  animation-fill-mode: both;
}

.stone.flip-to-black {
  animation-name: flip-to-black;
}

.stone.flip-to-white {
  animation-name: flip-to-white;
}

@keyframes flip-to-black {
  0% {
    transform: scaleX(1);
    background: var(--white-disc);
    box-shadow: none;
  }
  50% {
    transform: scaleX(0.05);
    background: var(--white-disc);
    box-shadow: none;
  }
  51% {
    transform: scaleX(0.05);
    background: var(--black-disc);
    box-shadow: inset 0 0 0 1px var(--black-ring);
  }
  100% {
    transform: scaleX(1);
    background: var(--black-disc);
    box-shadow: inset 0 0 0 1px var(--black-ring);
  }
}

@keyframes flip-to-white {
  0% {
    transform: scaleX(1);
    background: var(--black-disc);
    box-shadow: inset 0 0 0 1px var(--black-ring);
  }
  50% {
    transform: scaleX(0.05);
    background: var(--black-disc);
    box-shadow: inset 0 0 0 1px var(--black-ring);
  }
  51% {
    transform: scaleX(0.05);
    background: var(--white-disc);
    box-shadow: none;
  }
  100% {
    transform: scaleX(1);
    background: var(--white-disc);
    box-shadow: none;
  }
}

.controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 16px;
}

button,
select {
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 7px 12px;
  font: inherit;
  font-size: 13px;
  cursor: pointer;
}

button:hover:not(:disabled),
select:hover {
  border-color: #33373d;
}

button:disabled {
  color: var(--muted);
  cursor: default;
}

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

label[hidden] {
  display: none;
}

.sims {
  margin-left: auto;
}

.sims b {
  color: var(--text);
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}

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

.eval {
  margin: 0;
  min-height: 1.5em;
  color: var(--muted);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

.bot-warning {
  margin: 0;
  padding: 8px 12px;
  border: 1px solid #a73333;
  border-radius: 4px;
  background: rgba(167, 51, 51, 0.12);
  color: #f06a6a;
  font-size: 13px;
}

.bot-warning[hidden] {
  display: none;
}

.busy .cell.legal {
  cursor: progress;
}

.toggle-fight {
  border-color: #1f8a4c;
  color: #4fd489;
}

.toggle-fight:hover:not(:disabled) {
  border-color: #29a75d;
}

.toggle-fight.running {
  border-color: #a73333;
  color: #f06a6a;
}

.toggle-fight.running:hover {
  border-color: #c23e3e;
}

.arena {
  display: grid;
  grid-template-columns: 180px minmax(0, 1fr) 180px;
  gap: 20px;
  align-items: start;
}

.arena-board {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 0;
}

.fighter {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
}

.fighter h2 {
  margin: 0;
  font-size: 13px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
}

.fighter h2 .disc {
  width: 12px;
  height: 12px;
  border-radius: 50%;
}

.fighter label {
  flex-direction: column;
  align-items: stretch;
  gap: 4px;
}

.fighter select {
  width: 100%;
}

@media (max-width: 680px) {
  .arena {
    grid-template-columns: 1fr;
  }

  .arena-board {
    order: -1;
  }
}

main.landing {
  width: min(92vw, 640px);
  align-items: center;
  text-align: center;
}

main.landing header {
  max-width: 480px;
}

.game-grid {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 20px;
  width: 100%;
}

.game-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  width: 220px;
  height: 220px;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
  color: var(--text);
  text-decoration: none;
  transition: border-color 0.15s ease, transform 0.15s ease;
}

.game-card:hover,
.game-card:focus-visible {
  border-color: var(--accent);
  transform: translateY(-2px);
  outline: none;
}

.game-icon {
  width: 96px;
  height: 96px;
}

.game-icon svg {
  display: block;
  width: 100%;
  height: 100%;
}

.game-label {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.01em;
}

@media (max-width: 500px) {
  .game-grid {
    flex-direction: column;
    align-items: center;
  }
}

/* The chess page's board is lichess's own chessground library (vendored
   under ./chess/chessground/, see its LICENSE.txt) plus its "brown"
   board / "cburnett" piece CSS -- this wrapper just gives chessground's
   `.cg-wrap` element the concrete size it requires; chessground renders
   everything inside it. */
.cg-board-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 1;
  margin: 22px 0 0 18px;
  box-shadow: 0 2px 14px rgba(0, 0, 0, 0.45);
}

/* Square highlight colors, ported from lichess's own board CSS
   (lila's ui/lib/css/theme/board/_chessground.scss) so a move, capture,
   check, or selection looks exactly like it does on lichess.org. */
.cg-board-wrap square.move-dest {
  background: radial-gradient(rgba(20, 85, 30, 0.5) 19%, rgba(0, 0, 0, 0) 20%);
}

.cg-board-wrap square.move-dest:hover {
  background: rgba(20, 85, 30, 0.3);
}

.cg-board-wrap square.oc.move-dest {
  background: radial-gradient(transparent 0%, transparent 79%, rgba(20, 85, 0, 0.3) 80%);
}

.cg-board-wrap square.last-move {
  background-color: rgba(155, 199, 0, 0.41);
}

.cg-board-wrap square.selected {
  background-color: rgba(20, 85, 30, 0.5);
}

.cg-board-wrap square.check {
  background: radial-gradient(
    ellipse at center,
    rgba(255, 0, 0, 1) 0%,
    rgba(231, 0, 0, 1) 25%,
    rgba(169, 0, 0, 0) 89%,
    rgba(158, 0, 0, 0) 100%
  );
}

.cg-board-wrap coords {
  color: rgba(255, 255, 255, 0.55);
  text-shadow: 0 1px 1px rgba(0, 0, 0, 0.4);
  font-size: 9px;
  font-weight: 600;
}

.busy .cg-board-wrap {
  cursor: progress;
}

.promotion {
  display: flex;
  align-items: center;
  gap: 8px;
  justify-content: center;
}

.promotion[hidden] {
  display: none;
}

.promotion button {
  font-size: 20px;
  line-height: 1;
  padding: 6px 10px;
}
