/* style.css */

/* Reset default browser styles for consistency */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* Body Styling */
body {
  margin: 0;
  padding: 0;
  overflow: hidden; /* Prevent scrolling */
  font-family: Arial, sans-serif;
  background-color: #f0f0f0; /* Light background for contrast */
}

/* Container for the Game and UI */
#gameContainer {
  position: relative;
  width: 800px; /* Match canvas width */
  margin: 20px auto; /* Center the game container */
}

/* Canvas Styling */
#gameCanvas {
  display: block;
  background-color: transparent; /* Removed sky blue background */
  border: 2px solid #333; /* Optional: Add a border for clarity */
  border-radius: 8px; /* Rounded corners for aesthetics */
}

/* UI Overlay Container */
#ui {
  position: absolute;
  top: 10px;
  left: 10px;
  right: 10px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: rgba(255, 255, 255, 0.8);
  padding: 15px;
  border-radius: 10px;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
  pointer-events: none; /* Allow clicks to pass through to the canvas */
}

/* Letters Box */
#lettersBox {
  display: flex;
  align-items: center;
  gap: 10px;
}

#lettersBox span {
  font-weight: bold;
  font-size: 18px;
}

/* Letters Display */
#letters {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

#letters div {
  border: 2px solid #333;
  border-radius: 5px;
  padding: 5px 10px;
  font-size: 20px;
  font-weight: bold;
  background-color: #fff;
  transition: background-color 0.3s, color 0.3s;
}

/* Special Symbols Styling */
#letters div.special {
  background-color: green;
  color: white;
  border: 2px solid darkgreen;
}

/* Word Info Display */
#wordInfo {
  display: flex;
  align-items: center;
  gap: 10px;
}

#currentWord {
  font-size: 20px;
  font-weight: bold;
  color: orange;
}

#wordLengths {
  display: flex;
  gap: 5px;
}

/* Word Length Squares */
#wordLengths div {
  width: 20px;
  height: 20px;
  border: 1px solid #333;
  border-radius: 4px;
  cursor: default;
  transition: background-color 0.3s;
}

/* Collected Letters (Black Squares) */
#wordLengths div.collected {
  background-color: black;
}

/* Valid Word Lengths (Green Squares) */
#wordLengths div.valid {
  background-color: green;
}

/* No Valid Word Lengths (Grey Squares) */
#wordLengths div.invalid {
  background-color: grey;
}

/* Score Display */
#score {
  display: flex;
  align-items: center;
  gap: 5px;
}

#score span:first-child {
  font-weight: bold;
  font-size: 18px;
}

#score span#scoreValue {
  font-size: 18px;
}

/* Lives Display */
#lives {
  display: flex;
  align-items: center;
  gap: 5px;
}

#lives span:first-child {
  font-weight: bold;
  font-size: 18px;
}

#lives span#livesValue {
  display: flex;
  gap: 5px;
}

#lives span#livesValue span {
  color: red;
  font-size: 24px;
  margin-right: 2px;
}

/* Leaderboard Styling */
#leaderboard {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(255, 255, 255, 0.95);
  padding: 25px 30px;
  border-radius: 12px;
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.2);
  text-align: center;
  max-width: 90%;
  max-height: 90%;
  overflow-y: auto;
  z-index: 10; /* Ensure it appears above other elements */
}

#leaderboard h2 {
  margin-bottom: 15px;
  font-size: 28px;
  color: #333;
}

#leaderboardList {
  list-style-type: none;
  padding: 0;
  margin-bottom: 15px;
}

#leaderboardList li {
  margin: 8px 0;
  font-size: 20px;
  color: #555;
  display: flex;
  justify-content: center;
  gap: 10px;
}

#leaderboardList li:nth-child(odd) {
  background-color: #f9f9f9;
  padding: 8px;
  border-radius: 4px;
}

#leaderboardList li:nth-child(even) {
  background-color: #e9e9e9;
  padding: 8px;
  border-radius: 4px;
}

#newHighScoreMessage {
  margin-top: 10px;
  font-size: 18px;
  color: green;
}

/* Game Over Message Styling */
#gameCanvas.game-over-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  pointer-events: none; /* Allow clicks to pass through */
}

#gameCanvas.game-over-overlay::after {
  content: "GAME OVER";
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: white;
  font-size: 80px;
  font-weight: bold;
  text-align: center;
}

/* Gameplay Instructions */
#instructions {
  margin-top: 20px;
  padding: 15px;
  background: rgba(255, 255, 255, 0.9);
  border-radius: 8px;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
  width: 800px; /* Match canvas width */
  margin: 20px auto 0; /* Center below the game container */
}

#instructions h3 {
  margin-bottom: 10px;
  font-size: 22px;
  color: #333;
}

#instructions p {
  font-size: 16px;
  color: #555;
  line-height: 1.5;
}

#instructions ul {
  list-style-type: disc;
  margin-left: 20px;
  margin-bottom: 10px;
}

#instructions ul li {
  font-size: 16px;
  color: #555;
  margin-bottom: 5px;
}

/* Responsive Design */
@media (max-width: 850px) {
  #gameContainer, #instructions {
    width: 90%;
  }
}

@media (max-width: 600px) {
  #ui {
    flex-direction: column;
    padding: 10px;
  }

  #lettersBox span,
  #wordInfo span,
  #score span:first-child,
  #lives span:first-child {
    font-size: 16px;
  }

  #letters div {
    font-size: 18px;
  }

  #wordLengths div {
    width: 18px;
    height: 18px;
  }

  #score span#scoreValue {
    font-size: 16px;
  }

  #lives span#livesValue span {
    font-size: 20px;
  }

  #leaderboard h2 {
    font-size: 24px;
  }

  #leaderboardList li {
    font-size: 18px;
  }

  #newHighScoreMessage {
    font-size: 16px;
  }

  #instructions h3 {
    font-size: 20px;
  }

  #instructions p {
    font-size: 14px;
  }

  #instructions ul li {
    font-size: 14px;
  }
}
