: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: 18px;
  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;
  gap: 8px;
}

h1,
p {
  margin: 0;
}

h1 {
  font-size: 30px;
}

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

.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 {
  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;
}

.board {
  --board-padding: clamp(12px, 3.2vmin, 28px);
  --grid-line: rgba(123, 79, 37, 0.72);
  position: relative;
  align-self: center;
  justify-self: center;
  display: block;
  width: min(88vmin, 640px);
  aspect-ratio: 1;
  padding: var(--board-padding);
  border: 3px solid var(--line);
  border-radius: 8px;
  background: var(--wood);
  box-shadow: 0 18px 40px rgba(31, 41, 51, 0.18);
}

.board-grid,
.board-points {
  position: absolute;
  inset: var(--board-padding);
}

.board-grid {
  border: 1px solid var(--grid-line);
  background:
    linear-gradient(to right, var(--grid-line) 1px, transparent 1px) 0 0 / calc(100% / 14) 100% repeat-x,
    linear-gradient(to bottom, var(--grid-line) 1px, transparent 1px) 0 0 / 100% calc(100% / 14) repeat-y;
  pointer-events: none;
}

.board-points {
  z-index: 1;
}

.cell {
  position: absolute;
  display: block;
  width: calc(100% / 14);
  height: calc(100% / 14);
  min-width: 0;
  min-height: 0;
  background: transparent;
  padding: 0;
  border-radius: 0;
  transform: translate(-50%, -50%);
  appearance: none;
  -webkit-appearance: none;
}

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

.cell.black::after {
  background: radial-gradient(circle at 35% 30%, #4b5563, var(--black) 60%);
}

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

.cell.last-move::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  z-index: 2;
  width: 18%;
  height: 18%;
  border: 1px solid rgba(255, 255, 255, 0.9);
  border-radius: 50%;
  background: #ef233c;
  box-shadow: 0 1px 3px rgba(31, 41, 51, 0.35);
  transform: translate(-50%, -50%);
  pointer-events: none;
}

.result-overlay {
  position: fixed;
  top: 50%;
  left: 50%;
  z-index: 10;
  display: grid;
  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-burst {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #facc15;
  box-shadow:
    0 -82px 0 #ef4444,
    58px -58px 0 #22c55e,
    82px 0 0 #0ea5e9,
    58px 58px 0 #f97316,
    0 82px 0 #a855f7,
    -58px 58px 0 #14b8a6,
    -82px 0 0 #eab308,
    -58px -58px 0 #ec4899;
  transform: translate(-50%, -50%) scale(0.2);
  animation: burst-pop 1.1s ease-out infinite;
}

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

.result-overlay[data-result="lose"] {
  border-color: #94a3b8;
  background: rgba(248, 250, 252, 0.96);
}

.result-message {
  position: relative;
  z-index: 1;
  color: #0f766e;
  font-size: clamp(48px, 11vmin, 92px);
  font-weight: 900;
  line-height: 1;
}

.result-overlay[data-result="lose"] .result-message {
  color: #475569;
}

@keyframes burst-pop {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.2) rotate(0deg);
  }
  18% {
    opacity: 1;
  }
  68% {
    opacity: 0.95;
    transform: translate(-50%, -50%) scale(1) rotate(20deg);
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(1.18) rotate(32deg);
  }
}
