:root {
  --bg:         #FFF9F0;
  --primary:    #FF6B35;
  --secondary:  #4ECDC4;
  --correct:    #2ECC71;
  --wrong:      #E74C3C;
  --label-verb: #3498DB;
  --label-past: #E67E22;
  --text:       #2C3E50;
  --accent:     #FFD93D;
  --card-bg:    #FFFFFF;
  --shadow:     0 4px 20px rgba(0,0,0,0.10);
}

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Segoe UI', Arial, sans-serif;
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 16px;
}

#app {
  width: 100%;
  max-width: 600px;
}

/* ── SCREENS ─────────────────────────────────────────── */
.screen {
  display: none;
  animation: fade-in 0.25s ease;
}
.screen.active {
  display: block;
}

@keyframes fade-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── WELCOME SCREEN ──────────────────────────────────── */
#screen-welcome {
  text-align: center;
  padding-top: 40px;
}

.welcome-title {
  font-size: 2rem;
  font-weight: 800;
  color: var(--primary);
  margin-bottom: 6px;
}

.welcome-subtitle {
  font-size: 1.1rem;
  color: var(--text);
  opacity: 0.7;
  margin-bottom: 40px;
}

.mode-buttons {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.btn-mode {
  background: var(--card-bg);
  border: 3px solid var(--primary);
  border-radius: 16px;
  padding: 20px 24px;
  cursor: pointer;
  text-align: right;
  transition: transform 0.15s, box-shadow 0.15s, background 0.15s;
  box-shadow: var(--shadow);
}

.btn-mode:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 28px rgba(255,107,53,0.25);
  background: #FFF3EE;
}

.btn-mode:active {
  transform: translateY(0);
}

.mode-icon {
  font-size: 2rem;
  display: block;
  margin-bottom: 6px;
}

.mode-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--primary);
  display: block;
}

.mode-desc {
  font-size: 0.9rem;
  color: var(--text);
  opacity: 0.65;
  display: block;
  margin-top: 4px;
}

/* ── QUIZ SCREEN ─────────────────────────────────────── */
#screen-quiz {
  position: relative;
}

.quiz-topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 18px;
}

.btn-home {
  background: none;
  border: 2px solid var(--text);
  border-radius: 10px;
  padding: 8px 12px;
  font-size: 1rem;
  cursor: pointer;
  opacity: 0.55;
  flex-shrink: 0;
  transition: opacity 0.15s;
}
.btn-home:hover { opacity: 1; }

.progress-wrap {
  flex: 1;
  height: 12px;
  background: #E0D8CF;
  border-radius: 6px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--secondary), var(--primary));
  border-radius: 6px;
  width: 0%;
  transition: width 0.4s ease;
}

.score-display {
  flex-shrink: 0;
  font-size: 0.9rem;
  font-weight: 700;
  display: flex;
  gap: 8px;
}

.score-correct { color: var(--correct); }
.score-wrong   { color: var(--wrong); }

/* ── QUESTION CARD ───────────────────────────────────── */
.question-card {
  background: var(--card-bg);
  border-radius: 20px;
  padding: 28px 24px 20px;
  box-shadow: var(--shadow);
  margin-bottom: 18px;
  text-align: center;
  position: relative;
}

.question-number {
  font-size: 0.8rem;
  opacity: 0.45;
  margin-bottom: 12px;
}

.question-label-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-bottom: 6px;
}

.question-word {
  font-size: 1.8rem;
  font-weight: 800;
  color: var(--text);
  direction: ltr;
}

.question-word.hebrew {
  font-size: 1.7rem;
  direction: rtl;
}

.btn-pronounce {
  background: var(--secondary);
  border: none;
  border-radius: 50%;
  width: 40px;
  height: 40px;
  font-size: 1.1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: transform 0.15s, background 0.15s;
  box-shadow: 0 2px 8px rgba(78,205,196,0.35);
}
.btn-pronounce:hover  { transform: scale(1.12); }
.btn-pronounce:active { transform: scale(0.95); }

/* ── LABEL BADGES ────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 20px;
  font-size: 0.72rem;
  font-weight: 700;
  color: #fff;
  vertical-align: middle;
  direction: rtl;
}
.badge-verb { background: var(--label-verb); }
.badge-past { background: var(--label-past); }

/* ── CHOICES GRID ────────────────────────────────────── */
.choices-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.btn-choice {
  background: var(--card-bg);
  border: 2.5px solid #D9D0C7;
  border-radius: 14px;
  padding: 16px 12px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  direction: ltr;
  text-align: center;
  transition: border-color 0.15s, transform 0.15s, background 0.15s;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  gap: 8px;
  line-height: 1.3;
}

.btn-choice:not(:disabled):hover {
  border-color: var(--primary);
  transform: translateY(-2px);
  background: #FFF3EE;
}

.btn-choice:disabled {
  cursor: default;
}

/* Speak button inside choice */
.btn-choice-speak {
  background: none;
  border: none;
  font-size: 0.85rem;
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 6px;
  opacity: 0.5;
  transition: opacity 0.15s, transform 0.15s;
  flex-shrink: 0;
}
.btn-choice-speak:hover {
  opacity: 1;
  transform: scale(1.2);
}

/* Hebrew choice buttons: RTL text */
.btn-choice.hebrew-choice {
  direction: rtl;
  font-size: 1rem;
}

/* Answer states */
.btn-choice.correct-choice {
  background: #EAFAF1;
  border-color: var(--correct);
  animation: bounce-correct 0.5s ease forwards;
}

.btn-choice.wrong-choice {
  background: #FDECEA;
  border-color: var(--wrong);
  animation: shake 0.45s ease forwards;
}

.btn-choice.reveal-correct {
  background: #EAFAF1;
  border-color: var(--correct);
  animation: glow-correct 1s ease-in-out infinite;
}

@keyframes bounce-correct {
  0%   { transform: scale(1); }
  40%  { transform: scale(1.10); }
  65%  { transform: scale(0.96); }
  100% { transform: scale(1); }
}

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

@keyframes glow-correct {
  0%, 100% { box-shadow: 0 0 0 0 rgba(46,204,113,0.3); }
  50%       { box-shadow: 0 0 0 8px rgba(46,204,113,0.15); }
}

/* ── FEEDBACK OVERLAY ────────────────────────────────── */
.feedback-overlay {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%) translateY(100%);
  width: 100%;
  max-width: 600px;
  background: var(--card-bg);
  border-radius: 24px 24px 0 0;
  padding: 28px 24px 32px;
  box-shadow: 0 -6px 32px rgba(0,0,0,0.15);
  z-index: 100;
  text-align: center;
  transition: transform 0.35s cubic-bezier(0.34,1.56,0.64,1);
}

.feedback-overlay.visible {
  transform: translateX(-50%) translateY(0);
}

.feedback-icon {
  font-size: 2.5rem;
  display: block;
  margin-bottom: 8px;
}

.feedback-message {
  font-size: 1.3rem;
  font-weight: 800;
  margin-bottom: 8px;
  direction: rtl;
}

.feedback-message.correct { color: var(--correct); }
.feedback-message.wrong   { color: var(--wrong); }

.feedback-correct-answer {
  font-size: 0.95rem;
  color: var(--text);
  opacity: 0.75;
  margin-bottom: 18px;
  direction: rtl;
}

.feedback-correct-word {
  font-weight: 700;
  direction: ltr;
  display: inline-block;
}

.btn-next {
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 14px;
  padding: 14px 40px;
  font-size: 1.1rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
  box-shadow: 0 4px 14px rgba(255,107,53,0.4);
}
.btn-next:hover  { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(255,107,53,0.5); }
.btn-next:active { transform: translateY(0); }

/* ── END SCREEN ──────────────────────────────────────── */
#screen-end {
  text-align: center;
  padding: 32px 16px 48px;
}

.trophy {
  font-size: 4rem;
  display: block;
  margin-bottom: 12px;
  animation: trophy-appear 0.7s cubic-bezier(0.34,1.56,0.64,1) forwards;
}

@keyframes trophy-appear {
  0%   { opacity: 0; transform: scale(0.3) rotate(-20deg); }
  70%  { transform: scale(1.15) rotate(5deg); }
  100% { opacity: 1; transform: scale(1) rotate(0); }
}

.end-score {
  font-size: 2.8rem;
  font-weight: 900;
  color: var(--primary);
  margin-bottom: 6px;
}

.end-message {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 28px;
  direction: rtl;
}

.wrong-review-section {
  text-align: right;
  margin-bottom: 28px;
}

.wrong-review-title {
  font-size: 1rem;
  font-weight: 700;
  opacity: 0.6;
  margin-bottom: 12px;
  direction: rtl;
}

.no-mistakes {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--correct);
  text-align: center;
  direction: rtl;
}

.review-card {
  background: var(--card-bg);
  border-radius: 12px;
  padding: 12px 16px;
  margin-bottom: 8px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.07);
  display: flex;
  align-items: center;
  gap: 10px;
  direction: ltr;
  flex-wrap: wrap;
}

.review-verb   { font-weight: 700; }
.review-arrow  { opacity: 0.4; font-size: 1.1rem; }
.review-past   { font-weight: 700; }
.review-hebrew {
  margin-right: auto;
  opacity: 0.55;
  font-size: 0.85rem;
  direction: rtl;
}

.end-buttons {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 14px;
  padding: 14px 28px;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
  box-shadow: 0 4px 14px rgba(255,107,53,0.4);
}
.btn-primary:hover  { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(255,107,53,0.5); }
.btn-primary:active { transform: translateY(0); }

.btn-secondary {
  background: var(--card-bg);
  color: var(--text);
  border: 2.5px solid var(--text);
  border-radius: 14px;
  padding: 14px 28px;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.15s, opacity 0.15s;
  opacity: 0.65;
}
.btn-secondary:hover  { transform: translateY(-2px); opacity: 1; }
.btn-secondary:active { transform: translateY(0); }

/* ── RESPONSIVE ──────────────────────────────────────── */
@media (max-width: 400px) {
  .choices-grid {
    grid-template-columns: 1fr;
  }
  .question-word {
    font-size: 1.5rem;
  }
  .welcome-title {
    font-size: 1.6rem;
  }
}

.verbs-list-link {
  display: block;
  margin-top: 1rem;
  text-align: center;
  color: var(--text);
  opacity: 0.45;
  text-decoration: none;
  font-size: 0.88rem;
  transition: opacity 0.15s;
}
.verbs-list-link:hover { opacity: 0.8; }

/* ── USER STATS CARD ────────────────────────────────────────────────────── */
#user-section       { margin-top: 1.2rem; }
#leaderboard-section { margin-top: 1rem; }

.stats-card {
  background: var(--card-bg);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 1rem 1.2rem;
  text-align: center;
  position: relative;
}
.stats-greeting {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 0.75rem;
}
.btn-logout {
  position: absolute;
  top: 8px;
  left: 10px;
  background: none;
  border: none;
  font-size: 0.85rem;
  color: #bbb;
  cursor: pointer;
  font-family: inherit;
  line-height: 1;
  padding: 2px 4px;
  transition: color 0.15s;
}
.btn-logout:hover { color: var(--wrong); }
.stats-row {
  display: flex;
  justify-content: space-around;
}
.stat-item { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.stat-value {
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--primary);
}
.stat-label { font-size: 0.75rem; color: #888; }

/* ── AUTH PROMPT ────────────────────────────────────────────────────────── */
.auth-prompt {
  background: var(--card-bg);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 1rem 1.2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}
.auth-prompt-text { font-size: 0.95rem; font-weight: 600; color: var(--text); }
.auth-prompt-buttons { display: flex; gap: 0.5rem; flex-shrink: 0; }
.btn-small { padding: 0.4rem 0.9rem; font-size: 0.85rem; }

/* ── LEADERBOARD ────────────────────────────────────────────────────────── */
.leaderboard-card {
  background: var(--card-bg);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 1rem 1.2rem;
}
.leaderboard-title {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 0.6rem;
  text-align: center;
}
.leaderboard-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.3rem 0.2rem;
  border-radius: 8px;
  font-size: 0.9rem;
}
.leaderboard-me { background: #FFF3CD; font-weight: 700; }
.leaderboard-medal { font-size: 1.1rem; }
.leaderboard-name  { flex: 1; color: var(--text); }
.leaderboard-points { color: var(--primary); font-weight: 700; }

/* ── AUTH SCREEN ────────────────────────────────────────────────────────── */
#screen-auth.active {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding-top: 1.5rem;
  gap: 0;
}
.auth-title {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--text);
  margin: 0.5rem 0 1.2rem;
}
.auth-form {
  width: 100%;
  max-width: 360px;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
.auth-input {
  width: 100%;
  padding: 0.75rem 1rem;
  border: 2px solid #E0E0E0;
  border-radius: 10px;
  font-size: 1rem;
  font-family: inherit;
  background: var(--card-bg);
  color: var(--text);
  transition: border-color 0.2s;
  text-align: right;
}
.auth-input:focus {
  outline: none;
  border-color: var(--secondary);
}
.auth-error {
  color: var(--wrong);
  font-size: 0.9rem;
  min-height: 1.2rem;
  text-align: center;
}
.btn-link {
  background: none;
  border: none;
  color: var(--secondary);
  font-size: 0.9rem;
  cursor: pointer;
  text-align: center;
  padding: 0.2rem;
  font-family: inherit;
}
.btn-link:hover { text-decoration: underline; }

/* ── END SCREEN POINTS ──────────────────────────────────────────────────── */
.end-points {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--primary);
  margin: 0.3rem 0 0.5rem;
  text-align: center;
}
.end-points-login-hint {
  color: var(--secondary);
  font-size: 0.9rem;
  font-weight: 400;
  text-decoration: none;
}
.end-points-login-hint:hover { text-decoration: underline; }
