body {
  font-family: sans-serif;
  background: #f5f5f5;
  color: #333;
  margin: 0;
  padding: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

header {
  text-align: center;
  margin: 0 0 20px 0;
  width: 100%;
}

.title-container {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 15px;
  margin-bottom: 20px;
}

/* Game Container Styles */

body.dark .instruction-section li {
  color: #bbb;
}

body.dark {
  background: linear-gradient(145deg, #404040, #2a2a2a);
  color: #66b3ff;
  border-color: #66b3ff;
}

body.dark {
  background: linear-gradient(145deg, #505050, #3a3a3a);
}

.instructions {
  background: rgba(0, 123, 255, 0.1);
  border-radius: 8px;
  padding: 12px 16px;
  margin: 10px 0;
  border: 1px solid rgba(0, 123, 255, 0.2);
  max-width: 600px;
  text-align: center;
}

.instructions p {
  margin: 0;
  font-size: 14px;
  line-height: 1.4;
  color: #495057;
}

body.dark .instructions {
  background: rgba(52, 144, 220, 0.2);
  border-color: rgba(52, 144, 220, 0.3);
}

body.dark .instructions p {
  color: #ccc;
}

.score-area {
  font-size: 0.9em;
  margin: 10px 0;
  color: #555;
}

body.dark .score-area {
  color: #ccc;
}

body.dark {
  color: #eee;
}

.button-area {
  margin: 10px 0;
}

.button-area button {
  background: #007bff;
  color: white;
  border: none;
  border-radius: 8px;
  padding: 8px 12px;
  margin: 0 5px;
  cursor: pointer;
  font-size: 1.2em;
  transition: background-color 0.2s;
  min-height: 44px; /* Ensure touch target size */
  min-width: 44px;
  touch-action: manipulation; /* Optimize for touch */
}

.button-area button:hover {
  background: #0056b3;
}

.button-area button:active {
  transform: scale(0.95);
}

.message {
  min-height: 20px;
  font-size: 0.9em;
  color: #666;
  margin: 5px 0;
}

/* Custom tooltip styles */
.tooltip {
  position: relative;
  display: inline-block;
}

.tooltip .tooltiptext {
  visibility: hidden;
  width: 200px;
  background-color: #333;
  color: #fff;
  text-align: center;
  border-radius: 6px;
  padding: 8px 10px;
  position: absolute;
  z-index: 1000;
  bottom: 125%;
  left: 50%;
  margin-left: -100px;
  opacity: 0;
  transition: opacity 0.3s;
  font-size: 13px;
  line-height: 1.4;
  pointer-events: none;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

.tooltip .tooltiptext::after {
  content: "";
  position: absolute;
  top: 100%;
  left: 50%;
  margin-left: -5px;
  border-width: 5px;
  border-style: solid;
  border-color: #333 transparent transparent transparent;
}

/* Desktop hover */
.tooltip:hover .tooltiptext {
  visibility: visible;
  opacity: 1;
}

/* Mobile/touch - show on tap */
.tooltip.active .tooltiptext {
  visibility: visible;
  opacity: 1;
}

/* Responsive tooltip positioning */
@media (max-width: 768px) {
  .tooltip .tooltiptext {
    width: 180px;
    margin-left: -90px;
    font-size: 12px;
    padding: 6px 8px;
  }
}

body.dark .message {
  color: #ccc;
}

body.dark .tooltip .tooltiptext {
  background-color: #555;
  color: #fff;
}

body.dark .tooltip .tooltiptext::after {
  border-color: #555 transparent transparent transparent;
}

main {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  width: 100%;
}

.word-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  max-width: 700px;
  width: 100%;
  padding: 10px;
}

.word-row {
  display: flex;
  justify-content: center;
  gap: 3px;
  cursor: pointer;
}

.letter-box {
  width: 40px;
  height: 48px;
  border-bottom: 2px solid #aaa;
  font-size: 1.5em;
  text-align: center;
  line-height: 48px;
  text-transform: uppercase;
  user-select: none;
}

/* Smaller letter boxes for larger grids on desktop */
.word-grid.large-grid .letter-box {
  width: 36px;
  height: 44px;
  font-size: 1.4em;
  line-height: 44px;
}

/* Desktop responsive grid for large word counts */
@media (min-width: 768px) {
  body {
    padding: 20px;
  }
  
  .word-grid.large-grid {
    grid-template-columns: repeat(3, 1fr);
    max-width: 900px;
  }
  
  /* Ensure consistent sizing on desktop */
  .letter-box {
    width: 42px;
    height: 50px;
    font-size: 1.6em;
    line-height: 50px;
  }
  
  .word-grid.large-grid .letter-box {
    width: 38px;
    height: 46px;
    font-size: 1.4em;
    line-height: 46px;
  }
}

@media (max-width: 767px) {
  body {
    justify-content: flex-start;
    padding: 10px 0;
  }
  
  .letter-box {
    width: 35px;
    height: 42px;
    font-size: 1.3em;
    line-height: 42px;
  }
  
  main {
    gap: 5px;
  }
  
  .letter-circle {
    padding: 15px;
    gap: 8px;
  }
  
  .letter {
    width: 42px;
    height: 42px;
    font-size: 1.3em;
  }
  
  .word-grid {
    padding: 5px;
  }
  
  .word-grid.large-grid .letter-box {
    width: 30px;
    height: 38px;
    font-size: 1.2em;
    line-height: 38px;
  }
  
  /* Mobile button improvements */
  .button-area button {
    padding: 12px 16px;
    margin: 5px;
    font-size: 1.1em;
    min-height: 48px;
    min-width: 48px;
  }
  
  .button-area {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 5px;
  }
}

.word-row.active .letter-box {
  border-bottom: 2px solid #007bff;
}

.word-row.correct .letter-box {
  background-color: #c8f7c5;
  border-bottom: 2px solid #4caf50;
}

.word-row.incorrect .letter-box {
  background-color: #f7c5c5;
  border-bottom: 2px solid #f44336;
  animation: shake 0.5s ease-in-out;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-5px); }
  75% { transform: translateX(5px); }
}

.letter-circle {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
  padding: 20px;
  background: white;
  border-radius: 15px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.1);
  margin-bottom: 20px;
}

.letter {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: #007bff;
  color: white;
  font-size: 1.5em;
  display: flex;
  justify-content: center;
  align-items: center;
  font-weight: bold;
  transition: transform 0.2s;
}

.letter:hover {
  transform: scale(1.1);
}

/* Dark mode */
body.dark {
  background: #1c1c1c;
  color: #eee;
}
body.dark .letter {
  background: #3399ff;
}

body.dark .letter-circle {
  background: #2a2a2a;
  box-shadow: 0 2px 10px rgba(0,0,0,0.3);
}
body.dark .letter-box {
  /* border-color: #555; */
  color: #eee;
}

body.dark .button-area button {
  background: #3399ff;
}

body.dark .button-area button:hover {
  background: #2277dd;
}

body.dark .word-row.correct .letter-box {
  background-color: #2d5a2d;
  border-bottom: 2px solid #4caf50;
}

body.dark .word-row.incorrect .letter-box {
  background-color: #5a2d2d;
  border-bottom: 2px solid #f44336;
}
