:root {
  --ink: #1f2933;
  --wood: #e8bd77;
  --line: #7b4f25;
  --black: #15191f;
  --white: #f7fafc;
  --accent: #0f8b8d;
}

* {
  box-sizing: border-box;
}

.hidden {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: #fbf7ef;
  font-family: Arial, Helvetica, sans-serif;
}

.game {
  position: relative;
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 16px;
  min-height: 100vh;
  padding: 22px;
}

header,
footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

footer {
  flex-wrap: wrap;
}

.header-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

h1,
p {
  margin: 0;
}

#contextLabel {
  margin-bottom: 4px;
  color: #667085;
  font-size: 13px;
}

.status-block {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.captures {
  color: #667085;
  font-size: 13px;
  font-weight: 700;
}

.player-color {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 6px 10px;
  border: 1px solid #d6a765;
  border-radius: 8px;
  color: #4f3420;
  background: #fff8ec;
  font-size: 14px;
  font-weight: 700;
  white-space: nowrap;
}

.player-color::before {
  content: "";
  width: 14px;
  height: 14px;
  margin-right: 8px;
  border-radius: 50%;
  background: #d6a765;
}

.player-color[data-color="black"]::before {
  background: var(--black);
}

.player-color[data-color="white"]::before {
  border: 1px solid #cbd5e1;
  background: var(--white);
}

button {
  min-height: 40px;
  border: 0;
  border-radius: 8px;
  padding: 10px 14px;
  color: white;
  background: var(--accent);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

button:disabled {
  background: #a3aab5;
  cursor: not-allowed;
}

#resignButton {
  background: #b3441f;
}

#resignButton:disabled {
  background: #a3aab5;
}

.board {
  --grid-line: rgba(123, 79, 37, 0.72);
  position: relative;
  align-self: center;
  justify-self: center;
  display: grid;
  grid-template-columns: repeat(19, minmax(14px, 1fr));
  width: min(94vmin, 720px);
  aspect-ratio: 1;
  padding: 8px;
  border: 3px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(to right, transparent calc(50% - 0.5px), var(--grid-line) calc(50% - 0.5px), var(--grid-line) calc(50% + 0.5px), transparent calc(50% + 0.5px)) 0 0 / calc(100% / 19) 100% repeat-x,
    linear-gradient(to bottom, transparent calc(50% - 0.5px), var(--grid-line) calc(50% - 0.5px), var(--grid-line) calc(50% + 0.5px), transparent calc(50% + 0.5px)) 0 0 / 100% calc(100% / 19) repeat-y,
    var(--wood);
  background-clip: content-box, content-box, border-box;
  background-origin: content-box, content-box, border-box;
  box-shadow: 0 18px 40px rgba(31, 41, 51, 0.18);
}

.cell,
.cell:disabled {
  position: relative;
  min-width: 0;
  min-height: 0;
  background: transparent;
  padding: 0;
  border-radius: 0;
  cursor: default;
}

.cell.star::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  z-index: 0;
  width: 16%;
  height: 16%;
  border-radius: 50%;
  background: var(--line);
  transform: translate(-50%, -50%);
  pointer-events: none;
}

.cell::after {
  content: "";
  position: absolute;
  inset: 10%;
  z-index: 1;
  border-radius: 50%;
}

.cell.black::after {
  background: radial-gradient(circle at 35% 30%, #4b5563, var(--black) 60%);
  box-shadow: 0 2px 3px rgba(0, 0, 0, 0.4);
}

.cell.white::after {
  border: 1px solid #cbd5e1;
  background: radial-gradient(circle at 35% 30%, white, var(--white) 70%);
  box-shadow: 0 2px 3px rgba(0, 0, 0, 0.25);
}

.cell.last-move::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  z-index: 2;
  width: 22%;
  height: 22%;
  border-radius: 50%;
  background: #ef233c;
  transform: translate(-50%, -50%);
  pointer-events: none;
}

.board[data-current="black"] .cell:not(:disabled):hover::after {
  z-index: 1;
  background: rgba(21, 25, 31, 0.35);
}

.board[data-current="white"] .cell:not(:disabled):hover::after {
  z-index: 1;
  background: rgba(247, 250, 252, 0.55);
  border: 1px solid rgba(203, 213, 225, 0.7);
}

.result-overlay {
  position: fixed;
  top: 50%;
  left: 50%;
  z-index: 10;
  display: grid;
  gap: 10px;
  min-width: min(78vw, 340px);
  padding: 26px 32px;
  border: 2px solid #facc15;
  border-radius: 8px;
  color: #111827;
  background: rgba(255, 248, 236, 0.96);
  box-shadow: 0 24px 60px rgba(31, 41, 51, 0.3);
  text-align: center;
  transform: translate(-50%, -50%);
  pointer-events: none;
}

.result-overlay.hidden {
  display: none;
}

.result-message {
  color: #0f766e;
  font-size: clamp(44px, 10vmin, 84px);
  font-weight: 900;
  line-height: 1;
}

.result-score {
  color: #4f3420;
  font-size: 16px;
  font-weight: 700;
}

@media (max-width: 620px) {
  .game {
    padding: 14px;
  }

  header {
    align-items: flex-start;
    flex-direction: column;
  }

  footer {
    flex-direction: column;
    align-items: flex-start;
  }
}
