@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=Noto+Sans+Arabic:wght@400;600;700&display=swap');

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

body {
  font-family: 'Inter', 'Noto Sans Arabic', sans-serif;
  background: linear-gradient(135deg, #059669 0%, #065f46 100%);
  min-height: 100vh;
  display: flex; justify-content: center; align-items: flex-start;
  padding: 12px;
}

.container-app {
  background: rgba(255,255,255,0.96);
  backdrop-filter: blur(20px);
  border-radius: 24px;
  box-shadow: 0 25px 80px rgba(0,0,0,0.25);
  max-width: 560px; width: 100%;
  padding: 24px;
  min-height: 80vh;
}

.app-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 8px;
}
.app-title { font-weight: 700; font-size: 24px; color: #065f46; }
.app-title span { color: #059669; }
#dark-toggle, #home-btn {
  background: none; border: none; font-size: 22px; cursor: pointer;
}
#stats-bar {
  font-size: 12px; color: #666; text-align: center;
  padding: 6px 0 12px; border-bottom: 1px solid #e5e7eb; margin-bottom: 16px;
}

/* HOME GRID */
.home-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.home-card {
  background: linear-gradient(135deg, #ecfdf5, #d1fae5);
  border: 1px solid rgba(5,150,105,0.15);
  border-radius: 16px; padding: 20px 16px;
  text-align: center; cursor: pointer;
  transition: all 0.2s;
}
.home-card:hover { transform: translateY(-2px); box-shadow: 0 8px 24px rgba(5,150,105,0.2); }
.home-icon { font-size: 32px; display: block; margin-bottom: 6px; }
.home-label { font-weight: 600; font-size: 14px; color: #065f46; line-height: 1.4; }
.home-count { font-size: 12px; color: #059669; display: block; margin-top: 4px; }
.today-stats {
  text-align: center; margin-top: 12px; padding: 10px;
  background: #f0fdf4; border-radius: 12px; font-size: 13px; color: #065f46;
}
.home-streak {
  display: flex; justify-content: space-between; align-items: center;
  margin-top: 10px; padding: 10px 14px;
  background: #f0fdf4; border-radius: 12px;
}
.streak-fire { font-size: 14px; font-weight: 700; color: #065f46; }
.share-btn {
  background: linear-gradient(135deg, #059669, #047857); color: white;
  border: none; border-radius: 20px; padding: 6px 14px;
  font-size: 13px; font-weight: 600; cursor: pointer;
}
.share-btn:hover { transform: scale(1.05); }
body.dark .home-streak { background: rgba(5,150,105,0.1); }
body.dark .streak-fire { color: #6ee7b7; }

/* BACK BUTTON */
.back-btn {
  background: none; border: none; font-size: 16px; font-weight: 600;
  color: #059669; cursor: pointer; padding: 4px 0; margin-bottom: 12px;
}

.section-title { font-size: 20px; font-weight: 700; color: #065f46; margin-bottom: 16px; }

/* ALPHABET */
.alpha-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.alpha-card {
  background: #f0fdf4; border: 1px solid #d1fae5; border-radius: 12px;
  padding: 14px 8px; text-align: center; cursor: pointer; transition: all 0.2s;
}
.alpha-card:hover { background: #d1fae5; transform: scale(1.05); }
.alpha-letter { font-size: 28px; font-weight: 700; color: #065f46; display: block; font-family: 'Noto Sans Arabic'; }
.alpha-name { font-size: 11px; color: #059669; display: block; }

.letter-detail { text-align: center; }
.letter-big { font-size: 80px; font-weight: 700; color: #059669; font-family: 'Noto Sans Arabic'; margin: 16px 0; }
.letter-name { font-size: 20px; font-weight: 600; color: #065f46; margin-bottom: 24px; }
.letter-forms {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 20px;
}
.letter-forms div {
  background: #f0fdf4; border-radius: 12px; padding: 12px 8px; text-align: center;
}
.letter-forms small { display: block; font-size: 10px; color: #666; margin-bottom: 4px; }
.letter-forms span { font-size: 28px; font-family: 'Noto Sans Arabic'; color: #065f46; }
.letter-example { font-size: 16px; color: #333; margin-bottom: 20px; font-family: 'Noto Sans Arabic', 'Inter'; }
.letter-nav { display: flex; gap: 12px; justify-content: center; }
.letter-nav button {
  padding: 10px 24px; border-radius: 12px; border: 2px solid #059669;
  background: white; color: #059669; font-weight: 600; cursor: pointer;
  font-size: 16px; font-family: 'Noto Sans Arabic', 'Inter';
}
.letter-nav button:hover { background: #059669; color: white; }

/* VOCAB & PHRASES */
.cat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.cat-card {
  background: #f0fdf4; border: 1px solid #d1fae5; border-radius: 12px;
  padding: 14px; cursor: pointer; transition: all 0.2s;
  display: flex; flex-direction: column;
}
.cat-card:hover { background: #d1fae5; }
.cat-card span { font-weight: 600; font-size: 14px; color: #065f46; }
.cat-card small { font-size: 11px; color: #059669; }

.search-input {
  width: 100%; padding: 10px 14px; border-radius: 12px;
  border: 1.5px solid #d1fae5; font-size: 15px; margin-bottom: 12px;
  background: #f9fafb; color: #333; outline: none;
}
.search-input:focus { border-color: #059669; background: white; }
body.dark .search-input { background: rgba(255,255,255,0.07); border-color: rgba(5,150,105,0.3); color: #e0e0e0; }

.letter-tap-hint { font-size: 12px; color: #059669; margin: -10px 0 12px; opacity: 0.7; }

.speak-btn { font-size: 14px; cursor: pointer; margin-left: 4px; opacity: 0.7; vertical-align: middle; display: inline; }
.speak-btn:hover { opacity: 1; }

.vocab-list { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.vocab-row {
  display: flex; justify-content: space-between; align-items: center;
  background: #f9fafb; border-radius: 12px; padding: 12px 14px;
  gap: 12px;
}
.vocab-sv { font-weight: 600; font-size: 14px; color: #333; flex: 1; }
.vocab-ar { text-align: right; flex: 1; font-family: 'Noto Sans Arabic', 'Inter'; }
.vocab-msa { font-size: 15px; color: #065f46; }
.vocab-leb { font-size: 14px; color: #059669; }
.phrase-cat { font-size: 16px; font-weight: 700; color: #065f46; margin: 16px 0 8px; }

/* FLASHCARDS */
.fc-mode-btn {
  background: #f0fdf4; border: 1.5px solid #d1fae5; border-radius: 20px;
  padding: 6px 12px; font-size: 13px; cursor: pointer; color: #065f46; font-weight: 600;
}
.fc-mode-btn:hover { background: #d1fae5; }
body.dark .fc-mode-btn { background: rgba(5,150,105,0.1); border-color: rgba(5,150,105,0.3); color: #6ee7b7; }

.fc-scene {
  width: 100%; height: 220px; perspective: 1000px;
  margin: 16px 0;
}
.fc-card {
  width: 100%; height: 220px;
  position: relative; transform-style: preserve-3d;
  transition: transform 0.5s ease;
  cursor: pointer;
}
.fc-card.flipped { transform: rotateY(180deg); }
.fc-front, .fc-back {
  position: absolute; inset: 0;
  backface-visibility: hidden; -webkit-backface-visibility: hidden;
  border-radius: 24px; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 12px; padding: 32px 24px;
  box-shadow: 0 12px 40px rgba(0,0,0,0.15);
}
.fc-front {
  background: linear-gradient(135deg, #ecfdf5, #d1fae5);
  border: 2px solid rgba(5,150,105,0.2);
}
.fc-back {
  background: linear-gradient(135deg, #065f46, #059669);
  transform: rotateY(180deg);
}
.fc-card:active { transform: scale(0.97); }
.fc-card.flipped:active { transform: rotateY(180deg) scale(0.97); }
.fc-sv { font-size: 28px; font-weight: 700; color: #065f46; text-align: center; }
.fc-hint { font-size: 13px; color: #059669; opacity: 0.7; }
.fc-ar { font-size: 36px; font-weight: 700; color: white; font-family: 'Noto Sans Arabic'; text-align: center; }
.fc-leb { font-size: 18px; color: #d1fae5; font-family: 'Noto Sans Arabic'; }
.fc-speak {
  background: rgba(255,255,255,0.2); border: none; color: white;
  border-radius: 20px; padding: 6px 16px; font-size: 14px; cursor: pointer; margin-top: 4px;
}
.fc-speak:hover { background: rgba(255,255,255,0.3); }
.fc-nav { display: flex; gap: 10px; }
.fc-btn {
  flex: 1; padding: 12px; border-radius: 14px; border: 2px solid #d1fae5;
  background: #f0fdf4; font-size: 15px; font-weight: 600; color: #065f46; cursor: pointer;
}
.fc-btn.primary { background: linear-gradient(135deg, #059669, #047857); color: white; border-color: transparent; }
.fc-cats { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; align-items: center; }
.fc-cats small { color: #666; font-size: 12px; }
.fc-cat-btn {
  padding: 4px 10px; border-radius: 20px; border: 1.5px solid #d1fae5;
  background: #f0fdf4; font-size: 12px; color: #065f46; cursor: pointer;
}
.fc-cat-btn.active, .fc-cat-btn:hover { background: #059669; color: white; border-color: transparent; }
body.dark .fc-front { background: rgba(5,150,105,0.15); border-color: rgba(5,150,105,0.3); }
body.dark .fc-sv { color: #6ee7b7; }
body.dark .fc-btn { background: rgba(5,150,105,0.1); border-color: rgba(5,150,105,0.2); color: #6ee7b7; }
body.dark .fc-cat-btn { background: rgba(5,150,105,0.1); border-color: rgba(5,150,105,0.2); color: #6ee7b7; }

/* PAGE TRANSITIONS */
#app { animation: none; }
#app.page-in { animation: slideIn 0.2s ease; }
@keyframes slideIn {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ANSWER ANIMATIONS */
@keyframes bounce {
  0%,100% { transform: scale(1); }
  40%      { transform: scale(1.12); }
  70%      { transform: scale(0.95); }
}
@keyframes shake {
  0%,100% { transform: translateX(0); }
  20%     { transform: translateX(-8px); }
  40%     { transform: translateX(8px); }
  60%     { transform: translateX(-5px); }
  80%     { transform: translateX(5px); }
}
.quiz-opt.bounce { animation: bounce 0.4s ease; }
.quiz-opt.shake  { animation: shake 0.4s ease; }

/* QUIZ */
.quiz-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.quiz-progress { font-weight: 600; color: #065f46; }
.quiz-score { font-weight: 600; color: #059669; }
.progress-bar-wrap {
  height: 6px; background: #e5e7eb; border-radius: 3px; margin-bottom: 24px; overflow: hidden;
}
.progress-bar-fill { height: 100%; background: linear-gradient(90deg, #059669, #10b981); border-radius: 3px; transition: width 0.3s; }

.quiz-question {
  font-size: 18px; font-weight: 600; color: #333; text-align: center;
  margin-bottom: 20px; line-height: 1.6;
}
.quiz-ar { font-size: 32px; font-family: 'Noto Sans Arabic'; color: #059669; display: block; margin: 8px 0; }

.quiz-options { display: flex; flex-direction: column; gap: 8px; }
.quiz-opt {
  background: white; border: 2px solid #e5e7eb; border-radius: 14px;
  padding: 14px 18px; cursor: pointer; font-size: 16px; font-weight: 500;
  color: #333; text-align: center; transition: all 0.2s;
  font-family: 'Noto Sans Arabic', 'Inter';
}
.quiz-opt { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.opt-msa { font-size: 15px; color: inherit; font-family: 'Noto Sans Arabic', 'Inter'; }
.opt-leb { font-size: 13px; opacity: 0.8; font-family: 'Noto Sans Arabic', 'Inter'; }
.quiz-opt.correct .opt-msa, .quiz-opt.correct .opt-leb,
.quiz-opt.wrong .opt-msa, .quiz-opt.wrong .opt-leb { color: white; opacity: 1; }
.quiz-opt.correct { background: linear-gradient(135deg, #10B981, #059669); color: white; border-color: transparent; }
.quiz-opt.wrong { background: linear-gradient(135deg, #EF4444, #DC2626); color: white; border-color: transparent; }
.quiz-opt:disabled { cursor: default; }

.quiz-info {
  margin-top: 12px; padding: 12px; border-radius: 12px;
  font-size: 14px; font-family: 'Noto Sans Arabic', 'Inter'; line-height: 1.6;
}
.quiz-info.wrong { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }

.quiz-setup { display: flex; flex-direction: column; gap: 8px; }
.quiz-setup h3 { font-size: 15px; color: #065f46; margin-top: 12px; }
.setup-btn {
  padding: 14px; border-radius: 14px; border: 2px solid #d1fae5;
  background: #f0fdf4; font-size: 15px; font-weight: 600; color: #065f46;
  cursor: pointer; transition: all 0.2s; text-align: left;
}
.setup-btn:hover { background: #d1fae5; border-color: #059669; }

.quiz-start-btn {
  display: block; width: 100%; padding: 14px; border-radius: 14px; border: none;
  background: linear-gradient(135deg, #059669, #047857); color: white;
  font-size: 15px; font-weight: 600; cursor: pointer; margin-top: 8px;
}
.quiz-start-btn:hover { transform: translateY(-1px); box-shadow: 0 4px 16px rgba(5,150,105,0.4); }
.quiz-start-btn.secondary { background: linear-gradient(135deg, #6B7280, #4B5563); }

/* GRAMMATIK */
.grammar-menu { display: flex; flex-direction: column; gap: 10px; }
.grammar-card {
  background: linear-gradient(135deg, #ecfdf5, #d1fae5);
  border: 1px solid rgba(5,150,105,0.2);
  border-radius: 16px; padding: 16px 18px; cursor: pointer; transition: all 0.2s;
}
.grammar-card:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(5,150,105,0.2); }
.grammar-card-title { font-size: 16px; font-weight: 700; color: #065f46; margin-bottom: 4px; }
.grammar-card-desc { font-size: 13px; color: #059669; }
.grammar-desc { font-size: 14px; color: #666; margin-bottom: 14px; padding: 10px 14px; background: #f0fdf4; border-radius: 10px; }
body.dark .grammar-card { background: rgba(5,150,105,0.1); border-color: rgba(5,150,105,0.2); }
body.dark .grammar-card-title { color: #6ee7b7; }
body.dark .grammar-card-desc { color: #34d399; }
body.dark .grammar-desc { background: rgba(5,150,105,0.1); color: #aaa; }

/* DAGLIG UTMANING */
.daily-header {
  display: flex; justify-content: space-between; align-items: center;
  font-weight: 700; font-size: 16px; color: #065f46; margin-bottom: 8px;
}
.daily-progress { color: #059669; font-size: 14px; }
.daily-stars { display: flex; justify-content: center; gap: 8px; margin: 12px 0; }
.daily-stars.large { gap: 12px; margin: 16px 0; }
.daily-star { font-size: 24px; opacity: 0.25; transition: all 0.3s; }
.daily-star.earned { opacity: 1; animation: starPop 0.4s ease; }
.daily-stars.large .daily-star { font-size: 36px; }
@keyframes starPop {
  0%   { transform: scale(0); }
  60%  { transform: scale(1.3); }
  100% { transform: scale(1); }
}

/* BADGES */
.badges-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.badge-item {
  background: #f0fdf4; border-radius: 12px; padding: 10px 6px;
  text-align: center; display: flex; flex-direction: column; align-items: center; gap: 4px;
  transition: transform 0.2s;
}
.badge-item.locked { background: #f3f4f6; opacity: 0.5; }
.badge-item.earned { border: 2px solid #059669; }
.badge-item.earned:hover { transform: scale(1.08); }
.badge-icon { font-size: 24px; }
.badge-name { font-size: 10px; font-weight: 600; color: #065f46; line-height: 1.2; }
.badge-item.locked .badge-name { color: #999; }

.badge-toast {
  position: fixed; bottom: 30px; left: 50%; transform: translateX(-50%);
  background: linear-gradient(135deg, #F59E0B, #D97706);
  color: white; font-size: 14px; padding: 12px 20px;
  border-radius: 20px; box-shadow: 0 8px 24px rgba(245,158,11,0.4);
  display: flex; align-items: center; gap: 10px;
  animation: toastIn 0.3s ease, toastOut 0.3s ease 3.2s forwards;
  z-index: 200;
}
.badge-toast-icon { font-size: 28px; }
body.dark .badge-item { background: rgba(5,150,105,0.1); }
body.dark .badge-item.locked { background: rgba(255,255,255,0.05); }
body.dark .badge-name { color: #6ee7b7; }

/* XP & LEVELS */
.xp-pop {
  position: fixed; top: 40%; left: 50%; transform: translate(-50%, -50%);
  background: #059669; color: white; font-weight: 700; font-size: 20px;
  padding: 8px 20px; border-radius: 20px; pointer-events: none;
  animation: xpFloat 1s ease-out forwards; z-index: 100;
}
@keyframes xpFloat {
  0%   { opacity: 1; transform: translate(-50%, -50%); }
  100% { opacity: 0; transform: translate(-50%, -120%); }
}
.levelup-toast {
  position: fixed; bottom: 30px; left: 50%; transform: translateX(-50%);
  background: linear-gradient(135deg, #059669, #047857);
  color: white; font-size: 16px; padding: 12px 24px;
  border-radius: 20px; box-shadow: 0 8px 24px rgba(5,150,105,0.4);
  animation: toastIn 0.3s ease, toastOut 0.3s ease 2.7s forwards;
  z-index: 200;
}
@keyframes toastIn  { from { opacity:0; transform: translateX(-50%) translateY(20px); } to { opacity:1; transform: translateX(-50%) translateY(0); } }
@keyframes toastOut { from { opacity:1; } to { opacity:0; } }

.level-display { display: flex; align-items: center; gap: 16px; background: #f0fdf4; border-radius: 16px; padding: 16px; }
.level-icon { font-size: 40px; }
.level-info { flex: 1; }
.level-name { font-size: 18px; font-weight: 700; color: #065f46; }
.level-xp { font-size: 12px; color: #059669; margin: 2px 0 6px; }
.level-bar-wrap { height: 8px; background: #d1fae5; border-radius: 4px; overflow: hidden; }
.level-bar-fill { height: 100%; background: linear-gradient(90deg, #059669, #10b981); border-radius: 4px; transition: width 0.5s; }
body.dark .level-display { background: rgba(5,150,105,0.1); }
body.dark .level-name { color: #6ee7b7; }

/* OM-SIDAN */
.about-section { margin-bottom: 20px; }
.about-section h3 { font-size: 15px; font-weight: 700; color: #065f46; margin-bottom: 10px; }
.about-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 10px; }
.about-stat {
  background: #f0fdf4; border-radius: 12px; padding: 12px 8px;
  text-align: center; display: flex; flex-direction: column; gap: 4px;
}
.about-num { font-size: 22px; font-weight: 700; color: #059669; }
.about-stat span:last-child { font-size: 11px; color: #666; }
.about-content {
  background: #f9fafb; border-radius: 12px; padding: 12px 14px;
  display: flex; flex-direction: column; gap: 6px; font-size: 14px; color: #333;
}
.about-reset {
  background: none; border: 1.5px solid #fca5a5; color: #dc2626;
  border-radius: 10px; padding: 8px 14px; font-size: 13px; cursor: pointer;
}
.about-reset:hover { background: #fef2f2; }
body.dark .about-stat { background: rgba(5,150,105,0.1); }
body.dark .about-num { color: #34d399; }
body.dark .about-content { background: rgba(255,255,255,0.05); color: #e0e0e0; }

/* RESULT */
.result-page { text-align: center; padding: 20px 0; }
.result-emoji { font-size: 64px; margin-bottom: 12px; }
.result-score { font-size: 36px; font-weight: 700; color: #065f46; }
.result-pct { font-size: 18px; color: #059669; margin-bottom: 8px; }
.result-streak { font-size: 14px; color: #666; margin-bottom: 20px; }
.missed-title { font-size: 16px; color: #991b1b; margin: 16px 0 8px; }

#confetti { position: fixed; top: 0; left: 0; width: 100%; height: 100%; pointer-events: none; z-index: 999; }

/* DARK MODE */
body.dark { background: linear-gradient(135deg, #064e3b 0%, #022c22 100%); }
body.dark .container-app { background: rgba(20,30,25,0.96); color: #e0e0e0; }
body.dark .home-card, body.dark .alpha-card, body.dark .cat-card {
  background: rgba(5,150,105,0.1); border-color: rgba(5,150,105,0.2);
}
body.dark .home-label, body.dark .section-title, body.dark .alpha-letter,
body.dark .letter-name, body.dark .cat-card span { color: #6ee7b7; }
body.dark .vocab-row { background: rgba(255,255,255,0.05); }
body.dark .vocab-sv, body.dark .quiz-question { color: #e0e0e0; }
body.dark .vocab-msa { color: #6ee7b7; }
body.dark .vocab-leb { color: #34d399; }
body.dark .quiz-opt { background: rgba(255,255,255,0.05); border-color: rgba(255,255,255,0.1); color: #e0e0e0; }
body.dark .quiz-opt:hover { background: rgba(5,150,105,0.15); border-color: #059669; }
body.dark .setup-btn { background: rgba(5,150,105,0.1); border-color: rgba(5,150,105,0.2); color: #6ee7b7; }
body.dark .letter-forms div { background: rgba(5,150,105,0.1); }
body.dark .letter-forms span { color: #6ee7b7; }
body.dark .letter-nav button { background: transparent; border-color: #059669; color: #6ee7b7; }
body.dark .letter-example { color: #ccc; }
body.dark #stats-bar { color: #999; border-color: rgba(255,255,255,0.1); }
body.dark .today-stats { background: rgba(5,150,105,0.1); color: #6ee7b7; }
body.dark .progress-bar-wrap { background: rgba(255,255,255,0.1); }

@media (max-width: 480px) {
  body { padding: 6px; }
  .container-app { padding: 16px; border-radius: 20px; }
  .app-title { font-size: 20px; }
  .alpha-grid { grid-template-columns: repeat(4, 1fr); gap: 6px; }
  .letter-big { font-size: 60px; }
}
