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

:root {
  --yellow:  #FFD93D;
  --orange:  #FF6B35;
  --pink:    #FF6B9D;
  --blue:    #4ECDC4;
  --green:   #6BCB77;
  --purple:  #A855F7;
  --white:   #FFFEF5;
  --shadow:  0 6px 0px rgba(0,0,0,0.18);
  --radius:  22px;
  --font-main: 'Nunito', sans-serif;
  --font-title: 'Fredoka One', cursive;
}

html, body {
  height: 100%;
  font-family: var(--font-main);
  background: #FFF9F0;
  overflow-x: hidden;
}

/* ============ SCREENS ============ */
.screen {
  display: none;
  min-height: 100vh;
  animation: fadeIn 0.35s ease;
}
.screen.active { display: flex; flex-direction: column; }

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

/* ============ HOME SCREEN ============ */
#screen-home {
  background: linear-gradient(160deg, #FFF176 0%, #FFB3C6 50%, #A5EDFF 100%);
  position: relative;
  align-items: center;
  justify-content: center;
}

.home-bg { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.cloud {
  position: absolute;
  font-size: 3rem;
  animation: drift 8s ease-in-out infinite alternate;
  opacity: 0.6;
}
.c1 { top: 8%;  left: 5%;  animation-delay: 0s; }
.c2 { top: 15%; right: 8%; animation-delay: 2s; font-size: 2.2rem; }
.c3 { top: 5%;  left: 42%; animation-delay: 4s; font-size: 1.8rem; }

@keyframes drift {
  from { transform: translateX(0); }
  to   { transform: translateX(18px); }
}

.home-content {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
  padding: 30px 20px 40px;
  max-width: 480px;
  width: 100%;
}

.logo-wrap { text-align: center; }
.logo-icon { font-size: 3rem; animation: spin-y 4s ease-in-out infinite; display: inline-block; }
@keyframes spin-y {
  0%,100% { transform: rotateY(0deg); }
  50%      { transform: rotateY(180deg); }
}

.logo-title {
  font-family: var(--font-title);
  font-size: clamp(2.8rem, 10vw, 4.5rem);
  color: var(--orange);
  text-shadow: 4px 4px 0 #fff, 6px 6px 0 rgba(255,107,53,0.25);
  letter-spacing: 2px;
  line-height: 1;
}
.logo-sub {
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--purple);
  margin-top: 4px;
}

.home-mascot {
  font-size: clamp(5rem, 18vw, 8rem);
  animation: bounce 1.8s ease-in-out infinite;
  filter: drop-shadow(0 8px 12px rgba(0,0,0,0.15));
}
@keyframes bounce {
  0%,100% { transform: translateY(0) rotate(-3deg); }
  50%      { transform: translateY(-18px) rotate(3deg); }
}

.home-buttons {
  display: flex;
  flex-direction: column;
  gap: 14px;
  width: 100%;
  max-width: 320px;
}

/* ============ BUTTONS ============ */
.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  border: none;
  border-radius: 50px;
  padding: 18px 28px;
  font-family: var(--font-title);
  font-size: 1.4rem;
  cursor: pointer;
  transition: transform 0.12s, box-shadow 0.12s;
  width: 100%;
  letter-spacing: 1px;
}
.btn:active { transform: translateY(4px); box-shadow: 0 2px 0 rgba(0,0,0,0.18) !important; }

.btn-learn {
  background: var(--green);
  color: #fff;
  box-shadow: 0 6px 0 #3a9b44;
}
.btn-learn:hover { transform: translateY(-3px); box-shadow: 0 9px 0 #3a9b44; }

.btn-quiz {
  background: var(--orange);
  color: #fff;
  box-shadow: 0 6px 0 #c44d1e;
}
.btn-quiz:hover { transform: translateY(-3px); box-shadow: 0 9px 0 #c44d1e; }

.btn-icon { font-size: 1.6rem; }
.btn-label { font-size: 1.35rem; }

.stars-row { font-size: 1.8rem; letter-spacing: 8px; animation: twinkle 2s ease-in-out infinite; }
@keyframes twinkle {
  0%,100% { opacity: 1; transform: scale(1); }
  50%      { opacity: 0.6; transform: scale(1.12); }
}

/* ============ TOPBAR ============ */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--white);
  padding: 14px 18px;
  box-shadow: 0 3px 0 rgba(0,0,0,0.08);
  position: sticky;
  top: 0;
  z-index: 10;
}
.topbar-title {
  font-family: var(--font-title);
  font-size: 1.5rem;
  color: var(--orange);
}

.back-btn {
  background: var(--yellow);
  border: none;
  border-radius: 50px;
  padding: 10px 18px;
  font-family: var(--font-title);
  font-size: 1rem;
  cursor: pointer;
  box-shadow: 0 4px 0 #d4a800;
  transition: transform 0.1s;
  color: #333;
}
.back-btn:hover { transform: translateY(-2px); }
.back-btn:active { transform: translateY(2px); box-shadow: 0 2px 0 #d4a800; }

/* ============ WORD GRID ============ */
.word-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 16px;
  padding: 20px;
  max-width: 900px;
  margin: 0 auto;
  width: 100%;
}

.word-card {
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 12px 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
  border: 3px solid transparent;
  animation: popIn 0.4s ease both;
}
.word-card:hover { transform: translateY(-6px) rotate(-1deg); box-shadow: 0 12px 0 rgba(0,0,0,0.12); }
.word-card:active { transform: scale(0.95); }

@keyframes popIn {
  from { opacity: 0; transform: scale(0.6); }
  to   { opacity: 1; transform: scale(1); }
}

.word-emoji { font-size: 3.2rem; line-height: 1; }
.word-name {
  font-family: var(--font-title);
  font-size: 1.25rem;
  color: #333;
  text-align: center;
}
.word-translation {
  font-size: 0.85rem;
  font-weight: 700;
  color: #888;
}
.word-play-btn {
  background: var(--blue);
  color: #fff;
  border: none;
  border-radius: 50px;
  padding: 8px 16px;
  font-size: 0.9rem;
  font-family: var(--font-main);
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 4px 0 #2a9e96;
  transition: transform 0.1s;
  display: flex;
  align-items: center;
  gap: 5px;
  margin-top: 4px;
}
.word-play-btn:hover { transform: translateY(-2px); }
.word-play-btn:active { transform: translateY(2px); box-shadow: 0 2px 0 #2a9e96; }
.word-play-btn.playing { background: var(--pink); box-shadow: 0 4px 0 #c44d7a; }

/* Card color accents */
.word-card:nth-child(1)  { border-color: var(--yellow); }
.word-card:nth-child(2)  { border-color: var(--pink); }
.word-card:nth-child(3)  { border-color: var(--blue); }
.word-card:nth-child(4)  { border-color: var(--green); }
.word-card:nth-child(5)  { border-color: var(--orange); }
.word-card:nth-child(6)  { border-color: var(--purple); }
.word-card:nth-child(7)  { border-color: var(--yellow); }
.word-card:nth-child(8)  { border-color: var(--pink); }
.word-card:nth-child(9)  { border-color: var(--blue); }
.word-card:nth-child(10) { border-color: var(--green); }

/* ============ QUIZ ============ */
#screen-quiz { background: #FFF0FA; }

.quiz-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 24px 16px;
  gap: 20px;
  flex: 1;
}

.quiz-progress {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  max-width: 500px;
}
.progress-bar {
  flex: 1;
  height: 14px;
  background: #f0d0e8;
  border-radius: 50px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--pink), var(--purple));
  border-radius: 50px;
  transition: width 0.5s ease;
  width: 10%;
}
.progress-text {
  font-family: var(--font-title);
  font-size: 1rem;
  color: var(--purple);
  white-space: nowrap;
}

.score-badge {
  background: var(--yellow);
  border-radius: 50px;
  padding: 8px 16px;
  font-family: var(--font-title);
  font-size: 1.1rem;
  color: #333;
  box-shadow: 0 3px 0 #d4a800;
}

.quiz-card {
  background: #fff;
  border-radius: 32px;
  padding: 32px 24px 28px;
  box-shadow: 0 8px 0 rgba(200,100,180,0.18);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  width: 100%;
  max-width: 500px;
  border: 3px solid #f9c4e8;
  animation: fadeIn 0.4s ease;
}

.quiz-emoji { font-size: 5rem; animation: wiggle 1.5s ease-in-out infinite; }
@keyframes wiggle {
  0%,100% { transform: rotate(-4deg); }
  50%      { transform: rotate(4deg); }
}

.quiz-question {
  font-family: var(--font-title);
  font-size: 1.4rem;
  color: #444;
  text-align: center;
}

.quiz-options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  width: 100%;
}

.opt-btn {
  background: var(--white);
  border: 3px solid #e0d0f0;
  border-radius: 18px;
  padding: 14px 10px;
  font-family: var(--font-title);
  font-size: 1.1rem;
  cursor: pointer;
  transition: transform 0.12s, background 0.15s, border-color 0.15s;
  color: #333;
  box-shadow: 0 4px 0 #d0c0e8;
  text-align: center;
  word-break: break-word;
}
.opt-btn:hover:not(:disabled) { transform: translateY(-3px) scale(1.03); border-color: var(--purple); background: #f5e8ff; }
.opt-btn:active:not(:disabled) { transform: scale(0.96); }
.opt-btn.correct { background: #CCFFD8; border-color: var(--green); color: #2a6b2a; box-shadow: 0 4px 0 var(--green); }
.opt-btn.wrong   { background: #FFDDDD; border-color: #e05555; color: #7a1a1a; box-shadow: 0 4px 0 #e05555; }
.opt-btn:disabled { cursor: default; }

/* ============ QUIZ RESULT ============ */
.quiz-result {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  flex: 1;
  padding: 30px 20px;
  animation: fadeIn 0.5s ease;
}

.result-emoji { font-size: 6rem; animation: bounce 1.5s ease-in-out infinite; }
.result-title {
  font-family: var(--font-title);
  font-size: 2.5rem;
  color: var(--orange);
  text-shadow: 3px 3px 0 var(--yellow);
}
.result-score {
  font-size: 1.3rem;
  font-weight: 800;
  color: var(--purple);
}
.result-stars { font-size: 2rem; letter-spacing: 6px; }
.quiz-result .btn { max-width: 280px; }

/* ============ FEEDBACK TOAST ============ */
.toast {
  position: fixed;
  bottom: 30px;
  left: 50%;
  transform: translateX(-50%) translateY(80px);
  background: #333;
  color: #fff;
  padding: 12px 28px;
  border-radius: 50px;
  font-family: var(--font-title);
  font-size: 1.1rem;
  z-index: 999;
  transition: transform 0.3s ease;
  white-space: nowrap;
  pointer-events: none;
}
.toast.show { transform: translateX(-50%) translateY(0); }
.toast.correct-toast { background: var(--green); }
.toast.wrong-toast   { background: #e05555; }

/* ============ RESPONSIVE ============ */
@media (max-width: 420px) {
  .word-grid { grid-template-columns: repeat(2, 1fr); gap: 12px; padding: 14px; }
  .quiz-options { grid-template-columns: 1fr 1fr; gap: 10px; }
  .opt-btn { font-size: 1rem; padding: 12px 8px; }
  .home-buttons { max-width: 280px; }
}
