:root {
  --bg1: #ffe66d; --bg2: #ff9f68;
  --ink: #3b2a63; --card: #ffffff;
  --a1: #4ecdc4; --a2: #ff6b9d; --a3: #6c8cff;
  --good: #2ecc71; --bad: #ff7675;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  font-family: "Fredoka", "Comic Sans MS", system-ui, sans-serif;
  color: var(--ink);
  background: linear-gradient(160deg, var(--bg1), var(--bg2));
  background-attachment: fixed;
  overflow-x: hidden;
  user-select: none;
}
#app { max-width: 760px; margin: 0 auto; min-height: 100dvh; padding: 16px; display: flex; }
.screen { display: none; flex-direction: column; align-items: center; justify-content: center; gap: 18px; width: 100%; text-align: center; }
.screen.active { display: flex; }
h1 { font-size: clamp(2.4rem, 9vw, 4rem); margin: 0; text-shadow: 3px 3px 0 #fff; }
.big-emoji { font-size: clamp(4rem, 20vw, 8rem); line-height: 1.1; }
.bounce { animation: bounce 1.6s ease-in-out infinite; }
@keyframes bounce { 50% { transform: translateY(-14px); } }

.play-btn {
  font-size: clamp(3.5rem, 16vw, 6rem); width: 1.8em; height: 1.8em; border-radius: 50%;
  border: 8px solid #fff; background: var(--good); cursor: pointer;
  box-shadow: 0 10px 0 #1e9e55, 0 14px 30px rgba(0,0,0,.2);
  display: grid; place-items: center; padding: 0; line-height: 1;
  animation: pulse 1.4s ease-in-out infinite;
}
.play-btn:active { transform: translateY(8px); box-shadow: 0 2px 0 #1e9e55; }
@keyframes pulse { 50% { transform: scale(1.08); } }

#quiz-screen { justify-content: space-evenly; }
.top-bar { display: flex; align-items: center; gap: 12px; width: 100%; }
.progress { flex: 1; height: 26px; background: rgba(255,255,255,.7); border-radius: 20px; overflow: hidden; border: 4px solid #fff; }
#progress-fill { height: 100%; width: 0; background: linear-gradient(90deg, var(--a1), var(--a3)); border-radius: 20px; transition: width .5s ease; }
.stars-count { font-size: 1.6rem; font-weight: 700; background: #fff; border-radius: 20px; padding: 2px 14px; }

.picture { font-size: clamp(3.5rem, 16vw, 6.5rem); min-height: 1.2em; line-height: 1.2; letter-spacing: .05em; }
.picture:empty { display: none; }
.prompt-row { display: flex; align-items: center; gap: 14px; justify-content: center; }
.prompt { font-size: clamp(1.4rem, 5.5vw, 2.2rem); font-weight: 700; margin: 0; background: rgba(255,255,255,.75); padding: 8px 18px; border-radius: 22px; }
.speak-btn {
  font-size: 2.6rem; width: 84px; height: 84px; flex: none; border-radius: 50%; border: 6px solid #fff;
  background: var(--a3); cursor: pointer; box-shadow: 0 6px 0 #4a63c4; padding: 0;
}
.speak-btn:active { transform: translateY(5px); box-shadow: 0 1px 0 #4a63c4; }
.speak-btn.talking { animation: pulse .6s ease-in-out infinite; }

.answers { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; width: 100%; margin-top: 6px; }
.answer {
  min-width: 0;
  aspect-ratio: 1 / 1.05; border-radius: 32px; border: 8px solid #fff; cursor: pointer;
  font-family: inherit; color: var(--ink); padding: 6px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  box-shadow: 0 10px 0 rgba(0,0,0,.18); transition: transform .15s;
}
.answer:nth-child(1) { background: var(--a1); }
.answer:nth-child(2) { background: var(--a2); }
.answer:nth-child(3) { background: var(--a3); }
.answer .emo { font-size: clamp(3rem, 15vw, 5.5rem); line-height: 1; }
.answer .word { font-size: clamp(.9rem, 3.6vw, 1.4rem); font-weight: 700; background: rgba(255,255,255,.85); border-radius: 12px; padding: 2px 8px; }
.answer:active { transform: translateY(8px); box-shadow: 0 2px 0 rgba(0,0,0,.18); }
.answer.reading { transform: scale(1.07); outline: 6px solid #ffe66d; }
.answer.right { background: var(--good) !important; animation: pop .5s; }
.answer.wrong { animation: shake .45s; opacity: .45; }
.answers.locked .answer { pointer-events: none; }
@keyframes pop { 50% { transform: scale(1.18); } }
@keyframes shake { 20%,60% { transform: translateX(-12px); } 40%,80% { transform: translateX(12px); } }

.feedback { font-size: clamp(2rem, 8vw, 3rem); font-weight: 700; min-height: 1.3em; }
.final-stars { font-size: clamp(2rem, 9vw, 3.4rem); max-width: 100%; word-break: break-all; }
.final-score { font-size: 2.4rem; font-weight: 700; margin: 0; background: #fff; border-radius: 24px; padding: 6px 24px; }

#confetti { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 10; }
.bit { position: absolute; top: -40px; font-size: 2rem; animation: fall linear forwards; }
@keyframes fall { to { transform: translateY(110vh) rotate(540deg); } }

/* Phones in portrait: stack the three answers as wide, tall buttons. */
@media (max-width: 600px) and (orientation: portrait) {
  .answers { grid-template-columns: 1fr; gap: 14px; }
  .answer { aspect-ratio: auto; min-height: 17dvh; flex-direction: row; gap: 18px; border-width: 6px; border-radius: 28px; }
  .answer .emo { font-size: clamp(3.2rem, 11dvh, 5.5rem); }
  .answer .word { font-size: 1.4rem; }
  .speak-btn { width: 72px; height: 72px; font-size: 2.2rem; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* Short screens (phones in landscape): size everything by viewport height. */
@media (max-height: 500px) and (orientation: landscape) {
  #app { padding: 8px 16px; }
  .screen { gap: 8px; }
  .top-bar .progress { height: 18px; border-width: 3px; }
  .stars-count { font-size: 1.2rem; }
  .picture { font-size: 11dvh; }
  .prompt { font-size: 1.3rem; padding: 4px 14px; }
  .speak-btn { width: 56px; height: 56px; font-size: 1.7rem; border-width: 4px; }
  .answers { gap: 12px; margin-top: 0; }
  .answer { aspect-ratio: auto; height: 44dvh; border-width: 5px; border-radius: 24px; }
  .answer .emo { font-size: 17dvh; }
  .answer .word { font-size: 1rem; }
  .feedback { font-size: 1.6rem; min-height: 1.2em; }
  .big-emoji { font-size: 22dvh; }
  h1 { font-size: 12dvh; }
  .play-btn { font-size: 13dvh; border-width: 5px; }
  .final-stars { font-size: 7dvh; }
  .final-score { font-size: 1.6rem; }
}
