/* ── Quiz character (Sofia / Valentina / Camila) ───────── */
.quiz-girl {
  position: relative;
  width: 100%;
  max-width: 580px;
  flex: 1 1 0;              /* takes whatever height is left, so the whole quiz fits the screen */
  min-height: 90px;
  max-height: min(380px, calc((100vw - 2rem) * .85));   /* phones: a little taller than 3:2, uses the spare height */
  margin: 0 auto;
  border-radius: 18px;
  overflow: hidden;
  background: var(--surface);
  border: 2px solid var(--surface2);
  box-shadow: 0 4px 0 var(--surface2);
  transition: opacity .18s ease, transform .18s ease, border-color .25s, box-shadow .25s;
}
.quiz-girl.is-swapping { opacity: 0; transform: scale(.97); }

.quiz-girl img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: 10% 28%;
  opacity: 0;
  transition: opacity .18s ease;
  pointer-events: none;
  user-select: none;
  -webkit-user-drag: none;
}
.quiz-girl img.is-on { opacity: 1; }

.quiz-girl[data-state="inlove"] {
  border-color: var(--accent);
  box-shadow: 0 4px 0 #a2301f;
}
.quiz-girl[data-state="inlove"] img.is-on { animation: girl-pop .6s cubic-bezier(.2, .8, .2, 1); }

.quiz-girl[data-state="angry"] {
  border-color: #ff4d3d;
  box-shadow: 0 4px 0 #7a1d12;
  animation: girl-shake .4s ease;
}

/* hearts + peppers that float up on a correct answer */
.quiz-girl-hearts { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.quiz-girl-heart {
  position: absolute;
  left: var(--x);
  bottom: -8%;
  font-size: var(--s, 1.2rem);
  opacity: 0;
  animation: girl-heart var(--dur, 1.8s) ease-out forwards;
}

/* thin bar showing how long until the next question */
.quiz-girl-timer {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 4px;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
  transform: scaleX(0);
  transform-origin: left;
  opacity: 0;
}
.quiz-girl.is-counting .quiz-girl-timer {
  opacity: 1;
  animation: girl-countdown var(--advance-ms, 4000ms) linear forwards;
}

/* question content eases in when the next question loads */
#quiz-game.quiz-q-in > :not(.quiz-girl) { animation: quiz-q-in .35s ease both; }

.quiz-check-btn:disabled { opacity: .5; cursor: default; }

@keyframes girl-pop {
  0%   { transform: scale(1.06); }
  100% { transform: scale(1); }
}
@keyframes girl-shake {
  10%, 90% { transform: translateX(-2px); }
  30%, 70% { transform: translateX(-5px); }
  50%      { transform: translateX(5px); }
}
@keyframes girl-heart {
  0%   { opacity: 0; transform: translateY(0) scale(.6); }
  15%  { opacity: 1; }
  100% { opacity: 0; transform: translate(var(--dx, 0), -150px) scale(1.15); }
}
@keyframes girl-countdown { to { transform: scaleX(1); } }
@keyframes quiz-q-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
  .quiz-girl, .quiz-girl img { transition: opacity .12s linear; }
  .quiz-girl.is-swapping { transform: none; }
  .quiz-girl[data-state="angry"],
  .quiz-girl[data-state="inlove"] img.is-on,
  #quiz-game.quiz-q-in > :not(.quiz-girl) { animation: none; }
  .quiz-girl-timer, .quiz-girl-hearts { display: none; }
}

/* ── Fit-to-screen layout (no scrolling to reach "Check") ───────── */
body:has(#quiz-screen:not(.hidden)) { padding-bottom: .8rem; }

#quiz-screen {
  height: calc(100dvh - 1.6rem);
  min-height: 0;
  gap: .6rem;
  overflow-y: auto;          /* safety net only: very long sentences on very small phones */
  overscroll-behavior: contain;
}
#quiz-game { flex: 1 1 auto; min-height: 0; gap: .6rem; }
#quiz-game > :not(.quiz-girl) { flex: none; }

/* back button: small round chip on the image corner instead of its own row */
.quiz-girl .quiz-back-btn {
  position: absolute;
  top: 8px; right: 8px;       /* the images carry the girl's name tag top-left */
  z-index: 4;
  width: 34px; height: 34px; min-width: 34px;
  font-size: 1rem;
  background: rgba(15, 15, 26, .85);
  border-color: rgba(237, 242, 244, .22);
}
.quiz-girl .quiz-back-btn:hover { background: rgba(15, 15, 26, .85); }

/* feedback floats over the bottom of the image (no layout jump when it appears) */
.quiz-girl .quiz-feedback {
  position: absolute;
  left: 10px; right: 10px; bottom: 12px;
  z-index: 3;
  padding: .35rem .6rem;
  font-size: .95rem;
  background: rgba(15, 15, 26, .9);
}

/* slimmer pieces */
#quiz-game .quiz-card { min-height: 0; padding: .85rem 1rem; }
#quiz-game .quiz-spanish { font-size: clamp(1.1rem, 4.8vw, 1.5rem); line-height: 1.3; }
#quiz-game .quiz-answer-area { min-height: 54px; padding: .5rem; gap: .4rem; }
#quiz-game .quiz-wordbank { gap: .45rem; padding: 0; }
#quiz-game .quiz-chip { min-height: 40px; padding: .45rem .9rem; font-size: .95rem; }
#quiz-game .quiz-check-btn { padding: .85rem 1.5rem; }
#quiz-screen .quiz-label { margin-top: 0; font-size: .72rem; text-align: center; flex: none; }

/* level-up / daily-dose banners: one compact row */
#quiz-screen .quiz-challenge-banner:not(.hidden),
#quiz-screen .quiz-dailydose-banner:not(.hidden) {
  display: flex; align-items: baseline; justify-content: center; gap: .6rem;
  padding: .35rem .8rem; margin: 0; flex: none;
}
#quiz-screen .quiz-challenge-title,
#quiz-screen .quiz-dailydose-title { margin: 0; font-size: .9rem; }
#quiz-screen .quiz-challenge-sub,
#quiz-screen .quiz-dailydose-sub { font-size: .8rem; }

@media (max-height: 700px) { #quiz-screen .quiz-label { display: none; } }

/* Check button sits at the bottom of the game area: stable position, thumb-friendly */
#quiz-game .quiz-check-btn { margin-top: auto; }
@media (min-width: 600px) { .quiz-girl { max-height: 620px; } }   /* desktop: image's natural 3:2 */

/* ── Level 2 characters (Lucía · Isabella · Mariana) ───────────────
   Their artwork is portrait / square (the original girls are 3:2 landscape), so the 3:2 stage crops it
   from the top: face and shoulders stay in view. Only applied while Level 2's set is active. */
.quiz-girl.quiz-girl--l2 img { object-position: 50% 3%; }
