:root {
  --c1: #FF6B6B;
  --c2: #FF9F43;
  --c3: #FECA57;
  --c4: #1DD1A1;
  --c5: #48DBFB;
  --c6: #A29BFE;
  --c7: #FD79A8;
  --bg1: #1a1a2e;
  --bg2: #16213e;
  --bg3: #0f3460;
  --text-light: #ffffff;
  --text-dim: rgba(255,255,255,0.8);
  --nav-h: 72px;
  --radius-lg: 20px;
  --radius-md: 14px;
  --radius-sm: 10px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; margin: 0; padding: 0; }
html, body { height: 100%; overflow: hidden; }
body {
  background: linear-gradient(135deg, var(--bg1) 0%, var(--bg2) 50%, var(--bg3) 100%);
  font-family: 'Trebuchet MS', 'Arial Rounded MT Bold', Arial, sans-serif;
  color: var(--text-light);
  min-height: 100vh;
  position: relative;
  overflow: hidden;
}
#bg-canvas {
  position: fixed; top: 0; left: 0; width: 100%; height: 100%;
  pointer-events: none; z-index: 0;
  overflow: hidden;
}
.bubble {
  position: absolute;
  border-radius: 50%;
  opacity: 0;
  animation: floatUp linear infinite;
}
@keyframes floatUp {
  0%   { transform: translateY(110vh) rotate(0deg);   opacity: 0; }
  10%  { opacity: 0.5; }
  90%  { opacity: 0.3; }
  100% { transform: translateY(-120px) rotate(720deg); opacity: 0; }
}
#app {
  position: relative; z-index: 1;
  max-width: 480px;
  margin: 0 auto;
  height: 100%;
  display: flex;
  flex-direction: column;
}
#screens {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom));
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
#screens::-webkit-scrollbar { display: none; }
.screen { display: none; padding: 16px; animation: fadeIn 0.35s ease; }
.screen.active { display: block; }
#home.active { display: flex; flex-direction: column; align-items: center; min-height: calc(100vh - var(--nav-h)); }
@keyframes fadeIn { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: translateY(0); } }

/* ---- BOTTOM NAV ---- */
#nav {
  position: fixed; bottom: 0; left: 50%;
  transform: translateX(-50%);
  width: 100%; max-width: 480px;
  height: var(--nav-h);
  padding-bottom: env(safe-area-inset-bottom);
  background: rgba(255,255,255,0.12);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid rgba(255,255,255,0.2);
  display: flex;
  z-index: 100;
}
.nav-btn {
  flex: 1; display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 3px;
  background: none; border: none; cursor: pointer;
  color: rgba(255,255,255,0.5);
  transition: all 0.2s ease;
  min-height: 44px;
  padding: 6px 2px;
}
.nav-btn .nav-icon { font-size: 1.6rem; line-height: 1; transition: transform 0.2s ease; }
.nav-btn .nav-label { font-size: 0.6rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; }
.nav-btn.active { color: var(--text-light); }
.nav-btn.active .nav-icon { transform: scale(1.15) translateY(-2px); }
.nav-btn:active .nav-icon { transform: scale(0.9); }

/* ---- HOME SCREEN ---- */
.home-header { text-align: center; padding: 32px 16px 20px; width: 100%; }
.home-title {
  font-size: 2.4rem; font-weight: 900; letter-spacing: -1px;
  background: linear-gradient(135deg, #FECA57, #FF9F43, #FF6B6B);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
  animation: pulse 2.5s ease-in-out infinite;
}
@keyframes pulse { 0%,100% { transform: scale(1); } 50% { transform: scale(1.04); } }
.home-sub { font-size: 1rem; color: var(--text-dim); margin-top: 6px; }
.home-mascot { font-size: 5rem; margin: 8px 0; animation: bounce 1.8s ease-in-out infinite; display: block; }
@keyframes bounce { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-14px); } }
.menu-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; width: 100%; padding: 4px; }
.menu-card {
  border-radius: var(--radius-lg);
  padding: 24px 16px;
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  cursor: pointer; border: none; color: white;
  transition: transform 0.18s ease, box-shadow 0.18s ease;
  box-shadow: 0 6px 20px rgba(0,0,0,0.3);
  min-height: 130px; justify-content: center;
}
.menu-card:active { transform: scale(0.94); }
.menu-card .mc-icon { font-size: 2.8rem; }
.menu-card .mc-title { font-size: 1rem; font-weight: 800; text-align: center; }
.menu-card .mc-sub { font-size: 0.72rem; opacity: 0.85; text-align: center; }

/* ---- SCREEN HEADER ---- */
.screen-header {
  display: flex; align-items: center; gap: 12px;
  padding: 16px 0 14px;
  border-bottom: 1px solid rgba(255,255,255,0.12);
  margin-bottom: 16px;
}
.screen-header .sh-icon { font-size: 1.8rem; }
.screen-header h2 { font-size: 1.4rem; font-weight: 900; }
.screen-header .sh-sub { font-size: 0.75rem; color: var(--text-dim); margin-top: 1px; }

/* ---- LETTERS SCREEN ---- */
#letter-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
  gap: 10px;
}
.letter-card {
  border-radius: var(--radius-md);
  padding: 12px 6px;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  cursor: pointer; border: none; color: white;
  box-shadow: 0 4px 14px rgba(0,0,0,0.25);
  transition: transform 0.15s ease;
  min-height: 44px;
}
.letter-card:active { transform: scale(0.88); }
.lc-letter { font-size: 1.8rem; font-weight: 900; line-height: 1; }
.lc-emoji { font-size: 1.3rem; }
.lc-word { font-size: 0.6rem; font-weight: 700; text-transform: uppercase; opacity: 0.9; text-align: center; }

/* ---- VOWELS SCREEN ---- */
.vowel-tabs {
  display: flex; gap: 8px; justify-content: center;
  margin-bottom: 16px; flex-wrap: nowrap;
}
.vowel-tab {
  width: 52px; height: 52px; border-radius: 50%;
  border: 3px solid transparent;
  font-size: 1.5rem; font-weight: 900;
  cursor: pointer; color: white;
  transition: all 0.2s ease;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.vowel-tab.active {
  border-color: white;
  transform: scale(1.15);
  box-shadow: 0 6px 20px rgba(0,0,0,0.4);
}
.vowel-display {
  background: rgba(255,255,255,0.08);
  border-radius: var(--radius-lg);
  padding: 20px;
  text-align: center;
  margin-bottom: 16px;
  border: 1px solid rgba(255,255,255,0.12);
}
.vd-letter { font-size: 4rem; font-weight: 900; line-height: 1; }
.vd-desc { font-size: 0.85rem; color: var(--text-dim); margin: 8px 0; }
.vd-mouth { font-size: 2rem; margin: 4px 0; }
.hear-btn {
  margin-top: 10px; padding: 10px 24px;
  border-radius: 30px; border: none; cursor: pointer;
  font-size: 0.9rem; font-weight: 800;
  color: white; display: inline-flex; align-items: center; gap: 6px;
  box-shadow: 0 4px 14px rgba(0,0,0,0.3);
  transition: transform 0.15s ease;
}
.hear-btn:active { transform: scale(0.92); }
.word-grid {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px;
}
.word-card {
  border-radius: var(--radius-md);
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.14);
  padding: 12px 10px;
  display: flex; align-items: center; gap: 10px;
  cursor: pointer;
  transition: all 0.15s ease;
  min-height: 54px;
}
.word-card:active { transform: scale(0.94); background: rgba(255,255,255,0.18); }
.wc-emoji { font-size: 1.5rem; flex-shrink: 0; }
.wc-word { font-size: 1rem; font-weight: 700; letter-spacing: 0.5px; }
.wc-hl { font-weight: 900; text-decoration: underline; }

/* ---- WORD FAMILIES SCREEN ---- */
.family-tabs {
  display: flex; gap: 6px; flex-wrap: nowrap;
  overflow-x: auto; padding-bottom: 6px; margin-bottom: 16px;
  scrollbar-width: none;
}
.family-tabs::-webkit-scrollbar { display: none; }
.family-tab {
  flex-shrink: 0;
  padding: 8px 16px; border-radius: 30px;
  border: 2px solid transparent;
  font-size: 0.85rem; font-weight: 800;
  cursor: pointer; color: white;
  background: rgba(255,255,255,0.1);
  transition: all 0.18s ease;
  min-height: 44px; display: flex; align-items: center; justify-content: center;
}
.family-tab.active {
  border-color: white;
  box-shadow: 0 4px 14px rgba(0,0,0,0.3);
}
.family-display {
  background: rgba(255,255,255,0.08);
  border-radius: var(--radius-lg);
  padding: 20px;
  text-align: center;
  margin-bottom: 16px;
  border: 1px solid rgba(255,255,255,0.12);
}
.fd-pattern { font-size: 2.6rem; font-weight: 900; letter-spacing: 2px; }
.fd-prefix { color: rgba(255,255,255,0.6); }
.fd-word-card {
  border-radius: var(--radius-md);
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.14);
  padding: 14px 10px;
  display: flex; align-items: center; gap: 10px;
  cursor: pointer;
  transition: all 0.15s ease;
  min-height: 56px;
}
.fd-word-card:active { transform: scale(0.93); background: rgba(255,255,255,0.2); }
.fd-prefix-text { color: rgba(255,255,255,0.6); font-size: 1.05rem; font-weight: 700; }
.fd-suffix-text { font-size: 1.05rem; font-weight: 900; }

/* ---- QUIZ SCREEN ---- */
#quiz-container { text-align: center; }
.quiz-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 10px;
}
.quiz-score { font-size: 1.1rem; font-weight: 800; }
.quiz-progress-text { font-size: 0.85rem; color: var(--text-dim); }
.quiz-bar-wrap {
  background: rgba(255,255,255,0.15);
  border-radius: 10px; height: 8px; margin-bottom: 20px; overflow: hidden;
}
.quiz-bar {
  height: 100%; border-radius: 10px;
  background: linear-gradient(90deg, var(--c4), var(--c5));
  transition: width 0.5s ease;
}
.quiz-card {
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: var(--radius-lg);
  padding: 28px 20px 22px;
  margin-bottom: 20px;
}
.quiz-emoji { font-size: 5rem; display: block; margin-bottom: 12px; animation: pop 0.4s ease; }
@keyframes pop { 0% { transform: scale(0.5); opacity: 0; } 70% { transform: scale(1.15); } 100% { transform: scale(1); opacity: 1; } }
.quiz-word { font-size: 2rem; font-weight: 900; letter-spacing: 3px; margin-bottom: 6px; }
.quiz-hint { font-size: 0.8rem; color: var(--text-dim); }
.quiz-choices { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.choice-btn {
  padding: 16px 10px; border-radius: var(--radius-md);
  border: 2px solid rgba(255,255,255,0.25);
  background: rgba(255,255,255,0.1);
  color: white; font-size: 1.6rem; font-weight: 900;
  cursor: pointer;
  transition: all 0.15s ease;
  min-height: 60px;
}
.choice-btn:active { transform: scale(0.93); }
.choice-btn.correct { background: var(--c4) !important; border-color: var(--c4) !important; animation: scaleUp 0.4s ease; }
.choice-btn.wrong { background: var(--c1) !important; border-color: var(--c1) !important; animation: shake 0.4s ease; }
@keyframes scaleUp { 0% { transform: scale(1); } 50% { transform: scale(1.12); } 100% { transform: scale(1); } }
@keyframes shake {
  0%,100% { transform: translateX(0); }
  20% { transform: translateX(-7px); }
  40% { transform: translateX(7px); }
  60% { transform: translateX(-5px); }
  80% { transform: translateX(5px); }
}
.quiz-flash {
  position: fixed; inset: 0; pointer-events: none; z-index: 50;
  opacity: 0; transition: opacity 0.3s;
}
.quiz-flash.correct-flash { background: rgba(29,209,161,0.25); }
.quiz-flash.wrong-flash   { background: rgba(255,107,107,0.25); }
.quiz-flash.show { opacity: 1; }
.quiz-end {
  text-align: center; padding: 30px 16px;
  display: flex; flex-direction: column; align-items: center; gap: 14px;
}
.qe-trophy { font-size: 5rem; animation: bounce 1.5s ease-in-out infinite; display: block; }
.qe-score { font-size: 2.4rem; font-weight: 900; }
.qe-msg { font-size: 1rem; color: var(--text-dim); max-width: 260px; text-align: center; }
.play-again-btn {
  padding: 16px 36px; border-radius: 30px;
  border: none; cursor: pointer;
  font-size: 1.1rem; font-weight: 900;
  background: linear-gradient(135deg, var(--c3), var(--c2));
  color: #1a1a2e;
  box-shadow: 0 6px 20px rgba(0,0,0,0.3);
  transition: transform 0.15s ease;
}
.play-again-btn:active { transform: scale(0.93); }

/* ---- CONFETTI ---- */
.confetti-piece {
  position: fixed; pointer-events: none; z-index: 200;
  width: 10px; height: 10px;
  border-radius: 2px;
  animation: confettiFall 1.4s ease-in forwards;
}
@keyframes confettiFall {
  0%   { transform: translateY(-20px) rotate(0deg) scale(1); opacity: 1; }
  100% { transform: translateY(100vh) rotate(720deg) scale(0.5); opacity: 0; }
}

/* ---- UTILS ---- */
.section-label {
  font-size: 0.7rem; font-weight: 800; text-transform: uppercase;
  letter-spacing: 1px; color: var(--text-dim); margin-bottom: 8px; margin-top: 4px;
}
