/* ===== CSS RESET & BASE ===== */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --primary: #667eea;
  --primary-dark: #5a67d8;
  --secondary: #f6ad55;
  --success: #48bb78;
  --danger: #fc8181;
  --warning: #f6e05e;
  --bg: #f0f4ff;
  --card-bg: #ffffff;
  --text: #2d3748;
  --text-light: #718096;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 4px 15px rgba(0,0,0,0.1);
  --shadow-lg: 0 8px 30px rgba(0,0,0,0.15);
  --font: 'Segoe UI', Tahoma, Arial, sans-serif;
  --header-height: 60px;
  --nav-height: 70px;
  
  /* Subject colors */
  --hebrew-color: #e53e3e;
  --hebrew-bg: #fff5f5;
  --english-color: #3182ce;
  --english-bg: #ebf8ff;
  --math-color: #38a169;
  --math-bg: #f0fff4;
}

html, body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  height: 100%;
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

.hidden { display: none !important; }

/* ===== SPLASH SCREEN ===== */
.splash {
  position: fixed;
  inset: 0;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  transition: opacity 0.5s ease, transform 0.5s ease;
}

.splash.fade-out {
  opacity: 0;
  transform: scale(1.1);
}

.splash-content {
  text-align: center;
  color: white;
}

.splash-icon {
  font-size: 80px;
  animation: bounce 1s ease infinite;
}

.splash h1 {
  font-size: 36px;
  margin: 16px 0 8px;
  text-shadow: 2px 2px 4px rgba(0,0,0,0.2);
}

.splash p {
  font-size: 18px;
  opacity: 0.9;
}

.loading-dots {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-top: 24px;
}

.loading-dots span {
  width: 12px;
  height: 12px;
  background: white;
  border-radius: 50%;
  animation: dot-pulse 1.2s ease infinite;
}

.loading-dots span:nth-child(2) { animation-delay: 0.2s; }
.loading-dots span:nth-child(3) { animation-delay: 0.4s; }

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

@keyframes dot-pulse {
  0%, 100% { opacity: 0.3; transform: scale(0.8); }
  50% { opacity: 1; transform: scale(1.2); }
}

/* ===== APP LAYOUT ===== */
.app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
}

/* ===== HEADER ===== */
.app-header {
  height: var(--header-height);
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  box-shadow: var(--shadow);
  z-index: 100;
  flex-shrink: 0;
}

.header-logo {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  flex: 1;
  justify-content: center;
}

.header-brain {
  font-size: 24px;
  animation: bounce 2s ease infinite;
}

.app-header h1 {
  font-size: 18px;
  font-weight: 700;
  white-space: nowrap;
}

.btn-back, .btn-header-icon {
  background: rgba(255,255,255,0.2);
  border: none;
  color: white;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  font-size: 20px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}

.btn-back:active, .btn-header-icon:active {
  background: rgba(255,255,255,0.4);
}

/* ===== MAIN CONTENT ===== */
.main-content {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
}

.screen {
  display: none;
  padding: 16px;
  animation: fadeIn 0.3s ease;
}

.screen.active {
  display: block;
}

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

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

/* ===== WELCOME BANNER ===== */
.welcome-banner {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border-radius: var(--radius);
  padding: 16px;
  color: white;
  margin-bottom: 16px;
  box-shadow: var(--shadow-lg);
}

.welcome-banner.compact {
  padding: 12px 16px;
}

.welcome-row {
  display: flex;
  align-items: center;
  gap: 14px;
}

.welcome-info {
  text-align: right;
  flex: 1;
}

.welcome-avatar {
  font-size: 40px;
}

.welcome-banner h2 {
  font-size: 20px;
  margin: 0 0 4px;
}

.welcome-banner .streak-badge {
  font-size: 14px;
  opacity: 0.9;
  background: transparent;
  padding: 0;
  box-shadow: none;
}

/* ===== SUBJECT CARDS ===== */
.subjects-grid {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-bottom: 20px;
}

.subject-card {
  background: var(--card-bg);
  border: none;
  border-radius: var(--radius);
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  text-align: right;
  position: relative;
  overflow: hidden;
}

.subject-card::before {
  content: '';
  position: absolute;
  right: 0;
  top: 0;
  bottom: 0;
  width: 6px;
}

.subject-card.hebrew::before { background: var(--hebrew-color); }
.subject-card.english::before { background: var(--english-color); }
.subject-card.math::before { background: var(--math-color); }

.subject-card:active {
  transform: scale(0.97);
}

.subject-icon {
  font-size: 42px;
  flex-shrink: 0;
}

.subject-name {
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
}

.subject-desc {
  font-size: 13px;
  color: var(--text-light);
  margin-top: 2px;
}

.subject-progress {
  position: absolute;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 14px;
  color: var(--primary);
  font-weight: 600;
}

/* ===== DAILY TIP ===== */
.daily-tip {
  background: #fffbeb;
  border: 2px solid #f6e05e;
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.tip-icon { font-size: 28px; }
.tip-text { font-size: 14px; line-height: 1.6; color: #744210; }

/* ===== FEATURE GRID ===== */
.feature-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  padding-top: 10px;
}

.feature-card {
  background: var(--card-bg);
  border: none;
  border-radius: var(--radius);
  padding: 28px 16px;
  text-align: center;
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: transform 0.15s ease;
}

.feature-card:active {
  transform: scale(0.95);
}

.feature-icon {
  font-size: 48px;
  margin-bottom: 10px;
}

.feature-name {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
}

.feature-desc {
  font-size: 13px;
  color: var(--text-light);
  margin-top: 4px;
}

.lessons-card { background: linear-gradient(135deg, #fef3c7, #fffbeb); }
.quiz-card { background: linear-gradient(135deg, #c6f6d5, #f0fff4); }
.balloon-card { background: linear-gradient(135deg, #fce4ec, #ffeef2); }

/* ===== LESSONS ===== */
.lessons-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.lesson-item {
  background: var(--card-bg);
  border-radius: var(--radius-sm);
  padding: 16px;
  box-shadow: var(--shadow);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 14px;
  transition: transform 0.15s;
  border: none;
  width: 100%;
  text-align: right;
}

.lesson-item:active { transform: scale(0.98); }

.lesson-num {
  width: 40px;
  height: 40px;
  background: var(--primary);
  color: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 16px;
  flex-shrink: 0;
}

.lesson-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
}

.lesson-preview {
  font-size: 12px;
  color: var(--text-light);
  margin-top: 3px;
}

/* ===== LESSON DETAIL ===== */
.lesson-content {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
  line-height: 1.8;
  font-size: 16px;
}

.lesson-content h2 {
  font-size: 22px;
  color: var(--primary);
  margin-bottom: 16px;
  border-bottom: 3px solid var(--primary);
  padding-bottom: 8px;
}

.lesson-content h3 {
  font-size: 18px;
  color: var(--text);
  margin: 16px 0 8px;
}

.lesson-content p {
  margin-bottom: 12px;
}

.lesson-content .example {
  background: #f7fafc;
  border-right: 4px solid var(--primary);
  padding: 12px 16px;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  margin: 12px 0;
  font-style: italic;
}

.lesson-content .highlight {
  background: #fefcbf;
  padding: 2px 6px;
  border-radius: 4px;
  font-weight: 600;
}

/* ===== QUIZ ===== */
.quiz-container { max-width: 600px; margin: 0 auto; }

.quiz-header { margin-bottom: 20px; }

.quiz-progress-bar {
  height: 10px;
  background: #e2e8f0;
  border-radius: 5px;
  overflow: hidden;
  margin-bottom: 8px;
}

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

.quiz-counter {
  text-align: center;
  font-size: 14px;
  color: var(--text-light);
}

.quiz-question {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 16px;
  text-align: center;
  font-size: 18px;
  font-weight: 600;
  box-shadow: var(--shadow);
  margin-bottom: 12px;
  min-height: 60px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  line-height: 1.5;
  gap: 8px;
}

.quiz-question .math-equation {
  direction: ltr;
  font-size: 1.3rem;
  font-weight: 700;
  color: #333;
  font-family: 'Segoe UI', Tahoma, sans-serif;
}

.quiz-options {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 12px;
}

.quiz-option {
  background: var(--card-bg);
  border: 2px solid #e2e8f0;
  border-radius: var(--radius-sm);
  padding: 12px;
  font-size: 16px;
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: center;
  font-family: var(--font);
}

.quiz-option:active {
  transform: scale(0.98);
}

.quiz-option.selected {
  border-color: var(--primary);
  background: #ebf4ff;
}

.quiz-option.correct {
  border-color: var(--success);
  background: #c6f6d5;
  animation: pop 0.3s ease;
}

.btn-timer-fill {
  position: relative;
  overflow: hidden;
}

.btn-timer-fill::after {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  height: 100%;
  width: 0%;
  background: rgba(255, 255, 255, 0.3);
  animation: timerFill 2s linear forwards;
  border-radius: inherit;
  pointer-events: none;
}

@keyframes timerFill {
  0% { width: 0%; }
  100% { width: 100%; }
}

.quiz-option.wrong {
  border-color: var(--danger);
  background: #fed7d7;
  animation: shake 0.4s ease;
}

.quiz-option.disabled {
  pointer-events: none;
  opacity: 0.7;
}

@keyframes pop {
  0% { transform: scale(1); }
  50% { transform: scale(1.05); }
  100% { transform: scale(1); }
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-8px); }
  75% { transform: translateX(8px); }
}

.quiz-feedback {
  text-align: center;
  padding: 16px;
  border-radius: var(--radius-sm);
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 12px;
}

.quiz-feedback.correct {
  background: #c6f6d5;
  color: #276749;
}

.quiz-feedback.wrong {
  background: #fed7d7;
  color: #9b2c2c;
}

/* ===== QUIZ RESULTS ===== */
.quiz-results {
  text-align: center;
  padding: 20px;
}

.results-emoji {
  font-size: 80px;
  margin-bottom: 16px;
  animation: bounce 1s ease infinite;
}

.quiz-results h2 {
  font-size: 24px;
  margin-bottom: 12px;
  color: var(--text);
}

.results-score {
  font-size: 48px;
  font-weight: 800;
  color: var(--primary);
  margin-bottom: 16px;
}

.results-details {
  font-size: 15px;
  color: var(--text-light);
  margin-bottom: 24px;
  line-height: 1.8;
}

/* ===== BALLOON POP GAME ===== */
.balloon-game {
  text-align: center;
  max-width: 400px;
  margin: 0 auto;
  padding: 10px;
}

.balloon-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 15px;
  padding: 10px 15px;
  background: var(--bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.balloon-score {
  font-size: 20px;
  font-weight: 700;
  color: var(--primary);
}

.balloon-lives {
  font-size: 18px;
  letter-spacing: 3px;
}

.balloon-question {
  background: linear-gradient(135deg, #667eea, #764ba2);
  color: white;
  padding: 20px;
  border-radius: var(--radius);
  font-size: 20px;
  font-weight: 600;
  line-height: 1.5;
  margin-bottom: 15px;
  min-height: 80px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-lg);
}

.balloon-arena {
  position: relative;
  height: 320px;
  background: linear-gradient(to top, #e8f5e9 0%, #bbdefb 50%, #e3f2fd 100%);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 15px;
}

.balloon {
  position: absolute;
  width: 80px;
  cursor: pointer;
  transition: transform 0.1s;
  animation: floatUp 6s linear forwards;
}

.balloon:hover {
  transform: scale(1.1);
}

.balloon:active {
  transform: scale(0.95);
}

.balloon-body {
  width: 80px;
  height: 95px;
  border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 600;
  color: white;
  text-shadow: 0 1px 2px rgba(0,0,0,0.3);
  box-shadow: inset -10px -10px 30px rgba(0,0,0,0.15), 
              inset 10px 10px 20px rgba(255,255,255,0.3);
  padding: 8px;
  text-align: center;
  line-height: 1.2;
}

.balloon-string {
  width: 2px;
  height: 40px;
  background: #999;
  margin: 0 auto;
  border-radius: 0 0 2px 2px;
}

@keyframes floatUp {
  0% { 
    bottom: -120px;
    opacity: 1;
  }
  90% { 
    opacity: 1;
  }
  100% { 
    bottom: 350px;
    opacity: 0;
  }
}

@keyframes pop {
  0% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.3); opacity: 0.5; }
  100% { transform: scale(0); opacity: 0; }
}

.balloon.popped {
  animation: pop 0.3s ease-out forwards !important;
}

.balloon.correct .balloon-body {
  background: linear-gradient(135deg, #48bb78, #38a169) !important;
}

.balloon.wrong .balloon-body {
  background: linear-gradient(135deg, #fc8181, #e53e3e) !important;
}

.balloon-progress {
  font-size: 14px;
  color: var(--text-light);
}

.balloon-done {
  text-align: center;
  padding: 20px;
}

#balloon-summary {
  font-size: 18px;
  color: var(--text-light);
  margin: 16px 0 24px;
  line-height: 1.8;
}

/* ===== PROGRESS SCREEN ===== */
.progress-container {
  max-width: 500px;
  margin: 0 auto;
}

.progress-header-card {
  background: linear-gradient(135deg, #667eea, #764ba2);
  color: white;
  border-radius: var(--radius);
  padding: 30px;
  text-align: center;
  box-shadow: var(--shadow-lg);
  margin-bottom: 20px;
}

.big-star {
  font-size: 36px;
  font-weight: 800;
  margin-bottom: 4px;
}

.progress-details {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 24px;
}

.progress-subject-card {
  background: var(--card-bg);
  border-radius: var(--radius-sm);
  padding: 16px;
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  gap: 14px;
}

.progress-subject-icon {
  font-size: 32px;
}

.progress-subject-info {
  flex: 1;
}

.progress-subject-name {
  font-weight: 600;
  font-size: 16px;
  margin-bottom: 6px;
}

.progress-bar-track {
  height: 8px;
  background: #e2e8f0;
  border-radius: 4px;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.6s ease;
}

.progress-bar-fill.hebrew { background: var(--hebrew-color); }
.progress-bar-fill.english { background: var(--english-color); }
.progress-bar-fill.math { background: var(--math-color); }

.progress-stats {
  font-size: 12px;
  color: var(--text-light);
  margin-top: 4px;
}

/* ===== BUTTONS ===== */
.btn-primary {
  background: linear-gradient(135deg, #667eea, #764ba2);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  padding: 14px 28px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  width: 100%;
  margin-bottom: 10px;
  font-family: var(--font);
  transition: transform 0.15s;
}

.btn-primary:active { transform: scale(0.97); }

.btn-secondary {
  background: var(--card-bg);
  color: var(--text);
  border: 2px solid #e2e8f0;
  border-radius: var(--radius-sm);
  padding: 14px 28px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  width: 100%;
  margin-bottom: 10px;
  font-family: var(--font);
}

.btn-danger {
  background: none;
  color: var(--danger);
  border: 2px solid var(--danger);
  border-radius: var(--radius-sm);
  padding: 12px 24px;
  font-size: 14px;
  cursor: pointer;
  width: 100%;
  font-family: var(--font);
}

.btn-icon {
  background: var(--card-bg);
  border: 2px solid #e2e8f0;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  font-size: 20px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ===== BOTTOM NAV ===== */
.bottom-nav {
  height: var(--nav-height);
  background: var(--card-bg);
  display: flex;
  justify-content: space-around;
  align-items: center;
  box-shadow: 0 -2px 15px rgba(0,0,0,0.08);
  flex-shrink: 0;
  padding-bottom: env(safe-area-inset-bottom, 0);
}

.nav-item {
  background: none;
  border: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  padding: 8px 4px;
  position: relative;
  color: var(--text-light);
  transition: color 0.2s;
}

.nav-item.active {
  color: var(--primary);
}

.nav-item.active::after {
  content: '';
  position: absolute;
  top: -2px;
  left: 25%;
  right: 25%;
  height: 3px;
  background: var(--primary);
  border-radius: 2px;
}

.nav-icon {
  font-size: 24px;
}

.nav-label {
  font-size: 10px;
  font-weight: 600;
}

/* ===== CONFETTI ===== */
.confetti-piece {
  position: fixed;
  width: 10px;
  height: 10px;
  border-radius: 2px;
  animation: confetti-fall 2s ease forwards;
  z-index: 9999;
  pointer-events: none;
}

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

/* ===== HEADER RIGHT GROUP ===== */
.header-right {
  display: flex;
  gap: 6px;
}

/* ===== MODAL / PROFILE SETUP ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  padding: 16px;
}

.modal-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 24px;
  max-width: 360px;
  width: 100%;
  text-align: center;
  box-shadow: var(--shadow-lg);
  max-height: 85vh;
  overflow: hidden;
}

.modal-header {
  font-size: 28px;
  font-weight: 700;
  margin-bottom: 12px;
  color: var(--text);
}

.text-input {
  width: 100%;
  padding: 14px;
  border: 2px solid #e2e8f0;
  border-radius: var(--radius-sm);
  font-size: 16px;
  font-family: var(--font);
  text-align: center;
  margin: 10px 0 16px;
  transition: border-color 0.2s;
}

.text-input:focus {
  outline: none;
  border-color: var(--primary);
}

.avatar-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin: 10px 0 16px;
}

.avatar-option {
  font-size: 28px;
  padding: 6px;
  border-radius: 10px;
  border: 2px solid transparent;
  cursor: pointer;
  transition: all 0.2s;
  background: none;
}

.avatar-option.selected {
  border-color: var(--primary);
  background: rgba(102,126,234,0.1);
  transform: scale(1.1);
}

/* ===== PROFILE ===== */
.profile-container { max-width: 500px; margin: 0 auto; }

.profile-card {
  background: linear-gradient(135deg, var(--primary), #764ba2);
  color: white;
  border-radius: var(--radius);
  padding: 30px;
  text-align: center;
  box-shadow: var(--shadow-lg);
  margin-bottom: 16px;
}

.profile-avatar {
  font-size: 64px;
  margin-bottom: 8px;
}

.profile-card h2 { font-size: 24px; margin-bottom: 8px; }
.profile-stars { font-size: 18px; margin-bottom: 4px; }
.profile-streak { font-size: 16px; opacity: 0.9; }

.section-title {
  font-size: 18px;
  color: var(--text);
  margin: 20px 0 12px;
  padding-right: 4px;
}

/* ===== STREAK BADGE ===== */
.streak-badge {
  background: rgba(255,255,255,0.2);
  border-radius: 20px;
  padding: 6px 16px;
  font-size: 14px;
  display: inline-block;
  margin-top: 8px;
}

/* ===== GRADE INDICATOR ===== */
.grade-indicator {
  background: rgba(255, 255, 255, 0.25);
  color: white;
  border-radius: 12px;
  padding: 4px 12px;
  font-size: 13px;
  font-weight: 600;
  display: inline-block;
  margin-top: 4px;
}

/* ===== DAILY CHALLENGE CARD ===== */
.daily-challenge-card {
  background: linear-gradient(135deg, #f6ad55, #ed8936);
  color: white;
  border-radius: var(--radius);
  padding: 16px 20px;
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: transform 0.15s;
}

.daily-challenge-card:active { transform: scale(0.97); }
.dc-icon { font-size: 36px; }
.dc-info { flex: 1; }
.dc-title { font-size: 18px; font-weight: 700; }
.dc-subtitle { font-size: 13px; opacity: 0.9; }
.dc-arrow { font-size: 20px; }

/* ===== WELCOME BANNER UPDATE ===== */
.welcome-avatar {
  font-size: 50px;
}

/* ===== BADGES ===== */
.badges-preview {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 14px;
  box-shadow: var(--shadow);
  margin-bottom: 16px;
  cursor: pointer;
}

.badges-title {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 8px;
}

.badges-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.badge-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 8px;
  border-radius: 12px;
  min-width: 72px;
}

.badge-icon { font-size: 32px; }
.badge-label { font-size: 10px; color: var(--text-light); margin-top: 4px; text-align: center; }
.badge-item.locked { opacity: 0.35; filter: grayscale(1); }

.badges-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.achievements-container {
  max-width: 500px;
  margin: 0 auto;
}

.achievement-card {
  background: var(--card-bg);
  border-radius: var(--radius-sm);
  padding: 16px;
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 10px;
}

.achievement-card.locked {
  opacity: 0.5;
}

.achievement-icon { font-size: 40px; }
.achievement-name { font-weight: 700; font-size: 15px; }
.achievement-desc { font-size: 12px; color: var(--text-light); margin-top: 2px; }

/* ===== GAMES ===== */
.game-container {
  max-width: 500px;
  margin: 0 auto;
  text-align: center;
}

/* Hangman */
.hangman-display {
  font-size: 48px;
  margin-bottom: 16px;
  min-height: 60px;
}

.hangman-word {
  font-size: 32px;
  letter-spacing: 8px;
  font-weight: 700;
  margin-bottom: 12px;
  font-family: monospace;
}

.hangman-hint {
  font-size: 14px;
  color: var(--text-light);
  margin-bottom: 10px;
}

.hangman-lives {
  font-size: 18px;
  margin-bottom: 16px;
}

.hangman-keyboard {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px;
}

.hk-btn {
  width: 38px;
  height: 42px;
  border: 2px solid #e2e8f0;
  border-radius: 8px;
  background: var(--card-bg);
  font-size: 18px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  font-family: var(--font);
}

.hk-btn:active { transform: scale(0.9); }
.hk-btn.correct { background: #c6f6d5; border-color: var(--success); }
.hk-btn.wrong { background: #fed7d7; border-color: var(--danger); opacity: 0.5; }
.hk-btn.used { pointer-events: none; }

/* Memory Game */
.memory-stats {
  display: flex;
  justify-content: space-around;
  margin-bottom: 16px;
  font-size: 16px;
}

.memory-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  max-width: 350px;
  margin: 0 auto;
}

.memory-card {
  aspect-ratio: 1;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, var(--primary), #764ba2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  cursor: pointer;
  transition: transform 0.3s, background 0.3s;
  border: none;
  color: white;
  font-weight: 700;
}

.memory-card.flipped {
  background: var(--card-bg);
  color: var(--text);
  box-shadow: var(--shadow);
  font-size: 16px;
}

.memory-card.matched {
  background: #c6f6d5;
  color: var(--success);
  pointer-events: none;
}

.memory-card:active { transform: scale(0.95); }

.memory-hint {
  background: #fef3c7;
  color: #92400e;
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  text-align: center;
  font-size: 14px;
  font-weight: 600;
  margin-top: 12px;
}

/* Math Race */
.race-timer {
  font-size: 28px;
  font-weight: 700;
  color: var(--danger);
  margin-bottom: 8px;
}

.race-score {
  font-size: 20px;
  margin-bottom: 16px;
}

.race-question {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 24px;
  font-size: 28px;
  font-weight: 700;
  box-shadow: var(--shadow);
  margin-bottom: 16px;
  min-height: 70px;
  display: flex;
  align-items: center;
  justify-content: center;
  direction: ltr;
}

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

.race-option {
  background: var(--card-bg);
  border: 2px solid #e2e8f0;
  border-radius: var(--radius-sm);
  padding: 24px 16px;
  font-size: 26px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  font-family: var(--font);
  min-height: 70px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.race-option:active { transform: scale(0.95); }
.race-option.correct { background: #c6f6d5; border-color: var(--success); }
.race-option.wrong { background: #fed7d7; border-color: var(--danger); }

/* Game Result */
.game-result {
  margin-top: 20px;
  text-align: center;
}

.game-result .results-emoji { font-size: 60px; margin-bottom: 12px; }
.game-result h2 { margin-bottom: 8px; }

/* ===== DICTATION ===== */
.dictation-header {
  margin-bottom: 20px;
}

.dictation-header h2 {
  color: var(--primary);
  margin-bottom: 4px;
}

.dictation-week {
  color: var(--text-light);
  font-size: 14px;
}

.dictation-week-selector {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 12px 0;
}

.dictation-week-selector label {
  font-weight: 500;
  color: var(--text);
}

.dictation-week-selector select {
  flex: 1;
  padding: 10px;
  font-size: 14px;
  border: 2px solid #e2e8f0;
  border-radius: var(--radius-sm);
  background: white;
}

.dictation-word-area {
  margin-bottom: 16px;
}

.dictation-prompt {
  font-size: 20px;
  font-weight: 600;
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  margin-bottom: 12px;
}

.dictation-input {
  direction: ltr;
  text-align: center;
  font-size: 20px;
  letter-spacing: 2px;
}

.dictation-progress {
  margin-top: 12px;
}

/* ===== TTS BUTTON ===== */
.btn-tts-inline {
  background: rgba(102,126,234,0.1);
  color: var(--primary);
  border: 2px solid var(--primary);
  border-radius: var(--radius-sm);
  padding: 10px 20px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  font-family: var(--font);
  margin: 12px 0;
  display: inline-block;
}

.btn-tts-inline:active { transform: scale(0.97); }

/* ===== SETTINGS ===== */
.settings-container {
  max-width: 500px;
  margin: 0 auto;
}

.setting-row {
  background: var(--card-bg);
  border-radius: var(--radius-sm);
  padding: 16px;
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
  font-size: 15px;
}

.setting-row input[type="range"] {
  width: 120px;
  accent-color: var(--primary);
}

/* Toggle Switch */
.switch {
  position: relative;
  display: inline-block;
  width: 52px;
  height: 28px;
}

.switch input { opacity: 0; width: 0; height: 0; }

.slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background: #cbd5e0;
  border-radius: 28px;
  transition: 0.3s;
}

.slider::before {
  content: "";
  position: absolute;
  height: 22px;
  width: 22px;
  right: 3px;
  bottom: 3px;
  background: white;
  border-radius: 50%;
  transition: 0.3s;
}

.switch input:checked + .slider {
  background: var(--primary);
}

.switch input:checked + .slider::before {
  transform: translateX(-24px);
}

/* ===== THEME GRID ===== */
.theme-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 20px;
}

.theme-option {
  border-radius: var(--radius-sm);
  padding: 16px 10px;
  text-align: center;
  cursor: pointer;
  border: 3px solid transparent;
  transition: all 0.2s;
  font-family: var(--font);
  font-size: 13px;
  font-weight: 600;
}

.theme-option.active {
  border-color: var(--text);
  transform: scale(1.05);
}

.theme-swatch {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  margin: 0 auto 8px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

/* ===== LEADERBOARD ===== */
.leaderboard {
  margin-bottom: 20px;
}

.leaderboard-row {
  background: var(--card-bg);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
}

.leaderboard-rank {
  font-size: 20px;
  font-weight: 800;
  width: 36px;
  text-align: center;
}

.leaderboard-avatar { font-size: 28px; }
.leaderboard-name { flex: 1; font-weight: 600; }
.leaderboard-score { font-weight: 700; color: var(--primary); }

/* ===== DARK THEME ===== */
body.theme-dark {
  --bg: #1a202c;
  --card-bg: #2d3748;
  --text: #e2e8f0;
  --text-light: #a0aec0;
  --shadow: 0 4px 15px rgba(0,0,0,0.3);
  --shadow-lg: 0 8px 30px rgba(0,0,0,0.4);
}

body.theme-dark .app-header {
  background: linear-gradient(135deg, #2d3748, #4a5568);
}

body.theme-dark .subject-card { background: #2d3748; }
body.theme-dark .quiz-option { background: #2d3748; border-color: #4a5568; }
body.theme-dark .text-input { background: #2d3748; color: #e2e8f0; border-color: #4a5568; }

/* ===== COLOR THEMES ===== */
body.theme-ocean {
  --primary: #0ea5e9;
  --primary-dark: #0284c7;
}

body.theme-ocean .app-header {
  background: linear-gradient(135deg, #0ea5e9, #0369a1);
}

body.theme-forest {
  --primary: #22c55e;
  --primary-dark: #16a34a;
}

body.theme-forest .app-header {
  background: linear-gradient(135deg, #22c55e, #15803d);
}

body.theme-sunset {
  --primary: #f97316;
  --primary-dark: #ea580c;
}

body.theme-sunset .app-header {
  background: linear-gradient(135deg, #f97316, #dc2626);
}

body.theme-pink {
  --primary: #ec4899;
  --primary-dark: #db2777;
}

body.theme-pink .app-header {
  background: linear-gradient(135deg, #ec4899, #be185d);
}

/* ===== RESPONSIVE ===== */
@media (min-width: 600px) {
  .subjects-grid {
    flex-direction: row;
    flex-wrap: wrap;
  }
  .subject-card {
    flex: 1;
    min-width: 250px;
    flex-direction: column;
    text-align: center;
  }
  .subject-progress {
    position: static;
    transform: none;
    margin-top: 8px;
  }
  .feature-grid {
    grid-template-columns: 1fr 1fr;
  }
  .memory-grid {
    max-width: 400px;
  }
}

/* ===== TABLET / SMALL DESKTOP (768px+) ===== */
@media (min-width: 768px) {
  .screen {
    padding: 24px;
  }
  
  .welcome-banner {
    padding: 20px;
  }
  
  .quiz-options {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
  }
  
  .quiz-question {
    font-size: 1.3rem;
  }
  
  .lesson-content {
    font-size: 1.1rem;
    line-height: 1.8;
  }
  
  .flashcard {
    min-height: 220px;
  }
  
  .game-container {
    max-width: 600px;
    margin: 0 auto;
  }
}

/* ===== DESKTOP (1024px+) ===== */
@media (min-width: 1024px) {
  /* Desktop background */
  html {
    background: linear-gradient(135deg, #e0e7ff 0%, #c7d2fe 50%, #ddd6fe 100%);
  }
  
  body {
    background: transparent;
  }
  
  /* Center app in phone-like container */
  .app {
    max-width: 480px;
    margin: 0 auto;
    background: var(--bg);
    box-shadow: 0 0 60px rgba(0, 0, 0, 0.15);
    border-radius: 0;
    position: relative;
  }
  
  /* Adjust header for desktop view */
  .app-header {
    border-radius: 0;
  }
  
  /* Hide bottom nav shadow bleed */
  .bottom-nav {
    border-radius: 0;
  }
  
  .screen {
    padding: 24px 20px;
  }
  
  /* Wider quiz options */
  .quiz-options {
    grid-template-columns: 1fr 1fr;
  }
  
  .subjects-grid {
    flex-direction: column;
  }
  
  .subject-card {
    flex-direction: row;
    text-align: right;
  }
}

/* ===== LARGE DESKTOP (1200px+) ===== */
@media (min-width: 1200px) {
  .app {
    max-width: 500px;
    margin-top: 20px;
    margin-bottom: 20px;
    height: calc(100vh - 40px);
    border-radius: 24px;
    overflow: hidden;
  }
  
  .app-header {
    border-radius: 24px 24px 0 0;
  }
  
  .bottom-nav {
    border-radius: 0 0 24px 24px;
  }
}

/* ===== EXTRA LARGE DESKTOP (1400px+) ===== */
@media (min-width: 1400px) {
  .app {
    max-width: 520px;
  }
}

/* ===== ACHIEVEMENT TOAST ===== */
.achievement-toast {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%) translateY(-100px);
  background: linear-gradient(135deg, #f6e05e, #f6ad55);
  color: #2d3748;
  padding: 14px 24px;
  border-radius: 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: 0 8px 30px rgba(0,0,0,0.2);
  z-index: 10000;
  transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  font-size: 14px;
  max-width: 90vw;
}
.achievement-toast.show {
  transform: translateX(-50%) translateY(0);
}
.toast-icon {
  font-size: 32px;
}

/* ===== ACHIEVEMENT CARDS ===== */
.achievements-container {
  padding: 8px 0;
}
.achievement-card {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--card-bg);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  margin-bottom: 10px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
  transition: opacity 0.3s;
}
.achievement-card.locked {
  opacity: 0.45;
}
.achievement-card.unlocked {
  border-right: 4px solid var(--success);
}
.achievement-icon {
  font-size: 32px;
  min-width: 40px;
  text-align: center;
}
.achievement-info {
  flex: 1;
}
.achievement-name {
  font-weight: 700;
  font-size: 15px;
  color: var(--text);
}
.achievement-desc {
  font-size: 13px;
  color: var(--text-light);
}
.achievement-check {
  font-size: 20px;
}

/* ===== BADGE ITEMS ===== */
.badges-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}
.badge-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 60px;
  text-align: center;
}
.badge-item span {
  font-size: 28px;
}
.badge-item small {
  font-size: 10px;
  color: var(--text-light);
  margin-top: 2px;
}
.badge-item.locked {
  opacity: 0.35;
}
.badge-mini {
  font-size: 24px;
  margin: 0 2px;
}

/* ===== PROFILE CONTAINER ===== */
.profile-container {
  padding: 8px 0;
}
.profile-card {
  text-align: center;
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 16px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.06);
}
.profile-avatar {
  font-size: 56px;
}
.profile-stars, .profile-streak {
  font-size: 16px;
  color: var(--text-light);
  margin-top: 6px;
}
.section-title {
  font-size: 16px;
  font-weight: 700;
  margin: 20px 0 10px;
  color: var(--text);
}

/* ===== LEADERBOARD ===== */
.leaderboard-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: var(--card-bg);
  border-radius: var(--radius-sm);
  margin-bottom: 6px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.04);
}
.leaderboard-row.me {
  background: linear-gradient(135deg, #ebf8ff, #bee3f8);
  border: 2px solid var(--primary);
  font-weight: 700;
}
.lb-rank { font-size: 18px; min-width: 28px; text-align: center; }
.lb-avatar { font-size: 22px; }
.lb-name { flex: 1; font-size: 15px; }
.lb-stars { font-size: 14px; color: var(--primary); font-weight: 600; }

/* ===== TEXT INPUT ===== */
.text-input {
  width: 100%;
  padding: 12px 16px;
  border: 2px solid #e2e8f0;
  border-radius: var(--radius-sm);
  font-size: 16px;
  font-family: inherit;
  background: var(--card-bg);
  color: var(--text);
  transition: border-color 0.3s;
  margin: 8px 0;
}
.text-input:focus {
  outline: none;
  border-color: var(--primary);
}
.dictation-input {
  font-size: 20px;
  text-align: center;
  letter-spacing: 1px;
}

/* ===== SETTINGS CONTAINER ===== */
.settings-container {
  padding: 8px 0;
}
.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  background: var(--card-bg);
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.04);
  font-size: 15px;
}
.setting-row input[type="range"] {
  width: 120px;
  accent-color: var(--primary);
}

/* ===== BTN-DANGER ===== */
.btn-danger {
  background: var(--danger);
  color: white;
  border: none;
  padding: 12px 24px;
  border-radius: var(--radius-sm);
  font-size: 15px;
  cursor: pointer;
  font-family: inherit;
  width: 100%;
}

/* ===== HEADER RIGHT ===== */
.header-right {
  display: flex;
  gap: 4px;
}
.btn-header-icon {
  background: rgba(255,255,255,0.2);
  border: none;
  color: white;
  font-size: 18px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ===== BADGES PREVIEW ===== */
.badges-preview {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 14px 18px;
  margin: 12px 0;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}
.badges-title {
  font-weight: 700;
  font-size: 15px;
  margin-bottom: 8px;
}
.badges-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
}

/* ===== GAME CONTAINER ===== */
.game-container {
  text-align: center;
  padding: 8px 0;
}
.game-result {
  margin-top: 16px;
  padding: 20px;
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: 0 2px 10px rgba(0,0,0,0.06);
}

/* ===== HANGMAN ===== */
.hangman-display {
  font-size: 40px;
  min-height: 60px;
  white-space: pre-line;
}
.hangman-word {
  font-size: 32px;
  letter-spacing: 6px;
  font-weight: 700;
  margin: 16px 0;
  min-height: 44px;
}
.hangman-hint {
  font-size: 14px;
  color: var(--text-light);
  margin-bottom: 12px;
}
.hangman-lives {
  font-size: 20px;
  margin-bottom: 16px;
}
.hangman-keyboard {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px;
  max-width: 400px;
  margin: 0 auto;
}
.hangman-key {
  min-width: 36px;
  height: 40px;
  border: 2px solid #e2e8f0;
  border-radius: 8px;
  background: var(--card-bg);
  font-size: 16px;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.2s;
}
.hangman-key:active { transform: scale(0.9); }
.hangman-key.correct { background: var(--success); color: white; border-color: var(--success); }
.hangman-key.wrong { background: var(--danger); color: white; border-color: var(--danger); opacity: 0.5; }
.hangman-key:disabled { cursor: default; }

/* ===== MEMORY GAME ===== */
.memory-stats {
  display: flex;
  justify-content: space-around;
  margin-bottom: 16px;
  font-size: 15px;
}
.memory-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  max-width: 360px;
  margin: 0 auto;
}
.memory-card {
  aspect-ratio: 1;
  border: 2px solid #e2e8f0;
  border-radius: 10px;
  background: var(--primary);
  color: white;
  font-size: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  transition: transform 0.3s, background 0.3s;
  font-family: inherit;
  min-height: 60px;
}
.memory-card .memory-card-front,
.memory-card .memory-card-back {
  position: absolute;
  transition: opacity 0.3s;
}
.memory-card .memory-card-back {
  opacity: 0;
  font-size: 12px;
  padding: 4px;
  word-break: break-word;
}
.memory-card.flipped {
  background: var(--card-bg);
  color: var(--text);
  border-color: var(--primary);
}
.memory-card.flipped .memory-card-front { opacity: 0; }
.memory-card.flipped .memory-card-back { opacity: 1; }
.memory-card.matched {
  background: #c6f6d5;
  border-color: var(--success);
}

/* ===== MATH RACE ===== */
.race-timer {
  font-size: 24px;
  font-weight: 700;
  color: var(--danger);
  margin-bottom: 8px;
}
.race-score {
  font-size: 18px;
  margin-bottom: 16px;
}
.race-question {
  font-size: 32px;
  font-weight: 700;
  margin: 16px 0;
  transition: color 0.2s;
}

/* ===== DICTATION ===== */
.dictation-header {
  margin-bottom: 16px;
}
.dictation-word-area {
  background: var(--card-bg);
  padding: 20px;
  border-radius: var(--radius);
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
  margin-bottom: 16px;
}
.dictation-prompt {
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 12px;
}
.dictation-progress {
  margin-top: 16px;
}

/* ===== THEME GRID ===== */
.theme-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 20px;
}
.theme-option {
  padding: 14px 8px;
  border: 3px solid transparent;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.2s;
}
.theme-option.selected {
  border-color: white;
  box-shadow: 0 0 0 3px var(--primary), 0 4px 12px rgba(0,0,0,0.15);
  transform: scale(1.05);
}

/* ===== SWITCH TOGGLE ===== */
.switch {
  position: relative;
  display: inline-block;
  width: 48px;
  height: 26px;
}
.switch input { opacity: 0; width: 0; height: 0; }
.switch .slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background: #cbd5e0;
  border-radius: 26px;
  transition: 0.3s;
}
.switch .slider::before {
  content: '';
  position: absolute;
  height: 20px;
  width: 20px;
  right: 3px;
  bottom: 3px;
  background: white;
  border-radius: 50%;
  transition: 0.3s;
}
.switch input:checked + .slider {
  background: var(--primary);
}
.switch input:checked + .slider::before {
  transform: translateX(-22px);
}

/* ===== WORD MATCHING GAME ===== */
.match-instructions {
  font-size: 14px;
  color: var(--text-light);
  margin-bottom: 12px;
}
.match-score {
  font-size: 16px;
  margin-bottom: 16px;
}
.match-game-area {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 20px;
  position: relative;
  min-height: 400px;
}
.match-column {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 42%;
}
.match-word {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  border: 3px solid transparent;
  text-align: center;
}
.match-word.hebrew {
  background: linear-gradient(135deg, #e0e7ff, #c7d2fe);
  color: #3730a3;
}
.match-word.english {
  background: linear-gradient(135deg, #fef3c7, #fde68a);
  color: #92400e;
  direction: ltr;
}
.match-word.selected {
  border-color: var(--primary);
  transform: scale(1.05);
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}
.match-word.matched {
  background: linear-gradient(135deg, #d1fae5, #a7f3d0);
  color: #065f46;
  border-color: var(--success);
  cursor: default;
  opacity: 0.8;
}
.match-word.wrong {
  animation: shake 0.4s ease;
  border-color: var(--danger);
}
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-8px); }
  75% { transform: translateX(8px); }
}
.match-lines {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 1;
}
.match-line {
  stroke: var(--success);
  stroke-width: 3;
  stroke-linecap: round;
  fill: none;
}

/* ===== ADMIN STYLES ===== */
.admin-container {
  padding: 20px;
  max-width: 600px;
  margin: 0 auto;
}
.admin-logo {
  font-size: 64px;
  text-align: center;
  margin: 30px 0 20px;
}
.admin-container h2 {
  text-align: center;
  margin-bottom: 30px;
  color: var(--primary-dark);
}
.admin-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.admin-form .text-input {
  padding: 16px;
  font-size: 16px;
  border: 2px solid #e2e8f0;
  border-radius: var(--radius-sm);
}
.admin-form .text-input:focus {
  border-color: var(--primary);
  outline: none;
}
.admin-error {
  color: var(--danger);
  text-align: center;
  padding: 10px;
  background: #fff5f5;
  border-radius: var(--radius-sm);
}
.admin-menu {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.admin-menu-btn {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 20px;
  background: var(--card-bg);
  border: 2px solid #e2e8f0;
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 0.2s;
}
.admin-menu-btn:hover {
  border-color: var(--primary);
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}
.admin-btn-icon {
  font-size: 32px;
}
.admin-btn-text {
  font-size: 18px;
  font-weight: 600;
  color: var(--text);
}
.admin-section {
  background: var(--card-bg);
  padding: 20px;
  border-radius: var(--radius);
  margin-bottom: 16px;
  box-shadow: var(--shadow);
}
.admin-section h3 {
  margin-bottom: 12px;
  color: var(--text);
}
.admin-select {
  width: 100%;
  padding: 12px;
  font-size: 16px;
  border: 2px solid #e2e8f0;
  border-radius: var(--radius-sm);
  background: white;
  cursor: pointer;
}
.admin-word-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 250px;
  overflow-y: auto;
}
.admin-word-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px;
  background: #f7fafc;
  border-radius: var(--radius-sm);
  border: 1px solid #e2e8f0;
}
.admin-word-item .word-text {
  display: flex;
  gap: 12px;
}
.admin-word-item .english {
  font-weight: 600;
  color: var(--english-color);
  direction: ltr;
}
.admin-word-item .hebrew {
  color: var(--text-light);
}
.admin-word-delete {
  background: var(--danger);
  color: white;
  border: none;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.admin-word-delete:hover {
  background: #e53e3e;
}
.admin-add-word {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.admin-add-word .text-input {
  padding: 12px;
}
.admin-access {
  cursor: pointer;
}

/* ===== USER SELECTION ===== */
.user-select-card {
  max-width: 400px;
  width: 90%;
  position: relative;
}

.modal-close-btn {
  position: absolute;
  top: 10px;
  left: 10px;
  width: 32px;
  height: 32px;
  border: none;
  background: rgba(0,0,0,0.1);
  border-radius: 50%;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  color: #666;
  transition: all 0.2s;
}

.modal-close-btn:hover {
  background: rgba(0,0,0,0.2);
  color: #333;
}

.user-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin: 20px 0;
  max-height: 300px;
  overflow-y: auto;
}
.user-item {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px;
  background: linear-gradient(135deg, #f8fafc, #f1f5f9);
  border-radius: var(--radius-md);
  border: 2px solid transparent;
  cursor: pointer;
  transition: all 0.2s ease;
}
.user-item:hover {
  border-color: var(--primary);
  background: linear-gradient(135deg, #eef2ff, #e0e7ff);
  transform: translateY(-2px);
}
.user-item-avatar {
  font-size: 2.5rem;
  width: 60px;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: white;
  border-radius: 50%;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}
.user-item-info {
  flex: 1;
  text-align: right;
}
.user-item-name {
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--text);
}
.user-item-stats {
  font-size: 0.85rem;
  color: var(--text-light);
  margin-top: 4px;
}
.user-item-delete {
  background: transparent;
  border: none;
  font-size: 1.2rem;
  cursor: pointer;
  padding: 8px;
  border-radius: 50%;
  opacity: 0.5;
  transition: all 0.2s;
}
.user-item-delete:hover {
  opacity: 1;
  background: rgba(229, 62, 62, 0.1);
}
.add-user-btn {
  width: 100%;
  margin-top: 10px;
}
.no-users-message {
  text-align: center;
  padding: 30px;
  color: var(--text-light);
}

/* ===== GRADE SELECTOR ===== */
.grade-selector {
  display: flex;
  gap: 16px;
  justify-content: center;
  margin: 12px 0 20px;
}
.grade-option {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 16px 24px;
  border: 3px solid #e2e8f0;
  border-radius: var(--radius);
  background: #f8fafc;
  cursor: pointer;
  transition: all 0.2s ease;
}
.grade-option:hover {
  border-color: var(--primary);
  background: #eef2ff;
}
.grade-option.selected {
  border-color: var(--primary);
  background: linear-gradient(135deg, #eef2ff, #e0e7ff);
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}
.grade-icon {
  font-size: 2rem;
}
.grade-label {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
}
.user-item-grade {
  font-size: 0.75rem;
  color: var(--primary);
  background: rgba(102, 126, 234, 0.1);
  padding: 2px 8px;
  border-radius: 10px;
  margin-top: 4px;
  display: inline-block;
}

/* ===== GAMIFICATION SYSTEM ===== */

/* Compact Result */
.compact-result {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 12px;
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.compact-result .result-emoji {
  font-size: 36px;
}

.compact-result .result-text {
  font-size: 14px;
  text-align: center;
}

.compact-result .result-stars {
  font-size: 20px;
  letter-spacing: 4px;
}

.compact-result .result-score {
  font-size: 24px;
  font-weight: 700;
  color: var(--primary);
}

.compact-result .result-btns {
  display: flex;
  gap: 12px;
  margin-top: 12px;
  width: 100%;
  justify-content: center;
}

.btn-sm {
  padding: 12px 28px;
  font-size: 18px;
  border-radius: var(--radius);
  border: none;
  cursor: pointer;
  font-family: var(--font);
  font-weight: 700;
  transition: transform 0.15s, box-shadow 0.15s;
  min-width: 100px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

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

.btn-sm.btn-primary {
  background: linear-gradient(135deg, var(--primary), #764ba2);
  color: white;
  box-shadow: 0 3px 10px rgba(102, 126, 234, 0.3);
}

.btn-sm.btn-primary:hover {
  box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
  transform: translateY(-2px);
}

.btn-sm.btn-secondary {
  background: var(--card-bg);
  color: var(--text);
  border: 2px solid var(--border);
}

.btn-sm.btn-secondary:hover {
  background: var(--card-hover);
}

/* Points Popup */
.points-popup {
  position: fixed;
  font-size: 24px;
  font-weight: 700;
  color: #f6ad55;
  text-shadow: 0 2px 4px rgba(0,0,0,0.2);
  pointer-events: none;
  z-index: 9999;
  transform: translate(-50%, -50%) scale(0.5);
  opacity: 0;
  transition: all 0.5s ease-out;
}

.points-popup.animate {
  transform: translate(-50%, -150%) scale(1.2);
  opacity: 1;
}

/* Record Banner */
.record-banner {
  position: fixed;
  top: -60px;
  left: 50%;
  transform: translateX(-50%);
  background: linear-gradient(135deg, #ffd700, #ffb347);
  color: #7c5c00;
  padding: 12px 32px;
  border-radius: 0 0 16px 16px;
  font-size: 18px;
  font-weight: 700;
  box-shadow: 0 4px 20px rgba(255, 193, 7, 0.5);
  z-index: 9999;
  transition: top 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.record-banner.show {
  top: 0;
}

/* Streak Banner */
.streak-banner {
  position: fixed;
  bottom: -60px;
  left: 50%;
  transform: translateX(-50%);
  background: linear-gradient(135deg, #ff6b6b, #ff8e53);
  color: white;
  padding: 12px 32px;
  border-radius: 16px 16px 0 0;
  font-size: 18px;
  font-weight: 700;
  box-shadow: 0 -4px 20px rgba(255, 107, 107, 0.4);
  z-index: 9999;
  transition: bottom 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.streak-banner.show {
  bottom: 0;
}

/* Compact Hangman */
.hangman-display {
  font-size: 32px !important;
  min-height: 45px !important;
  margin-bottom: 8px !important;
}

.hangman-word {
  font-size: 24px !important;
  letter-spacing: 4px !important;
  margin: 8px 0 !important;
}

.hangman-hint {
  font-size: 12px !important;
  margin-bottom: 6px !important;
}

.hangman-lives {
  font-size: 16px !important;
  margin-bottom: 10px !important;
}

.hangman-key {
  min-width: 30px !important;
  height: 34px !important;
  font-size: 14px !important;
}

#screen-game-hangman .game-result {
  margin-top: 10px !important;
  padding: 10px !important;
}
/* ===== NEW GAMES STYLES ===== */

/* Word Scramble */
.scramble-score {
  font-size: 16px;
  margin-bottom: 12px;
  color: var(--text-light);
}

.scramble-hint {
  font-size: 18px;
  color: var(--primary);
  margin-bottom: 16px;
  font-weight: 500;
}

.scramble-letters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  margin-bottom: 20px;
}

.scramble-letter {
  width: 45px;
  height: 45px;
  font-size: 20px;
  font-weight: 700;
  border: 2px solid var(--primary);
  border-radius: 8px;
  background: white;
  color: var(--primary);
  cursor: pointer;
  transition: all 0.2s;
  font-family: inherit;
}

.scramble-letter:hover {
  background: var(--primary);
  color: white;
  transform: scale(1.1);
}

.scramble-letter.used {
  background: #e2e8f0;
  border-color: #e2e8f0;
  color: #a0aec0;
}

.scramble-answer {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: center;
  min-height: 50px;
  padding: 12px;
  background: #f7fafc;
  border-radius: 8px;
  margin-bottom: 16px;
}

.scramble-answer-letter {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: 700;
  background: var(--primary);
  color: white;
  border-radius: 6px;
}

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

/* Math Speed Challenge */
.speed-math-timer {
  font-size: 28px;
  font-weight: 700;
  color: var(--danger);
  margin-bottom: 12px;
}

.speed-math-score {
  font-size: 16px;
  margin-bottom: 20px;
  color: var(--text-light);
}

.speed-math-problem {
  font-size: 36px;
  font-weight: 700;
  margin: 24px 0;
  color: var(--text);
}

.speed-math-input {
  display: block;
  width: 120px;
  height: 50px;
  font-size: 24px;
  text-align: center;
  border: 3px solid var(--primary);
  border-radius: 12px;
  margin: 0 auto 16px;
  font-family: inherit;
  direction: ltr;
}

.speed-math-input:focus {
  outline: none;
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.3);
}

/* Fill in the Blank */
.fill-blank-progress,
.fill-blank-score {
  font-size: 16px;
  margin-bottom: 8px;
  color: var(--text-light);
}

.fill-blank-sentence {
  font-size: 20px;
  line-height: 1.6;
  margin: 24px 0;
  padding: 20px;
  background: #f7fafc;
  border-radius: 12px;
}

.fill-blank-options {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: 300px;
  margin: 0 auto;
}

.fill-blank-option {
  padding: 14px 20px;
  font-size: 16px;
  border: 2px solid #e2e8f0;
  border-radius: 10px;
  background: white;
  cursor: pointer;
  transition: all 0.2s;
  font-family: inherit;
}

.fill-blank-option:hover {
  border-color: var(--primary);
  background: #f7fafc;
}

.fill-blank-option.correct {
  background: #c6f6d5;
  border-color: var(--success);
}

.fill-blank-option.wrong {
  background: #fed7d7;
  border-color: var(--danger);
}

/* True or False */
.true-false-progress,
.true-false-score {
  font-size: 16px;
  margin-bottom: 8px;
  color: var(--text-light);
}

.true-false-statement {
  font-size: 22px;
  line-height: 1.5;
  margin: 30px 0;
  padding: 24px;
  background: #f7fafc;
  border-radius: 12px;
  font-weight: 500;
}

.true-false-buttons {
  display: flex;
  gap: 16px;
  justify-content: center;
}

.btn-true,
.btn-false {
  padding: 16px 40px;
  font-size: 18px;
  font-weight: 700;
  border: none;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.2s;
  font-family: inherit;
}

.btn-true {
  background: var(--success);
  color: white;
}

.btn-false {
  background: var(--danger);
  color: white;
}

.btn-true:hover {
  transform: scale(1.05);
  box-shadow: 0 4px 15px rgba(72, 187, 120, 0.4);
}

.btn-false:hover {
  transform: scale(1.05);
  box-shadow: 0 4px 15px rgba(245, 101, 101, 0.4);
}

.btn-true.correct,
.btn-false.correct {
  box-shadow: 0 0 0 4px rgba(72, 187, 120, 0.5);
}

.btn-true.wrong,
.btn-false.wrong {
  opacity: 0.5;
}

/* Reading Comprehension */
.rc-passage-card {
  min-height: 120px;
}

.rc-title {
  font-size: 22px;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 16px;
  text-align: center;
}

.rc-text {
  font-size: 17px;
  line-height: 1.9;
  padding: 20px;
  background: #f7fafc;
  border-radius: 12px;
  margin-bottom: 20px;
  direction: rtl;
  text-align: right;
  max-height: 300px;
  overflow-y: auto;
  border: 1px solid #e2e8f0;
}

.rc-divider {
  text-align: center;
  font-size: 18px;
  font-weight: 700;
  color: var(--primary);
  margin: 16px 0;
  padding: 8px;
  background: linear-gradient(135deg, #e8f5e9, #c8e6c9);
  border-radius: 8px;
}

.rc-progress {
  font-size: 16px;
  margin-bottom: 12px;
  color: var(--text-light);
  text-align: center;
}

.rc-question {
  font-size: 18px;
  font-weight: 600;
  margin: 16px 0;
  padding: 16px;
  background: #fffde7;
  border-radius: 10px;
  direction: rtl;
  text-align: right;
  line-height: 1.6;
}

.rc-options {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.rc-option-btn {
  padding: 14px 16px;
  font-size: 16px;
  font-weight: 500;
  border: 2px solid #e2e8f0;
  border-radius: 10px;
  background: white;
  cursor: pointer;
  transition: all 0.2s;
  font-family: inherit;
  text-align: right;
  direction: rtl;
  line-height: 1.4;
}

.rc-option-btn:hover:not(:disabled) {
  border-color: var(--primary);
  background: #f0f4ff;
}

.rc-option-btn.correct {
  background: #c6f6d5;
  border-color: var(--success);
  box-shadow: 0 0 0 3px rgba(72, 187, 120, 0.3);
}

.rc-option-btn.wrong {
  background: #fed7d7;
  border-color: var(--danger);
  opacity: 0.7;
}

.rc-option-btn:disabled {
  cursor: default;
}

/* Word Problems Game */
.wp-progress,
.wp-score {
  font-size: 16px;
  margin-bottom: 8px;
  color: var(--text-light);
}

.wp-question {
  font-size: 20px;
  line-height: 1.7;
  margin: 24px 0;
  padding: 24px;
  background: #f7fafc;
  border-radius: 12px;
  font-weight: 500;
  direction: rtl;
  text-align: right;
}

.wp-options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  max-width: 400px;
  margin: 0 auto;
}

.wp-option-btn {
  padding: 16px 12px;
  font-size: 20px;
  font-weight: 700;
  border: 2px solid #e2e8f0;
  border-radius: 12px;
  background: white;
  cursor: pointer;
  transition: all 0.2s;
  font-family: inherit;
  direction: ltr;
}

.wp-option-btn:hover:not(:disabled) {
  transform: scale(1.05);
  border-color: var(--primary);
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.2);
}

.wp-option-btn.correct {
  background: #c6f6d5;
  border-color: var(--success);
  box-shadow: 0 0 0 3px rgba(72, 187, 120, 0.4);
}

.wp-option-btn.wrong {
  background: #fed7d7;
  border-color: var(--danger);
  opacity: 0.7;
}

.wp-option-btn:disabled {
  cursor: default;
}

/* Match Drag */
.match-drag-score {
  font-size: 18px;
  margin-bottom: 20px;
  color: var(--text-light);
}

.match-drag-area {
  display: flex;
  gap: 20px;
  justify-content: center;
}

.match-drag-left,
.match-drag-right {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.match-item {
  padding: 14px 24px;
  font-size: 16px;
  border: 2px solid #e2e8f0;
  border-radius: 10px;
  background: white;
  cursor: pointer;
  transition: all 0.2s;
  min-width: 120px;
  font-family: inherit;
}

.match-item:hover {
  border-color: var(--primary);
  background: #f7fafc;
}

.match-item.selected {
  border-color: var(--primary);
  background: var(--primary);
  color: white;
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.match-item.matched {
  background: #c6f6d5;
  border-color: var(--success);
  cursor: default;
}

/* Spelling Bee */
.spelling-progress,
.spelling-score {
  font-size: 16px;
  margin-bottom: 8px;
  color: var(--text-light);
}

.spelling-hint {
  font-size: 20px;
  color: var(--primary);
  margin: 20px 0;
  font-weight: 500;
}

.spelling-play-btn {
  margin-bottom: 20px;
  font-size: 18px;
}

.spelling-input {
  width: 80%;
  max-width: 300px;
  height: 50px;
  font-size: 20px;
  text-align: center;
  border: 3px solid var(--primary);
  border-radius: 12px;
  margin-bottom: 16px;
  font-family: inherit;
}

.spelling-input:focus {
  outline: none;
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.3);
}

/* ===== Global Record Bar (in-game display) ===== */
.game-record-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: linear-gradient(135deg, #fff8e1, #ffecb3);
  border: 2px solid #ffd54f;
  border-radius: 12px;
  padding: 8px 16px;
  margin-bottom: 12px;
  font-size: 14px;
  font-weight: 600;
  color: #5d4037;
  min-height: 36px;
  animation: recordBarSlideIn 0.4s ease;
}

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

.game-record-bar .record-trophy {
  font-size: 18px;
}

.game-record-bar .record-holder {
  font-size: 14px;
}

.game-record-bar .record-divider {
  color: #bbb;
  font-weight: 300;
}

.game-record-bar .record-score {
  background: linear-gradient(135deg, #ffd700, #ffb347);
  color: #5d4037;
  padding: 2px 10px;
  border-radius: 10px;
  font-weight: 700;
  font-size: 13px;
}

.game-record-bar .record-loading {
  color: #999;
  font-weight: 400;
}

/* Global record broken banner */
.global-record-banner {
  position: fixed;
  top: -80px;
  left: 50%;
  transform: translateX(-50%);
  background: linear-gradient(135deg, #ff6b6b, #ffd700, #ff6b6b);
  background-size: 200% 200%;
  animation: globalRecordShimmer 1.5s ease infinite;
  color: #fff;
  padding: 14px 36px;
  border-radius: 0 0 20px 20px;
  font-size: 20px;
  font-weight: 800;
  box-shadow: 0 6px 30px rgba(255, 107, 107, 0.6);
  z-index: 10000;
  text-shadow: 0 1px 4px rgba(0,0,0,0.3);
  transition: top 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  white-space: nowrap;
}

.global-record-banner.show {
  top: 0;
}

@keyframes globalRecordShimmer {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}