:root {
  --bg-a: #0f1c29;
  --bg-b: #1a2c3d;
  --panel: rgba(8, 17, 27, 0.82);
  --border: rgba(140, 179, 204, 0.35);
  --text: #eef8fe;
  --muted: #9eb5c6;
  --accent: #f8b66d;
  --accent-2: #74ddc8;
  --red-piece: #ad615c;
  --black-piece: #3f5569;
  --light-square: #d7c8b3;
  --wood-mid: #b29273;
  --dark-square: #7a5438;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  font-family: "Space Grotesk", "Trebuchet MS", sans-serif;
  background:
    radial-gradient(circle at 18% 9%, #27445c 0%, transparent 34%),
    radial-gradient(circle at 86% 92%, #35506d 0%, transparent 36%),
    linear-gradient(145deg, var(--bg-a), var(--bg-b));
}

.checkers-page {
  width: min(1040px, 94vw);
  margin: 0 auto;
  padding: 1.2rem 0 2.2rem;
}

.topbar,
.controls,
.status-grid,
.board-wrap,
.log-wrap {
  border: 1px solid var(--border);
  border-radius: 1rem;
  background: var(--panel);
}

.topbar {
  padding: 1rem;
}

.back-link {
  color: var(--accent-2);
  text-decoration: none;
}

.back-link:hover,
.back-link:focus-visible {
  text-decoration: underline;
}

.topbar h1 {
  margin: 0.35rem 0 0;
  font-size: clamp(1.9rem, 5vw, 2.8rem);
  font-family: "Fraunces", Georgia, serif;
}

.topbar p {
  margin: 0.42rem 0 0;
  color: var(--muted);
}

.controls {
  margin-top: 0.8rem;
  padding: 0.85rem 1rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.6rem;
}

.controls label {
  color: var(--muted);
  font-size: 0.9rem;
}

select,
button {
  border: 0;
  border-radius: 0.6rem;
  font-family: inherit;
}

select {
  background: #203446;
  color: var(--text);
  padding: 0.52rem 0.65rem;
}

button {
  background: linear-gradient(135deg, #ffc88f, #f7a95f);
  color: #08131d;
  font-weight: 700;
  padding: 0.54rem 0.82rem;
  cursor: pointer;
}

button.secondary {
  background: linear-gradient(135deg, #2f475e, #253849);
  color: #d8e8f4;
}

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.status-grid {
  margin-top: 0.8rem;
  padding: 0.8rem 1rem;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.65rem;
}

.status-item {
  border: 1px solid rgba(145, 180, 202, 0.28);
  border-radius: 0.7rem;
  padding: 0.58rem 0.7rem;
  display: grid;
  gap: 0.2rem;
}

.status-item.wide {
  grid-column: span 1;
}

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

.board-wrap {
  margin-top: 0.8rem;
  padding: 1rem;
  display: grid;
  place-items: center;
}

.board-shell {
  width: min(94vw, 700px);
}

.board-row {
  display: grid;
  grid-template-columns: 1.4rem minmax(0, 1fr) 1.4rem;
  align-items: center;
  gap: 0.32rem;
}

.files {
  margin: 0 1.72rem;
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  color: #97acbc;
  font-size: 0.8rem;
  letter-spacing: 0.02em;
}

.files.top {
  margin-bottom: 0.28rem;
}

.files.bottom {
  margin-top: 0.28rem;
}

.files span,
.ranks span {
  display: grid;
  place-items: center;
}

.ranks {
  display: grid;
  grid-template-rows: repeat(8, 1fr);
  align-self: stretch;
  color: #97acbc;
  font-size: 0.8rem;
}

.files span,
.ranks span {
  opacity: 0.88;
  transition: opacity 140ms ease, color 140ms ease;
}

.files span.is-dim,
.ranks span.is-dim {
  opacity: 0.24;
}

.files span.is-active,
.ranks span.is-active {
  color: #d8e8f4;
  opacity: 1;
}

.board {
  width: 100%;
  max-width: 640px;
  aspect-ratio: 1;
  border-radius: 0.8rem;
  overflow: hidden;
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  grid-template-rows: repeat(8, 1fr);
  border: 1px solid rgba(24, 36, 49, 0.72);
  box-shadow:
    0 8px 16px rgba(0, 0, 0, 0.2),
    inset 0 0 0 1px rgba(246, 233, 214, 0.05);
}

.square {
  border: 0;
  position: relative;
  display: grid;
  place-items: center;
  padding: 0;
  width: 100%;
  height: 100%;
  border-radius: 0;
  appearance: none;
}

.square:disabled {
  opacity: 1;
  filter: none;
  -webkit-text-fill-color: inherit;
}

.square.light {
  background: linear-gradient(160deg, #dfd0bc, var(--light-square) 52%, #ccb9a2);
}

.square.dark {
  background: linear-gradient(160deg, #8d6547, var(--dark-square) 52%, #6b4a32);
}

.square.playable {
  cursor: pointer;
}

.square.selected::after {
  content: "";
  position: absolute;
  inset: 5%;
  border: 3px solid rgba(156, 214, 201, 0.9);
  border-radius: 0.35rem;
  box-shadow: 0 0 0 2px rgba(20, 31, 44, 0.44);
}

.square.move-target::before {
  content: "";
  position: absolute;
  inset: 16%;
  border-radius: 0.28rem;
}

.square.move-target.target-red::before {
  background: rgba(123, 177, 166, 0.34);
  box-shadow: inset 0 0 0 2px rgba(173, 214, 205, 0.56);
}

.square.move-target.target-black::before {
  background: rgba(123, 177, 166, 0.34);
  box-shadow: inset 0 0 0 2px rgba(173, 214, 205, 0.56);
}

.piece {
  width: 74%;
  aspect-ratio: 1;
  border-radius: 999px;
  position: relative;
  border: 2px solid rgba(23, 34, 45, 0.5);
  box-shadow:
    0 5px 9px rgba(0, 0, 0, 0.27),
    inset 0 1px 0 rgba(255, 255, 255, 0.08);
  display: grid;
  place-items: center;
  animation: none;
}

.piece.red {
  background: linear-gradient(160deg, #bf7b75, var(--red-piece));
  border-color: rgba(87, 46, 43, 0.58);
}

.piece.black {
  background: linear-gradient(160deg, #657d92, var(--black-piece));
  border-color: rgba(181, 202, 220, 0.5);
  box-shadow:
    0 5px 9px rgba(0, 0, 0, 0.31),
    inset 0 1px 0 rgba(255, 255, 255, 0.12);
}

.piece.active-turn.red {
  box-shadow:
    0 0 0 2px rgba(207, 222, 233, 0.72),
    0 5px 9px rgba(0, 0, 0, 0.3);
  animation: none;
}

.piece.active-turn.black {
  box-shadow:
    0 0 0 2px rgba(207, 222, 233, 0.72),
    0 5px 9px rgba(0, 0, 0, 0.3);
  animation: none;
}

.piece.king::before {
  content: "";
  position: absolute;
  width: 56%;
  height: 56%;
  border-radius: 999px;
  border: 2px solid rgba(244, 226, 184, 0.62);
}

.piece.king::after {
  content: "♔";
  font-size: clamp(14px, 2.2vw, 22px);
  color: #f8e7b7;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.45);
}

.log-wrap {
  margin-top: 0.8rem;
  padding: 0.8rem 1rem;
}

.log-wrap h2 {
  margin: 0 0 0.5rem;
  font-size: 1rem;
}

#move-log {
  margin: 0;
  padding-left: 1rem;
  max-height: 210px;
  overflow-y: auto;
  color: var(--muted);
  line-height: 1.35;
}

@keyframes pop-in {
  from {
    transform: scale(0.84);
    opacity: 0.6;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}

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

  .board-row {
    grid-template-columns: 1.1rem minmax(0, 1fr) 1.1rem;
    gap: 0.24rem;
  }

  .files {
    margin: 0 1.34rem;
    font-size: 0.74rem;
  }

  .ranks {
    font-size: 0.74rem;
  }
}
