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

body {
  font-family: 'Fredoka', sans-serif;
  background-color: #f0f8ff; /* Alice Blue */
  background-image: url('images/background.png'); /* Optional background */
  background-size: cover;
  color: #333;
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  padding: 20px;
}

.container {
  background-color: rgba(255, 255, 255, 0.9); /* Slightly transparent white */
  padding: 30px 40px;
  border-radius: 25px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
  text-align: center;
  max-width: 700px;
  width: 90%;
}

h1 {
  color: #ff6347; /* Tomato Red */
  margin-bottom: 25px;
  font-size: 2.5em;
}

h2 {
  color: #4682b4; /* Steel Blue */
  margin-top: 20px;
  margin-bottom: 15px;
  font-size: 1.8em;
}

.controls {
  margin-bottom: 25px;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
}

label {
  font-size: 1.2em;
  font-weight: 500;
  color: #555;
}

select {
  padding: 10px 15px;
  font-size: 1.1em;
  border-radius: 10px;
  border: 2px solid #add8e6; /* Light Blue */
  background-color: #fff;
  cursor: pointer;
  font-family: 'Fredoka', sans-serif;
}

select:focus {
  outline: none;
  border-color: #4682b4; /* Steel Blue */
}

.main-content {
  display: flex;
  flex-direction: column;
  gap: 30px;
  margin-bottom: 30px;
}

.suggestion-box, .translation-box {
  background-color: #e0ffff; /* Light Cyan */
  padding: 20px;
  border-radius: 15px;
  border: 2px dashed #afeeee; /* Pale Turquoise */
}

.word-display {
  font-size: 2.2em;
  font-weight: 700;
  color: #ff4500; /* Orange Red */
  margin: 10px 0;
  padding: 10px;
  background-color: #fff;
  border-radius: 10px;
  min-height: 50px; /* Ensure space even if empty */
  display: flex;
  justify-content: center;
  align-items: center;
}

.action-btn {
  padding: 12px 20px;
  font-size: 1.1em;
  font-family: 'Fredoka', sans-serif;
  font-weight: 500;
  border-radius: 10px;
  border: none;
  cursor: pointer;
  margin: 5px;
  transition: transform 0.2s ease, background-color 0.2s ease;
}

.action-btn:hover {
  transform: scale(1.05);
}

.action-btn:active {
  transform: scale(0.98);
}

.action-btn:disabled {
  background-color: #cccccc;
  cursor: not-allowed;
  transform: none;
}

#next-word-btn {
  background-color: #32cd32; /* Lime Green */
  color: white;
}
#next-word-btn:hover:not(:disabled) {
  background-color: #228b22; /* Forest Green */
}

.speak-btn {
  background-color: #1e90ff; /* Dodger Blue */
  color: white;
  font-size: 1.5em; /* Make speaker icon larger */
  padding: 8px 15px;
}
.speak-btn:hover:not(:disabled) {
  background-color: #104e8b; /* Darker Dodger Blue */
}

.learnt-btn {
  background-color: #ffaf40; /* Bright Orange */
  color: #fff;
}
.learnt-btn:hover:not(:disabled) {
  background-color: #ff8c00; /* Dark Orange */
}

#toggle-learned-btn {
  padding: 5px 10px;
  font-size: 0.8em;
  margin-left: 10px;
  background-color: #4682b4;
  color: white;
  border: none;
  border-radius: 5px;
  cursor: pointer;
}
#toggle-learned-btn:hover {
  background-color: #3670a0;
}


.learned-section {
  margin-top: 30px;
  background-color: #fffacd; /* Lemon Chiffon */
  padding: 20px;
  border-radius: 15px;
  border: 2px dashed #fafa8a; /* Lighter Yellow */
}

.word-list {
  margin-top: 10px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
  padding: 10px;
  max-height: 200px; /* Limit height */
  overflow-y: auto; /* Add scroll if needed */
  transition: max-height 0.5s ease-in-out, opacity 0.5s ease-in-out;
  opacity: 1;
  max-height: 200px;
}

.word-list.hidden {
  max-height: 0;
  opacity: 0;
  overflow: hidden;
  padding: 0 10px; /* Keep padding consistent during transition */
  margin-top: 0;
}

.learned-word {
  background-color: #98fb98; /* Pale Green */
  padding: 8px 15px;
  border-radius: 20px;
  font-size: 1.1em;
  cursor: pointer;
  transition: background-color 0.2s ease;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.learned-word:hover {
  background-color: #7fdd7f; /* Slightly darker green */
}

footer {
  margin-top: 30px;
  font-size: 0.9em;
  color: #777;
}

em {
  color: #555;
  font-size: 0.95em;
}

/* Simple loading spinner */
.loader {
  border: 4px solid #f3f3f3; /* Light grey */
  border-top: 4px solid #3498db; /* Blue */
  border-radius: 50%;
  width: 20px;
  height: 20px;
  animation: spin 1s linear infinite;
  display: inline-block;
  margin-left: 10px;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

#text-to-translate {
  padding: 12px 15px;
  font-size: 1.1em;
  border-radius: 10px;
  border: 2px solid #add8e6;
  background-color: #fff;
  font-family: 'Fredoka', sans-serif;
  width: 60%;
  max-width: 400px;
}

#translate-and-speak-btn {
  background-color: #ffa07a; /* Light Salmon */
  color: white;
}
#translate-and-speak-btn:hover {
  background-color: #ff7f50; /* Coral */
}

/* --- Responsive Design --- */

/* Target screens smaller than 600px (adjust breakpoint as needed) */
@media (max-width: 600px) {

  .container {
    padding: 20px 15px; /* Reduce padding on small screens */
    width: 95%; /* Allow container to use more screen width */
  }

  h1 {
    font-size: 2em; /* Slightly smaller heading */
  }

  h2 {
    font-size: 1.5em; /* Slightly smaller sub-headings */
  }

  .controls {
    flex-direction: column; /* Stack controls vertically */
    align-items: stretch; /* Make items fill width */
    gap: 15px; /* Adjust gap for vertical layout */
  }

  /* Specifically target the controls div holding the text input and translate button */
  .controls:has(#text-to-translate) { /* Modern CSS selector */
     /* You might not need specific rules here if the general .controls rule works */
  }

  /* Make input and select elements take more width */
  select,
  #text-to-translate {
     width: 100%; /* Use full available width within the controls */
  }

   /* Ensure buttons also take appropriate width */
  .controls button {
      width: 100%; /* Make buttons in controls take full width */
      max-width: 300px; /* Optional: prevent buttons getting TOO wide */
      align-self: center; /* Center buttons if max-width is applied */
  }

  .main-content {
     flex-direction: column; /* Already column, but ensures consistency */
     gap: 20px;
  }

  .word-display {
      font-size: 1.8em; /* Adjust font size for smaller screens */
  }

  .action-btn {
      padding: 10px 15px; /* Adjust padding */
      font-size: 1em;
  }

  .speak-btn {
      font-size: 1.3em;
      padding: 6px 12px;
  }

}

/* --- Styling for Learned Word Pairs --- */

.word-list {
  /* Keep existing flexbox/grid settings if desired for overall layout */
  /* For example: */
  display: flex;
  flex-wrap: wrap;
  gap: 15px; /* Increased gap slightly */
  justify-content: center; /* Or 'flex-start' if you prefer left-align */
  /* Keep max-height, overflow etc. */
  margin-top: 10px;
  padding: 10px;
  max-height: 200px;
  overflow-y: auto;
  transition: max-height 0.5s ease-in-out, opacity 0.5s ease-in-out;
  opacity: 1;
}

.word-list.hidden {
  /* Keep existing hidden styles */
  max-height: 0;
  opacity: 0;
  overflow: hidden;
  padding: 0 10px;
  margin-top: 0;
}

/* Styles for the new card container for each pair */
.learned-pair-card {
  display: flex; /* Use flexbox internally for stacking */
  flex-direction: column; /* Stack items vertically */
  align-items: center; /* Center text within the card */
  background-color: #e6f7ff; /* Light blue background */
  border: 1px solid #91d5ff; /* Slightly darker blue border */
  border-radius: 10px; /* Rounded corners */
  padding: 10px 15px;
  min-width: 100px; /* Ensure cards have some minimum width */
  text-align: center;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.learned-pair-card:hover {
  transform: translateY(-2px); /* Slight lift on hover */
  box-shadow: 0 4px 8px rgba(0,0,0,0.1); /* Increase shadow */
}

/* Style for the English word inside the card */
.english-word {
  font-size: 0.9em;
  color: #555; /* Darker grey for English */
  margin-bottom: 3px; /* Space between English and Target */
}

/* Style for the Target (translated) word inside the card */
.target-word {
  font-size: 1.2em;
  font-weight: 500; /* Make target word slightly bolder */
  color: #0050b3; /* Darker blue for target */
}

/* Style for the phonetic transcription display */
.phonetic-display {
  font-size: 1.1em;  /* Adjust size as needed */
  color: #666;      /* Grey color */
  margin-top: 5px;   /* Space above it */
  margin-bottom: 10px; /* Space below it */
  min-height: 1.2em; /* Reserve some space even when empty */
  font-style: italic; /* Optional: make it italic */
}

.phonetic-word-card {
  font-size: 0.8em;
  color: #888;
  font-style: italic;
  margin-top: 2px;
}

/* --- Quiz Section Styles --- */
.quiz-section {
  background-color: #e6e6fa; /* Lavender */
  padding: 20px;
  border-radius: 15px;
  margin-top: 30px;
  border: 2px dashed #cbc3e3; /* Light Lavender */
}

.quiz-card {
  background-color: #fff;
  padding: 15px;
  border-radius: 10px;
  margin-bottom: 20px;
  box-shadow: 0 4px 8px rgba(0,0,0,0.05);
}

.quiz-question-area, .quiz-answer-area {
  margin-bottom: 15px;
}

.quiz-question-area p, .quiz-answer-area p {
  font-weight: 500;
  color: #555;
  margin-bottom: 5px;
  font-size: 1.1em;
}

/* Style for the answer area when hidden */
.quiz-answer-area[style*="visibility: hidden;"] {
    opacity: 0.5; /* Optional: slightly visible hint */
}

/* Inherit word-display styles, but maybe adjust size */
#quiz-question, #quiz-answer {
   font-size: 1.8em;
   min-height: 40px;
}

/* Inherit phonetic display styles */
#quiz-phonetic {
    min-height: 1em;
}

.quiz-controls {
    display: flex;
    justify-content: center;
    gap: 10px;
    flex-wrap: wrap; /* Allow buttons to wrap on small screens */
}

/* Add specific styles for quiz buttons if needed, */
/* otherwise they use .action-btn styles */
#reveal-answer-btn {
  background-color: #32cd32; /* Lime Green */
  color: white;
}
 #reveal-answer-btn:hover:not(:disabled) {
   background-color: #228b22; /* Forest Green */
 }

#end-quiz-btn {
  background-color: #ff6347; /* Tomato Red */
}
 #end-quiz-btn:hover:not(:disabled) {
  background-color: #d24d32;
}

/* Add responsive rules for quiz if needed */
@media (max-width: 600px) {
    .quiz-section {
        padding: 15px;
    }
    #quiz-question, #quiz-answer {
       font-size: 1.5em;
    }
    .quiz-controls button {
      /* Ensure quiz buttons stack reasonably */
       width: calc(50% - 10px); /* Two buttons per row */
       min-width: 120px;
    }
    #end-quiz-btn {
       width: 100%; /* Make end button full width */
    }
}