/*
  SNAKE GAME - STYLES

  Styles for the snake game interface.
  The game graphics are drawn on canvas with JavaScript,
  but we style the UI elements with CSS.
*/

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 20px;
}

/* ===================================
   GAME CONTAINER
   =================================== */

.game-container {
  background: white;
  border-radius: 16px;
  padding: 30px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  max-width: 500px;
  width: 100%;
}

/* ===================================
   HEADER
   =================================== */

header {
  text-align: center;
  margin-bottom: 20px;
}

header h1 {
  font-size: 2rem;
  color: #333;
  margin-bottom: 15px;
}

.stats {
  display: flex;
  justify-content: center;
  gap: 30px;
}

.stat {
  font-size: 1.1rem;
}

.label {
  color: #666;
  margin-right: 5px;
}

.value {
  font-weight: bold;
  color: #667eea;
  font-size: 1.3rem;
}

/* ===================================
   CANVAS
   =================================== */

/*
  The canvas element where we draw the game.
  We add a border and center it.
*/

#gameCanvas {
  display: block;
  margin: 0 auto 20px;
  border: 3px solid #333;
  border-radius: 8px;
  background-color: #000;
  /* Prevent canvas from being selected/highlighted */
  -webkit-user-select: none;
  user-select: none;
}

/* ===================================
   CONTROLS
   =================================== */

.controls {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin-bottom: 30px;
}

.btn {
  padding: 12px 24px;
  font-size: 1rem;
  font-weight: 600;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.3s ease;
  font-family: inherit;
}

.btn-primary {
  background-color: #667eea;
  color: white;
}

.btn-primary:hover:not(:disabled) {
  background-color: #5568d3;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.btn-secondary {
  background-color: #e0e0e0;
  color: #333;
}

.btn-secondary:hover:not(:disabled) {
  background-color: #d0d0d0;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn:active:not(:disabled) {
  transform: translateY(0);
}

/* ===================================
   INSTRUCTIONS
   =================================== */

.instructions {
  background-color: #f8f9fa;
  padding: 20px;
  border-radius: 8px;
  margin-top: 20px;
}

.instructions h3 {
  color: #333;
  margin-bottom: 10px;
  font-size: 1.1rem;
}

.instructions ul {
  margin-left: 20px;
  margin-bottom: 20px;
}

.instructions li {
  margin-bottom: 8px;
  color: #666;
}

/* Keyboard visual controls */
.keyboard-controls {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  margin-top: 15px;
}

.key-row {
  display: flex;
  gap: 5px;
}

.key {
  width: 50px;
  height: 50px;
  background-color: white;
  border: 2px solid #ddd;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  font-weight: bold;
  color: #667eea;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* ===================================
   GAME OVER SCREEN
   =================================== */

.game-over {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: white;
  padding: 40px;
  border-radius: 16px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
  text-align: center;
  z-index: 1000;
  min-width: 300px;
}

.game-over h2 {
  color: #e74c3c;
  font-size: 2.5rem;
  margin-bottom: 20px;
}

.game-over p {
  font-size: 1.3rem;
  color: #666;
  margin-bottom: 30px;
}

#finalScore {
  color: #667eea;
  font-weight: bold;
  font-size: 2rem;
}

/* Hidden class to hide game over screen */
.hidden {
  display: none;
}

/* ===================================
   FOOTER
   =================================== */

footer {
  text-align: center;
  margin-top: 30px;
  padding-top: 20px;
  border-top: 2px solid #e0e0e0;
}

footer a {
  color: #667eea;
  text-decoration: none;
  font-weight: 500;
  border-bottom: 2px solid transparent;
  transition: border-color 0.2s ease;
}

footer a:hover {
  border-bottom-color: #667eea;
}

/* ===================================
   RESPONSIVE DESIGN
   =================================== */

@media (max-width: 500px) {
  .game-container {
    padding: 20px;
  }

  #gameCanvas {
    width: 100%;
    height: auto;
  }

  .controls {
    flex-direction: column;
  }

  .btn {
    width: 100%;
  }
}
