:root {
  --ink: #24313f;
  --muted: #65717f;
  --panel: #ffffff;
  --line: #d9e4ea;
  --ocean: #146c94;
  --leaf: #2e7d32;
  --leaf-dark: #1b5e20;
  --sun: #f6b333;
  --rose: #e53935;
  --blue: #1e88e5;
  --green: #43a047;
  --purple: #8e24aa;
  --wood: #8d6e63;
  --cream: #fff3d6;
  --yellow: #ffe082;
  --mint: #c8e6c9;
  --sky: #bbdefb;
  --orange: #ffcc80;
  --plum: #5a3f8c;
  --teal: #0e8a83;
  --gold: #ffd166;
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  font-family: "Segoe UI", system-ui, sans-serif;
  background:
    linear-gradient(180deg, rgba(187, 222, 251, 0.9), rgba(244, 251, 248, 0.84) 48%, rgba(255, 243, 214, 0.92)),
    repeating-linear-gradient(90deg, rgba(20, 108, 148, 0.06) 0 2px, transparent 2px 92px),
    #f4fbf8;
  overflow-x: hidden;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  position: relative;
  width: min(1180px, calc(100vw - 28px));
  margin: 0 auto;
  padding: 24px 0;
}

.skyline {
  position: absolute;
  inset: 22px 0 auto;
  height: 165px;
  pointer-events: none;
  z-index: -1;
}

.skyline span {
  position: absolute;
  bottom: 0;
  border-radius: 8px 8px 0 0;
  background: rgba(20, 108, 148, 0.11);
  box-shadow: 0 10px 0 rgba(246, 179, 51, 0.09);
}

.skyline span:nth-child(1) {
  left: 4%;
  width: 22%;
  height: 80px;
}

.skyline span:nth-child(2) {
  left: 35%;
  width: 30%;
  height: 130px;
}

.skyline span:nth-child(3) {
  right: 2%;
  width: 24%;
  height: 100px;
}

.hidden {
  display: none !important;
}

.setup-screen,
.win-screen {
  min-height: calc(100vh - 48px);
  display: grid;
  align-content: center;
  gap: 22px;
}

.brand-panel {
  max-width: 760px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--ocean);
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2 {
  font-family: "Trebuchet MS", "Segoe UI", system-ui, sans-serif;
  margin: 0;
  line-height: 1;
}

h1 {
  font-size: clamp(3rem, 12vw, 7.5rem);
  max-width: 850px;
}

h2 {
  font-size: clamp(2rem, 5vw, 3.6rem);
}

.intro {
  max-width: 640px;
  margin: 16px 0 0;
  color: var(--muted);
  font-size: 1.2rem;
}

.setup-form,
.win-screen {
  border: 2px solid rgba(255, 255, 255, 0.88);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(248, 253, 255, 0.93)),
    var(--panel);
  box-shadow: 0 22px 0 rgba(20, 108, 148, 0.12), 0 28px 70px rgba(36, 49, 63, 0.15);
}

.setup-form {
  width: min(720px, 100%);
  padding: 22px;
  display: grid;
  gap: 18px;
}

.form-row,
.player-row {
  display: grid;
  gap: 8px;
}

label {
  font-weight: 800;
}

input[type="text"],
select {
  width: 100%;
  min-height: 46px;
  border: 2px solid #cddce5;
  border-radius: 8px;
  padding: 0 12px;
  color: var(--ink);
  background: white;
}

.player-fields,
.lobby-list {
  display: grid;
  gap: 12px;
}

.lobby-list {
  min-height: 72px;
}

.lobby-player,
.lobby-empty {
  display: grid;
  grid-template-columns: 34px 1fr auto;
  align-items: center;
  gap: 10px;
  border: 2px solid #dce8ef;
  border-radius: 8px;
  padding: 10px;
  background: rgba(255, 255, 255, 0.78);
}

.lobby-player.ready {
  border-color: rgba(14, 138, 131, 0.55);
  background: #eefcf9;
}

.lobby-player.mine {
  box-shadow: 0 0 0 3px rgba(14, 138, 131, 0.16);
}

.lobby-status {
  color: var(--muted);
  font-weight: 900;
}

.lobby-player.ready .lobby-status {
  color: var(--teal);
}

.lobby-empty {
  grid-template-columns: 1fr;
  color: var(--muted);
  font-weight: 900;
  text-align: center;
}

.player-row {
  grid-template-columns: 1fr 110px;
  align-items: end;
}

.color-select {
  height: 46px;
  border: 2px solid #cddce5;
  border-radius: 8px;
}

.option-grid {
  display: grid;
  gap: 10px;
}

.switch-line {
  display: flex;
  align-items: center;
  gap: 10px;
}

.switch-line input {
  width: 22px;
  height: 22px;
}

.primary-button,
.secondary-button {
  min-height: 48px;
  border-radius: 8px;
  border: 0;
  padding: 0 18px;
  font-weight: 900;
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.primary-button {
  color: #fff;
  background: linear-gradient(180deg, #1783ad, var(--ocean));
  box-shadow: 0 7px 0 #0d4d68;
}

.primary-button:hover {
  transform: translateY(-2px);
  background: linear-gradient(180deg, #1b94c3, #0f5878);
}

.primary-button:disabled {
  cursor: wait;
  opacity: 0.65;
}

.secondary-button {
  border: 2px solid #bfd0da;
  color: var(--ink);
  background: #f8fbfd;
  box-shadow: 0 5px 0 rgba(137, 158, 172, 0.35);
}

.game-layout {
  min-height: calc(100vh - 48px);
  display: grid;
  place-items: center;
}

.board-wrap {
  position: relative;
  width: min(calc(100vh - 48px), 100%);
  max-width: min(940px, calc(100vw - 28px));
  justify-self: center;
}

.board {
  position: relative;
  display: grid;
  grid-template-columns: repeat(10, 1fr);
  aspect-ratio: 1;
  overflow: hidden;
  border: 7px solid #184e77;
  border-radius: 18px;
  background: #fff8e6;
  box-shadow:
    inset 0 0 0 6px rgba(255, 255, 255, 0.72),
    0 12px 0 #0e5b73,
    0 30px 60px rgba(24, 78, 119, 0.2);
  cursor: pointer;
}

.player-list,
.event-toast,
.center-dice {
  position: absolute;
  z-index: 9;
}

.square {
  position: relative;
  display: flex;
  align-items: flex-start;
  justify-content: flex-start;
  min-width: 0;
  min-height: 0;
  border: 1px solid rgba(36, 49, 63, 0.1);
  padding: 5px;
  box-shadow: inset 0 0 18px rgba(255, 255, 255, 0.35);
}

.square::after {
  content: "";
  position: absolute;
  right: 7px;
  bottom: 7px;
  width: 9px;
  aspect-ratio: 1;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.44);
}

.square.special-ladder::before,
.square.special-snake::before,
.square.finish-square::before {
  position: absolute;
  right: 6px;
  top: 5px;
  z-index: 2;
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: white;
  font-size: 0.8rem;
  font-weight: 900;
  box-shadow: 0 2px 6px rgba(36, 49, 63, 0.22);
}

.square.special-ladder::before {
  content: "+";
  background: var(--teal);
}

.square.special-snake::before {
  content: "!";
  background: var(--rose);
}

.square.finish-square::before {
  content: "100";
  width: 34px;
  border-radius: 999px;
  background: var(--plum);
  font-size: 0.68rem;
}

.square-number {
  position: relative;
  z-index: 2;
  font-size: clamp(0.62rem, 1.5vw, 0.9rem);
  font-weight: 900;
  color: rgba(36, 49, 63, 0.64);
}

.path-layer {
  position: absolute;
  inset: 0;
  z-index: 3;
  pointer-events: none;
}

.snake-body {
  fill: none;
  stroke: var(--leaf);
  stroke-width: 21;
  stroke-linecap: round;
  filter: drop-shadow(0 5px 0 var(--leaf-dark));
}

.snake-belly {
  fill: none;
  stroke: rgba(255, 255, 255, 0.48);
  stroke-width: 7;
  stroke-linecap: round;
}

.snake-head {
  fill: var(--leaf);
  stroke: var(--leaf-dark);
  stroke-width: 4;
}

.snake-eye {
  fill: white;
  stroke: #12351a;
  stroke-width: 2;
}

.snake-tongue {
  stroke: #d32f2f;
  stroke-width: 4;
  stroke-linecap: round;
}

.ladder-side {
  stroke: var(--wood);
  stroke-width: 13;
  stroke-linecap: round;
  filter: drop-shadow(0 4px 0 rgba(81, 55, 42, 0.25));
}

.ladder-rung {
  stroke: #d7ccc8;
  stroke-width: 7;
  stroke-linecap: round;
}

.ladder-glow {
  stroke: rgba(255, 209, 102, 0.75);
  stroke-width: 28;
  stroke-linecap: round;
  opacity: 0.5;
}

.tokens {
  position: absolute;
  inset: 22px 5px 5px;
  z-index: 5;
  display: flex;
  flex-wrap: wrap;
  align-content: flex-end;
  align-items: flex-end;
  gap: 2px;
}

.token {
  position: relative;
  width: clamp(18px, 45%, 30px);
  aspect-ratio: 1;
  border: 3px solid white;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: white;
  font-size: clamp(0.58rem, 1.35vw, 0.78rem);
  font-weight: 900;
  box-shadow: inset 0 7px 8px rgba(255, 255, 255, 0.25), 0 4px 0 rgba(36, 49, 63, 0.24), 0 7px 12px rgba(36, 49, 63, 0.25);
  animation: token-pop 0.28s ease;
}

.token::after {
  content: "";
  position: absolute;
  width: 28%;
  aspect-ratio: 1;
  border-radius: 50%;
  top: 18%;
  left: 22%;
  background: rgba(255, 255, 255, 0.6);
}

@keyframes token-pop {
  0% { transform: scale(0.76); }
  80% { transform: scale(1.12); }
  100% { transform: scale(1); }
}

.dice {
  width: clamp(92px, 19%, 150px);
  aspect-ratio: 1;
  justify-self: center;
  border: 5px solid #424242;
  border-radius: 22px;
  background:
    radial-gradient(circle at 28% 22%, rgba(255, 255, 255, 0.95), transparent 28%),
    linear-gradient(145deg, #ffffff, #f1f3f5);
  color: #111;
  box-shadow: 0 12px 0 #c5cbd1, 0 20px 28px rgba(66, 66, 66, 0.18);
}

.center-dice {
  left: 50%;
  top: 50%;
  z-index: 14;
  transform: translate(-50%, -50%);
  pointer-events: none;
}

.dice-face {
  position: relative;
  display: grid;
  width: 100%;
  height: 100%;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  padding: 20px;
}

.pip {
  width: 18px;
  aspect-ratio: 1;
  align-self: center;
  justify-self: center;
  border-radius: 50%;
  background: #20252b;
  box-shadow: inset 0 3px 0 rgba(255, 255, 255, 0.16);
}

.dice.rolling {
  animation: center-dice-roll 0.45s ease-in-out infinite;
}

@keyframes center-dice-roll {
  0%, 100% { transform: translate(-50%, -50%) rotate(0deg) scale(1); }
  25% { transform: translate(calc(-50% - 5px), -50%) rotate(-8deg) scale(1.04); }
  75% { transform: translate(calc(-50% + 5px), -50%) rotate(8deg) scale(1.04); }
}

.player-list {
  left: 10px;
  right: 10px;
  top: 10px;
  display: flex;
  justify-content: center;
  flex-wrap: nowrap;
  gap: 7px;
  pointer-events: none;
}

.player-card {
  display: flex;
  align-items: center;
  gap: 7px;
  border: 2px solid rgba(255, 255, 255, 0.82);
  border-radius: 999px;
  padding: 6px 10px;
  overflow: hidden;
  flex: 0 1 auto;
  max-width: 25%;
  background: rgba(251, 253, 255, 0.86);
  box-shadow: 0 8px 16px rgba(36, 49, 63, 0.12);
}

.player-card.active {
  outline: 3px solid rgba(246, 179, 51, 0.72);
  background: #fff9e8;
}

.player-card.claimed {
  border-color: rgba(36, 49, 63, 0.28);
}

.player-card.mine {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(14, 138, 131, 0.22), 0 8px 16px rgba(36, 49, 63, 0.12);
}

.mini-token {
  width: 24px;
  flex: 0 0 auto;
  aspect-ratio: 1;
  border-radius: 50%;
  border: 3px solid white;
  box-shadow: 0 2px 5px rgba(36, 49, 63, 0.25);
}

.player-meta {
  min-width: 0;
}

.player-meta strong {
  display: block;
  overflow: hidden;
  color: var(--ink);
  font-size: clamp(0.68rem, 1.6vw, 0.9rem);
  font-weight: 900;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.position-label {
  color: var(--muted);
  flex: 0 0 auto;
  font-size: clamp(0.64rem, 1.4vw, 0.82rem);
  font-weight: 900;
}

.event-toast {
  left: 50%;
  top: 50%;
  z-index: 12;
  min-width: min(360px, 86%);
  transform: translate(-50%, -50%);
  border: 3px solid white;
  border-radius: 999px;
  padding: 13px 18px;
  color: white;
  background: var(--ocean);
  text-align: center;
  font-weight: 900;
  box-shadow: 0 8px 0 rgba(36, 49, 63, 0.18), 0 16px 32px rgba(36, 49, 63, 0.18);
  animation: toast-pop 0.28s ease;
  pointer-events: none;
}

.event-toast.ladder {
  background: var(--teal);
}

.event-toast.snake {
  background: var(--rose);
}

.event-toast.bonus {
  color: #563b00;
  background: var(--gold);
}

@keyframes toast-pop {
  0% { transform: translate(-50%, calc(-50% + 16px)) scale(0.9); opacity: 0; }
  100% { transform: translate(-50%, -50%) scale(1); opacity: 1; }
}

.control-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.centered {
  max-width: 420px;
  margin-top: 22px;
}

.win-screen {
  padding: 34px;
  justify-items: start;
}

.winner-token {
  width: 84px;
  aspect-ratio: 1;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: white;
  border: 5px solid white;
  font-size: 2.2rem;
  font-weight: 900;
  box-shadow: inset 0 10px 12px rgba(255, 255, 255, 0.25), 0 10px 28px rgba(36, 49, 63, 0.2);
  animation: winner-bounce 1s ease infinite alternate;
}

@keyframes winner-bounce {
  from { transform: translateY(0); }
  to { transform: translateY(-8px); }
}

.confetti {
  position: fixed;
  top: -20px;
  width: 10px;
  height: 16px;
  border-radius: 2px;
  animation: fall 1.8s linear forwards;
  z-index: 20;
}

@keyframes fall {
  to {
    transform: translateY(110vh) rotate(560deg);
    opacity: 0.7;
  }
}

@media (max-width: 880px) {
  .game-layout {
    align-items: center;
  }

  .board-wrap {
    width: min(100%, calc(100vh - 24px));
  }
}

@media (max-width: 560px) {
  .app-shell {
    width: min(100vw - 16px, 520px);
    padding: 8px 0 18px;
  }

  .setup-screen,
  .win-screen {
    min-height: calc(100vh - 26px);
  }

  .setup-form,
  .win-screen {
    padding: 14px;
  }

  .player-row {
    grid-template-columns: 1fr;
  }

  .board {
    border-width: 3px;
  }

  .square {
    padding: 3px;
  }

  .tokens {
    inset: 18px 2px 2px;
  }

  .dice-face {
    padding: 14px;
  }

  .pip {
    width: 10px;
  }

  .player-list {
    left: 5px;
    right: 5px;
    top: 5px;
    gap: 3px;
  }

  .player-card {
    gap: 4px;
    padding: 4px 6px;
    font-size: 0.62rem;
    max-width: 25%;
  }

  .mini-token {
    width: 16px;
    border-width: 2px;
  }

  .position-label {
    display: none;
  }

  .event-toast {
    min-width: min(270px, 86%);
    padding: 9px 12px;
    font-size: 0.78rem;
  }
}
