/* Help Modal Styles */
.modal-container {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
  z-index: 1000;
  justify-content: center;
  align-items: center;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.modal-container.show {
  display: flex;
  opacity: 1;
  animation: fadeIn 0.3s ease-out;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal-content {
  background-color: #fff;
  width: 90%;
  max-width: 600px;
  max-height: 90vh;
  border-radius: 12px;
  box-shadow: 0 5px 20px rgba(0, 0, 0, 0.2);
  overflow: hidden;
  position: relative;
  animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
  from { transform: translateY(-30px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.modal-header {
  padding: 15px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background-color: #4a90e2;
  color: white;
  border-top-left-radius: 12px;
  border-top-right-radius: 12px;
}

.modal-header h2 {
  margin: 0;
  font-size: 1.4rem;
}

.close-button {
  background: none;
  border: none;
  font-size: 1.6rem;
  color: white;
  cursor: pointer;
  padding: 0;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: background-color 0.2s;
}

.close-button:hover {
  background-color: rgba(255, 255, 255, 0.2);
}

.modal-body {
  padding: 20px;
  overflow-y: auto;
  max-height: calc(90vh - 70px);
}

.rules-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.rule-item {
  display: flex;
  margin-bottom: 20px;
  align-items: flex-start;
}

.rule-number {
  background-color: #4a90e2;
  color: white;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  margin-right: 15px;
  flex-shrink: 0;
}

.rule-text {
  flex: 1;
}

.rule-text h3 {
  margin: 0 0 5px 0;
  color: #333;
  font-size: 1.1rem;
}

.rule-text p {
  margin: 0;
  color: #555;
  line-height: 1.4;
}

/* Responsive adjustments */
@media (max-width: 600px) {
  .modal-content {
    width: 95%;
  }

  .modal-header h2 {
    font-size: 1.2rem;
  }

  .rule-text h3 {
    font-size: 1rem;
  }

  .rule-text p {
    font-size: 0.9rem;
  }
}

/* ---- Letter Selection Modal ---- */
#letter-selection-modal .ls-modal-content {
  max-width: 480px;
  text-align: center;
}

/* Force the body to a simple single-column stack regardless of
   any grid/flex layout the host page applies to .modal-body */
#letter-selection-modal .ls-modal-body {
  display: block !important;
  padding: 16px 20px;
  overflow-y: auto;
  max-height: calc(90vh - 64px);
}

#letter-selection-modal .ls-modal-header {
  background: #1565c0;
  justify-content: space-between;
}

#letter-selection-modal .ls-modal-header h2 {
  flex: 1;
  text-align: center;
}

.ls-modal-instructions {
  margin: 0 0 0.25rem;
  font-size: 1rem;
  color: #444;
}

.ls-modal-hint {
  margin: 0 0 0.75rem;
  font-size: 1rem;
  color: #444;
}

/* Three slots showing chosen letters */
.ls-selection-slots {
  display: flex;
  gap: 0.75rem;
  justify-content: center;
  margin: 0.75rem 0;
}

.ls-slot {
  width: 72px;
  height: 48px;
  border-radius: 8px;
  border: 2px dashed #bbb;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.65rem;
  font-weight: 600;
  color: #aaa;
  transition: all 0.2s;
  text-align: center;
  line-height: 1.2;
  padding: 2px;
}

.ls-slot.filled-vowel {
  background: #ffd700;
  border-color: #b8860b;
  color: #5a3e00;
  font-size: 1.6rem;       /* large for the single letter */
}

.ls-slot.filled-consonant {
  background: #e8f5e9;
  border-color: #388e3c;
  color: #1b5e20;
  font-size: 1.6rem;       /* large for the single letter */
}

/* Modal letter grid: centered rows */
.ls-modal-grid {
  display: flex;
  justify-content: center;
  background: transparent;
  padding: 0;
  margin-bottom: 0;
}

.ls-modal-grid .letter-grid {
  align-items: center;
}

/* Tiles in modal — sized to fit 10 across in ~480px */
.ls-modal-grid .letter-tile {
  width: 36px;
  height: 36px;
  font-size: 14px;
  margin: 2px;
}

/* Selected vowel in modal: golden + lifted */
.ls-modal-grid .letter-tile.ls-vowel-selected {
  background: #ffd700;
  border-color: #b8860b;
  color: #5a3e00;
  transform: translateY(-3px);
  box-shadow: 0 3px 8px rgba(184,134,11,0.4);
}

/* Unselected vowels during consonant phase: soft gold outline, not filled */
.ls-modal-grid .letter-tile.vowel-enabled:not(.ls-vowel-selected) {
  background: #fffde7;
  border-color: #f9a825;
  color: #b8860b;
  opacity: 0.75;
}

/* Available consonants: clearly clickable once vowel is chosen */
.ls-modal-grid .letter-tile.consonant-enabled {
  background: #a5d6a7;
  border-color: #2e7d32;
  color: #1b5e20;
  font-weight: bold;
  box-shadow: 0 2px 4px rgba(46,125,50,0.25);
  opacity: 1;
}

.ls-modal-grid .letter-tile.consonant-enabled:hover {
  background: #dcedc8;
  border-color: #8bc34a;
  color: #558b2f;
  opacity: 1;
  transform: none;
}

/* Selected consonant in modal: bold, solid, lifted */
.ls-modal-grid .letter-tile.ls-consonant-selected {
  background: #2e7d32;
  border: 2px solid #1b5e20;
  color: #fff;
  font-weight: bold;
  transform: translateY(-4px);
  box-shadow: 0 5px 12px rgba(46,125,50,0.5);
  opacity: 1;
}

/* Confirm button */
.ls-confirm-btn {
  margin-top: 0.25rem;
  padding: 0.65rem 2.5rem;
  font-size: 1.1rem;
  font-weight: bold;
  border: none;
  border-radius: 8px;
  background: #1565c0;
  color: white;
  cursor: pointer;
  transition: background 0.2s, opacity 0.2s;
}

.ls-confirm-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.ls-confirm-btn:not(:disabled):hover {
  background: #0d47a1;
}

/* Fade-out animation on close */
#letter-selection-modal.closing {
  animation: fadeOut 0.35s ease-out forwards;
}

@keyframes fadeOut {
  from { opacity: 1; }
  to   { opacity: 0; }
}

/* ── Mobile adjustments for letter selection modal ────────────────── */
@media (max-width: 768px) {
  #letter-selection-modal .ls-modal-body {
    padding: 10px 8px;
  }

  #letter-selection-modal .ls-modal-header h2 {
    font-size: 1rem;
  }

  /* Tiles: fit 10 across in ~355px → 32px + 1.5px margin each side = 35px × 10 = 350px */
  .ls-modal-grid .letter-tile {
    width: 32px;
    height: 32px;
    font-size: 13px;
    margin: 1.5px;
  }

  /* Adjust keyboard row offsets for smaller tiles */
  .ls-modal-grid .keyboard-row:nth-child(2) {
    margin-left: 17px;
  }

  .ls-modal-grid .keyboard-row:nth-child(3) {
    margin-left: 49px;
  }

  .ls-selection-slots {
    gap: 0.5rem;
    margin: 0.5rem 0;
  }

  .ls-slot {
    width: 60px;
    height: 40px;
    font-size: 0.6rem;
  }

  .ls-slot.filled-vowel,
  .ls-slot.filled-consonant {
    font-size: 1.3rem;
  }

  .ls-modal-hint {
    font-size: 0.85rem;
    margin-bottom: 0.5rem;
  }

  .ls-confirm-btn {
    padding: 0.55rem 2rem;
    font-size: 1rem;
  }
}

@media (max-width: 480px) {
  /* Tiles: fit 10 across in ~310px → 28px + 1.5px margin each side = 31px × 10 = 310px */
  .ls-modal-grid .letter-tile {
    width: 28px;
    height: 28px;
    font-size: 12px;
    margin: 1.5px;
  }

  .ls-modal-grid .keyboard-row:nth-child(2) {
    margin-left: 15px;
  }

  .ls-modal-grid .keyboard-row:nth-child(3) {
    margin-left: 43px;
  }
}