* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  font-family: Arial, Helvetica, sans-serif;
  color: #f6f0e6;
  background:
    linear-gradient(rgba(18, 17, 16, 0.74), rgba(18, 17, 16, 0.9)),
    radial-gradient(circle at top, #75583d, transparent 36%),
    #161412;
  -webkit-tap-highlight-color: transparent;
}

.game-shell {
  width: min(100%, 920px);
  min-height: 100vh;
  margin: 0 auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 22px;
}

.topbar {
  display: grid;
  grid-template-columns: 96px 1fr 96px;
  align-items: center;
  gap: 16px;
}

.title-block {
  text-align: center;
}

h1 {
  margin: 0;
  font-size: clamp(2rem, 6vw, 4rem);
}

#status {
  min-height: 28px;
  margin: 6px 0 0;
  color: #d6c3a4;
  font-weight: 700;
}

.back-link,
#resetBtn {
  min-height: 42px;
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-radius: 8px;
  color: #f6f0e6;
  background: rgba(31, 29, 26, 0.78);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  touch-action: manipulation;
  user-select: none;
}

.back-link:hover,
#resetBtn:hover {
  background: rgba(91, 71, 48, 0.9);
}

.board-wrap {
  margin: 0 auto;
  padding: clamp(10px, 2vw, 18px);
  border-radius: 8px;
  background: linear-gradient(135deg, #5d3921, #231713);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.46), inset 0 0 0 2px rgba(255, 255, 255, 0.08);
}

#board {
  width: min(86vw, 78vh, 660px);
  aspect-ratio: 1;
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  grid-template-rows: repeat(8, 1fr);
  border: 3px solid #1f150e;
  touch-action: manipulation;
  user-select: none;
}

.cell {
  position: relative;
  width: 100%;
  aspect-ratio: 1;
  border: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  touch-action: manipulation;
}

.light-cell {
  background: linear-gradient(135deg, #e8d3ac, #c8a16a);
}

.dark-cell {
  background: linear-gradient(135deg, #664126, #321f17);
}

.piece {
  width: 74%;
  aspect-ratio: 1;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-weight: 900;
  font-size: clamp(1rem, 3vw, 1.7rem);
  box-shadow:
    inset 0 8px 10px rgba(255, 255, 255, 0.2),
    inset 0 -10px 14px rgba(0, 0, 0, 0.32),
    0 10px 12px rgba(0, 0, 0, 0.32);
}

.dark-piece {
  color: #ffe6b0;
  background: radial-gradient(circle at 35% 25%, #c94f47, #721c19 70%);
}

.light-piece {
  color: #5a251f;
  background: radial-gradient(circle at 35% 25%, #fff8e8, #d6c49f 72%);
}

.king {
  border: 3px solid rgba(255, 221, 128, 0.9);
}

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

.move-target::after {
  content: "";
  position: absolute;
  width: 30%;
  aspect-ratio: 1;
  border-radius: 50%;
  background: rgba(246, 211, 101, 0.75);
  box-shadow: 0 0 18px rgba(246, 211, 101, 0.6);
}

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

  .topbar {
    grid-template-columns: 1fr 1fr;
  }

  .title-block {
    grid-column: 1 / -1;
    grid-row: 1;
  }

  .back-link,
  #resetBtn {
    grid-row: 2;
  }

  #board {
    width: min(92vw, 72vh);
  }
}
