:root {
  --bg: #FFF8EC;
  --card: #FFFFFF;
  --primary: #FF6B35;
  --primary-light: #FF8C5A;
  --yellow: #FFD93D;
  --yellow-dark: #F5C400;
  --green: #6BCB77;
  --green-dark: #4CAF58;
  --red: #FF4D6D;
  --red-dark: #E03050;
  --blue: #4D96FF;
  --blue-dark: #2B7BF5;
  --purple: #C77DFF;
  --text: #2D2D2D;
  --text-light: #888;
  --shadow: 0 6px 0px rgba(0,0,0,0.12);
  --shadow-sm: 0 3px 0px rgba(0,0,0,0.10);
  --radius: 20px;
  --radius-sm: 14px;
}

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

body {
  font-family: 'Nunito Sans', sans-serif;
  background: var(--bg);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 20px 16px 40px;
  background-image: radial-gradient(circle at 20% 20%, #FFE0CC 0%, transparent 50%),
                    radial-gradient(circle at 80% 80%, #D4F1D8 0%, transparent 50%);
}

/* APP SWITCHER */
.app-switcher {
  display: flex;
  gap: 6px;
  margin-bottom: 12px;
  background: rgba(0,0,0,0.07);
  padding: 5px;
  border-radius: 50px;
}

.app-btn {
  font-family: 'Nunito', sans-serif;
  font-weight: 800;
  font-size: 1rem;
  padding: 9px 22px;
  border-radius: 50px;
  border: none;
  cursor: pointer;
  transition: all 0.2s;
  color: var(--text-light);
  background: transparent;
  letter-spacing: 0.3px;
}

.app-btn.active {
  background: white;
  color: var(--primary);
  box-shadow: 0 3px 10px rgba(0,0,0,0.13);
}

h1 {
  font-family: 'Nunito', sans-serif;
  font-weight: 900;
  font-size: clamp(2rem, 6vw, 3rem);
  color: var(--primary);
  letter-spacing: -1px;
  margin-bottom: 4px;
  text-shadow: 0 4px 0 rgba(255,107,53,0.15);
}

.subtitle {
  font-family: 'Nunito', sans-serif;
  font-weight: 700;
  color: var(--text-light);
  font-size: 1rem;
  margin-bottom: 20px;
}

/* CATEGORY PILLS */
.categories {
  display: flex;
  gap: 10px;
  margin-bottom: 24px;
  flex-wrap: wrap;
  justify-content: center;
}

.cat-pill {
  font-family: 'Nunito', sans-serif;
  font-weight: 800;
  font-size: 0.9rem;
  padding: 8px 18px;
  border-radius: 50px;
  border: none;
  cursor: pointer;
  transition: transform 0.12s, box-shadow 0.12s;
  box-shadow: var(--shadow-sm);
  letter-spacing: 0.3px;
}

.cat-pill:active { transform: translateY(3px); box-shadow: none; }

/* Andulingo categories */
.cat-pill.animals  { background: #FFD93D; color: #7A5800; box-shadow: 0 4px 0 #C9A000; }
.cat-pill.colors   { background: #C77DFF; color: #3B0070; box-shadow: 0 4px 0 #8B40CC; }
.cat-pill.numbers  { background: #4D96FF; color: #003080; box-shadow: 0 4px 0 #1A5FC0; }
.cat-pill.body     { background: #FF9EAA; color: #7A0020; box-shadow: 0 4px 0 #D05060; }
.cat-pill.mix      { background: #43D49A; color: #004030; box-shadow: 0 4px 0 #25A070; }
.cat-pill.multiply { background: #FF9500; color: #6B3000; box-shadow: 0 4px 0 #C06000; }

.cat-pill.active.animals  { background: #FFD93D; outline: 4px solid #7A5800; }
.cat-pill.active.colors   { background: #C77DFF; outline: 4px solid #3B0070; }
.cat-pill.active.numbers  { background: #4D96FF; outline: 4px solid #003080; }
.cat-pill.active.body     { background: #FF9EAA; outline: 4px solid #7A0020; }
.cat-pill.active.mix      { background: #43D49A; outline: 4px solid #004030; }
.cat-pill.active.multiply { background: #FF9500; outline: 4px solid #6B3000; }

/* Vovolingo categories */
.cat-pill.v-halves   { background: #FF9EAA; color: #7A0020; box-shadow: 0 4px 0 #D05060; }
.cat-pill.v-thirds   { background: #4D96FF; color: #003080; box-shadow: 0 4px 0 #1A5FC0; }
.cat-pill.v-quarters { background: #C77DFF; color: #3B0070; box-shadow: 0 4px 0 #8B40CC; }
.cat-pill.v-fifths   { background: #FFD93D; color: #7A5800; box-shadow: 0 4px 0 #C9A000; }

.cat-pill.active.v-halves   { outline: 4px solid #7A0020; }
.cat-pill.active.v-thirds   { outline: 4px solid #003080; }
.cat-pill.active.v-quarters { outline: 4px solid #3B0070; }
.cat-pill.active.v-fifths   { outline: 4px solid #7A5800; }
.cat-pill.v-addition    { background: #43D49A; color: #004030; box-shadow: 0 4px 0 #25A070; }
.cat-pill.v-subtraction { background: #FF9500; color: #6B3000; box-shadow: 0 4px 0 #C06000; }
.cat-pill.active.v-addition    { outline: 4px solid #004030; }
.cat-pill.active.v-subtraction { outline: 4px solid #6B3000; }
.cat-pill.v-multiply { background: #4D96FF; color: #003080; box-shadow: 0 4px 0 #1A5FC0; }
.cat-pill.active.v-multiply { outline: 4px solid #003080; }

/* SCORE BAR */
.scorebar {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 24px;
  font-family: 'Nunito', sans-serif;
  font-weight: 800;
}

.hearts {
  font-size: 1.4rem;
  letter-spacing: 2px;
}

.score-label {
  font-size: 1rem;
  color: var(--text-light);
}

.score-val {
  font-size: 1.4rem;
  color: var(--primary);
}

/* STREAK */
.streak {
  font-size: 1rem;
  color: #FF9500;
  display: flex;
  align-items: center;
  gap: 4px;
}

/* QUESTION CARD */
.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: 0 8px 0 rgba(0,0,0,0.10);
  padding: 32px 28px 28px;
  width: 100%;
  max-width: 460px;
  margin-bottom: 20px;
  text-align: center;
  position: relative;
  overflow: hidden;
}

.card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 6px;
  background: linear-gradient(90deg, var(--primary), var(--yellow));
  border-radius: var(--radius) var(--radius) 0 0;
}

.direction-badge {
  display: inline-block;
  font-family: 'Nunito', sans-serif;
  font-weight: 700;
  font-size: 0.75rem;
  padding: 3px 12px;
  border-radius: 50px;
  background: #FFF3E8;
  color: var(--primary);
  margin-bottom: 14px;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

.word-display {
  font-family: 'Nunito', sans-serif;
  font-weight: 900;
  font-size: clamp(2.2rem, 8vw, 3.2rem);
  color: var(--text);
  line-height: 1.1;
  margin-bottom: 8px;
  letter-spacing: -1px;
}

.word-emoji {
  font-size: clamp(2.5rem, 8vw, 3.5rem);
  margin-bottom: 8px;
  display: block;
  animation: pop 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

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

/* ANSWER BUTTONS */
.answers {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
  max-width: 460px;
}

.answer-btn {
  font-family: 'Nunito', sans-serif;
  font-weight: 800;
  font-size: clamp(1.1rem, 4vw, 1.3rem);
  padding: 16px 20px;
  border-radius: var(--radius-sm);
  border: 3px solid transparent;
  cursor: pointer;
  transition: transform 0.12s, box-shadow 0.12s;
  background: var(--card);
  color: var(--text);
  border: 3px solid #E8E0D5;
  box-shadow: 0 5px 0 #D0C8C0;
  text-align: left;
  display: flex;
  align-items: center;
  gap: 14px;
  position: relative;
  overflow: hidden;
}

.answer-btn .btn-letter {
  width: 32px; height: 32px;
  border-radius: 8px;
  background: #F5F0EA;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.85rem;
  font-weight: 900;
  color: #999;
  flex-shrink: 0;
  transition: background 0.15s, color 0.15s;
}

.answer-btn:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 7px 0 #D0C8C0;
  border-color: #C0B8B0;
}

.answer-btn:active:not(:disabled) {
  transform: translateY(4px);
  box-shadow: none;
}

.answer-btn.correct {
  background: #E8FAE8;
  border-color: var(--green-dark);
  box-shadow: 0 5px 0 var(--green-dark);
  color: #1A6B20;
  animation: wiggle-good 0.4s ease;
}

.answer-btn.correct .btn-letter {
  background: var(--green);
  color: white;
}

.answer-btn.wrong {
  background: #FFE8EC;
  border-color: var(--red-dark);
  box-shadow: 0 5px 0 var(--red-dark);
  color: #8B0020;
  animation: shake 0.4s ease;
}

.answer-btn.wrong .btn-letter {
  background: var(--red);
  color: white;
}

.answer-btn.reveal-correct {
  background: #E8FAE8;
  border-color: var(--green-dark);
  box-shadow: 0 5px 0 var(--green-dark);
  color: #1A6B20;
  opacity: 0.7;
}

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

@keyframes wiggle-good {
  0%   { transform: scale(1); }
  30%  { transform: scale(1.04); }
  60%  { transform: scale(0.98); }
  100% { transform: scale(1); }
}

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

/* FEEDBACK TOAST */
.feedback {
  font-family: 'Nunito', sans-serif;
  font-weight: 800;
  font-size: 1.1rem;
  padding: 12px 24px;
  border-radius: 50px;
  margin-top: 16px;
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.25s, transform 0.25s;
  pointer-events: none;
}

.feedback.show {
  opacity: 1;
  transform: translateY(0);
}

.feedback.good { background: #E8FAE8; color: #1A6B20; }
.feedback.bad  { background: #FFE8EC; color: #8B0020; }

/* PROGRESS */
.progress-wrap {
  width: 100%;
  max-width: 460px;
  margin-bottom: 20px;
}

.progress-bar {
  height: 10px;
  background: #E8E0D5;
  border-radius: 50px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--yellow));
  border-radius: 50px;
  transition: width 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
  width: 0%;
}

.progress-info {
  display: flex;
  justify-content: space-between;
  font-family: 'Nunito', sans-serif;
  font-weight: 700;
  font-size: 0.82rem;
  color: var(--text-light);
  margin-bottom: 6px;
}

/* RESULTS SCREEN */
.results {
  display: none;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 16px;
  width: 100%;
  max-width: 460px;
}

.results.show { display: flex; }

.result-title {
  font-family: 'Nunito', sans-serif;
  font-weight: 900;
  font-size: clamp(2rem, 7vw, 2.8rem);
  color: var(--primary);
  animation: pop 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.result-emoji {
  font-size: 5rem;
  animation: pop 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) 0.1s both;
}

.result-score {
  font-family: 'Nunito', sans-serif;
  font-weight: 800;
  font-size: 1.2rem;
  color: var(--text-light);
}

.result-score span {
  color: var(--text);
  font-size: 1.8rem;
}

.restart-btn {
  font-family: 'Nunito', sans-serif;
  font-weight: 900;
  font-size: 1.2rem;
  padding: 16px 40px;
  border-radius: 50px;
  border: none;
  cursor: pointer;
  background: var(--primary);
  color: white;
  box-shadow: 0 6px 0 #C04010;
  transition: transform 0.12s, box-shadow 0.12s;
  margin-top: 8px;
}

.restart-btn:hover { transform: translateY(-2px); box-shadow: 0 8px 0 #C04010; }
.restart-btn:active { transform: translateY(4px); box-shadow: none; }

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

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

/* DIRECTION TOGGLE */
.dir-toggle {
  font-family: 'Nunito', sans-serif;
  font-weight: 700;
  font-size: 0.85rem;
  padding: 6px 16px;
  border-radius: 50px;
  border: 2px solid #E0D8D0;
  background: white;
  cursor: pointer;
  color: var(--text-light);
  transition: all 0.15s;
  margin-bottom: 16px;
}

.dir-toggle:hover { border-color: var(--primary); color: var(--primary); }

/* MATH FRACTION in buttons */
.math-frac {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  font-family: 'Nunito', sans-serif;
  font-weight: 900;
  font-size: 1.25em;
  line-height: 1;
  gap: 1px;
  vertical-align: middle;
}

.frac-num {
  border-bottom: 3px solid currentColor;
  padding: 0 6px 3px;
  min-width: 28px;
  text-align: center;
}

.frac-den {
  padding: 3px 6px 0;
  min-width: 28px;
  text-align: center;
}
