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

.hidden {
  display: none !important;
}

/* How to Play Screen */
.how-to-play-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 5px;
}

.how-to-play-content {
  background: rgba(255, 255, 255, 0.9);
  border-radius: 20px;
  padding: 10px;
  max-width: 500px;
  width: 100%;
  text-align: center;
  border: 1px solid rgba(0, 0, 0, 0.1);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
}

.how-to-play-content h1 {
  font-size: 1.5rem;
  margin-bottom: 30px;
  color: #1e40af;
  text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.1);
}

.instructions {
  margin-bottom: 30px;
  text-align: left;
}

.instructions h2 {
  font-size: 1.2rem;
  margin-bottom: 15px;
  color: #1e40af;
  text-align: center;
}

.instructions ul {
  list-style: none;
  padding: 0;
}

.instructions li {
  margin-bottom: 7px;
  font-size: 0.8rem;
  color: #374151;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.difficulty-selection {
  margin-bottom: 30px;
}

.difficulty-selection h3 {
  font-size: 1.2rem;
  margin-bottom: 15px;
  color: #1e40af;
}

.difficulty-buttons {
  display: flex;
  gap: 10px;
  justify-content: center;
}

.difficulty-btn {
  padding: 12px 24px;
  border: 2px solid #3b82f6;
  background: transparent;
  color: #3b82f6;
  border-radius: 25px;
  cursor: pointer;
  font-size: 1rem;
  font-weight: bold;
  transition: all 0.3s ease;
  outline: none;
  -webkit-tap-highlight-color: transparent;
}

.difficulty-btn:hover {
  background: #3b82f6;
  color: white;
}

.difficulty-btn.active {
  background: #3b82f6;
  color: white;
}

.difficulty-btn:focus {
  outline: none;
  box-shadow: none;
}

.start-game-btn {
  padding: 12px 36px;
  background: linear-gradient(45deg, #10b981, #059669);
  color: white;
  border: none;
  border-radius: 30px;
  font-size: 1.2rem;
  font-weight: bold;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 4px 15px rgba(16, 185, 129, 0.3);
  outline: none;
  -webkit-tap-highlight-color: transparent;
}

.start-game-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(16, 185, 129, 0.4);
}

.start-game-btn:focus {
  outline: none;
  box-shadow: 0 4px 15px rgba(16, 185, 129, 0.3);
}

/* Congratulations Modal */
.congratulations-modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  padding: 20px;
}

.congratulations-content {
  background: rgba(255, 255, 255, 0.95);
  border-radius: 20px;
  padding: 40px;
  max-width: 500px;
  width: 100%;
  text-align: center;
  border: 1px solid rgba(0, 0, 0, 0.1);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
}

.congratulations-content h1 {
  font-size: 1.25rem;
  margin-bottom: 20px;
  color: #10b981;
  text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.1);
}

.congratulations-content p {
  font-size: 1.3rem;
  margin-bottom: 20px;
  color: #374151;
}

.difficulty-info {
  margin-bottom: 30px;
  padding: 15px;
  background: rgba(59, 130, 246, 0.1);
  border-radius: 10px;
  border: 1px solid rgba(59, 130, 246, 0.3);
}

.difficulty-info p {
  font-size: 1.2rem;
  margin: 0;
  color: #3b82f6;
}

.difficulty-info span {
  font-weight: bold;
  text-transform: capitalize;
}

.play-again-btn {
  padding: 15px 40px;
  background: linear-gradient(45deg, #3b82f6, #1d4ed8);
  color: white;
  border: none;
  border-radius: 30px;
  font-size: 1.2rem;
  font-weight: bold;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 4px 15px rgba(59, 130, 246, 0.3);
}

.play-again-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(59, 130, 246, 0.4);
}

/* Prevent zoom on double-click */
html,
body {
  touch-action: manipulation;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  -khtml-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
  height: 100%;
  
}

body {
  font-family: "Open Sans", sans-serif;
  font-optical-sizing: auto;
  background: linear-gradient(135deg, #e8e9eb 0%, #e8e9eb 100%);
  min-height: 100vh;
  color: #374151;
  letter-spacing: 0.07em;
  margin: 0;
  padding: 0;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

.game-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;

  max-width: 800px;
  width: 100%;
  text-align: center;
  margin-inline: auto;
  height: 100vh;
  
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  position: relative;
  z-index: 1;
}

.game-info {
  text-align: left;
  margin-bottom: 10px;
  flex-shrink: 0;
  width: 100%;
  max-width: 400px;
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  padding: 0 5px
}

.game-info h1 {
  font-size: 1rem;
  margin-bottom: 10px;
  color: #1e40af;
  text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.1);
}

.collision-counters {
  display: flex;
  gap: 20px;
  margin-bottom: 10px;
}

.counter {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 0.9rem;
  font-weight: bold;
  color: #374151;
}

.counter-icon {
  font-size: 1.1rem;
}

.snake-counter {
  color: #dc2626;
}

.ladder-counter {
  color: #10b981;
}

.score-info {
  display: flex;
  justify-content: center;
  gap: 30px;
  font-size: 1.2rem;
  font-weight: bold;
}

.score-info span {
  background: rgba(255, 255, 255, 0.8);
  color: #374151;
  padding: 5px 10px;
  border-radius: 5px;
  border: 1px solid rgba(0, 0, 0, 0.1);
}

.game-board {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  /* background: rgba(255, 255, 255, 0.05); */
  flex: 1;
  width: 100%;
  max-width: 400px;
  
}

#gameCanvas {
  background: transparent;
  border: 2px solid #e2e8f0;
  border-radius: 10px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
  cursor: pointer;
  flex: 1;
  width: 100%;
  max-width: 400px;
  height: auto;
  min-height: 200px;
  max-height: calc(100vh - 200px);
  outline: none;
  -webkit-tap-highlight-color: transparent;
}

.bottom-controls {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
  flex-shrink: 0;
  margin-top: 0px;
}

.dice-row {
  display: flex;
  justify-content: space-between;
  width: 100%;
  max-width: 400px;
  gap: 0;
}

.dice-face {
  width: calc(100% / 6);
  height: 40px;
  background: transparent;
  border: none;
  border-radius: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 4rem;
  font-weight: 100;
  color: #6b7280;
  cursor: default;
  transition: all 0.3s ease;
  box-shadow: none;
  opacity: 0.3;
  padding: 0;
  margin: 0;
}

@keyframes pulse {
  0%,
  100% {
    opacity: 0.6;
  }
  50% {
    opacity: 1;
  }
}

/* Responsive design */
@media (max-width: 768px) {
  .game-container {
    height: 100vh;
  }

  .game-info h1 {
    font-size: 1.2rem;
  }

  #gameCanvas {
    width: 100%;
    max-width: 400px;
    height: auto;
    min-height: 150px;
    max-height: calc(100vh - 150px);
  }

  .dice-face {
    width: calc(100% / 6);
    height: 35px;
  }

  .score-info {
    flex-direction: column;
    gap: 10px;
  }

  .swipe-area {
    height: 40px;
  }

  .swipe-indicator {
    font-size: 0.9rem;
  }
}

/* iPhone 12 mini and smaller screens */
@media (max-width: 375px) {
  .game-container {
    height: 100vh;
    padding: 5px;
  }

  .game-info {
    margin-bottom: 5px;
  }

  .game-info h1 {
    font-size: 1.2rem;
    margin-bottom: 3px;
  }

  .score-info {
    font-size: 0.9rem;
    gap: 5px;
  }

  #gameCanvas {
    width: 100%;
    max-width: 350px;
    height: auto;
    min-height: 120px;
    max-height: calc(85vh - 120px);
  }

  .dice-face {
    width: calc(100% / 6);
    height: 25px;
    font-size: 2.5rem;
  }

  .bottom-controls {
    gap: 5px;
    margin-top: 5px;
  }
}

/* Extra small screens (iPhone SE, etc.) */
@media (max-width: 320px) {
  .game-container {
    padding: 3px;
  }

  .game-info h1 {
    font-size: 1rem;
  }

  .score-info {
    font-size: 0.8rem;
  }

  #gameCanvas {
    max-width: 300px;
    min-height: 100px;
    max-height: calc(100vh - 100px);
  }

  .dice-face {
    height: 20px;
    font-size: 2rem;
  }
}
