@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;600;700&family=Playfair+Display:wght@600;700&display=swap');

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --cream: #f8efdc;
  --brown: #4b2d20;
  --brown-light: #76523d;
  --wood: #71452d;
  --light-cell: #efd49b;
  --dark-cell: #986844;
  --red: #b52d3b;
  --red-light: #ff858b;
  --blue: #2865a7;
  --blue-light: #78b5f5;
  --gold: #e0ad4f;
}

body {
  min-height: 100vh;
  padding: 25px;

  display: flex;
  justify-content: center;
  align-items: center;

  font-family: "DM Sans", sans-serif;
  color: var(--brown);

  background:
    radial-gradient(
      circle at 10% 10%,
      #fff7df,
      transparent 35%
    ),
    linear-gradient(
      135deg,
      #e7d1ac,
      #c4a47b
    );
}

.game-container {
  width: min(900px, 100%);

  padding: 30px;

  border-radius: 30px;

  background: rgba(255,255,255,.45);

  backdrop-filter: blur(18px);

  border: 1px solid rgba(255,255,255,.6);

  box-shadow:
    0 30px 70px rgba(62,38,24,.25);
}

/* HEADER */

header {
  text-align: center;
  margin-bottom: 25px;
}

.label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 4px;
  color: var(--brown-light);
}

h1 {
  margin-top: 7px;

  font-family: "Playfair Display", serif;

  font-size: clamp(40px, 7vw, 64px);

  line-height: 1;
}

header p {
  margin-top: 8px;

  color: var(--brown-light);

  font-size: 14px;
}

/* INFO */

.game-info {
  display: grid;

  grid-template-columns: 1fr auto 1fr;

  align-items: center;

  gap: 15px;

  margin-bottom: 22px;
}

.player {
  display: flex;

  align-items: center;

  gap: 10px;

  padding: 12px 15px;

  border-radius: 17px;

  background: rgba(255,255,255,.55);

  box-shadow: 0 8px 20px rgba(70,40,20,.07);
}

.player b,
.player small {
  display: block;
}

.player small {
  font-size: 10px;
  color: #8b7567;
}

.player b {
  margin-top: 2px;
  font-size: 15px;
}

.player strong {
  margin-left: auto;
  font-size: 20px;
}

.dot {
  width: 30px;
  height: 30px;

  flex-shrink: 0;

  border-radius: 50%;

  box-shadow:
    inset 3px 3px 5px rgba(255,255,255,.4),
    inset -4px -4px 6px rgba(0,0,0,.25);
}

.dot.red {
  background:
    radial-gradient(
      circle at 30% 25%,
      var(--red-light),
      var(--red)
    );
}

.dot.blue {
  background:
    radial-gradient(
      circle at 30% 25%,
      var(--blue-light),
      var(--blue)
    );
}

.turn {
  padding: 11px 18px;

  border-radius: 50px;

  background: var(--brown);

  color: white;

  font-size: 13px;

  font-weight: 700;

  white-space: nowrap;
}

/* BOARD */

main {
  display: flex;
  justify-content: center;
}

.board {
  width: min(650px, 100%);

  aspect-ratio: 1;

  display: grid;

  grid-template-columns: repeat(8, 1fr);

  padding: 10px;

  border-radius: 22px;

  background:
    linear-gradient(
      135deg,
      #5b3423,
      #321e16
    );

  box-shadow:
    0 20px 40px rgba(50,30,18,.3);
}

.cell {
  position: relative;

  display: flex;

  justify-content: center;
  align-items: center;

  cursor: pointer;

  transition: .2s;
}

.cell:nth-child(odd) {
  background: var(--light-cell);
}

.cell:nth-child(even) {
  background: var(--dark-cell);
}

.cell:hover {
  filter: brightness(1.12);
}

.cell.selected {
  box-shadow:
    inset 0 0 0 5px var(--gold);
}

.cell.valid::after {
  content: "";

  position: absolute;

  width: 22%;
  aspect-ratio: 1;

  border-radius: 50%;

  background: rgba(255,255,255,.7);

  animation: pulse 1s infinite;
}

@keyframes pulse {
  50% {
    transform: scale(1.3);
    opacity: .4;
  }
}

/* PIECES */

.piece {
  width: 67%;
  aspect-ratio: 1;

  position: relative;
  z-index: 2;

  border-radius: 50%;

  box-shadow:
    inset 6px 6px 8px rgba(255,255,255,.4),
    inset -7px -8px 10px rgba(0,0,0,.3),
    0 6px 12px rgba(0,0,0,.3);

  transition: .2s;
}

.piece:hover {
  transform: translateY(-4px) scale(1.06);
}

.piece.red {
  background:
    radial-gradient(
      circle at 30% 25%,
      #ff9b9f,
      var(--red) 60%,
      #721d28
    );
}

.piece.blue {
  background:
    radial-gradient(
      circle at 30% 25%,
      #a7d1ff,
      var(--blue) 60%,
      #193e6d
    );
}

.piece.king::after {
  content: "♛";

  position: absolute;
  inset: 0;

  display: flex;
  justify-content: center;
  align-items: center;

  color: #ffe79a;

  font-size: clamp(16px, 3vw, 30px);

  text-shadow:
    0 2px 3px rgba(0,0,0,.5);
}

/* MESSAGE */

.message {
  margin-top: 18px;

  text-align: center;

  color: var(--brown-light);

  font-size: 13px;
  font-weight: 600;
}

/* BUTTON */

.buttons {
  display: flex;

  justify-content: center;

  gap: 10px;

  margin-top: 17px;
}

button {
  padding: 12px 20px;

  border: none;

  border-radius: 50px;

  font-family: inherit;

  font-weight: 700;

  cursor: pointer;

  transition: .2s;
}

#resetBtn,
#playAgain {
  background: var(--brown);

  color: white;
}

#undoBtn {
  background: rgba(255,255,255,.75);

  color: var(--brown);
}

button:hover {
  transform: translateY(-3px);

  box-shadow:
    0 8px 20px rgba(60,35,20,.2);
}

button:active {
  transform: scale(.96);
}

/* MODAL */

.modal {
  position: fixed;
  inset: 0;

  display: none;

  justify-content: center;
  align-items: center;

  padding: 20px;

  background: rgba(40,25,15,.65);

  backdrop-filter: blur(8px);

  z-index: 100;
}

.modal.show {
  display: flex;
}

.modal-box {
  width: min(380px, 100%);

  padding: 35px;

  text-align: center;

  border-radius: 25px;

  background: var(--cream);

  box-shadow:
    0 30px 70px rgba(0,0,0,.3);

  animation: popup .3s ease;
}

.trophy {
  font-size: 60px;
  margin-bottom: 10px;
}

.modal-box h2 {
  font-family: "Playfair Display", serif;
  font-size: 32px;
}

.modal-box p {
  margin: 10px 0 20px;

  color: var(--brown-light);
}

@keyframes popup {
  from {
    transform: scale(.7);
    opacity: 0;
  }

  to {
    transform: scale(1);
    opacity: 1;
  }
}

/* RESPONSIVE */

@media (max-width: 650px) {

  body {
    padding: 10px;
  }

  .game-container {
    padding: 18px 12px;
    border-radius: 22px;
  }

  .game-info {
    grid-template-columns: 1fr 1fr;
  }

  .turn {
    grid-column: 1 / -1;
    grid-row: 1;
    justify-self: center;
  }

  .player {
    padding: 10px;
  }

  .board {
    padding: 6px;
    border-radius: 15px;
  }

  .buttons button {
    flex: 1;
  }
}
