* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --board-size: min(94vw, calc(100vh - 250px), 615px);
  --cell-size: calc(var(--board-size) / 10);
  --token-size: calc(var(--cell-size) * 0.78);
}

body {
  min-height: 100vh;
  display: grid;
  place-items: center;
  overflow-x: hidden;
  padding: 18px 12px;
  font-family: Arial, Helvetica, sans-serif;
  color: #f8fafc;
  background:
    radial-gradient(circle at 14% 18%, rgba(34, 197, 94, 0.35), transparent 26rem),
    radial-gradient(circle at 86% 78%, rgba(234, 179, 8, 0.3), transparent 28rem),
    linear-gradient(135deg, #052e16, #164e63 58%, #111827);
}

.game-shell {
  width: min(100%, 760px);
  display: grid;
  justify-items: center;
  gap: 12px;
}

.back-link {
  justify-self: start;
  color: #bbf7d0;
  text-decoration: none;
  font-weight: 800;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 999px;
  padding: 10px 14px;
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(10px);
}

.hero {
  text-align: center;
}

.eyebrow {
  color: #fde68a;
  font-size: 0.78rem;
  font-weight: 900;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

h1 {
  text-align: center;
  font-size: clamp(2rem, 7vw, 4rem);
  line-height: 1;
  text-shadow: 0 12px 28px rgba(0, 0, 0, 0.42);
}

.board-stage {
  display: grid;
  width: min(100%, calc(var(--board-size) + 24px));
  padding: clamp(8px, 2vw, 12px);
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-radius: 28px;
  background: rgba(255, 255, 255, 0.1);
  box-shadow: 0 28px 90px rgba(0, 0, 0, 0.42);
  backdrop-filter: blur(14px);
  animation: boardPop 650ms ease both;
  position: relative;
  overflow: hidden;
  transition: box-shadow 180ms ease, border-color 180ms ease;
}

.board-stage::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 4;
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms ease;
}

.board-stage.ladder-flash {
  border-color: rgba(250, 204, 21, 0.72);
  box-shadow: 0 28px 90px rgba(250, 204, 21, 0.26);
}

.board-stage.ladder-flash::before {
  opacity: 1;
  background:
    radial-gradient(circle at 50% 35%, rgba(250, 204, 21, 0.34), transparent 12rem),
    linear-gradient(135deg, rgba(250, 204, 21, 0.1), transparent);
  animation: sparkleSweep 1.1s ease both;
}

.board-stage.snake-flash {
  border-color: rgba(248, 113, 113, 0.72);
  box-shadow: 0 28px 90px rgba(248, 113, 113, 0.24);
}

.board-stage.snake-flash::before {
  opacity: 1;
  background:
    radial-gradient(circle at 50% 40%, rgba(248, 113, 113, 0.3), transparent 12rem),
    linear-gradient(135deg, rgba(127, 29, 29, 0.15), transparent);
  animation: snakeSweep 1.1s ease both;
}

.cont {
  display: grid;
  grid-template-columns: repeat(10, 1fr);
  width: var(--board-size);
  margin: 0 auto;
  position: relative;
  z-index: 2;
}

.cont div {
  width: var(--cell-size);
  height: var(--cell-size);
  border: 0.2px solid black;
}

#p1,
#p2 {
  width: var(--token-size);
  height: var(--token-size);
  border-radius: 100px;
  background-color: rgb(236, 82, 82);
  position: relative;
  border: max(2px, calc(var(--cell-size) * 0.045)) solid black;
  box-shadow: 0 8px 14px rgba(0, 0, 0, 0.3);
  z-index: 3;
}

#p1 {
  top: 0;
  left: calc(0px - var(--cell-size));
  transition: all linear 0.5s;
  animation: tokenPulse 1.8s ease-in-out infinite;
}

#p2 {
  top: calc(0px - var(--token-size) - 5px);
  left: calc(0px - var(--cell-size));
  transition: all linear 0.5s;
  background-color: rgb(243, 181, 46);
  animation: tokenPulse 1.8s ease-in-out infinite;
  animation-delay: -0.9s;
}

#p1.ladder-boost,
#p2.ladder-boost {
  animation: ladderBoost 1.05s ease both;
}

#p1.snake-hit,
#p2.snake-hit {
  animation: snakeBite 1.05s ease both;
}

.board-stage > img {
  position: relative;
  z-index: 1;
  width: var(--board-size);
  height: var(--board-size);
  margin-inline: auto;
  margin-top: calc(0px - var(--board-size));
  object-fit: cover;
  border-radius: 16px;
  box-shadow: inset 0 0 0 3px rgba(15, 23, 42, 0.16);
}

#diceCont {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font-size: clamp(1rem, 4vw, 1.6rem);
  padding: 12px 14px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 20px;
  background: rgba(15, 23, 42, 0.45);
  box-shadow: 0 18px 42px rgba(0, 0, 0, 0.24);
  backdrop-filter: blur(12px);
  z-index: 99;
}

#dice {
  display: grid;
  place-items: center;
  min-width: 48px;
  min-height: 48px;
  color: #111827;
  background: linear-gradient(135deg, #fef3c7, #f59e0b);
  border-radius: 14px;
  font-weight: 900;
  box-shadow: inset 0 -4px 0 rgba(0, 0, 0, 0.12);
}

#diceBtn {
  z-index: 99;
  padding: 10px 20px;
  cursor: pointer;
  background: linear-gradient(135deg, #22c55e, #16a34a);
  border: 0;
  border-radius: 14px;
  color: white;
  font-weight: 700;
  min-width: 140px;
  box-shadow: 0 12px 26px rgba(34, 197, 94, 0.24);
  transition: transform 160ms ease, box-shadow 160ms ease, filter 160ms ease;
}

#diceBtn:hover {
  transform: translateY(-3px) rotate(-1deg);
  box-shadow: 0 18px 36px rgba(34, 197, 94, 0.32);
  filter: brightness(1.06);
}

#diceBtn:disabled {
  cursor: wait;
  opacity: 0.72;
  transform: none;
}

#eventMessage {
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: 6;
  transform: translate(-50%, -50%) scale(0.86);
  min-width: min(88%, 360px);
  padding: 16px 20px;
  border-radius: 22px;
  color: #111827;
  font-size: clamp(1.1rem, 4vw, 1.8rem);
  font-weight: 900;
  text-align: center;
  letter-spacing: 0.02em;
  opacity: 0;
  pointer-events: none;
  box-shadow: 0 22px 54px rgba(0, 0, 0, 0.34);
}

#eventMessage.show {
  animation: eventPop 1.35s ease both;
}

#eventMessage.ladder {
  background: linear-gradient(135deg, #fef3c7, #f59e0b);
  border: 2px solid rgba(255, 255, 255, 0.82);
}

#eventMessage.snake {
  color: white;
  background: linear-gradient(135deg, #ef4444, #7f1d1d);
  border: 2px solid rgba(254, 202, 202, 0.82);
}

@keyframes boardPop {
  from {
    opacity: 0;
    transform: translateY(24px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes tokenPulse {
  0%, 100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.08);
  }
}

@keyframes ladderBoost {
  0% {
    transform: translateY(0) scale(1);
    box-shadow: 0 8px 14px rgba(0, 0, 0, 0.3);
  }
  35% {
    transform: translateY(-18px) scale(1.18) rotate(-8deg);
    box-shadow: 0 18px 30px rgba(250, 204, 21, 0.42);
  }
  70% {
    transform: translateY(-6px) scale(1.08) rotate(6deg);
  }
  100% {
    transform: translateY(0) scale(1);
    box-shadow: 0 8px 14px rgba(0, 0, 0, 0.3);
  }
}

@keyframes snakeBite {
  0%, 100% {
    transform: translateX(0) scale(1);
  }
  12%, 36%, 60% {
    transform: translateX(-8px) rotate(-8deg) scale(1.04);
  }
  24%, 48%, 72% {
    transform: translateX(8px) rotate(8deg) scale(0.94);
  }
}

@keyframes eventPop {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.7);
  }
  18% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1.06);
  }
  72% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -56%) scale(0.96);
  }
}

@keyframes sparkleSweep {
  0% {
    transform: translateY(18px);
    opacity: 0;
  }
  32% {
    opacity: 1;
  }
  100% {
    transform: translateY(-18px);
    opacity: 0;
  }
}

@keyframes snakeSweep {
  0%, 100% {
    opacity: 0;
    transform: translateX(0);
  }
  20%, 65% {
    opacity: 1;
  }
  35% {
    transform: translateX(-10px);
  }
  55% {
    transform: translateX(10px);
  }
}

@media (max-height: 620px) {
  :root {
    --board-size: min(88vw, calc(100vh - 190px), 615px);
  }

  .game-shell {
    gap: 6px;
  }

  .eyebrow {
    display: none;
  }
}

@media (max-width: 560px) {
  body {
    padding: 12px 8px;
  }

  .board-stage {
    border-radius: 20px;
  }

  #diceCont {
    width: min(100%, 420px);
  }
}
