.game {
  max-width: 540px;
  margin: 28px auto 0;
  text-align: center;
}

.game-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  max-width: 520px;
  margin: 0 auto 12px;
  flex-wrap: wrap;
  text-align: left;
}

.status {
  display: flex;
  align-items: center;
  gap: 7px;
  font-weight: 600;
  font-size: .95em;
}

.status::before {
  content: "";
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex: 0 0 auto;
  background: #f2f2f2;
  border: 1px solid #999;
}

.status.turn-black::before {
  background: #1a1a1a;
  border-color: #777;
}

.status.thinking::before {
  background: #f0b429;
  border-color: #f0b429;
  animation: turn-pulse 1s ease-in-out infinite;
}

.status.win::before {
  background: #D9411E;
  border-color: #D9411E;
}

@keyframes turn-pulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.35); opacity: .55; }
}

.status.win {
  color: #D9411E;
}

.last-move {
  min-height: 1.3em;
  max-width: 520px;
  margin: 0 auto 10px;
  font-size: .8em;
  color: #aaa;
  text-align: left;
}

.score {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: .9em;
  color: #999;
}

.score b {
  color: #eee;
}

.dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  display: inline-block;
}

.dot.white {
  background: #f2f2f2;
  border: 1px solid #999;
}

.dot.black {
  background: #1a1a1a;
  border: 1px solid #000;
}

.board {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  width: 100%;
  max-width: 520px;
  aspect-ratio: 1 / 1;
  margin: 0 auto;
  border: 6px solid #1a1a1a;
  border-radius: 6px;
  overflow: hidden;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .35);
  touch-action: manipulation;
  box-sizing: border-box;
}

.sq {
  position: relative;
  border: 0;
  padding: 0;
  background: transparent;
  min-width: 0;
  cursor: default;
}

.sq.light { background: #e6e0d4; }
.sq.dark  { background: #5a4a3a; }

.sq.movable { cursor: pointer; }

.sq:focus-visible {
  outline: 3px solid #D9411E;
  outline-offset: -3px;
}

.sq.selected {
  box-shadow: inset 0 0 0 4px #D9411E;
}

.sq.last-from {
  outline: 3px solid rgba(255, 209, 102, .45);
  outline-offset: -3px;
}

.sq.last-to {
  outline: 4px solid #ffd166;
  outline-offset: -4px;
}

.sq.last-to::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 2px;
  box-shadow: inset 0 0 16px rgba(255, 209, 102, .35);
  pointer-events: none;
}

.sq.target::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 24%;
  height: 24%;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: rgba(217, 65, 30, .8);
  box-shadow: 0 0 0 3px rgba(217, 65, 30, .25);
  transition: transform .15s;
}

.sq.target.capture::before {
  background: rgba(255, 160, 60, .9);
  box-shadow: 0 0 0 3px rgba(255, 160, 60, .25);
}

.sq.target:hover::before {
  transform: translate(-50%, -50%) scale(1.18);
}

.piece {
  position: absolute;
  inset: 11%;
  border-radius: 50%;
  z-index: 1;
  pointer-events: none;
  display: grid;
  place-items: center;
}

.piece.w {
  background: radial-gradient(circle at 32% 28%, #ffffff, #e8e3d8 62%, #cfc7b7);
  border: 2px solid #8d7c55;
  box-shadow: inset 0 -3px 6px rgba(0, 0, 0, .18), 0 2px 4px rgba(0, 0, 0, .3);
}

.piece.b {
  background: radial-gradient(circle at 32% 28%, #3a3a3a, #1d1d1d 60%, #101010);
  border: 2px solid #000;
  box-shadow: inset 0 2px 4px rgba(255, 255, 255, .12), 0 2px 4px rgba(0, 0, 0, .4);
}

.piece.king::after {
  content: "♛";
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: min(4.2vw, 22px);
  line-height: 1;
  color: #f0b429;
  text-shadow: 0 1px 2px rgba(0, 0, 0, .5);
}

.piece.just-moved {
  animation: piece-pop .35s ease;
}

@keyframes piece-pop {
  0% { transform: scale(.72); }
  60% { transform: scale(1.12); }
  100% { transform: scale(1); }
}

.game-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  max-width: 520px;
  margin: 14px auto 0;
  flex-wrap: wrap;
  text-align: left;
}

.game-actions button {
  background-color: #D9411E;
  color: #fff;
  border: 0;
  border-radius: .25em;
  padding: .65em 1.1em;
  font: 600 .85em 'Source Sans Pro', 'Roboto', sans-serif;
  cursor: pointer;
}

.game-actions button:hover {
  background-color: #FF5A09;
}

.game-actions button:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 2px;
}

.switch {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: .85em;
  color: #bbb;
  cursor: pointer;
}

.switch input {
  accent-color: #D9411E;
  width: 16px;
  height: 16px;
}

.difficulty {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: .85em;
  color: #bbb;
}

.difficulty select {
  background: #1f1f1f;
  color: #eee;
  border: 1px solid #555;
  border-radius: .3em;
  padding: 5px 8px;
  font: inherit;
  font-size: .95em;
  cursor: pointer;
}

.difficulty select:focus-visible {
  outline: 2px solid #D9411E;
  outline-offset: 2px;
}

@media (max-width: 600px) {
  .game { padding: 0 12px; }
  .piece.king::after { font-size: 20px; }
  .game-actions { justify-content: center; }
}
