/* ==========================================
   UTILITIES
========================================== */
.hidden { display: none !important; }


/* ==========================================
   FILL IN THE BLANKS — REDESIGNED
========================================== */

/* Self-contained scroll container for this game.
   #game-area (definido en game_template.css / index.html) ya tiene
   position:relative, padding (p-4 sm:p-6) y overflow-y-auto.
   Esta capa es position:absolute + inset:0, así que NO aporta altura
   al contenido de #game-area: #game-area se dimensiona correctamente
   vía flex-grow entre el header y el footer, sin scroll de página.
   Si el contenido es más alto que el espacio disponible, SOLO esta
   capa hace scroll internamente. */
.fb-scroll-area {
  position: absolute;
  inset: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

/* Outer wrapper — centra y limita el ancho, llena .fb-scroll-area */
.fb-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: clamp(0.5rem, 2.5vh, 1.25rem);
  padding: clamp(0.5rem, 2vh, 1.25rem) 0.75rem clamp(0.65rem, 2.5vh, 1.5rem);
  min-height: 100%;
  max-width: 700px;
  margin: 0 auto;
  width: 100%;
  box-sizing: border-box;
}

/* ---- Progress ---- */
.fb-progress-section {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.fb-progress-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.fb-progress-text {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: #93c5fd;
  font-family: 'Courier New', Courier, monospace;
}

.fb-progress-emoji {
  font-size: 1rem;
  opacity: 0.65;
}

.fb-progress-track {
  width: 100%;
  height: 5px;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 9999px;
  overflow: hidden;
}

.fb-progress-fill {
  height: 100%;
  border-radius: 9999px;
  background: linear-gradient(90deg, #3b82f6 0%, #06b6d4 100%);
  box-shadow: 0 0 8px rgba(6, 182, 212, 0.5);
  width: 0%;
  transition: width 0.55s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ---- Accent divider ---- */
.fb-divider {
  width: 100%;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(96, 165, 250, 0.35), transparent);
  flex-shrink: 0;
}

/* ---- Sentence card ---- */
.fb-sentence-card {
  width: 100%;
  background: linear-gradient(135deg, #111827 0%, #172554 40%, #0f172a 100%);
  border: 1px solid rgba(96, 165, 250, 0.25);
  box-shadow:
    0 0 0 1px rgba(96, 165, 250, 0.06),
    0 0 18px rgba(37, 99, 235, 0.12),
    0 4px 18px rgba(0, 0, 0, 0.35);
  border-radius: 16px;
  padding: clamp(1rem, 3.5vh, 1.5rem) clamp(1rem, 4vw, 1.75rem);
  text-align: center;
  transition: box-shadow 0.3s ease;
}

.fb-sentence-eyebrow {
  font-size: 0.62rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  color: #3b82f6;
  opacity: 0.7;
  margin-bottom: 0.85rem;
}

.fb-sentence-text {
  font-size: clamp(1.05rem, 4.2vh, 1.45rem);
  line-height: 1.65;
  color: #e2e8f0;
  font-weight: 500;
  margin: 0;
}

/* ---- Auto-fit size steps (applied by JS via fitSentenceText) ----
   Higher specificity (2 classes) wins over any single .fb-sentence-text
   rule, including the ones inside the responsive media queries below,
   regardless of source order. JS measures real overflow and applies
   the smallest step needed so the sentence never causes a scrollbar. */
.fb-sentence-text.fb-text-md {
  font-size: clamp(0.95rem, 3.6vh, 1.25rem);
  line-height: 1.55;
}

.fb-sentence-text.fb-text-sm {
  font-size: clamp(0.85rem, 3.1vh, 1.05rem);
  line-height: 1.5;
}

.fb-sentence-text.fb-text-xs {
  font-size: clamp(0.78rem, 2.7vh, 0.92rem);
  line-height: 1.45;
}

.fb-sentence-text.fb-text-2xs {
  font-size: clamp(0.7rem, 2.3vh, 0.82rem);
  line-height: 1.4;
}

/* Translation revealed after correct answer */
.fb-translation {
  margin-top: 1rem;
  padding: 0.65rem 1rem;
  font-size: 0.88rem;
  font-style: italic;
  color: #94a3b8;
  background: rgba(0, 0, 0, 0.25);
  border-radius: 8px;
  border-left: 2px solid rgba(6, 182, 212, 0.35);
  line-height: 1.55;
  text-align: left;
}

.fb-translation-word {
  color: #67e8f9;
  font-weight: 700;
  font-style: normal;
  text-shadow: 0 0 10px rgba(103, 232, 249, 0.35);
}

/* ---- Inline word container (slot group inside sentence) ---- */
#fill-blanks-word-container {
  display: inline-flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: flex-end;
  gap: 3px;
  margin: 0 6px;
  padding: 5px 8px 4px;
  background: rgba(2, 6, 23, 0.75);
  border: 1px solid rgba(71, 85, 105, 0.45);
  border-radius: 10px;
  vertical-align: middle;
  transition: border-color 0.3s ease, box-shadow 0.3s ease, background 0.3s ease;
}

#fill-blanks-word-container.correct {
  border-color: rgba(52, 211, 153, 0.55) !important;
  box-shadow: 0 0 22px rgba(16, 185, 129, 0.22) !important;
  background: rgba(6, 30, 18, 0.65) !important;
}

#fill-blanks-word-container.shake {
  animation: fb-shake 0.55s ease-in-out;
  border-color: rgba(239, 68, 68, 0.55) !important;
  box-shadow: 0 0 16px rgba(239, 68, 68, 0.2) !important;
}

/* ---- Letter slots (inside the word container) ---- */
.fb-letter-slot {
  width: 38px;
  height: 46px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  font-weight: 800;
  color: #38bdf8;
  background: rgba(2, 6, 23, 0.9);
  border: 1px solid rgba(71, 85, 105, 0.3);
  border-bottom: 2.5px solid rgba(6, 182, 212, 0.35);
  border-radius: 6px 6px 2px 2px;
  transition: background 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
  letter-spacing: 0.02em;
}

.fb-letter-slot.filled {
  background: rgba(23, 37, 84, 0.85);
  border-color: rgba(6, 182, 212, 0.5);
  border-bottom-color: #06b6d4;
  box-shadow: 0 0 12px rgba(6, 182, 212, 0.2), inset 0 1px 0 rgba(96, 165, 250, 0.08);
  animation: fb-slot-pop 0.22s ease-out;
}

/* Primera letra: pista ya colocada, no removible. Color distinto (ámbar)
   para diferenciarla claramente de las letras que el usuario completa. */
.fb-letter-slot.hint {
  color: #fbbf24;
  background: rgba(2, 6, 23, 0.9);
  border-color: rgba(251, 191, 36, 0.35);
  border-bottom-color: rgba(251, 191, 36, 0.55);
  box-shadow: 0 0 10px rgba(251, 191, 36, 0.15);
}

/* Shrink the slots too when the auto-fit reduces the sentence text,
   so the blank stays proportional and frees up extra vertical space. */
.fb-sentence-text.fb-text-sm .fb-letter-slot,
.fb-sentence-text.fb-text-xs .fb-letter-slot {
  width: 30px;
  height: 38px;
  font-size: 1rem;
}

.fb-sentence-text.fb-text-2xs .fb-letter-slot {
  width: 26px;
  height: 32px;
  font-size: 0.85rem;
}

/* ---- Choices section ---- */
.fb-choices-section {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.55rem;
}

.fb-choices-eyebrow {
  font-size: 0.62rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.13em;
  color: #475569;
  margin: 0;
}

.fb-choices-grid {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.45rem;
  max-width: 520px;
}

/* ---- Letter choice buttons ---- */
.fb-letter-choice {
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 0.95rem;
  color: #cbd5e1;
  background: linear-gradient(145deg, #111827 0%, #1a2744 60%, #0f172a 100%);
  border: 1px solid rgba(96, 165, 250, 0.2);
  border-radius: 10px;
  box-shadow:
    0 0 0 1px rgba(96, 165, 250, 0.05),
    0 2px 8px rgba(0, 0, 0, 0.3),
    inset 0 1px 0 rgba(255, 255, 255, 0.04);
  cursor: pointer;
  transition:
    background 0.14s ease,
    border-color 0.14s ease,
    box-shadow 0.14s ease,
    transform 0.14s ease,
    color 0.14s ease;
}

.fb-letter-choice:hover:not(:disabled) {
  background: linear-gradient(145deg, #1e3a8a 0%, #2563eb 60%, #172554 100%);
  border-color: rgba(96, 165, 250, 0.55);
  box-shadow:
    0 0 0 1px rgba(96, 165, 250, 0.12),
    0 0 18px rgba(59, 130, 246, 0.35),
    0 4px 12px rgba(0, 0, 0, 0.3);
  transform: translateY(-2px);
  color: #fff;
}

.fb-letter-choice:active:not(:disabled) {
  transform: translateY(0) scale(0.94);
  box-shadow:
    0 0 8px rgba(59, 130, 246, 0.2),
    0 1px 4px rgba(0, 0, 0, 0.3);
}

.fb-letter-choice:disabled {
  opacity: 0.2;
  cursor: not-allowed;
  transform: none !important;
  box-shadow: none;
}

/* ---- Delete control ---- */
.fb-controls {
  display: flex;
  justify-content: center;
}

.fb-delete-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 18px;
  font-size: 0.8rem;
  font-weight: 600;
  color: #64748b;
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid rgba(71, 85, 105, 0.3);
  border-radius: 8px;
  cursor: pointer;
  transition: color 0.2s ease, border-color 0.2s ease, background 0.2s ease, box-shadow 0.2s ease;
  letter-spacing: 0.02em;
}

.fb-delete-btn:hover:not(:disabled) {
  color: #fca5a5;
  border-color: rgba(239, 68, 68, 0.35);
  background: rgba(127, 29, 29, 0.18);
  box-shadow: 0 0 12px rgba(239, 68, 68, 0.1);
}

.fb-delete-btn:disabled {
  opacity: 0.25;
  cursor: not-allowed;
}

/* ---- Feedback area ---- */
.fb-feedback-area {
  width: 100%;
  min-height: 56px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

#fill-blanks-feedback {
  min-height: 28px;
  text-align: center;
  line-height: 1.4;
}

.fb-feedback-correct {
  color: #34d399;
  font-weight: 700;
  font-size: 1.1rem;
  text-shadow: 0 0 14px rgba(52, 211, 153, 0.65);
  display: inline-block;
}

.fb-feedback-wrong {
  color: #fb7185;
  font-weight: 600;
  font-size: 0.9rem;
  text-shadow: 0 0 12px rgba(251, 113, 133, 0.5);
  display: inline-block;
}

/* ---- Next button ---- */
.fb-next-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 36px;
  font-size: 1rem;
  font-weight: 700;
  color: #fff;
  background: linear-gradient(135deg, #1d4ed8 0%, #3b82f6 50%, #2563eb 100%);
  border: 1px solid rgba(96, 165, 250, 0.4);
  border-radius: 12px;
  cursor: pointer;
  box-shadow:
    0 0 20px rgba(59, 130, 246, 0.3),
    0 4px 16px rgba(0, 0, 0, 0.3),
    inset 0 1px 0 rgba(255, 255, 255, 0.1);
  transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
  letter-spacing: 0.02em;
}

.fb-next-btn:hover {
  transform: translateY(-2px);
  background: linear-gradient(135deg, #2563eb 0%, #60a5fa 50%, #3b82f6 100%);
  box-shadow:
    0 0 30px rgba(59, 130, 246, 0.5),
    0 8px 24px rgba(0, 0, 0, 0.3),
    inset 0 1px 0 rgba(255, 255, 255, 0.12);
}

.fb-next-btn:active {
  transform: translateY(0) scale(0.98);
}

/* Score highlight in final screen */
.fb-score-highlight {
  color: #67e8f9;
  font-weight: 800;
}

/* ==========================================
   ANIMATIONS
========================================== */

/* Shake on wrong answer */
@keyframes fb-shake {
  0%, 100% { transform: translateX(0); }
  12%       { transform: translateX(-7px); }
  25%       { transform: translateX(7px); }
  37%       { transform: translateX(-5px); }
  50%       { transform: translateX(5px); }
  62%       { transform: translateX(-3px); }
  75%       { transform: translateX(3px); }
  87%       { transform: translateX(-1px); }
}

/* Pop when a letter slot is filled */
@keyframes fb-slot-pop {
  0%   { transform: scale(1); }
  40%  { transform: scale(1.22); }
  70%  { transform: scale(0.93); }
  100% { transform: scale(1); }
}

/* ==========================================
   RESPONSIVE — MOBILE < 480px
========================================== */
@media (max-width: 480px) {
  .fb-sentence-card {
    padding: 1rem 0.9rem;
    border-radius: 12px;
  }

  .fb-sentence-text {
    font-size: 1.12rem;
    line-height: 1.55;
  }

  .fb-letter-slot {
    width: 30px;
    height: 38px;
    font-size: 1rem;
    border-radius: 5px 5px 2px 2px;
  }

  .fb-letter-choice {
    width: 40px;
    height: 40px;
    font-size: 0.88rem;
    border-radius: 8px;
  }

  .fb-choices-grid {
    gap: 0.32rem;
    max-width: 300px;
  }

  .fb-next-btn {
    padding: 10px 26px;
    font-size: 0.9rem;
  }

  .fb-delete-btn {
    font-size: 0.76rem;
    padding: 7px 14px;
  }
}

/* ==========================================
   RESPONSIVE — TABLET 640–767px
========================================== */
@media (min-width: 640px) and (max-width: 767px) {
  .fb-sentence-text {
    font-size: 1.35rem;
    line-height: 1.7;
  }

  .fb-letter-slot {
    width: 36px;
    height: 44px;
    font-size: 1.2rem;
  }

  .fb-letter-choice {
    width: 44px;
    height: 44px;
  }
}

/* ==========================================
   RESPONSIVE — DESKTOP ≥ 768px
========================================== */
@media (min-width: 768px) {
  .fb-sentence-card {
    padding: clamp(1.25rem, 4vh, 2rem) clamp(1.5rem, 5vw, 2.5rem);
  }

  .fb-sentence-text {
    font-size: 1.65rem;
    line-height: 1.75;
  }

  .fb-letter-slot {
    width: 44px;
    height: 52px;
    font-size: 1.4rem;
  }

  .fb-letter-choice {
    width: 48px;
    height: 48px;
    font-size: 1.05rem;
  }

  .fb-choices-grid {
    gap: 0.5rem;
    max-width: 560px;
  }
}

/* ==========================================
   RESPONSIVE — SHORT VIEWPORTS
   (landscape phones / small windows, regardless of width)
========================================== */
@media (max-height: 640px) {
  .fb-sentence-text {
    line-height: 1.4;
  }

  .fb-sentence-card {
    padding: 0.75rem 1rem;
  }

  .fb-feedback-area {
    min-height: 40px;
  }

  .fb-next-btn {
    padding: 9px 28px;
  }

  .fb-progress-section,
  .fb-divider {
    display: none; /* reclaim vertical space when height is tight */
  }
}