body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  margin: 0;
  font-family: 'VT323', monospace;
  background: linear-gradient(135deg, #1e3c72 0%, #2a5298 100%);
  color: #fff;
  overflow-x: auto; /* Better mobile handling */
}

#container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  background: rgba(40, 44, 52, 0.9);
  padding: 20px;
  border-radius: 20px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  max-width: 90vw; /* Responsive width */
}

#game-board-container {
  position: relative;
  display: inline-block;
}

body,
.snake {
  background-color: #414141;
}

#game-board {
  position: relative;
  border-radius: 20px; /* Adjust the border radius for game board */
  display: grid;
  grid-template-columns: repeat(20, 20px);
  grid-template-rows: repeat(20, 20px);
  margin: 5px;
}

.game-border-1 {
  border: #353b48 solid 10px; /* Dark border color */
  border-radius: 30px;
  box-shadow: inset 0 0 0 10px #353b48; /* Dark border shadow */
}

.game-border-2 {
  border: #718093 solid 8px; /* Lighter border color */
  border-radius: 26px;
  box-shadow: inset 0 0 0 10px #718093; /* Light border shadow */
}

.game-border-3 {
  border: #f0f0f0 solid 30px; /* Light border color */
  border-radius: 20px;
  box-shadow: inset 0 0 0 5px #f0f0f0; /* Light border shadow */
}

#instruction-text {
  position: static;
  color: #fff;
  width: auto;
  text-align: center;
  padding: 15px;
  margin-top: 20px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
  -webkit-backdrop-filter: blur(5px);
  backdrop-filter: blur(5px);
  font-size: 16px;
  line-height: 1.4;
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.top-section {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  width: 100%;
  margin-bottom: 10px;
}

.scores {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

#score {
  color: #f39c12;
  font-size: 24px;
  font-weight: bold;
  margin: 0;
  text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
  transition: color 0.3s ease;
}

#highScore {
  color: #e67e22;
  font-size: 24px;
  font-weight: bold;
  margin: 0;
  text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
  transition: color 0.3s ease;
}

#game-instruction {
  text-align: center;
  color: #fff;
  margin-bottom: 20px;
}

.game-border-3,
#logo {
  background: linear-gradient(135deg, #c4cfa3, #a8b88a);
}

.snake {
  background: linear-gradient(45deg, #27ae60, #2ecc71);
  border: 2px solid #1e8449;
  border-radius: 3px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.3);
  transition: all 0.1s ease;
}

.food {
  background: radial-gradient(circle, #e74c3c, #c0392b);
  border: 3px solid #a93226;
  border-radius: 50%;
  box-shadow: 0 0 10px rgba(231, 76, 60, 0.6);
  animation: pulse 1.5s infinite;
}

#logo {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 1;
  width: 250px;
  height: auto;
  max-width: 85%;
  max-height: 85%;
}

#start-button {
  background: linear-gradient(45deg, #3498db, #2980b9);
  border: none;
  color: white;
  padding: 12px 24px;
  text-align: center;
  text-decoration: none;
  display: inline-block;
  font-size: 18px;
  font-family: 'VT323', monospace;
  margin: 10px 2px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 4px 15px rgba(52, 152, 219, 0.3);
  text-transform: uppercase;
  letter-spacing: 1px;
}

#start-button:hover {
  background: linear-gradient(45deg, #2980b9, #1f618d);
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(52, 152, 219, 0.4);
}

#start-button:active {
  transform: translateY(0);
  box-shadow: 0 2px 10px rgba(52, 152, 219, 0.3);
}

/* Restart button styling (same as start button) */
#restart-button {
  background: linear-gradient(45deg, #e74c3c, #c0392b);
  border: none;
  color: white;
  padding: 12px 24px;
  text-align: center;
  text-decoration: none;
  display: inline-block;
  font-size: 18px;
  font-family: 'VT323', monospace;
  margin: 10px 2px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 4px 15px rgba(231, 76, 60, 0.3);
  text-transform: uppercase;
  letter-spacing: 1px;
}

#restart-button:hover {
  background: linear-gradient(45deg, #c0392b, #a93226);
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(231, 76, 60, 0.4);
}

#restart-button:active {
  transform: translateY(0);
  box-shadow: 0 2px 10px rgba(231, 76, 60, 0.3);
}

/* Keyboard Controls Display */
#controls-display {
  text-align: center;
}

.controls-title {
  color: #f39c12;
  font-size: 14px;
  font-weight: bold;
  margin-bottom: 8px;
  text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5);
}

.arrow-keys {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
}

.arrow-row {
  display: flex;
  gap: 3px;
}

.arrow-key {
  width: 28px;
  height: 28px;
  background: linear-gradient(145deg, #4a5568, #2d3748);
  border: 1px solid #718096;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  color: #e2e8f0;
  font-weight: bold;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
  transition: all 0.2s ease;
  cursor: pointer;
  -webkit-user-select: none;
  user-select: none;
}

.arrow-key:hover {
  background: linear-gradient(145deg, #5a6578, #3d4758);
  transform: translateY(-1px);
  box-shadow: 0 3px 6px rgba(0, 0, 0, 0.4);
}

.arrow-key.active {
  background: linear-gradient(145deg, #3498db, #2980b9);
  border-color: #2980b9;
  color: white;
  transform: translateY(1px);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
}

/* Mobile Touch Controls */
#mobile-controls {
  display: none;
  margin-top: 20px;
  text-align: center;
}

.mobile-control-row {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin-bottom: 10px;
}

.mobile-btn {
  width: 60px;
  height: 60px;
  background: linear-gradient(145deg, #3498db, #2980b9);
  border: 2px solid #2980b9;
  border-radius: 12px;
  color: white;
  font-size: 24px;
  font-weight: bold;
  cursor: pointer;
  -webkit-user-select: none;
  user-select: none;
  touch-action: manipulation;
  transition: all 0.2s ease;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
}

.mobile-btn:active {
  background: linear-gradient(145deg, #2980b9, #1f618d);
  transform: translateY(2px);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

/* Show mobile controls on touch devices */
@media (hover: none) and (pointer: coarse) {
  #mobile-controls {
    display: block;
  }
}

/* Animations */
@keyframes pulse {
  0% {
    transform: scale(1);
    box-shadow: 0 0 10px rgba(231, 76, 60, 0.6);
  }
  50% {
    transform: scale(1.1);
    box-shadow: 0 0 20px rgba(231, 76, 60, 0.8);
  }
  100% {
    transform: scale(1);
    box-shadow: 0 0 10px rgba(231, 76, 60, 0.6);
  }
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Responsive Design */
@media (max-width: 768px) {
  #container {
    padding: 10px;
    max-width: 95vw;
  }
  
  #game-board {
    grid-template-columns: repeat(20, 15px);
    grid-template-rows: repeat(20, 15px);
  }
  
  #score, #highScore {
    font-size: 20px;
  }
  
  #instruction-text {
    width: 250px;
    padding: 15px;
  }
  
  #start-button {
    font-size: 16px;
    padding: 10px 20px;
  }
}

@media (max-width: 480px) {
  #game-board {
    grid-template-columns: repeat(20, 12px);
    grid-template-rows: repeat(20, 12px);
  }
  
  #score, #highScore {
    font-size: 18px;
  }
  
  #instruction-text {
    width: 200px;
    padding: 10px;
  }
  
  #logo {
    width: 150px;
    max-width: 80%;
    max-height: 80%;
  }
}

/* Accessibility improvements */
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* Focus styles for better accessibility */
#start-button:focus {
  outline: 3px solid #f39c12;
  outline-offset: 2px;
}

/* Game over overlay */
#game-over-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.8);
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 10;
  border-radius: 20px;
}

#game-over-overlay.show {
  display: flex;
  animation: fadeIn 0.5s ease-in;
}

.game-over-text {
  color: #e74c3c;
  font-size: 36px;
  font-weight: bold;
  text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.8);
  margin-bottom: 20px;
  animation: gameOverPulse 1s ease-in-out infinite alternate;
}

.final-score {
  color: #fff;
  font-size: 24px;
  margin-bottom: 20px;
  text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.8);
}

@keyframes gameOverPulse {
  0% {
    transform: scale(1);
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.8);
  }
  100% {
    transform: scale(1.05);
    text-shadow: 0 0 20px rgba(231, 76, 60, 0.8);
  }
}

/* Score update animation */
@keyframes scoreBoost {
  0% {
    transform: scale(1);
    color: #f39c12;
  }
  50% {
    transform: scale(1.2);
    color: #e74c3c;
    text-shadow: 0 0 10px rgba(231, 76, 60, 0.8);
  }
  100% {
    transform: scale(1);
    color: #f39c12;
  }
}

.score-boost {
  animation: scoreBoost 0.4s ease-out;
}