* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}
body {
  font-family: Arial, sans-serif;
  background-image: url('../bg-snakesandladders.jpg');
  background-size: cover;
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 12px;
  font-size: 13px;
}
.container {
  position: relative;
  background: linear-gradient(135deg, rgba(10, 18, 35, 0.82), rgba(6, 26, 32, 0.65));
  backdrop-filter: blur(7px);
  border-radius: 24px;
  padding: 14px 14px 18px;
  box-shadow: 0 22px 60px rgba(0, 0, 0, 0.42);
  max-width: 1360px;
  width: 100%;
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: #e9edf7;
}
.in-game .container {
  max-width: 980px;
  padding: 10px 12px 12px;
}
.mute-button {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 1000;
  background: rgba(255, 255, 255, 0.9);
  border: none;
  border-radius: 50%;
  font-size: 24px;
  cursor: pointer;
  padding: 12px;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
  transition: all 0.3s ease;
}
.mute-button:hover {
  background: rgba(255, 255, 255, 1);
  transform: scale(1.1);
}
h1 {
  text-align: center;
  color: #1b2458;
  margin: 0;
  font-size: 2rem;
  letter-spacing: 0.03em;
}
.title-wrapper {
  display: flex;
  justify-content: center;
  margin-bottom: 12px;
}
.title-pill {
  position: relative;
  padding: 10px 22px;
  border-radius: 14px;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.8), rgba(214, 223, 255, 0.9));
  box-shadow: 0 8px 20px rgba(33, 40, 82, 0.28), inset 0 1px 0 rgba(255, 255, 255, 0.7);
  border: 1px solid rgba(70, 90, 190, 0.35);
  color: #1b2458;
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.12);
  backdrop-filter: blur(4px);
}
.layout-grid {
  display: grid;
  grid-template-columns: 1.06fr 0.94fr;
  gap: 12px;
  align-items: stretch;
}
.layout-left,
.layout-right {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
  align-self: stretch;
  height: 100%;
}
.layout-left {
  justify-content: space-between;
}
.in-game .layout-grid {
  grid-template-columns: 1fr;
  justify-items: center;
  gap: 10px;
}
.in-game .layout-left,
.in-game .layout-right {
  max-width: 960px;
  width: 100%;
  justify-content: center;
  height: auto;
}
.in-game .board-container {
  max-width: 720px;
  margin: 2px auto 0;
}
.in-game .legend {
  justify-content: center;
  margin: 2px 0 0;
}
.in-game #gameScreen {
  width: min(920px, 100%);
  margin: 0 auto 2px;
}
.in-game .game {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding-bottom: 4px;
}
.in-game .game-info {
  justify-content: center;
  gap: 10px;
}
.in-game .game-footer {
  margin-top: 10px;
}
.board-container {
  position: relative;
  margin: 6px 0 10px;
  width: 100%;
  align-self: stretch;
}
.board {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 0;
  padding: 0;
  border-radius: 18px;
  overflow: hidden;
  background: #f2e3c3 url('../snakesandladders-board.png') center/100% 100% no-repeat;
  position: relative;
  box-shadow: 0 14px 36px rgba(0, 0, 0, 0.35);
  width: 100%;
}
.cell {
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  color: #1f2f1a;
  background: transparent;
  text-shadow: 0 1px 1px rgba(255, 255, 255, 0.7), 0 0 4px rgba(0, 0, 0, 0.28);
  position: relative;
  font-size: 0.82em;
  user-select: none;
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.12s ease, outline 0.12s ease, background 0.12s ease;
}
.cell:hover {
  transform: translateY(-1px);
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.35), 0 3px 8px rgba(0, 0, 0, 0.35);
  outline: 2px solid rgba(102, 126, 234, 0.3);
}
.cell.preview-cell {
  outline: 3px solid rgba(102, 126, 234, 0.95);
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.8) inset;
}
.player-token {
  position: absolute;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 3px solid #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  color: #ffffff;
  font-size: 0.8em;
  z-index: 300;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.45);
  transition: transform 0.25s ease;
  background-position: center;
  background-size: contain;
  background-repeat: no-repeat;
}
.player-token.has-image {
  border: 0;
  box-shadow: none;
  background: none;
  width: 100px;
  height: 100px;
  padding: 0;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  bottom: auto;
  right: auto;
}
.player-token-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  pointer-events: none;
}
.player1-token {
  background: #ff6b6b;
  top: 5px;
  left: 5px;
}
.player2-token {
  background: #4ecdc4;
  bottom: 5px;
  right: 5px;
}
.svg-layer {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 20;
}
.legend {
  display: flex;
  justify-content: flex-start;
  gap: 20px;
  margin: 4px 0 10px;
  font-size: 0.9em;
  align-items: center;
  flex-wrap: wrap;
}
.legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
}
.legend-box {
  width: 20px;
  height: 20px;
  border-radius: 6px;
}
.ladder-box {
  background: linear-gradient(135deg, #2ecc71, #27ae60);
}
.snake-box {
  background: linear-gradient(135deg, #e74c3c, #c0392b);
}
.setup-header {
  margin-bottom: 8px;
}
.setup-title {
  font-size: 1.2rem;
  font-weight: 700;
  color: #e9edff;
  margin-bottom: 2px;
}
.setup-subtitle {
  font-size: 0.95rem;
  color: #c8d1ee;
}
.setup-row {
  display: flex;
  flex-wrap: wrap;
  gap: 22px;
  align-items: stretch;
  justify-content: center;
  margin: 12px 0 10px;
}
.current-piece {
  flex: 1;
  min-width: 280px;
  display: grid;
  grid-template-columns: 92px auto;
  grid-template-rows: auto auto auto;
  align-items: center;
  padding: 20px 24px;
  background: radial-gradient(circle at top left, #ffffff 0%, #f1f2ff 55%, #e3e4ff 100%);
  border-radius: 20px;
  border: 2px solid #cfd1ff;
  box-shadow: 0 12px 26px rgba(61, 64, 148, 0.25);
  gap: 10px 18px;
}
.piece-label {
  grid-column: 1 / -1;
  font-size: 1.2rem;
  font-weight: 700;
  color: #222;
}
.piece-visual {
  width: 80px;
  height: 80px;
  border-radius: 18px;
  background: #ffffff center/70% no-repeat;
  border: 2px solid #dde0ff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 46px;
  box-shadow: inset 0 4px 10px rgba(0, 0, 0, 0.06);
}
.piece-visual.snake-visual {
  background-image: url('../snakesandladders-snake.png');
}
.piece-visual.ladder-visual {
  background-image: url('../snakesandladders-ladder.png');
}
.piece-size {
  font-size: 1.05rem;
  font-weight: 600;
  color: #444;
}
.piece-help {
  grid-column: 1 / -1;
  font-size: 0.86rem;
  color: #666;
  margin-top: 2px;
}
.counts {
  flex: 1;
  min-width: 260px;
  display: grid;
  gap: 14px;
}
.count-line {
  padding: 14px 18px;
  background: rgba(255, 255, 255, 0.9);
  border-radius: 15px;
  border: 2px solid #ececf5;
  font-size: 1rem;
  font-weight: 700;
  color: #3b3b3b;
  box-shadow: 0 10px 22px rgba(29, 32, 80, 0.18);
}
.placement-hint {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 18px;
  background: linear-gradient(135deg, #fff8e8 0%, #eef0ff 100%);
  border: 2px solid #d8dafe;
  border-radius: 18px;
  box-shadow: 0 10px 26px rgba(58, 64, 137, 0.2);
  position: relative;
  overflow: hidden;
  isolation: isolate;
}
.placement-hint::before {
  content: "";
  position: absolute;
  width: 150px;
  height: 150px;
  background: radial-gradient(circle, rgba(102, 126, 234, 0.16) 0%, rgba(102, 126, 234, 0) 65%);
  top: -60px;
  right: -30px;
  transform: rotate(-10deg);
  z-index: 0;
}
.hint-icon {
  width: 56px;
  height: 56px;
  border-radius: 14px;
  background: linear-gradient(135deg, #667eea, #4a5bd0);
  display: grid;
  place-items: center;
  font-size: 26px;
  color: #fff;
  box-shadow: 0 12px 24px rgba(69, 92, 210, 0.35);
  position: relative;
  z-index: 1;
}
.hint-copy {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
  color: #1f2348;
  position: relative;
  z-index: 1;
}
.hint-label {
  font-size: 0.8rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #5b63a3;
}
.hint-text {
  font-size: 1.05rem;
  font-weight: 750;
  color: #161a3a;
}
.hint-sub {
  font-size: 0.9rem;
  color: #50567a;
}
.hint-steps {
  display: flex;
  gap: 8px;
  align-items: center;
  position: relative;
  z-index: 1;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.step-pill {
  padding: 6px 10px;
  border-radius: 12px;
  background: rgba(70, 85, 190, 0.12);
  color: #2b3275;
  border: 1px solid rgba(70, 85, 190, 0.2);
  font-size: 0.82rem;
  font-weight: 700;
  backdrop-filter: blur(2px);
}
.piece-panel-header {
  font-size: 0.98rem;
  font-weight: 650;
  color: #e5e8f5;
  margin-bottom: 6px;
  text-align: center;
}
.ai-note {
  text-align: center;
  color: #cfd6ff;
  font-size: 0.9rem;
  margin-bottom: 8px;
  opacity: 0.9;
}
.ai-note.subtle {
  color: #c0c8ef;
  font-size: 0.88rem;
}
.piece-selector {
  margin-top: 4px;
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  justify-content: center;
  padding-bottom: 18px;
}
.piece-option {
  padding: 13px 20px;
  min-width: 150px;
  font-size: 1.02rem;
  font-weight: 700;
  text-align: center;
  color: #2c2c2c;
  border-radius: 16px;
  border: 2px solid #dcdcff;
  background: rgba(255, 255, 255, 0.9);
  cursor: pointer;
  user-select: none;
  transition: transform 0.22s cubic-bezier(.4,.2,.2,1), box-shadow 0.22s ease, background 0.22s ease, border-color 0.22s ease, color 0.22s ease;
  box-shadow: 0 6px 16px rgba(41, 44, 120, 0.18);
  display: flex;
  justify-content: center;
  align-items: center;
}
.piece-option[data-type="snake"] {
  border-left-width: 12px;
  border-left-color: #e74c3c;
}
.piece-option[data-type="ladder"] {
  border-left-width: 12px;
  border-left-color: #2ecc71;
}
.piece-option:hover:not(.placed):not(:disabled) {
  transform: translateY(-4px) scale(1.02);
  box-shadow: 0 12px 26px rgba(30, 35, 110, 0.26);
}
.piece-option.selected {
  background: linear-gradient(135deg, #667eea, #4a5bd0);
  color: #ffffff;
  border-color: #4a5bd0;
  box-shadow: 0 14px 30px rgba(69, 92, 210, 0.5);
  transform: translateY(-4px) scale(1.03);
}
.piece-option.placed,
.piece-option:disabled {
  background: #e7e7e7;
  color: #8a8a8a;
  border-color: #c5c5c5;
  text-decoration: line-through;
  cursor: not-allowed;
  opacity: 0.55;
  box-shadow: none;
  transform: none;
}
.setup-buttons {
  display: flex;
  gap: 10px;
  margin-top: 10px;
  flex-wrap: wrap;
  justify-content: center;
}
.btn {
  padding: 12px 22px;
  font-size: 1rem;
  font-weight: 700;
  background: #e9e9f7;
  color: #2b2b2b;
  border: none;
  border-radius: 12px;
  cursor: pointer;
  transition: transform 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
  box-shadow: 0 6px 14px rgba(21, 23, 70, 0.22);
}
.btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 20px rgba(17, 20, 60, 0.28);
}
.btn:disabled {
  background: #c7c7d6;
  cursor: not-allowed;
  box-shadow: none;
}
.btn.primary {
  background: linear-gradient(135deg, #667eea, #4a5bd0);
  color: #ffffff;
}
.btn.primary:hover:not(:disabled) {
  background: linear-gradient(135deg, #5b6fe0, #4352c4);
}
.game-info {
  display: flex;
  justify-content: space-around;
  margin-bottom: 14px;
  padding: 12px;
  background: rgba(244, 244, 255, 0.95);
  border-radius: 14px;
  box-shadow: 0 8px 18px rgba(21, 22, 77, 0.18);
}
.player-info {
  text-align: center;
  padding: 8px 18px;
  border-radius: 10px;
  transition: all 0.25s ease;
}
.player-info.active {
  background: linear-gradient(135deg, #667eea, #4a5bd0);
  color: #ffffff;
  transform: scale(1.08);
  box-shadow: 0 10px 20px rgba(66, 89, 210, 0.4);
}
.player-name {
  font-weight: 700;
  font-size: 1.05em;
  margin-bottom: 4px;
}
.player-position {
  font-size: 0.9em;
}
.controls {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}
.dice-container {
  display: flex;
  justify-content: center;
}
.dice {
  width: 80px;
  height: 80px;
  background: #ffffff;
  border: 3px solid #333;
  border-radius: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 3em;
  font-weight: 700;
  margin: 6px;
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.35);
  color: #000;
  text-shadow: none;
}
.message {
  text-align: center;
  font-size: 1.05em;
  color: #333;
  min-height: 28px;
  font-weight: 700;
}
.winner {
  background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
  color: #ffffff;
  padding: 16px;
  border-radius: 12px;
  animation: pulse 1s infinite;
  box-shadow: 0 10px 24px rgba(206, 60, 120, 0.5);
}

@keyframes pulse {
  0% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.06);
  }
  100% {
    transform: scale(1);
  }
}
@media (max-width: 1080px) {
  .layout-grid {
    grid-template-columns: 1fr;
  }
  .layout-left,
  .layout-right {
    align-items: stretch;
    height: auto;
  }
  .legend {
    justify-content: center;
  }
}
@media (max-width: 640px) {
  .container {
    padding: 20px;
  }

  .current-piece {
    grid-template-columns: 78px auto;
  }

  .board {
    gap: 0;
  }
}
@media (max-width: 720px) {
  .placement-hint {
    flex-direction: column;
    align-items: flex-start;
  }
  .hint-steps {
    width: 100%;
    justify-content: flex-start;
  }
  .hint-icon {
    width: 48px;
    height: 48px;
  }
}
.game-footer {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin: 20px 0 10px;
  flex-wrap: wrap;
}
#resetBtn,
.menu-btn {
  margin-top: 10px;
  padding: 10px 20px;
  font-size: 1em;
  font-weight: bold;
  color: #fff;
  background-color: #333;
  border: none;
  border-radius: 5px;
  cursor: pointer;
  transition: background-color 0.3s ease;
  box-shadow: none;
  text-decoration: none;
}
#resetBtn:hover,
.menu-btn:hover {
  background-color: #555;
}
