/* ===== GLOBAL STYLES ===== */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Nunito', sans-serif;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  min-height: 100vh;
  overflow-x: hidden;
}

/* ===== ANIMATED BACKGROUND ===== */
.bg-animated {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
}

.bubble {
  position: absolute;
  border-radius: 50%;
  animation: floatUp linear infinite;
  opacity: 0.15;
}

@keyframes floatUp {
  0% { transform: translateY(100vh) scale(0); opacity: 0; }
  10% { opacity: 0.15; }
  90% { opacity: 0.1; }
  100% { transform: translateY(-200px) scale(1.2); opacity: 0; }
}

/* ===== APP CONTAINER ===== */
#app {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* ===== HEADER ===== */
.app-header {
  width: 100%;
  text-align: center;
  padding: 24px 16px 16px;
  background: rgba(255,255,255,0.1);
  backdrop-filter: blur(10px);
  border-bottom: 2px solid rgba(255,255,255,0.2);
}

.app-header h1 {
  font-family: 'Fredoka One', cursive;
  font-size: clamp(2rem, 5vw, 3.5rem);
  color: #fff;
  text-shadow: 3px 3px 0px rgba(0,0,0,0.2);
  letter-spacing: 2px;
}

.app-header p {
  color: rgba(255,255,255,0.85);
  font-size: 1.1rem;
  margin-top: 4px;
  font-weight: 600;
}

/* ===== STARS / SCORE BAR ===== */
.score-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 10px 24px;
  background: rgba(255,255,255,0.15);
  border-radius: 50px;
  margin: 12px auto;
  max-width: 500px;
  font-weight: 700;
  color: #fff;
  font-size: 1.1rem;
  backdrop-filter: blur(6px);
  border: 2px solid rgba(255,255,255,0.3);
}

.score-bar .star { font-size: 1.4rem; }
.score-stars { display: flex; gap: 4px; }

/* ===== NAV TABS ===== */
.nav-tabs {
  display: flex;
  gap: 8px;
  margin: 16px auto;
  padding: 6px;
  background: rgba(255,255,255,0.15);
  border-radius: 60px;
  backdrop-filter: blur(8px);
  border: 2px solid rgba(255,255,255,0.25);
  flex-wrap: wrap;
  justify-content: center;
}

.nav-tab {
  padding: 10px 22px;
  border-radius: 50px;
  border: none;
  cursor: pointer;
  font-family: 'Nunito', sans-serif;
  font-weight: 700;
  font-size: 1rem;
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  color: #fff;
  background: transparent;
}

.nav-tab:hover {
  background: rgba(255,255,255,0.2);
  transform: scale(1.05);
}

.nav-tab.active {
  background: #fff;
  color: #764ba2;
  box-shadow: 0 4px 15px rgba(0,0,0,0.2);
  transform: scale(1.07);
}

/* ===== MAIN CONTENT ===== */
.main-content {
  width: 100%;
  max-width: 1100px;
  padding: 16px;
  flex: 1;
}

/* ===== LEARN MODE ===== */
.alphabet-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 14px;
  padding: 8px;
}

.letter-card {
  background: #fff;
  border-radius: 20px;
  padding: 16px 10px;
  text-align: center;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  box-shadow: 0 6px 20px rgba(0,0,0,0.12);
  position: relative;
  overflow: hidden;
  border: 3px solid transparent;
  user-select: none;
}

.letter-card::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(255,255,255,0.6), transparent);
  border-radius: 17px;
}

.letter-card:hover {
  transform: translateY(-6px) scale(1.04);
  box-shadow: 0 14px 35px rgba(0,0,0,0.18);
}

.letter-card:active {
  transform: scale(0.96);
}

.letter-card.playing {
  animation: pulse-card 0.5s ease;
  border-color: #a855f7;
}

@keyframes pulse-card {
  0% { transform: scale(1); }
  50% { transform: scale(1.12); }
  100% { transform: scale(1); }
}

.letter-display {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin-bottom: 8px;
}

.letter-upper {
  font-family: 'Fredoka One', cursive;
  font-size: 2.6rem;
  line-height: 1;
}

.letter-lower {
  font-size: 1.8rem;
  font-weight: 800;
  line-height: 1;
  opacity: 0.75;
}

.letter-emoji {
  font-size: 2rem;
  margin: 4px 0;
  display: block;
}

.letter-word {
  font-size: 0.82rem;
  font-weight: 700;
  color: #555;
  letter-spacing: 0.5px;
  text-transform: capitalize;
}

.letter-sound-btn {
  margin-top: 8px;
  background: linear-gradient(135deg, #a855f7, #7c3aed);
  color: white;
  border: none;
  border-radius: 50px;
  padding: 5px 12px;
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: all 0.2s;
  font-family: 'Nunito', sans-serif;
}

.letter-sound-btn:hover {
  transform: scale(1.1);
  box-shadow: 0 3px 10px rgba(124,58,237,0.4);
}

/* ===== LETTER DETAIL MODAL ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(4px);
  padding: 16px;
  animation: fadeIn 0.2s ease;
}

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

.modal-card {
  background: #fff;
  border-radius: 30px;
  padding: 32px;
  max-width: 480px;
  width: 100%;
  text-align: center;
  position: relative;
  animation: popIn 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
  box-shadow: 0 25px 60px rgba(0,0,0,0.3);
}

@keyframes popIn {
  from { transform: scale(0.5); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.modal-close {
  position: absolute;
  top: 16px; right: 16px;
  background: #f3f4f6;
  border: none;
  border-radius: 50%;
  width: 36px; height: 36px;
  font-size: 1.2rem;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.2s;
  color: #666;
}
.modal-close:hover { background: #e5e7eb; transform: rotate(90deg); }

.modal-big-letter {
  font-family: 'Fredoka One', cursive;
  font-size: 7rem;
  line-height: 1;
  background: linear-gradient(135deg, #a855f7, #7c3aed);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.modal-both-cases {
  font-size: 3rem;
  font-weight: 800;
  color: #555;
  margin: 4px 0;
}

.modal-image {
  width: 120px; height: 120px;
  object-fit: contain;
  margin: 10px auto;
  border-radius: 16px;
  background: #f9f0ff;
  padding: 8px;
  border: 3px solid #e9d5ff;
  font-size: 5rem;
  display: flex; align-items: center; justify-content: center;
}

.modal-word {
  font-size: 1.8rem;
  font-weight: 800;
  color: #333;
  margin: 6px 0;
}

.modal-translation {
  font-size: 1.1rem;
  color: #7c3aed;
  font-weight: 700;
  direction: rtl;
}

.modal-play-btn {
  margin-top: 16px;
  background: linear-gradient(135deg, #a855f7, #7c3aed);
  color: white;
  border: none;
  border-radius: 50px;
  padding: 14px 32px;
  font-size: 1.2rem;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  font-family: 'Nunito', sans-serif;
  box-shadow: 0 6px 20px rgba(124,58,237,0.3);
}

.modal-play-btn:hover {
  transform: scale(1.08);
  box-shadow: 0 10px 30px rgba(124,58,237,0.45);
}

.modal-play-btn:active {
  transform: scale(0.95);
}

.modal-nav {
  display: flex; gap: 10px; justify-content: center; margin-top: 16px;
}

.modal-nav button {
  background: #f3e8ff;
  border: 2px solid #d8b4fe;
  color: #7c3aed;
  border-radius: 50px;
  padding: 8px 20px;
  font-weight: 700;
  cursor: pointer;
  font-family: 'Nunito', sans-serif;
  transition: all 0.2s;
  font-size: 0.95rem;
}

.modal-nav button:hover {
  background: #7c3aed;
  color: white;
  border-color: #7c3aed;
}

/* ===== QUIZ MODE ===== */
.quiz-container {
  max-width: 700px;
  margin: 0 auto;
  padding: 8px;
}

.quiz-progress {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 20px;
}

.quiz-progress-bar {
  flex: 1;
  height: 12px;
  background: rgba(255,255,255,0.3);
  border-radius: 10px;
  overflow: hidden;
}

.quiz-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #fbbf24, #f59e0b);
  border-radius: 10px;
  transition: width 0.5s ease;
}

.quiz-progress-text {
  color: #fff;
  font-weight: 700;
  font-size: 0.95rem;
  white-space: nowrap;
}

.quiz-card {
  background: #fff;
  border-radius: 28px;
  padding: 32px 28px;
  text-align: center;
  box-shadow: 0 20px 50px rgba(0,0,0,0.15);
  animation: slideUp 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes slideUp {
  from { transform: translateY(40px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.quiz-type-badge {
  display: inline-block;
  background: linear-gradient(135deg, #a855f7, #7c3aed);
  color: white;
  padding: 5px 16px;
  border-radius: 50px;
  font-size: 0.85rem;
  font-weight: 700;
  margin-bottom: 16px;
}

.quiz-question {
  font-size: 1.3rem;
  font-weight: 700;
  color: #333;
  margin-bottom: 20px;
  line-height: 1.4;
}

.quiz-big-letter {
  font-family: 'Fredoka One', cursive;
  font-size: 8rem;
  line-height: 1;
  background: linear-gradient(135deg, #a855f7, #7c3aed);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  display: block;
  margin: 8px 0 20px;
}

.quiz-emoji-display {
  font-size: 6rem;
  display: block;
  margin: 8px 0 20px;
  animation: bounce-emoji 1s ease infinite;
}

@keyframes bounce-emoji {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-10px); }
}

.quiz-options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 16px;
}

.quiz-option {
  padding: 16px;
  border-radius: 18px;
  border: 3px solid #e5e7eb;
  background: #f9fafb;
  cursor: pointer;
  font-family: 'Nunito', sans-serif;
  font-size: 1.5rem;
  font-weight: 800;
  color: #333;
  transition: all 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 70px;
}

.quiz-option:hover:not(:disabled) {
  border-color: #a855f7;
  background: #f3e8ff;
  transform: scale(1.04);
  color: #7c3aed;
}

.quiz-option.correct {
  border-color: #22c55e;
  background: #dcfce7;
  color: #15803d;
  animation: correctAnim 0.5s ease;
}

.quiz-option.wrong {
  border-color: #ef4444;
  background: #fee2e2;
  color: #dc2626;
  animation: shake 0.4s ease;
}

.quiz-option.show-correct {
  border-color: #22c55e;
  background: #dcfce7;
  color: #15803d;
}

@keyframes correctAnim {
  0% { transform: scale(1); }
  40% { transform: scale(1.15); }
  100% { transform: scale(1); }
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-8px); }
  40% { transform: translateX(8px); }
  60% { transform: translateX(-6px); }
  80% { transform: translateX(6px); }
}

.quiz-feedback {
  margin-top: 20px;
  padding: 16px 24px;
  border-radius: 16px;
  font-size: 1.3rem;
  font-weight: 700;
  display: none;
  animation: popIn 0.3s ease;
}

.quiz-feedback.show { display: block; }
.quiz-feedback.correct { background: #dcfce7; color: #15803d; border: 2px solid #22c55e; }
.quiz-feedback.wrong { background: #fee2e2; color: #dc2626; border: 2px solid #ef4444; }

.quiz-next-btn {
  margin-top: 16px;
  background: linear-gradient(135deg, #a855f7, #7c3aed);
  color: white;
  border: none;
  border-radius: 50px;
  padding: 14px 40px;
  font-size: 1.1rem;
  font-weight: 700;
  cursor: pointer;
  font-family: 'Nunito', sans-serif;
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  display: none;
  box-shadow: 0 6px 20px rgba(124,58,237,0.3);
}

.quiz-next-btn.show { display: inline-block; }
.quiz-next-btn:hover { transform: scale(1.08); box-shadow: 0 10px 30px rgba(124,58,237,0.45); }

/* ===== RESULTS SCREEN ===== */
.results-card {
  background: #fff;
  border-radius: 30px;
  padding: 40px 32px;
  text-align: center;
  max-width: 500px;
  margin: 0 auto;
  box-shadow: 0 20px 50px rgba(0,0,0,0.15);
  animation: popIn 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.results-trophy {
  font-size: 6rem;
  display: block;
  margin-bottom: 16px;
  animation: swing 1s ease;
}

@keyframes swing {
  0%, 100% { transform: rotate(-10deg); }
  50% { transform: rotate(10deg); }
}

.results-title {
  font-family: 'Fredoka One', cursive;
  font-size: 2.5rem;
  background: linear-gradient(135deg, #a855f7, #7c3aed);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.results-score {
  font-size: 4rem;
  font-weight: 800;
  color: #f59e0b;
  margin: 10px 0;
}

.results-stars {
  font-size: 2.5rem;
  margin: 10px 0;
  display: flex; justify-content: center; gap: 6px;
}

.results-msg {
  font-size: 1.15rem;
  color: #555;
  font-weight: 600;
  direction: rtl;
  margin: 10px 0 20px;
}

.btn-primary {
  background: linear-gradient(135deg, #a855f7, #7c3aed);
  color: white;
  border: none;
  border-radius: 50px;
  padding: 14px 32px;
  font-size: 1.1rem;
  font-weight: 700;
  cursor: pointer;
  font-family: 'Nunito', sans-serif;
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  margin: 6px;
  box-shadow: 0 6px 20px rgba(124,58,237,0.3);
}
.btn-primary:hover { transform: scale(1.08); box-shadow: 0 10px 30px rgba(124,58,237,0.45); }

.btn-secondary {
  background: linear-gradient(135deg, #38bdf8, #0284c7);
  color: white;
  border: none;
  border-radius: 50px;
  padding: 14px 32px;
  font-size: 1.1rem;
  font-weight: 700;
  cursor: pointer;
  font-family: 'Nunito', sans-serif;
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  margin: 6px;
  box-shadow: 0 6px 20px rgba(2,132,199,0.3);
}
.btn-secondary:hover { transform: scale(1.08); box-shadow: 0 10px 30px rgba(2,132,199,0.45); }

/* ===== WRITE MODE ===== */
.write-container {
  max-width: 600px;
  margin: 0 auto;
}

.write-card {
  background: #fff;
  border-radius: 28px;
  padding: 28px;
  text-align: center;
  box-shadow: 0 20px 50px rgba(0,0,0,0.15);
  animation: slideUp 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.write-prompt {
  font-size: 1.2rem;
  font-weight: 700;
  color: #555;
  margin-bottom: 8px;
  direction: rtl;
}

.write-target {
  font-family: 'Fredoka One', cursive;
  font-size: 6rem;
  background: linear-gradient(135deg, #a855f7, #7c3aed);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  line-height: 1;
  margin: 8px 0;
}

.write-input {
  font-family: 'Fredoka One', cursive;
  font-size: 4rem;
  width: 120px;
  height: 100px;
  text-align: center;
  border: 3px solid #e5e7eb;
  border-radius: 16px;
  margin: 12px auto;
  display: block;
  outline: none;
  transition: border-color 0.2s;
  background: #f9fafb;
  color: #333;
}

.write-input:focus {
  border-color: #a855f7;
  box-shadow: 0 0 0 3px rgba(168,85,247,0.2);
}

.write-input.correct {
  border-color: #22c55e;
  background: #dcfce7;
  color: #15803d;
}

.write-input.wrong {
  border-color: #ef4444;
  background: #fee2e2;
  color: #dc2626;
  animation: shake 0.4s ease;
}

.write-check-btn {
  background: linear-gradient(135deg, #a855f7, #7c3aed);
  color: white;
  border: none;
  border-radius: 50px;
  padding: 12px 30px;
  font-size: 1.1rem;
  font-weight: 700;
  cursor: pointer;
  font-family: 'Nunito', sans-serif;
  transition: all 0.2s;
  margin-top: 8px;
  box-shadow: 0 4px 15px rgba(124,58,237,0.3);
}

.write-check-btn:hover { transform: scale(1.06); }

/* ===== CONFETTI ===== */
.confetti-piece {
  position: fixed;
  width: 14px;
  height: 14px;
  border-radius: 3px;
  pointer-events: none;
  z-index: 9999;
  animation: confettiFall linear forwards;
}

@keyframes confettiFall {
  0% { transform: translateY(-20px) rotate(0deg); opacity: 1; }
  100% { transform: translateY(110vh) rotate(720deg); opacity: 0; }
}

/* ===== TOOLTIP ===== */
.tooltip-text {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0,0,0,0.8);
  color: white;
  padding: 5px 10px;
  border-radius: 8px;
  font-size: 0.75rem;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s;
}
.letter-card:hover .tooltip-text { opacity: 1; }

/* ===== RESPONSIVE ===== */
@media (max-width: 600px) {
  .alphabet-grid {
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 10px;
  }
  .letter-upper { font-size: 2rem; }
  .quiz-options { grid-template-columns: 1fr 1fr; }
  .modal-big-letter { font-size: 5rem; }
  .nav-tab { padding: 8px 14px; font-size: 0.88rem; }
}

/* ===== AUDIO PULSE ===== */
.audio-pulse {
  animation: audioPulse 0.8s ease;
}

@keyframes audioPulse {
  0% { box-shadow: 0 0 0 0 rgba(168,85,247,0.7); }
  70% { box-shadow: 0 0 0 15px rgba(168,85,247,0); }
  100% { box-shadow: 0 0 0 0 rgba(168,85,247,0); }
}

/* ===== FILTER BAR ===== */
.filter-bar {
  display: flex;
  gap: 8px;
  justify-content: center;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.filter-btn {
  padding: 7px 18px;
  border-radius: 50px;
  border: 2px solid rgba(255,255,255,0.5);
  background: rgba(255,255,255,0.15);
  color: #fff;
  font-weight: 700;
  cursor: pointer;
  font-family: 'Nunito', sans-serif;
  font-size: 0.9rem;
  transition: all 0.2s;
}

.filter-btn:hover, .filter-btn.active {
  background: #fff;
  color: #7c3aed;
  border-color: #fff;
}

/* ===== LOADING ===== */
.loading-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 200px;
  color: white;
  font-size: 1.3rem;
  font-weight: 700;
  gap: 16px;
}

.spinner {
  width: 50px; height: 50px;
  border: 5px solid rgba(255,255,255,0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}
