/* 1. Universal Reset & Braun-inspired Typography with Tamil Support */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');
@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+Tamil:wght@300;400;500;600;700;800&display=swap');

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: "Noto Sans Tamil", "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

/* 2. Neumorphic Body - Braun/TE Inspired */
body {
  background: #e8e8e8; /* Soft neutral background */
  color: #2c2c2c;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  min-height: 100dvh; /* Dynamic viewport height for better mobile support */
  font-weight: 400;
  line-height: 1.4;
  position: relative;
}

/* 3. Container for the Game Elements - Broader Desktop Layout */
/* 3. Neumorphic Game Container */
.game-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 90%;
  max-width: 520px;
  text-align: center;
  padding: 3rem 2.5rem;
  background: #e8e8e8;
  border-radius: 24px;
  box-shadow:
    12px 12px 24px rgba(163, 163, 163, 0.4),
    -12px -12px 24px rgba(255, 255, 255, 0.8);
  position: relative;
}

/* 4. Title */
/* 4. Braun-inspired Title */
.game-title {
  margin-bottom: 2rem;
  font-size: 2.2rem;
  color: #2c2c2c;
  letter-spacing: -0.02em;
  font-weight: 300;
  position: relative;
}

.game-title::after {
  content: '';
  position: absolute;
  bottom: -8px;
  left: 50%;
  transform: translateX(-50%);
  width: 60px;
  height: 2px;
  background: #ff6b35; /* TE Orange accent */
}

/* 5. Modal Styles */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
}

.modal-content {
  background: #e8e8e8;
  padding: 3rem 2.5rem;
  border-radius: 24px;
  text-align: center;
  max-width: 400px;
  width: 90%;
  box-shadow:
    12px 12px 24px rgba(163, 163, 163, 0.4),
    -12px -12px 24px rgba(255, 255, 255, 0.8);
}

.modal-content h2 {
  font-size: 2rem;
  margin-bottom: 1.5rem;
  color: #2c2c2c;
  font-weight: 300;
}

.modal-content p {
  font-size: 1.1rem;
  line-height: 1.6;
  margin-bottom: 1.5rem;
  color: #666;
  font-weight: 400;
}

/* 6. Scrambled Letters Container */
/* 6. TE-style Letter Display */
.letters-container {
  display: flex;
  justify-content: center;
  gap: 0.6rem;
  margin: 2rem 0;
  font-size: 2.5rem;
  flex-wrap: wrap;
  font-weight: 600;
  color: #2c2c2c;
  background: #e8e8e8;
  padding: 2rem 1.5rem;
  border-radius: 20px;
  box-shadow:
    inset 8px 8px 16px rgba(163, 163, 163, 0.3),
    inset -8px -8px 16px rgba(255, 255, 255, 0.8);
  letter-spacing: 4px;
  position: relative;
}

.letters-container::before {
  content: '';
  position: absolute;
  top: 12px;
  right: 16px;
  width: 8px;
  height: 8px;
  background: #00ff88; /* TE Green indicator */
  border-radius: 50%;
  box-shadow: 0 0 4px rgba(0, 255, 136, 0.6);
}

/* 7. Answer Input */
/* 7. Answer Form Container */
.answer-form {
  width: 100%;
  margin-bottom: 2rem;
}

/* 7. Neumorphic Input Field */
.answer-input {
  width: 100%;
  font-size: 1.1rem;
  padding: 1.2rem;
  text-align: center;
  border: none;
  border-radius: 16px;
  background: #e8e8e8;
  color: #2c2c2c;
  font-weight: 500;
  letter-spacing: 1px;
  box-shadow:
    inset 6px 6px 12px rgba(163, 163, 163, 0.3),
    inset -6px -6px 12px rgba(255, 255, 255, 0.8);
}

.answer-input:focus {
  outline: none;
  box-shadow:
    inset 8px 8px 16px rgba(163, 163, 163, 0.4),
    inset -8px -8px 16px rgba(255, 255, 255, 0.9),
    0 0 0 2px #ff6b35;
}

/* 8. Stats Container */
/* 8. Stats Display Row (Score, Timer, Streak) */
.stats-container {
  margin-bottom: 2rem;
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 1rem;
  width: 100%;
  align-items: stretch;
}

.stat-label {
  font-size: 1rem;
  font-weight: 500;
  color: #2c2c2c;
  background: #e8e8e8;
  padding: 1.2rem 1rem;
  border-radius: 14px;
  text-align: center;
  position: relative;
  box-shadow:
    inset 4px 4px 8px rgba(163, 163, 163, 0.2),
    inset -4px -4px 8px rgba(255, 255, 255, 0.7);
  min-width: 0;
  height: 4rem;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
}

.stat-label.timer {
  position: relative;
  height: 4rem !important;
  width: 100% !important;
  font-size: 1rem !important;
  font-weight: 500 !important;
  color: #2c2c2c !important;
  background: #e8e8e8 !important;
  padding: 1.2rem 1rem !important;
  border-radius: 14px !important;
  text-align: center !important;
  box-shadow:
    inset 4px 4px 8px rgba(163, 163, 163, 0.2),
    inset -6px -6px 12px rgba(255, 255, 255, 0.7) !important;
  min-width: 0 !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  box-sizing: border-box !important;
}

.stat-label.timer::after {
  display: none !important;
}

.stat-label.timer::before {
  content: '';
  position: absolute;
  top: 8px;
  right: 8px;
  width: 4px;
  height: 4px;
  background: #ff3366; /* TE Pink indicator */
  border-radius: 50%;
  animation: pulse 1s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

.stat-label::after {
  content: '';
  position: absolute;
  top: 8px;
  right: 8px;
  width: 4px;
  height: 4px;
  border-radius: 50%;
}

.stat-label:first-child::after {
  background: #00ff88; /* TE Green for score */
}

.stat-label:last-child::after {
  background: #ffaa00; /* TE Yellow for streak */
}

/* 10. Buttons */
/* 10. TE-style Neumorphic Buttons */
.button {
  background: #e8e8e8;
  color: #2c2c2c;
  border: none;
  border-radius: 20px;
  padding: 1.2rem 2.5rem;
  margin: 0.5rem;
  cursor: pointer;
  font-size: 1.1rem;
  font-weight: 600;
  transition: all 0.2s ease;
  min-width: 140px;
  position: relative;
  box-shadow:
    6px 6px 12px rgba(163, 163, 163, 0.3),
    -6px -6px 12px rgba(255, 255, 255, 0.8);
}

.button::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 20px;
  transform: translateY(-50%);
  width: 6px;
  height: 6px;
  background: #ff6b35;
  border-radius: 50%;
}

.button:hover {
  box-shadow:
    3px 3px 6px rgba(163, 163, 163, 0.4),
    -3px -3px 6px rgba(255, 255, 255, 0.9);
  transform: translateY(-1px);
}

.button:active {
  box-shadow:
    inset 4px 4px 8px rgba(163, 163, 163, 0.3),
    inset -4px -4px 8px rgba(255, 255, 255, 0.7);
  transform: translateY(0);
}

.submit-btn::before {
  background: #00ff88; /* TE Green for submit */
}

/* Sound Toggle Button */
.sound-toggle {
  position: absolute;
  top: 20px;
  right: 20px;
  width: 48px;
  height: 48px;
  background: #e8e8e8;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  font-size: 1.2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  box-shadow:
    4px 4px 8px rgba(163, 163, 163, 0.3),
    -4px -4px 8px rgba(255, 255, 255, 0.8);
}

.sound-toggle:hover {
  box-shadow:
    2px 2px 4px rgba(163, 163, 163, 0.4),
    -2px -2px 4px rgba(255, 255, 255, 0.9);
  transform: translateY(-1px);
}

.sound-toggle:active {
  box-shadow:
    inset 2px 2px 4px rgba(163, 163, 163, 0.3),
    inset -2px -2px 4px rgba(255, 255, 255, 0.7);
  transform: translateY(0);
}

.sound-toggle.muted {
  opacity: 0.5;
}

/* Correct Answer Display */
/* Correct Answer Display */
.correct-word {
  margin-top: 2rem;
  font-size: 1.3rem;
  color: #2c2c2c;
  background: #e8e8e8;
  padding: 1.5rem;
  border-radius: 16px;
  font-weight: 500;
  position: relative;
  box-shadow:
    inset 6px 6px 12px rgba(163, 163, 163, 0.3),
    inset -6px -6px 12px rgba(255, 255, 255, 0.8);
}

.correct-word::before {
  content: '';
  position: absolute;
  top: 16px;
  left: 16px;
  width: 6px;
  height: 6px;
  background: #ff3366; /* TE Pink for error */
  border-radius: 50%;
}


/* Hide Elements */
.hidden {
  display: none;
}

/* 11. Footer - Just below the main container */
/* Braun-inspired Footer */
footer {
  margin-top: 3rem;
  font-size: 0.8rem;
  color: #999;
  text-align: center;
  font-weight: 300;
  letter-spacing: 0.5px;
}

/* Enhanced Mobile Layout */
@media screen and (max-width: 480px) {
  body {
    padding: 1rem;
    justify-content: flex-start;
    min-height: 100vh;
    min-height: 100dvh;
  }

  .game-container {
    width: 100%;
    max-width: none;
    padding: 2rem 1.5rem;
    border-radius: 20px;
    margin: 0;
    position: relative;
    min-height: calc(100dvh - 2rem);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
  }

  /* Ensure submit button stays accessible when keyboard is open */
  .submit-btn {
    position: fixed;
    bottom: max(1rem, env(safe-area-inset-bottom));
    left: 50%;
    transform: translateX(-50%);
    z-index: 1000;
    width: calc(100% - 2rem);
    max-width: 360px;
    background: #e8e8e8;
    border-radius: 16px;
    box-shadow:
      6px 6px 12px rgba(163, 163, 163, 0.3),
      -6px -6px 12px rgba(255, 255, 255, 0.8),
      0 0 20px rgba(0, 0, 0, 0.1);
  }

  /* Add padding to game container to account for fixed submit button */
  .game-container {
    padding-bottom: 5rem;
  }

  .sound-toggle {
    top: 15px;
    right: 15px;
    width: 44px;
    height: 44px;
    font-size: 1.1rem;
  }

  .game-title {
    font-size: 1.6rem;
    margin-bottom: 1.5rem;
  }

  .instructions {
    font-size: 0.85rem;
    padding: 1.2rem;
    margin-bottom: 2rem;
    border-radius: 12px;
  }

  .letters-container {
    font-size: 1.4rem;
    padding: 1.5rem 1rem;
    border-radius: 16px;
    gap: 0.4rem;
    letter-spacing: 2px;
    margin: 1.5rem 0;
  }

  .answer-form {
    margin-bottom: 1rem;
  }

  .answer-input {
    font-size: 1rem;
    padding: 1rem;
    border-radius: 12px;
  }


  .stats-container {
    grid-template-columns: 1fr 1fr 1fr;
    gap: 0.6rem;
    margin-bottom: 1.5rem;
  }

  .stat-label {
    padding: 0.8rem 0.6rem;
    border-radius: 10px;
    font-size: 0.75rem;
    min-width: 0;
    height: 3rem;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
  }

  .stat-label.timer {
    height: 3rem !important;
    width: 100% !important;
    font-size: 0.75rem !important;
    padding: 0.8rem 0.6rem !important;
    border-radius: 10px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    box-sizing: border-box !important;
  }

  .button {
    font-size: 0.9rem;
    padding: 1rem 2rem;
    border-radius: 16px;
    min-width: 140px;
    margin: 0.4rem;
  }

  .button::before {
    left: 16px;
    width: 5px;
    height: 5px;
  }

  .correct-word {
    font-size: 1rem;
    padding: 1.2rem;
    margin-top: 1.5rem;
    border-radius: 12px;
  }

  footer {
    margin-top: 2rem;
    font-size: 0.75rem;
    padding: 0 1rem;
  }
}

/* Extra small screens */
@media screen and (max-width: 360px) {
  .game-container {
    padding: 1.5rem 1rem;
    min-height: calc(100dvh - 1rem);
  }

  .letters-container {
    font-size: 1.2rem;
    padding: 1.2rem 0.8rem;
    letter-spacing: 1px;
  }

  .stats-container {
    grid-template-columns: 1fr 1fr 1fr;
    gap: 0.4rem;
  }

  .stat-label {
    padding: 0.6rem 0.4rem;
    border-radius: 8px;
    font-size: 0.65rem;
    height: 2.5rem;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
  }

  .stat-label.timer {
    height: 2.5rem !important;
    width: 100% !important;
    font-size: 0.65rem !important;
    padding: 0.6rem 0.4rem !important;
    border-radius: 8px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    box-sizing: border-box !important;
  }

  .button {
    min-width: 120px;
    padding: 0.9rem 1.5rem;
  }

  .submit-btn {
    position: fixed;
    bottom: max(1rem, env(safe-area-inset-bottom));
    left: 50%;
    transform: translateX(-50%);
    width: calc(100% - 2rem);
    max-width: 320px;
  }
}

/* Landscape mobile devices */
@media screen and (max-height: 500px) and (orientation: landscape) {
  body {
    justify-content: flex-start;
    padding: 0.5rem;
  }

  .game-container {
    padding: 1rem;
    margin: 0;
  }

  .submit-btn {
    position: fixed;
    bottom: 0.5rem;
    right: 0.5rem;
    width: auto;
    transform: none;
    left: auto;
  }
}

/* Drag and Drop Styles */
.drop-zone {
  border: 2px dashed #ccc;
  min-height: 50px;
  margin-top: 20px;
}

.letter-tile {
  padding: 10px;
  background-color: #f2f2f2;
  border: 1px solid #ccc;
  cursor: grab;
  display: inline-block;
  margin: 5px;
  border-radius: 8px;
  box-shadow: 2px 2px 5px rgba(0,0,0,0.1);
}

.letter-tile:active {
  cursor: grabbing;
  box-shadow: inset 2px 2px 5px rgba(0,0,0,0.2);
}

.correct {
  background-color: #d4edda; /* Light green */
  border-color: #c3e6cb;
}

.incorrect {
  background-color: #f8d7da; /* Light red */
  border-color: #f5c6cb;
}
