:root {
  --ink: #241b4d;
  --violet: #5b3df5;
  --sky: #37c9f5;
  --mint: #26d07c;
  --sun: #ffc93c;
  --coral: #ff6b6b;
  --card: #ffffff;
  --shadow: 0 18px 40px rgba(36, 27, 77, .18);
  --round: 28px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  font-family: "Andika", "Chalkboard SE", "Comic Sans MS", ui-rounded,
               -apple-system, system-ui, sans-serif;
  color: var(--ink);
  background: linear-gradient(165deg, #eef2ff 0%, #e7fbff 55%, #fff7e8 100%);
  -webkit-user-select: none;
  user-select: none;
}

#app { height: 100%; position: relative; }

.screen {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 24px;
  padding: max(20px, env(safe-area-inset-top)) 20px max(20px, env(safe-area-inset-bottom));
}
.screen.active { display: flex; }

.hero { text-align: center; }
.mascot { font-size: clamp(64px, 16vw, 128px); line-height: 1; }
h1 { font-size: clamp(28px, 6vw, 46px); margin: 8px 0 4px; }
.sub { font-size: clamp(16px, 3.4vw, 22px); margin: 0; opacity: .7; }

.levels { display: flex; flex-wrap: wrap; gap: 16px; justify-content: center; }

.sticker-preview {
  display: flex; align-items: center; gap: 12px;
  border: 0; border-radius: 20px; padding: 10px 18px;
  background: rgba(255, 255, 255, .82); color: var(--ink); font: inherit;
  box-shadow: 0 8px 20px rgba(36, 27, 77, .1);
}
.sticker-preview-icon { font-size: 34px; }
.sticker-preview span:last-child { display: flex; flex-direction: column; text-align: left; }
.sticker-preview small { font-size: 13px; opacity: .55; }

.big-btn, .level-btn {
  border: none;
  border-radius: var(--round);
  background: var(--violet);
  color: #fff;
  font: inherit;
  font-size: clamp(20px, 4vw, 26px);
  padding: 20px 34px;
  box-shadow: var(--shadow);
  transition: transform .12s ease;
}
.level-btn { background: #fff; color: var(--ink); min-width: 170px; }
.level-btn:nth-child(2) { background: #fff; }
.level-btn small { display: block; font-size: 15px; opacity: .55; margin-top: 4px; }
.big-btn:active, .level-btn:active { transform: scale(.96); }

.text-link {
  background: none; border: none; font: inherit; font-size: 16px;
  color: var(--ink); opacity: .45; text-decoration: underline; padding: 10px;
}

.hud {
  position: absolute; top: max(14px, env(safe-area-inset-top)); left: 16px; right: 16px;
  display: flex; align-items: center; gap: 14px;
}
.hud.plain { justify-content: flex-start; }
.hud.plain h2 { font-size: 22px; margin: 0; }

.icon-btn {
  border: none; background: rgba(255, 255, 255, .8); color: var(--ink);
  width: 46px; height: 46px; border-radius: 50%; font-size: 20px;
  box-shadow: 0 6px 16px rgba(36, 27, 77, .12);
}

.progress { flex: 1; height: 14px; background: rgba(255, 255, 255, .75); border-radius: 99px; overflow: hidden; }
.progress-fill { height: 100%; width: 0; background: linear-gradient(90deg, var(--sky), var(--mint)); transition: width .35s ease; }
.stars { font-size: 20px; font-weight: 700; white-space: nowrap; }

.adventure {
  position: absolute;
  top: max(70px, calc(env(safe-area-inset-top) + 62px));
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  width: min(78vw, 560px);
  z-index: 2;
}
.trail {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(10, 1fr);
  align-items: center;
  position: relative;
}
.trail::before {
  content: "";
  position: absolute;
  left: 4%; right: 0; top: 50%;
  height: 5px;
  transform: translateY(-50%);
  border-radius: 99px;
  background: rgba(91, 61, 245, .13);
}
.trail-step {
  width: clamp(13px, 3vw, 20px);
  aspect-ratio: 1;
  border-radius: 50%;
  justify-self: center;
  background: #fff;
  border: 3px solid rgba(91, 61, 245, .2);
  z-index: 1;
  transition: transform .25s ease, background .25s ease;
}
.trail-step.done { background: var(--sun); border-color: #f1a900; transform: scale(1.12); }
.trail-step.current {
  background: var(--violet);
  border-color: #fff;
  box-shadow: 0 0 0 4px rgba(91, 61, 245, .16);
  animation: trailPulse 1.2s ease-in-out infinite;
}
.treasure { font-size: 30px; margin-left: 6px; filter: grayscale(.65); transition: transform .4s ease, filter .4s ease; }
.treasure.open { filter: none; transform: scale(1.35) rotate(-7deg); animation: treasureBounce .65s ease; }
@keyframes trailPulse { 50% { transform: scale(1.28); } }
@keyframes treasureBounce { 50% { transform: scale(1.6) rotate(8deg); } }

.owl-friend {
  position: absolute;
  top: max(102px, calc(env(safe-area-inset-top) + 94px));
  right: max(10px, calc((100vw - 720px) / 2));
  display: flex;
  align-items: center;
  z-index: 3;
  transform-origin: bottom center;
}
.owl-emoji {
  display: block;
  font-size: clamp(42px, 9vw, 68px);
  filter: drop-shadow(0 8px 8px rgba(36, 27, 77, .15));
}
.owl-bubble {
  position: absolute;
  right: 70%;
  top: -9px;
  width: max-content;
  max-width: 140px;
  background: #fff;
  border-radius: 16px 16px 4px 16px;
  padding: 7px 11px;
  font-size: 13px;
  font-weight: 700;
  box-shadow: 0 7px 16px rgba(36, 27, 77, .12);
  opacity: 0;
  transform: translateY(5px) scale(.9);
  transition: opacity .2s ease, transform .2s ease;
}
.owl-friend.speaking .owl-bubble { opacity: 1; transform: none; }
.owl-friend.listening { animation: owlListen 1s ease-in-out infinite; }
.owl-friend.happy { animation: owlHappy .65s ease; }
.owl-friend.encourage { animation: owlTilt .6s ease; }
@keyframes owlListen { 50% { transform: scale(1.08) rotate(3deg); } }
@keyframes owlHappy { 40% { transform: translateY(-14px) rotate(-7deg) scale(1.15); } }
@keyframes owlTilt { 50% { transform: rotate(-12deg); } }

.card-wrap { display: flex; flex-direction: column; align-items: center; gap: 16px; }

.word-card {
  background: var(--card);
  border-radius: 36px;
  box-shadow: var(--shadow);
  padding: clamp(28px, 6vw, 60px) clamp(40px, 12vw, 110px);
  min-width: min(84vw, 620px);
  text-align: center;
  transition: transform .2s ease, background .25s ease;
}
#word {
  font-size: clamp(64px, 17vw, 150px);
  line-height: 1.05;
  letter-spacing: 2px;
  display: block;
}
.word-card.good { background: #e6fbf0; animation: pop .45s ease; }
.word-card.bad { background: #fff1e8; animation: shake .45s ease; }

@keyframes pop { 0% { transform: scale(1); } 45% { transform: scale(1.07); } 100% { transform: scale(1); } }
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-11px); }
  50% { transform: translateX(11px); }
  75% { transform: translateX(-6px); }
}

.ghost-btn {
  border: 2px dashed rgba(36, 27, 77, .2); background: transparent; color: var(--ink);
  font: inherit; font-size: 17px; padding: 10px 20px; border-radius: 99px; opacity: .8;
}

.mic-area { display: flex; flex-direction: column; align-items: center; gap: 14px; }

.mic {
  position: relative;
  width: clamp(104px, 22vw, 148px);
  height: clamp(104px, 22vw, 148px);
  border-radius: 50%;
  border: none;
  background: radial-gradient(circle at 32% 28%, #7a5cff, var(--violet));
  box-shadow: 0 16px 34px rgba(91, 61, 245, .38);
  display: grid; place-items: center;
  transition: transform .12s ease;
  touch-action: manipulation;
  -webkit-touch-callout: none;
  user-select: none;
}
.mic:active { transform: scale(.95); }
.mic[disabled] { filter: grayscale(.5) brightness(1.1); }
.mic-glyph { font-size: clamp(42px, 9vw, 62px); pointer-events: none; }
.mic-ring { pointer-events: none; }

.mic-ring {
  position: absolute; inset: -10px; border-radius: 50%;
  border: 5px solid rgba(91, 61, 245, .45); opacity: 0;
}
.mic.listening .mic-ring { animation: pulse 1.1s ease-out infinite; opacity: 1; }
@keyframes pulse {
  0% { transform: scale(.92); opacity: .9; }
  100% { transform: scale(1.35); opacity: 0; }
}
.mic.thinking { animation: breathe 1s ease-in-out infinite; }
@keyframes breathe { 50% { transform: scale(1.05); } }

.coach { font-size: clamp(17px, 3.4vw, 22px); margin: 0; text-align: center; min-height: 2.4em; max-width: 22ch; }

.toast {
  position: absolute; bottom: max(26px, env(safe-area-inset-bottom));
  background: var(--ink); color: #fff; padding: 12px 20px; border-radius: 99px;
  font-size: 15px; opacity: .92;
}

.confetti { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.confetti i {
  position: absolute; top: -6vh; width: 12px; height: 12px; border-radius: 3px;
  animation: fall linear forwards;
}
@keyframes fall {
  to { transform: translateY(115vh) rotate(620deg); opacity: .1; }
}

.sticker-award {
  position: absolute;
  inset: 50% auto auto 50%;
  transform: translate(-50%, -50%);
  z-index: 12;
  display: flex;
  flex-direction: column;
  align-items: center;
  color: var(--ink);
  text-shadow: 0 2px 0 #fff;
  pointer-events: none;
  animation: stickerPop 1.15s ease forwards;
}
.sticker-award[hidden] { display: none; }
.sticker-award span { font-size: clamp(88px, 24vw, 150px); filter: drop-shadow(0 14px 12px rgba(36, 27, 77, .2)); }
.sticker-award b { font-size: 24px; background: #fff; border-radius: 99px; padding: 7px 16px; box-shadow: var(--shadow); }
@keyframes stickerPop {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(.1) rotate(-20deg); }
  30% { opacity: 1; transform: translate(-50%, -50%) scale(1.15) rotate(7deg); }
  72% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -70%) scale(.8); }
}

.practice { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; max-width: 90vw; }
.chip {
  background: #fff; border-radius: 99px; padding: 10px 18px; font-size: 20px;
  box-shadow: 0 6px 16px rgba(36, 27, 77, .1);
}

.parent-body { width: min(680px, 92vw); overflow-y: auto; max-height: 74vh; font-size: 17px; }
.parent-body h3 { margin: 22px 0 8px; font-size: 18px; opacity: .6; }
.stat-row { display: flex; gap: 12px; justify-content: space-between; background: #fff;
  border-radius: 14px; padding: 12px 16px; margin-bottom: 8px; box-shadow: 0 4px 12px rgba(36,27,77,.07); }
.summary { display: flex; gap: 14px; flex-wrap: wrap; }
.summary div { background: #fff; border-radius: 18px; padding: 16px 22px; box-shadow: 0 6px 16px rgba(36,27,77,.08); }
.summary b { display: block; font-size: 26px; }

.round-stickers { text-align: center; }
.round-stickers .sub { font-size: 15px; margin-bottom: 8px; }
.sticker-row { display: flex; flex-wrap: wrap; justify-content: center; gap: 7px; min-height: 44px; }
.sticker-row span { font-size: 36px; animation: pop .4s ease backwards; }

.sticker-book {
  width: min(620px, 92vw);
  max-height: 75vh;
  overflow-y: auto;
  background: linear-gradient(145deg, #fffaf0, #fff);
  border: 7px solid #fff;
  border-radius: 30px;
  padding: 20px;
  box-shadow: var(--shadow);
}
.sticker-book-title { text-align: center; font-size: 20px; font-weight: 700; margin-bottom: 16px; }
.sticker-book-title span { color: var(--violet); font-size: 28px; }
.sticker-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 12px;
  padding: 12px;
  background: repeating-linear-gradient(0deg, transparent, transparent 79px, rgba(91,61,245,.06) 80px);
  border-radius: 20px;
}
.sticker-slot {
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: rgba(91, 61, 245, .06);
  border: 2px dashed rgba(91, 61, 245, .16);
  font-size: clamp(34px, 8vw, 58px);
}
.sticker-slot.filled {
  background: #fff;
  border: 2px solid rgba(255, 201, 60, .5);
  box-shadow: 0 6px 12px rgba(36, 27, 77, .1);
  animation: pop .35s ease backwards;
}
#sticker-next { text-align: center; margin-top: 15px; font-size: 15px; }

.help {
  background: #fff; border-radius: 22px; padding: 18px 22px;
  width: min(520px, 88vw); box-shadow: var(--shadow); font-size: 16px;
  max-height: 44vh; overflow-y: auto;
}
.help h3 { margin: 0 0 10px; font-size: 17px; color: var(--coral); }
.help ol { margin: 0 0 16px; padding-left: 22px; line-height: 1.55; }
.help li { margin-bottom: 8px; }
.help .big-btn { font-size: 18px; padding: 14px 22px; width: 100%; }

.gate-form {
  display: flex; flex-direction: column; gap: 14px; align-items: stretch;
  width: min(320px, 86vw);
}
.gate-form input {
  font: inherit; font-size: 22px; text-align: center; letter-spacing: 2px;
  border: none; border-radius: 18px; padding: 16px 18px;
  box-shadow: var(--shadow); background: #fff; color: var(--ink);
}

/* ------------------------------------------------------------ install prompt */

.install-bar {
  /* fixed, not absolute: #app can be taller than the viewport on small phones */
  position: fixed;
  left: 12px; right: 12px;
  bottom: max(12px, env(safe-area-inset-bottom));
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 12px;
  background: #fff;
  border-radius: 22px;
  padding: 12px 14px;
  box-shadow: 0 14px 34px rgba(36, 27, 77, .22);
  animation: slideUp .35s ease;
}
.install-bar[hidden] { display: none; }
.install-icon { font-size: 34px; }
.install-text { flex: 1; display: flex; flex-direction: column; line-height: 1.25; }
.install-text b { font-size: 16px; }
.install-text small { font-size: 13px; opacity: .6; }
.install-yes {
  border: none; border-radius: 99px; background: var(--violet); color: #fff;
  font: inherit; font-size: 16px; padding: 12px 20px; box-shadow: 0 6px 14px rgba(91, 61, 245, .35);
}
.install-no {
  border: none; background: rgba(36, 27, 77, .07); color: var(--ink);
  width: 34px; height: 34px; border-radius: 50%; font-size: 15px;
}
@keyframes slideUp { from { transform: translateY(120%); opacity: 0; } }

.install-steps {
  position: fixed; inset: 0; z-index: 25;
  display: grid; place-items: center;
  background: rgba(36, 27, 77, .45);
  padding: 20px;
}
.install-steps[hidden] { display: none; }
.install-card {
  background: #fff; border-radius: 26px; padding: 22px;
  width: min(420px, 90vw); box-shadow: var(--shadow);
}
.install-card h3 { margin: 0 0 12px; font-size: 20px; }
.install-card ol { margin: 0 0 18px; padding-left: 22px; line-height: 1.6; font-size: 16px; }
.install-card .big-btn { width: 100%; font-size: 18px; padding: 14px; }

@media (max-width: 600px), (max-height: 760px) {
  .screen { gap: 14px; padding-left: 14px; padding-right: 14px; }
  #screen-play {
    justify-content: center;
    padding-top: max(120px, calc(env(safe-area-inset-top) + 108px));
    padding-bottom: max(14px, env(safe-area-inset-bottom));
  }
  .adventure { top: max(65px, calc(env(safe-area-inset-top) + 56px)); width: 84vw; }
  .owl-friend { top: max(94px, calc(env(safe-area-inset-top) + 84px)); right: 8px; }
  .owl-bubble { max-width: 112px; font-size: 11px; padding: 6px 8px; }
  .word-card { padding: 25px 32px; min-width: 86vw; }
  #word { font-size: clamp(58px, 17vw, 92px); }
  .card-wrap { gap: 9px; margin-bottom: 4px; }
  .mic-area { gap: 8px; }
  .mic { width: 94px; height: 94px; }
  .mic-glyph { font-size: 40px; }
  .coach { font-size: 16px; min-height: 2.2em; }
  #screen-done { overflow-y: auto; justify-content: flex-start; padding-top: max(24px, env(safe-area-inset-top)); }
  #screen-done .mascot { font-size: 62px; }
  #screen-done h1 { margin-top: 2px; }
  .sticker-grid { gap: 7px; padding: 8px; }
  .sticker-slot { font-size: 35px; }
}
