* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: 'Comic Sans MS', 'Segoe UI Rounded', 'Trebuchet MS', sans-serif;
  background: linear-gradient(160deg, #fff4e0 0%, #ffe0ec 45%, #e0f0ff 100%);
  color: #3a2a4a;
  min-height: 100vh;
  padding-bottom: 24px;
  -webkit-tap-highlight-color: transparent;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px;
  background: linear-gradient(135deg, #7c3aed, #ec4899);
  color: white;
  box-shadow: 0 4px 12px rgba(124, 58, 237, 0.3);
  position: sticky;
  top: 0;
  z-index: 10;
}

.app-title {
  font-size: 22px;
  font-weight: 800;
}

.coin-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(255, 255, 255, 0.25);
  padding: 8px 14px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 18px;
}

.coin-icon { font-size: 20px; }

.tabs {
  display: flex;
  gap: 8px;
  padding: 14px 16px 4px;
}

.tab-btn {
  flex: 1;
  border: none;
  background: white;
  color: #7c3aed;
  font-weight: 700;
  font-size: 15px;
  padding: 12px 8px;
  border-radius: 16px;
  box-shadow: 0 2px 6px rgba(124, 58, 237, 0.15);
  cursor: pointer;
  transition: transform 0.1s ease;
}

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

.tab-btn.active {
  background: linear-gradient(135deg, #7c3aed, #ec4899);
  color: white;
}

main { padding: 16px; }

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 14px;
}

.quest-card {
  background: white;
  border-radius: 20px;
  padding: 16px;
  text-align: center;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.08);
  display: flex;
  flex-direction: column;
  gap: 6px;
  border: 3px solid transparent;
}

.quest-card.prize-card.locked {
  opacity: 0.55;
}

.quest-emoji {
  font-size: 36px;
}

.quest-emoji.big { font-size: 52px; }

.quest-title {
  font-weight: 800;
  font-size: 16px;
}

.quest-desc {
  font-size: 13px;
  color: #6b5b76;
}

.quest-value {
  font-weight: 700;
  color: #d97706;
  font-size: 15px;
}

.quest-btn, .submit-btn {
  margin-top: 6px;
  border: none;
  border-radius: 14px;
  padding: 10px 12px;
  font-weight: 800;
  font-size: 14px;
  background: linear-gradient(135deg, #34d399, #10b981);
  color: white;
  cursor: pointer;
}

.quest-btn:active, .submit-btn:active { transform: scale(0.96); }

.quest-btn.pending, .quest-btn[disabled] {
  background: #e5e7eb;
  color: #9ca3af;
}

.empty-msg {
  grid-column: 1 / -1;
  text-align: center;
  padding: 40px 20px;
  font-size: 16px;
  color: #8a7a94;
}

.progress-panel {
  background: white;
  border-radius: 24px;
  padding: 32px 20px;
  text-align: center;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.08);
}

.big-coin { font-size: 48px; }
.big-coin-count {
  font-size: 48px;
  font-weight: 900;
  color: #d97706;
}
.progress-label {
  color: #8a7a94;
  margin-bottom: 20px;
}

.stat-row {
  display: flex;
  gap: 12px;
  justify-content: center;
  margin-bottom: 20px;
}

.stat-box {
  background: #f3e8ff;
  border-radius: 16px;
  padding: 14px 20px;
  flex: 1;
}

.stat-number {
  font-size: 28px;
  font-weight: 800;
  color: #7c3aed;
}

.stat-label {
  font-size: 12px;
  color: #6b5b76;
}

.encourage {
  font-size: 16px;
  font-weight: 700;
  color: #ec4899;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: flex-end;
}

.modal[hidden] { display: none; }

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
}

.modal-panel {
  position: relative;
  background: white;
  width: 100%;
  border-radius: 24px 24px 0 0;
  padding: 28px 20px 32px;
  text-align: center;
  animation: slideUp 0.2s ease;
  max-height: 85vh;
  overflow-y: auto;
}

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

.modal-close-btn {
  position: absolute;
  top: 14px;
  right: 16px;
  border: none;
  background: #f3e8ff;
  color: #7c3aed;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  font-weight: 800;
  cursor: pointer;
}

.capture-btn {
  display: block;
  margin: 16px auto;
  background: linear-gradient(135deg, #60a5fa, #3b82f6);
  color: white;
  font-weight: 700;
  padding: 14px 18px;
  border-radius: 16px;
  cursor: pointer;
  max-width: 260px;
}

.file-chosen {
  margin-top: 8px;
  color: #10b981;
  font-weight: 700;
}

.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: #3a2a4a;
  color: white;
  padding: 14px 22px;
  border-radius: 999px;
  font-weight: 700;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25);
  z-index: 200;
  max-width: 90vw;
  text-align: center;
}

.toast[hidden] { display: none; }

/* ---------- Learning ---------- */
.learning-grid {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.subject-card {
  background: white;
  border-radius: 20px;
  padding: 16px;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.08);
}

.subject-header {
  font-weight: 800;
  font-size: 17px;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.subject-emoji { font-size: 22px; }

.topic-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.topic-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #faf5ff;
  border: 2px solid #e5e7eb;
  border-radius: 14px;
  padding: 12px 14px;
  font-weight: 700;
  font-size: 14px;
  color: #3a2a4a;
  cursor: pointer;
}

.topic-row:active { transform: scale(0.97); }

.topic-stars { font-size: 14px; letter-spacing: 1px; }

.learning-progress {
  font-weight: 700;
  color: #7c3aed;
  margin-bottom: 8px;
}

.exercise-prompt {
  font-size: 20px;
  line-height: 1.4;
  margin: 8px 0 16px;
}

.choice-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 10px;
}

.choice-btn {
  border: 2px solid #ddd6fe;
  background: #faf5ff;
  color: #3a2a4a;
  font-weight: 700;
  font-size: 16px;
  padding: 14px;
  border-radius: 14px;
  cursor: pointer;
}

.choice-btn:active { transform: scale(0.98); }
.choice-btn[disabled] { opacity: 0.7; }
.choice-btn.choice-correct { background: #d1fae5; border-color: #10b981; }
.choice-btn.choice-wrong { background: #fee2e2; border-color: #ef4444; }

.typed-input {
  display: block;
  width: 100%;
  max-width: 220px;
  margin: 0 auto 14px;
  padding: 14px;
  font-size: 20px;
  text-align: center;
  border: 2px solid #ddd6fe;
  border-radius: 14px;
}

.clock-face {
  width: 160px;
  height: 160px;
  margin: 0 auto 16px;
  display: block;
}

.feedback-correct {
  color: #10b981;
  font-weight: 800;
  font-size: 16px;
  margin-top: 10px;
}

.feedback-wrong {
  color: #ec4899;
  font-weight: 700;
  font-size: 15px;
  margin-top: 10px;
}

/* ---------- Profile gate ---------- */
.topbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.profile-chip {
  border: none;
  background: rgba(255, 255, 255, 0.25);
  border-radius: 50%;
  width: 40px;
  height: 40px;
  font-size: 20px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.profile-gate {
  position: fixed;
  inset: 0;
  z-index: 500;
  background: linear-gradient(160deg, #fff4e0 0%, #ffe0ec 45%, #e0f0ff 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.profile-gate[hidden] { display: none; }

.profile-gate-panel {
  background: white;
  border-radius: 24px;
  padding: 32px 24px;
  max-width: 340px;
  width: 100%;
  text-align: center;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
}

.profile-gate-panel h1 {
  font-size: 22px;
  margin: 0 0 20px;
}

.profile-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 16px;
}

.profile-option {
  display: flex;
  align-items: center;
  gap: 12px;
  border: 2px solid #ddd6fe;
  background: #faf5ff;
  border-radius: 14px;
  padding: 12px 16px;
  font-weight: 700;
  font-size: 16px;
  color: #3a2a4a;
  cursor: pointer;
}

.profile-option:active { transform: scale(0.97); }
.profile-emoji { font-size: 24px; }

.profile-new-btn {
  border: none;
  background: none;
  color: #7c3aed;
  font-weight: 700;
  font-size: 14px;
  padding: 10px;
  cursor: pointer;
}

.profile-new-form[hidden] { display: none; }

.profile-new-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 12px;
}

.profile-new-form input {
  padding: 12px;
  font-size: 16px;
  text-align: center;
  border: 2px solid #ddd6fe;
  border-radius: 12px;
}

.profile-emoji-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
}

.emoji-choice {
  border: 2px solid #e5e7eb;
  background: #faf5ff;
  border-radius: 10px;
  font-size: 20px;
  width: 42px;
  height: 42px;
  cursor: pointer;
}

.emoji-choice.selected { border-color: #7c3aed; background: #ede9fe; }

.profile-language-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
}

.lang-choice {
  border: 2px solid #e5e7eb;
  background: #faf5ff;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 700;
  padding: 8px 12px;
  cursor: pointer;
}

.lang-choice.selected { border-color: #7c3aed; background: #ede9fe; color: #7c3aed; }
