/* ==========================================
   MeaghanLingo - Duolingo-style game UI
   ========================================== */

:root {
  --xp: #FFC800;
  --heart: #FF4B4B;
  --gem: #1CB0F6;
  --streak: #FF9600;
  --correct: #58CC02;
  --correct-shadow: #46A302;
  --wrong: #FF4B4B;
  --wrong-shadow: #EA2B2B;
  --locked: #E5E5E5;
  --locked-shadow: #C4C4C4;
  --ink: #3C3C3C;
  --muted: #777777;
  --panel: #FFFFFF;
  --hairline: #E5E5E5;
  --nav-h: 76px;
  --cta-shadow: #1899D6;
}

body.lang-en { --cta: #1CB0F6; --cta-shadow: #1899D6; }
body.lang-zh { --cta: #E76F51; --cta-shadow: #C45D43; }
body.lang-ms { --cta: #58CC02; --cta-shadow: #46A302; }

#app {
  padding: 0;
  justify-content: stretch;
  align-items: stretch;
}

#screen-root {
  width: 100%;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  position: relative;
}

.screen {
  width: 100%;
  height: 100%;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  padding: calc(var(--safe-top) + 8px) 20px calc(var(--nav-h) + var(--safe-bottom) + 16px);
}

.screen.screen-lesson {
  padding: calc(var(--safe-top) + 8px) 16px calc(var(--safe-bottom) + 16px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  height: 100%;
}

.hidden { display: none !important; }

/* Top HUD */
.hud {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.hud-left, .hud-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.hud-right { justify-content: flex-end; }

.hud-chip {
  display: flex;
  align-items: center;
  gap: 4px;
  font-weight: 800;
  font-size: 1rem;
  color: var(--ink);
}

.hud-chip.streak { color: var(--streak); }
.hud-chip.gems { color: var(--gem); }
.hearts { letter-spacing: -2px; font-size: 1.05rem; }
.hearts .empty { filter: grayscale(1); opacity: 0.35; }

.goal-ring {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: conic-gradient(var(--theme-color) var(--goal-pct, 0%), #E5E5E5 0);
}
.goal-ring-inner {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: #fff;
  display: grid;
  place-items: center;
  font-size: 0.95rem;
}

.lang-pills {
  display: flex;
  gap: 6px;
  justify-content: center;
}
.lang-pill {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 3px solid #fff;
  background: #fff;
  font-weight: 800;
  font-size: 0.8rem;
  box-shadow: 0 3px 0 #D0D0D0;
  cursor: pointer;
  color: var(--ink);
}
.lang-pill.active.en { background: #0EA5E9; color: #fff; box-shadow: 0 3px 0 #0369A1; }
.lang-pill.active.zh { background: #E76F51; color: #fff; box-shadow: 0 3px 0 #C2410C; }
.lang-pill.active.ms { background: #10B981; color: #fff; box-shadow: 0 3px 0 #047857; }
.lang-pill:active { transform: translateY(3px); box-shadow: 0 0 0 transparent; }

/* Path */
.unit-block {
  margin: 18px 0 8px;
}
.unit-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--unit-color, var(--theme-color));
  color: #fff;
  border-radius: 16px;
  padding: 12px 16px;
  box-shadow: 0 4px 0 rgba(0,0,0,0.12);
  margin-bottom: 18px;
}
.unit-header h2 {
  font-size: 1.15rem;
  font-weight: 800;
}
.unit-header p {
  font-size: 0.8rem;
  opacity: 0.9;
}

.path {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 28px;
  padding: 8px 0 24px;
}

.path-node-wrap {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.start-bubble {
  position: absolute;
  top: -34px;
  background: var(--cta);
  color: #fff;
  font-weight: 800;
  font-size: 0.8rem;
  letter-spacing: 0.08em;
  padding: 6px 12px;
  border-radius: 12px;
  box-shadow: 0 3px 0 var(--cta-shadow);
  animation: startBounce 1.4s ease-in-out infinite;
  z-index: 2;
}
.start-bubble::after {
  content: '';
  position: absolute;
  left: 50%;
  bottom: -6px;
  transform: translateX(-50%);
  border: 6px solid transparent;
  border-top-color: var(--cta);
}

.path-node {
  width: 74px;
  height: 70px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  font-size: 1.7rem;
  display: grid;
  place-items: center;
  position: relative;
  transition: transform 0.1s ease;
}
.path-node.current {
  background: var(--cta);
  box-shadow: 0 8px 0 var(--cta-shadow);
  color: #fff;
}
.path-node.complete {
  background: var(--xp);
  box-shadow: 0 8px 0 #E5A800;
  color: #3C3C3C;
}
.path-node.locked {
  background: var(--locked);
  box-shadow: 0 8px 0 var(--locked-shadow);
  color: #AFAFAF;
  cursor: default;
}
.path-node.checkpoint.current,
.path-node.checkpoint.complete {
  border-radius: 18px;
}
.path-node:not(.locked):active {
  transform: translateY(6px);
  box-shadow: 0 2px 0 var(--cta-shadow);
}
.path-node.complete:active { box-shadow: 0 2px 0 #E5A800; }

.mascot {
  position: absolute;
  right: -58px;
  top: 4px;
  width: 52px;
  height: 52px;
  filter: drop-shadow(0 6px 8px rgba(0,0,0,0.12));
  animation: mascotBob 2.2s ease-in-out infinite;
}

.path-label {
  margin-top: 8px;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--muted);
  text-align: center;
  max-width: 110px;
}

.finished-banner {
  background: #fff;
  border-radius: 20px;
  padding: 20px;
  text-align: center;
  box-shadow: 0 8px 24px rgba(0,0,0,0.06);
  margin: 12px 0 32px;
}
.finished-banner h3 { font-size: 1.2rem; margin-bottom: 6px; }

/* Bottom nav */
.bottom-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  height: calc(var(--nav-h) + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  background: #fff;
  border-top: 2px solid var(--hairline);
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  z-index: 50;
}
.bottom-nav.hidden { display: none; }
body.in-lesson .parent-gate-trigger { display: none; }
.nav-btn {
  border: none;
  background: transparent;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  font-weight: 800;
  font-size: 0.72rem;
  color: #AFAFAF;
  cursor: pointer;
}
.nav-btn .nav-ico { font-size: 1.45rem; line-height: 1; }
.nav-btn.active { color: var(--theme-color); }

/* 3D buttons */
.btn-3d {
  border: none;
  border-radius: 16px;
  font-weight: 800;
  font-size: 1rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 14px 20px;
  cursor: pointer;
  color: #fff;
  background: var(--cta);
  box-shadow: 0 4px 0 var(--cta-shadow);
}
.btn-3d:active { transform: translateY(4px); box-shadow: 0 0 0 var(--cta-shadow); }
.btn-3d:disabled { opacity: 0.45; cursor: default; transform: none; }
.btn-3d.wide { width: 100%; }
.btn-3d.green { background: var(--correct); box-shadow: 0 4px 0 var(--correct-shadow); }
.btn-3d.red { background: var(--wrong); box-shadow: 0 4px 0 var(--wrong-shadow); }
.btn-3d.ghost {
  background: #fff;
  color: var(--cta);
  box-shadow: 0 4px 0 #E5E5E5;
  border: 2px solid #E5E5E5;
}

/* Lesson chrome */
.lesson-top {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}
.lesson-close {
  width: 40px;
  height: 40px;
  border: none;
  background: transparent;
  font-size: 1.6rem;
  color: #AFAFAF;
  cursor: pointer;
}
.lesson-progress {
  flex: 1;
  height: 16px;
  background: #E5E5E5;
  border-radius: 16px;
  overflow: hidden;
}
.lesson-progress > span {
  display: block;
  height: 100%;
  width: 0%;
  background: var(--correct);
  border-radius: 16px;
  transition: width 0.35s ease;
}
.lesson-hearts { font-size: 1.05rem; }

.exercise-stage {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow-y: auto;
}

.listen-prompt {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  margin: 4px 0 16px;
  text-align: center;
}
.prompt-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 8px 0 14px;
}
.prompt-text {
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--ink);
}
.speaker-btn {
  width: 52px;
  height: 52px;
  border-radius: 16px;
  border: none;
  background: var(--cta);
  color: #fff;
  font-size: 1.4rem;
  box-shadow: 0 4px 0 var(--cta-shadow);
  cursor: pointer;
}
.speaker-btn.lg { width: 72px; height: 72px; font-size: 1.8rem; border-radius: 20px; }
.speaker-btn:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--cta-shadow); }

.intro-card {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: #fff;
  border-radius: 28px;
  padding: 20px 16px 24px;
  box-shadow: 0 12px 30px rgba(0,0,0,0.06);
}
.intro-art, .prompt-art {
  width: min(72vw, 280px);
  height: min(72vw, 280px);
  display: grid;
  place-items: center;
}
.intro-art .concept-svg, .prompt-art .concept-svg,
.choice-tile .concept-svg {
  width: 100%;
  height: 100%;
  max-width: 260px;
  max-height: 260px;
}
.intro-word {
  font-size: 2.4rem;
  font-weight: 800;
  margin-top: 8px;
}
.intro-hint {
  color: var(--muted);
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 16px;
}

.choice-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.choice-tile {
  background: #fff;
  border: 3px solid #E5E5E5;
  border-radius: 22px;
  min-height: 140px;
  padding: 8px;
  cursor: pointer;
  box-shadow: 0 4px 0 #E5E5E5;
  display: flex;
  align-items: center;
  justify-content: center;
}
.choice-tile.selected { border-color: var(--cta); box-shadow: 0 4px 0 var(--cta-shadow); }
.choice-tile.correct { border-color: var(--correct); box-shadow: 0 4px 0 var(--correct-shadow); background: #D7FFB8; }
.choice-tile.wrong { border-color: var(--wrong); box-shadow: 0 4px 0 var(--wrong-shadow); background: #FFDFE0; }
.choice-tile:active { transform: translateY(3px); box-shadow: 0 1px 0 #E5E5E5; }

.choice-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.choice-btn {
  width: 100%;
  background: #fff;
  border: 3px solid #E5E5E5;
  border-radius: 16px;
  padding: 16px 14px;
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--ink);
  cursor: pointer;
  box-shadow: 0 4px 0 #E5E5E5;
  text-align: center;
}
.choice-btn.selected { border-color: var(--cta); box-shadow: 0 4px 0 var(--cta-shadow); }
.choice-btn.correct { border-color: var(--correct); background: #D7FFB8; box-shadow: 0 4px 0 var(--correct-shadow); }
.choice-btn.wrong { border-color: var(--wrong); background: #FFDFE0; box-shadow: 0 4px 0 var(--wrong-shadow); }

.speak-card {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.mic-big {
  width: 92px;
  height: 92px;
  border-radius: 50%;
  border: none;
  background: var(--cta);
  color: #fff;
  font-size: 2.2rem;
  box-shadow: 0 8px 0 var(--cta-shadow);
  cursor: pointer;
  margin-top: 8px;
}
.mic-big.listening {
  animation: micPulse 1.2s ease-in-out infinite;
  background: var(--theme-color);
}
.speak-hint { color: var(--muted); font-weight: 700; }

.match-board {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.match-col { display: flex; flex-direction: column; gap: 10px; }
.match-item {
  min-height: 84px;
  border: 3px solid #E5E5E5;
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 4px 0 #E5E5E5;
  font-weight: 800;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10px;
}
.match-item-word {
  min-height: 96px;
  font-size: 1.85rem;
  line-height: 1.2;
}
.match-item-zh,
body.lang-zh .match-item-word {
  min-height: 110px;
  font-size: 2.75rem;
  line-height: 1.15;
  letter-spacing: 0.06em;
}
.match-word {
  display: block;
  text-align: center;
  font-weight: 800;
}
.match-item .concept-svg { width: 64px; height: 64px; }
.match-item.selected { border-color: var(--cta); box-shadow: 0 4px 0 var(--cta-shadow); }
.match-item.matched { border-color: var(--correct); background: #D7FFB8; box-shadow: 0 4px 0 var(--correct-shadow); opacity: 0.7; pointer-events: none; }
.match-item.wrong { border-color: var(--wrong); animation: shakeX 0.35s ease; }

.feedback-banner {
  margin-top: auto;
  border-radius: 24px 24px 0 0;
  padding: 16px 16px calc(12px + var(--safe-bottom));
  display: none;
}
.feedback-banner.show { display: block; }
.feedback-banner.good { background: #D7FFB8; color: #58A700; }
.feedback-banner.bad { background: #FFDFE0; color: #EA2B2B; }
.feedback-banner h3 { font-size: 1.4rem; margin-bottom: 4px; }
.feedback-banner p { font-weight: 700; margin-bottom: 12px; }
.xp-float {
  position: absolute;
  right: 24px;
  top: 70px;
  font-weight: 800;
  color: var(--xp);
  font-size: 1.4rem;
  text-shadow: 0 2px 0 #E5A800;
  animation: xpRise 0.8s ease forwards;
  pointer-events: none;
}

.complete-screen, .hearts-screen, .leave-modal {
  background: #fff;
  border-radius: 28px;
  padding: 28px 20px;
  text-align: center;
  box-shadow: 0 16px 40px rgba(0,0,0,0.08);
  margin: auto;
  width: 100%;
  max-width: 400px;
}
.complete-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin: 18px 0 22px;
}
.complete-stat {
  background: #F7F7F7;
  border-radius: 16px;
  padding: 12px 8px;
}
.complete-stat b { display: block; font-size: 1.3rem; }
.overlay-card {
  position: absolute;
  inset: 0;
  background: rgba(19, 31, 36, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 20;
}

/* Practice + Profile */
.page-title {
  font-size: 1.8rem;
  font-weight: 800;
  margin: 8px 0 16px;
}
.menu-card {
  background: #fff;
  border-radius: 22px;
  padding: 18px;
  margin-bottom: 14px;
  box-shadow: 0 8px 20px rgba(0,0,0,0.05);
  display: flex;
  gap: 14px;
  align-items: center;
  cursor: pointer;
  border: none;
  width: 100%;
  text-align: left;
}
.menu-card:active { transform: scale(0.98); }
.menu-emoji { font-size: 2.2rem; }
.menu-card h3 { font-size: 1.15rem; }
.menu-card p { color: var(--muted); font-size: 0.9rem; }

.profile-hero {
  background: #fff;
  border-radius: 24px;
  padding: 22px 16px;
  text-align: center;
  box-shadow: 0 8px 20px rgba(0,0,0,0.05);
  margin-bottom: 16px;
}
.avatar {
  width: 88px;
  height: 88px;
  margin: 0 auto 8px;
}
.xp-bar {
  height: 14px;
  background: #E5E5E5;
  border-radius: 14px;
  overflow: hidden;
  margin-top: 8px;
}
.xp-bar > span {
  display: block;
  height: 100%;
  background: var(--xp);
}
.stat-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 16px;
}
.stat-tile {
  background: #fff;
  border-radius: 18px;
  padding: 14px;
  box-shadow: 0 6px 16px rgba(0,0,0,0.05);
}
.stat-tile b { font-size: 1.4rem; display: block; }
.stat-tile span { color: var(--muted); font-size: 0.85rem; font-weight: 700; }

.lang-card {
  width: 100%;
  border: 3px solid #E5E5E5;
  background: #fff;
  border-radius: 18px;
  padding: 14px;
  margin-bottom: 10px;
  text-align: left;
  cursor: pointer;
  font-weight: 800;
  box-shadow: 0 4px 0 #E5E5E5;
}
.lang-card.active { border-color: var(--cta); box-shadow: 0 4px 0 var(--cta-shadow); }

.goal-options { display: flex; gap: 8px; margin-top: 8px; }
.goal-opt {
  flex: 1;
  padding: 10px;
  border-radius: 14px;
  border: 3px solid #E5E5E5;
  background: #fff;
  font-weight: 800;
  cursor: pointer;
}
.goal-opt.active { border-color: var(--xp); background: #FFF4CC; }

@keyframes startBounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-5px); }
}
@keyframes mascotBob {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}
@keyframes micPulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.08); }
}
@keyframes xpRise {
  0% { opacity: 1; transform: translateY(0); }
  100% { opacity: 0; transform: translateY(-28px); }
}
@keyframes shakeX {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-6px); }
  75% { transform: translateX(6px); }
}

@media (min-width: 720px) {
  .screen { max-width: 520px; margin: 0 auto; }
  .choice-tile { min-height: 180px; }
}
