/* Yaazhan Tamil Safari Premium — mobile-first */
@font-face {
  font-family: "Noto Tamil";
  src: url("../fonts/NotoSansTamil-Regular.ttf") format("truetype");
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: "Noto Tamil";
  src: url("../fonts/NotoSansTamil-Bold.ttf") format("truetype");
  font-weight: 700;
  font-display: swap;
}
@font-face {
  font-family: "Noto Sans";
  src: url("../fonts/NotoSans-Regular.ttf") format("truetype");
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: "Noto Sans";
  src: url("../fonts/NotoSans-Bold.ttf") format("truetype");
  font-weight: 700;
  font-display: swap;
}

:root {
  --coral: #e85a4f;
  --sun: #ffd54a;
  --mint: #3dcc5a;
  --sky: #3b9dff;
  --wood: #8b5a2b;
  --ink: #3a2a1a;
  --cream: #fff8e8;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-top: env(safe-area-inset-top, 0px);
}

*, *::before, *::after { box-sizing: border-box; }
html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: hidden;
  font-family: "Noto Tamil", "Noto Sans", system-ui, sans-serif;
  color: var(--ink);
  background: #6ec8ff;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
}

#app {
  position: relative;
  width: 100%;
  max-width: 480px;
  height: 100%;
  height: 100dvh;
  margin: 0 auto;
  overflow: hidden;
  /* ASSET: backgrounds/meadow.png */
  background: url("../assets/backgrounds/meadow-day.png") center / cover no-repeat, url("../assets/backgrounds/meadow.png") center / cover no-repeat;
}

.screen {
  display: none;
  position: absolute;
  inset: 0;
  flex-direction: column;
  padding: calc(12px + var(--safe-top)) 14px calc(16px + var(--safe-bottom));
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
}
.screen.active { display: flex; }

.ta { font-family: "Noto Tamil", sans-serif; }
.en {
  font-family: "Noto Sans", system-ui, sans-serif;
  font-size: 13px;
  opacity: 0.85;
  margin: 4px 0 0;
  font-weight: 400;
}
.h-ta {
  font-size: 22px;
  font-weight: 700;
  margin: 0;
  line-height: 1.35;
  text-align: center;
}
.h-ta.sm { font-size: 18px; }
.h-en { text-align: center; }
.line1 { color: var(--coral); font-size: 28px; }
.line2 { color: var(--wood); font-size: 24px; }

/* Wood board — image texture, not CSS-only panel */
.wood-board {
  /* ASSET: backgrounds/wood-board.png */
  background: url("../assets/backgrounds/wood-board.png") center / 100% 100% no-repeat;
  border-radius: 20px;
  padding: 16px 18px;
  box-shadow: 0 6px 0 rgba(90, 50, 20, 0.25);
  text-align: center;
  max-width: 340px;
  width: 100%;
  margin: 0 auto;
}
.wood-board.section-title { margin-bottom: 12px; align-self: center; }
.wood-board.welcome-board { max-width: 320px; }
.wood-board.letter-frame { position: relative; padding: 20px; }
.wood-board.balloon-coach { padding: 10px 14px; font-size: 16px; font-weight: 700; margin-bottom: 8px; }
.wood-board.map-title { flex: 1; margin: 0 8px; padding: 8px 14px; }
.wood-board.map-footer { margin-top: auto; }

.center-stack {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  flex: 1;
  justify-content: center;
  min-height: 0;
}

.mascot {
  background: transparent !important;
  background-color: rgba(0,0,0,0) !important;
  width: min(42vw, 180px);
  height: auto;
  object-fit: contain;
  filter: none;
  pointer-events: none;
}
.mascot.sm { width: min(28vw, 110px); }
.mascot.tiny { width: 64px; }
.welcome.mascot {
  background: transparent !important;
  background-color: rgba(0,0,0,0) !important; margin-top: 8px; }
.mascot-wrap { display: flex; justify-content: center; margin: 8px 0; }
.balloon.mascot {
  background: transparent !important;
  background-color: rgba(0,0,0,0) !important;
  position: absolute;
  left: 8px;
  bottom: calc(12px + var(--safe-bottom));
  z-index: 2;
  pointer-events: none;
}

.hero-letter-img {
  width: min(46vw, 180px);
  height: auto;
  display: block;
  margin: 0 auto;
}
.hero-glyph {
  font-size: 56px;
  color: var(--coral);
  margin-top: -8px;
}

.footer-cta {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  margin-top: auto;
  padding-top: 12px;
  width: 100%;
}
.footer-cta.row {
  flex-direction: row;
  justify-content: center;
  flex-wrap: wrap;
}
.tip { font-size: 12px; opacity: 0.75; margin: 0; }

.btn {
  appearance: none;
  border: 3px solid #e8b86d;
  border-radius: 999px;
  padding: 14px 28px;
  font-size: 16px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  min-width: 200px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  box-shadow: 0 4px 0 rgba(0,0,0,0.15);
  transition: transform 0.12s ease;
}
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.45; pointer-events: none; }
.btn-primary {
  background: linear-gradient(180deg, #ff8a65, #e85a4f);
  color: #fff;
  border-color: #ffc28a;
}
.btn-secondary {
  background: linear-gradient(180deg, #ffe082, #ffb74d);
  color: var(--ink);
}
.btn-map { background: #8b5a2b; color: #fff; border-color: #e8b86d; }
.btn-ico { width: 28px; height: 28px; object-fit: contain; }

.btn-speaker {
  appearance: none;
  border: none;
  background: rgba(255,255,255,0.55);
  border-radius: 50%;
  width: 52px;
  height: 52px;
  padding: 8px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin: 8px auto 0;
}
.btn-speaker img { width: 100%; height: 100%; object-fit: contain; }

.btn-icon {
  appearance: none;
  border: none;
  background: rgba(255,255,255,0.7);
  border-radius: 14px;
  width: 48px;
  height: 48px;
  padding: 10px;
  cursor: pointer;
}
.btn-icon img { width: 100%; height: 100%; }

.hud-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  z-index: 3;
}
.hud-pill {
  background: rgba(255,255,255,0.88);
  border-radius: 999px;
  padding: 8px 14px;
  display: flex;
  gap: 8px;
  align-items: center;
  font-weight: 700;
  font-size: 13px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.12);
}
.hud-pill .val { color: var(--coral); font-size: 18px; font-variant-numeric: tabular-nums; }
.quiz-progress { align-self: center; margin-bottom: 10px; }

/* Balloon field */
#screen-balloon { overflow: hidden; }
.balloon-field {
  position: relative;
  flex: 1;
  width: 100%;
  min-height: 280px;
  overflow: hidden;
  touch-action: none;
}
.balloon {
  position: absolute;
  left: 0;
  top: 0;
  border: none;
  background: transparent !important;
  background-color: rgba(0,0,0,0) !important;
  -webkit-appearance: none;
  appearance: none;
  -webkit-tap-highlight-color: transparent;
  box-shadow: none;
  outline: none;
  padding: 0;
  cursor: pointer;
  will-change: transform;
  touch-action: manipulation;
}
.balloon-img {
  background: transparent !important;
  width: 100%;
  height: 100%;
  object-fit: contain;
  pointer-events: none;
  filter: none;
}
/* Glyphs are baked into balloon PNGs — no CSS overlay */
.balloon .glyph { display: none !important; }
.balloon.popping {
  animation: pop 0.28s ease-out forwards;
  pointer-events: none;
}
.balloon.shake {
  animation: shake 0.28s ease;
}
@keyframes pop {
  0% { opacity: 1; filter: brightness(1); }
  40% { opacity: 1; filter: brightness(1.4); }
  100% { opacity: 0; filter: brightness(2); }
}
.balloon.popping .balloon-img {
  background: transparent !important;
  animation: popImg 0.28s ease-out forwards;
}
@keyframes popImg {
  to { transform: scale(1.5); opacity: 0; }
}
@keyframes shake {
  0%, 100% { filter: none; }
  25% { filter: hue-rotate(-20deg); margin-left: -6px; }
  50% { margin-left: 6px; }
  75% { margin-left: -4px; }
}
.pop-burst {
  position: absolute;
  width: 128px;
  height: 128px;
  object-fit: contain;
  pointer-events: none;
  animation: burst 0.5s ease-out forwards;
  z-index: 5;
}
.target-balloon-preview {
  width: 56px;
  height: 72px;
  object-fit: contain;
  display: inline-block;
  vertical-align: middle;
  margin-right: 6px;
}
.coach-line { display: inline; font-size: 16px; font-weight: 700; }
@keyframes burst {
  0% { transform: scale(0.4); opacity: 1; }
  100% { transform: scale(1.3); opacity: 0; }
}
.score-float {
  position: absolute;
  font-weight: 800;
  color: var(--sun);
  font-size: 28px;
  text-shadow: 0 2px 0 #8b5a2b;
  pointer-events: none;
  animation: floatUp 0.8s ease-out forwards;
  z-index: 6;
}
@keyframes floatUp {
  to { transform: translateY(-60px); opacity: 0; }
}
.speech-bubble {
  position: absolute;
  right: 12px;
  bottom: calc(80px + var(--safe-bottom));
  background: #fff;
  border-radius: 16px;
  padding: 10px 14px;
  font-weight: 700;
  font-size: 15px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.2s, transform 0.2s;
  pointer-events: none;
  z-index: 4;
  max-width: 60%;
}
.speech-bubble.show {
  opacity: 1;
  transform: translateY(0);
}
.target { color: var(--coral); font-size: 22px; }

.star-row {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin: 10px 0;
}
.star-img { width: 40px; height: 40px; object-fit: contain; }
.xp-chip {
  display: inline-block;
  background: rgba(255,255,255,0.75);
  border-radius: 999px;
  padding: 6px 14px;
  font-weight: 800;
  color: var(--coral);
}
.stats-line { font-size: 16px; margin: 10px 0 4px; }
.stats-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  margin-top: 10px;
}
.chip {
  background: rgba(255,255,255,0.8);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 13px;
  font-weight: 700;
}

/* Words */
.word-cards {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
  max-width: 360px;
  margin: 0 auto;
}
.word-card {
  appearance: none;
  border: 3px solid #e8b86d;
  border-radius: 18px;
  background: rgba(255,255,255,0.92);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  cursor: pointer;
  text-align: left;
  font-family: inherit;
}
.word-pic {
  width: 72px;
  height: 72px;
  object-fit: contain;
  border-radius: 12px;
  flex-shrink: 0;
}
.word-card .meta { flex: 1; }
.word-card .ta { font-size: 22px; font-weight: 700; display: block; }
.spk-mini { width: 28px; height: 28px; opacity: 0.7; }

/* Match / choices */
.match-choices {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: center;
  margin: 12px 0;
}
.choice-card {
  appearance: none;
  border: 3px solid #e8b86d;
  border-radius: 18px;
  background: rgba(255,255,255,0.95);
  width: 110px;
  min-height: 130px;
  padding: 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  font-family: inherit;
}
.choice-card.mini { width: 90px; min-height: 90px; }
.choice-pic {
  width: 72px;
  height: 72px;
  object-fit: contain;
}
.choice-card .lbl { font-size: 16px; font-weight: 700; }
.choice-card.correct { border-color: var(--mint); box-shadow: 0 0 0 3px rgba(61,204,90,0.35); }
.choice-card.wrong { animation: shake 0.28s ease; border-color: var(--coral); }

/* Trace */
.trace-slate {
  position: relative;
  width: 100%;
  max-width: 340px;
  aspect-ratio: 1;
  margin: 10px auto;
  background: rgba(255,252,240,0.92);
  border: 4px solid #e8b86d;
  border-radius: 20px;
  overflow: hidden;
  touch-action: none;
}
.trace-ghost {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: min(48vw, 180px);
  color: rgba(139, 90, 43, 0.12);
  pointer-events: none;
  z-index: 0;
}
#trace-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
  touch-action: none;
}
.attempt-dots {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin: 8px 0;
}
.attempt-dots span {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: rgba(139,90,43,0.25);
  border: 2px solid #e8b86d;
}
.attempt-dots span.done {
  background: var(--mint);
  border-color: #2a9e3f;
}

/* Quiz */
.quiz-options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  width: 100%;
  max-width: 360px;
  margin: 12px auto;
}
.quiz-opt {
  appearance: none;
  border: 3px solid #e8b86d;
  border-radius: 16px;
  background: rgba(255,255,255,0.95);
  min-height: 72px;
  padding: 12px;
  font-size: 28px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
}
.quiz-opt.pic { font-size: 16px; min-height: 110px; }
.opt-pic { width: 64px; height: 64px; object-fit: contain; }
.quiz-opt .sub { font-size: 14px; }
.quiz-flash {
  font-size: 72px;
  text-align: center;
  color: var(--coral);
  margin: 8px 0;
}
.quiz-flash.blurry { filter: blur(6px); opacity: 0.5; }
.quiz-speak-wrap { display: flex; justify-content: center; }

/* Feedback overlay */
#feedback-overlay {
  position: absolute;
  inset: 0;
  background: rgba(30, 20, 10, 0.45);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 50;
  padding: 20px;
}
#feedback-overlay.show { display: flex; }
.feedback-card { max-width: 320px; position: relative; }
.fb-icon { width: 64px; height: 64px; margin: 0 auto 8px; display: block; }
.ok-txt { color: #2a9e3f; }
.warn-txt { color: #c47a20; }
.big-glyph { font-size: 40px; color: var(--coral); margin: 8px 0; }
.learned { color: var(--coral); font-size: 36px; }
.trophy { width: 96px; height: 96px; object-fit: contain; margin-bottom: 4px; }

.confetti-piece {
  position: absolute;
  pointer-events: none;
  animation: confettiFall 1s ease-out forwards;
  z-index: 60;
}
@keyframes confettiFall {
  to { transform: translateY(80px) rotate(180deg); opacity: 0; }
}

/* Map */
#screen-map {
  /* ASSET: backgrounds/map-trail.png overlay soft */
  background:
    linear-gradient(180deg, rgba(255,248,230,0.55), rgba(255,248,230,0.35)),
    url("../assets/backgrounds/map-trail.png") top center / 100% auto no-repeat,
    url("../assets/backgrounds/meadow.png") center / cover no-repeat;
}
.map-scroll {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  margin: 8px 0;
  min-height: 0;
}
.map-path {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: center;
  padding: 12px 4px 24px;
}
.map-node {
  appearance: none;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  border: 3px solid #e8b86d;
  background: rgba(255,255,255,0.95);
  font-size: 22px;
  font-weight: 700;
  font-family: inherit;
  position: relative;
  cursor: pointer;
  color: var(--ink);
}
.map-node.done { background: #c8f0d0; border-color: var(--mint); }
.map-node.current {
  box-shadow: 0 0 0 4px rgba(232,90,79,0.35);
  border-color: var(--coral);
}
.map-node.locked { opacity: 0.55; background: #ddd; }
.map-node.stub:not(.locked) { opacity: 0.75; }
.map-node .lock,
.map-node .star-mini {
  position: absolute;
  width: 18px;
  height: 18px;
  right: -2px;
  bottom: -2px;
}
.map-node .star-mini { top: -4px; bottom: auto; right: -4px; }
.sm-line { font-size: 14px; margin: 0; }

/* Boot overlay */
#boot-overlay {
  position: absolute;
  inset: 0;
  z-index: 100;
  background: #6ec8ff url("../assets/backgrounds/meadow-day.png") center / cover no-repeat;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  transition: opacity 0.35s ease;
}
#boot-overlay.hide { opacity: 0; pointer-events: none; }
.boot-bar {
  width: 60%;
  max-width: 240px;
  height: 12px;
  background: rgba(255,255,255,0.5);
  border-radius: 999px;
  overflow: hidden;
}
.boot-bar-fill {
  height: 100%;
  width: 0%;
  background: var(--coral);
  border-radius: 999px;
  transition: width 0.15s ease;
}
.boot.mascot {
  background: transparent !important;
  background-color: rgba(0,0,0,0) !important; width: 140px; height: auto; background: transparent; mix-blend-mode: normal; }

.reduce-motion .balloon.popping,
.reduce-motion .balloon.shake,
.reduce-motion .pop-burst,
.reduce-motion .score-float,
.reduce-motion .confetti-piece {
  animation: none !important;
}

@media (min-width: 480px) {
  #app { box-shadow: 0 0 40px rgba(0,0,0,0.2); }
}
