/* ============================================================================
   LEADSTAR DESIGN CHALLENGE — game styles
   Loaded AFTER the Tailwind CDN so these rules always win.
   Tweak the palette below and the whole game re-skins.
   ========================================================================== */

:root {
  /* Palette */
  --ink:      #1b1035;
  --grape:    #7c3aed;
  --bubble:   #ff4fa3;
  --lime:     #b8ff3d;
  --sky:      #3ddcff;
  --sun:      #ffd12e;
  --good:     #22d37a;
  --bad:      #ff4d5e;
  --card:     #ffffff;

  /* Depth */
  --shadow-card:  0 18px 0 -6px rgba(27, 16, 53, .18), 0 26px 40px -18px rgba(27, 16, 53, .55);
  --shadow-lift:  0 26px 0 -6px rgba(27, 16, 53, .18), 0 40px 60px -22px rgba(27, 16, 53, .6);

  /* Rhythm */
  --radius:   28px;
  --gutter:   clamp(1rem, 4vw, 2.5rem);
}

/* ── Base ─────────────────────────────────────────────────────────────── */

* { box-sizing: border-box; }

html, body {
  height: 100%;
}

body {
  margin: 0;
  color: var(--ink);
  background: #2a0f52;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.stage {
  position: relative;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  isolation: isolate;
}

/* ── Animated background ──────────────────────────────────────────────── */

.bg-layer {
  position: fixed;
  inset: 0;
  z-index: -1;
  overflow: hidden;
  background:
    radial-gradient(120% 90% at 15% 0%,   #6d28d9 0%, transparent 60%),
    radial-gradient(110% 80% at 85% 10%,  #db2777 0%, transparent 55%),
    radial-gradient(120% 100% at 50% 110%, #0ea5e9 0%, transparent 60%),
    linear-gradient(160deg, #3b0764 0%, #1e1b4b 55%, #2e1065 100%);
}

.blob {
  position: absolute;
  border-radius: 50%;
  filter: blur(60px);
  opacity: .55;
  animation: drift 22s ease-in-out infinite;
}
.blob--1 { width: 46vmax; height: 46vmax; left: -12vmax; top: -14vmax; background: var(--grape); }
.blob--2 { width: 40vmax; height: 40vmax; right: -14vmax; top: 8vmax;  background: var(--bubble); animation-delay: -7s; animation-duration: 27s; }
.blob--3 { width: 38vmax; height: 38vmax; left: 22vmax;  bottom: -18vmax; background: var(--sky);  animation-delay: -13s; animation-duration: 31s; }

@keyframes drift {
  0%, 100% { transform: translate3d(0, 0, 0) scale(1); }
  33%      { transform: translate3d(6vmax, -4vmax, 0) scale(1.12); }
  66%      { transform: translate3d(-5vmax, 5vmax, 0) scale(.94); }
}

/* Floating decorative emoji, injected by game.js */
.floaties { position: absolute; inset: 0; }

.floaty {
  position: absolute;
  font-size: var(--size, 2rem);
  opacity: .35;
  filter: drop-shadow(0 6px 12px rgba(0, 0, 0, .35));
  animation: bob var(--dur, 9s) ease-in-out var(--delay, 0s) infinite;
  will-change: transform;
}

@keyframes bob {
  0%, 100% { transform: translateY(0) rotate(var(--rot, 0deg)); }
  50%      { transform: translateY(-28px) rotate(calc(var(--rot, 0deg) * -1)); }
}

/* ── Screens ──────────────────────────────────────────────────────────── */

.screens {
  flex: 1;
  display: flex;
  width: 100%;
}

.screen {
  display: none;
  flex: 1;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: clamp(1rem, 2.5vh, 1.75rem);
  width: 100%;
  max-width: 1100px;
  margin-inline: auto;
  padding: calc(var(--gutter) + 1.5rem) var(--gutter) calc(var(--gutter) + 2rem);
  text-align: center;
}

.screen.is-active {
  display: flex;
  animation: screen-in .5s cubic-bezier(.2, .9, .3, 1.2) both;
}

@keyframes screen-in {
  from { opacity: 0; transform: translateY(26px) scale(.96); }
  to   { opacity: 1; transform: none; }
}

/* ── Start screen ─────────────────────────────────────────────────────── */

.eyebrow {
  margin: 0;
  font-family: 'Fredoka', system-ui, sans-serif;
  font-weight: 600;
  letter-spacing: .3em;
  text-transform: uppercase;
  font-size: clamp(.7rem, 1.6vw, .95rem);
  color: var(--lime);
  text-shadow: 0 2px 10px rgba(184, 255, 61, .45);
  /* A full sentence at this tracking wraps badly on a phone otherwise */
  max-width: 34ch;
  text-wrap: balance;
}

.game-title {
  margin: 0;
  display: flex;
  flex-direction: column;
  font-family: 'Fredoka', system-ui, sans-serif;
  font-weight: 700;
  line-height: .92;
  letter-spacing: -.01em;
  text-transform: uppercase;
}

.game-title__line {
  display: block;
  animation: title-wobble 6s ease-in-out infinite;
  transform-origin: center;
}

.game-title__line--1 {
  font-size: clamp(3rem, 13vw, 8.5rem);
  background: linear-gradient(180deg, #fff 20%, var(--sun) 65%, var(--bubble) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 8px 0 rgba(27, 16, 53, .45));
}

.game-title__line--2 {
  font-size: clamp(1.1rem, 4.4vw, 2.9rem);
  letter-spacing: .18em;
  color: #fff;
  animation-delay: -3s;
  text-shadow: 0 4px 0 rgba(27, 16, 53, .35);
}

@keyframes title-wobble {
  0%, 100% { transform: rotate(-1.2deg) translateY(0); }
  50%      { transform: rotate(1.2deg) translateY(-6px); }
}

.tagline {
  margin: 0;
  max-width: 32ch;
  font-size: clamp(1rem, 2.2vw, 1.3rem);
  font-weight: 700;
  color: rgba(255, 255, 255, .82);
}

.hint {
  margin: 0;
  font-size: .85rem;
  font-weight: 700;
  color: rgba(255, 255, 255, .45);
}

/* ── Buttons ──────────────────────────────────────────────────────────── */

.btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: .7rem;
  border: 0;
  cursor: pointer;
  font-family: 'Fredoka', system-ui, sans-serif;
  color: var(--ink);
  background: linear-gradient(180deg, var(--sun) 0%, #ffb020 100%);
  box-shadow: 0 10px 0 #b8720a, 0 22px 34px -12px rgba(0, 0, 0, .6);
  transition: transform .12s ease, box-shadow .12s ease, filter .2s ease;
}

.btn--hero {
  margin-top: .5rem;
  padding: clamp(.9rem, 2.4vw, 1.25rem) clamp(2rem, 6vw, 3.2rem);
  border-radius: 999px;
  font-size: clamp(1.15rem, 3.4vw, 1.9rem);
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
  animation: hero-pulse 2.4s ease-in-out infinite;
}

.btn--alt {
  background: linear-gradient(180deg, var(--lime) 0%, #77d413 100%);
  box-shadow: 0 10px 0 #4d8c07, 0 22px 34px -12px rgba(0, 0, 0, .6);
}

.btn:hover  { transform: translateY(-3px); filter: saturate(1.12); }
.btn:active { transform: translateY(6px); box-shadow: 0 4px 0 #b8720a, 0 10px 18px -10px rgba(0, 0, 0, .6); }
.btn--alt:active { box-shadow: 0 4px 0 #4d8c07, 0 10px 18px -10px rgba(0, 0, 0, .6); }

.btn__spark { animation: spin-slow 4s linear infinite; }

@keyframes hero-pulse {
  0%, 100% { transform: scale(1); }
  50%      { transform: scale(1.045); }
}
@keyframes spin-slow { to { transform: rotate(360deg); } }

:where(button, [tabindex]):focus-visible {
  outline: 4px solid var(--sky);
  outline-offset: 4px;
}

/* ── Sound toggle ─────────────────────────────────────────────────────── */

.sound-toggle {
  position: fixed;
  top: 1rem; right: 1rem;
  z-index: 40;
  width: 3rem; height: 3rem;
  display: grid;
  place-items: center;
  font-size: 1.35rem;
  line-height: 1;
  border: 0;
  border-radius: 999px;
  cursor: pointer;
  background: rgba(255, 255, 255, .14);
  backdrop-filter: blur(8px);
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, .22);
  transition: transform .15s ease, background .2s ease;
}
.sound-toggle:hover { transform: scale(1.08); background: rgba(255, 255, 255, .24); }
.sound-toggle__off  { display: none; }
.sound-toggle.is-muted .sound-toggle__on  { display: none; }
.sound-toggle.is-muted .sound-toggle__off { display: block; }

/* ── Quiz head ────────────────────────────────────────────────────────── */

.quiz-head {
  width: 100%;
  max-width: 620px;
  display: flex;
  flex-direction: column;
  gap: .7rem;
}

.quiz-head__meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  padding: .4rem 1rem;
  border-radius: 999px;
  font-family: 'Fredoka', system-ui, sans-serif;
  font-size: .95rem;
  font-weight: 600;
  color: #fff;
  background: rgba(255, 255, 255, .13);
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, .2);
}
.pill b { color: var(--sun); }
.pill--score b { color: var(--lime); }

.progress {
  height: 14px;
  border-radius: 999px;
  background: rgba(255, 255, 255, .14);
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, .18);
  overflow: hidden;
}

.progress__fill {
  display: block;
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--lime), var(--sky), var(--bubble));
  background-size: 200% 100%;
  transition: width .5s cubic-bezier(.2, .9, .3, 1.2);
  animation: slide-bg 3s linear infinite;
}

@keyframes slide-bg { to { background-position: 200% 0; } }

/* ── Question ─────────────────────────────────────────────────────────── */

.question {
  margin: 0;
  max-width: 22ch;
  font-family: 'Fredoka', system-ui, sans-serif;
  font-weight: 600;
  font-size: clamp(1.5rem, 5vw, 3rem);
  line-height: 1.1;
  color: #fff;
  text-shadow: 0 6px 24px rgba(0, 0, 0, .4);
  animation: question-in .45s cubic-bezier(.2, .9, .3, 1.2) both;
}

@keyframes question-in {
  from { opacity: 0; transform: translateY(-14px); }
  to   { opacity: 1; transform: none; }
}

/* ── Answer cards ─────────────────────────────────────────────────────── */

.answers {
  display: grid;
  gap: clamp(.85rem, 2.2vw, 1.5rem);
  width: 100%;
  max-width: 980px;
  grid-template-columns: 1fr;
}

@media (min-width: 640px) {
  .answers[data-count="2"] { grid-template-columns: repeat(2, minmax(0, 1fr)); max-width: 720px; }
  .answers[data-count="3"] { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .answers[data-count="4"] { grid-template-columns: repeat(2, minmax(0, 1fr)); max-width: 760px; }
}

.answer-card {
  --accent: var(--grape);

  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .75rem;
  padding: clamp(1rem, 2.6vw, 1.6rem);
  border: 0;
  border-radius: var(--radius);
  cursor: pointer;
  background: var(--card);
  box-shadow: var(--shadow-card);
  transition: transform .18s cubic-bezier(.2, .9, .3, 1.2),
              box-shadow .18s ease,
              opacity .3s ease,
              filter .3s ease;
  /* `backwards`, not `both`: a filled animation would freeze `transform`
     and kill the hover lift once the entrance finished. */
  animation: card-in .45s cubic-bezier(.2, .9, .3, 1.2) backwards;
  animation-delay: calc(var(--i, 0) * 70ms);
  will-change: transform;
}

@keyframes card-in {
  from { opacity: 0; transform: translateY(28px) scale(.9) rotate(var(--tilt, 0deg)); }
  to   { opacity: 1; transform: none; }
}

/* Coloured top edge so each option reads as its own thing */
.answer-card::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  box-shadow: inset 0 0 0 4px var(--accent);
  opacity: .28;
  transition: opacity .2s ease;
  pointer-events: none;
}

.answer-card:hover:not(:disabled) {
  transform: translateY(-8px) rotate(-1deg) scale(1.02);
  box-shadow: var(--shadow-lift);
}
.answer-card:hover:not(:disabled)::before { opacity: 1; }
.answer-card:nth-child(even):hover:not(:disabled) { transform: translateY(-8px) rotate(1deg) scale(1.02); }
.answer-card:active:not(:disabled) { transform: translateY(-2px) scale(.99); }

.answer-card__visual {
  position: relative;
  display: grid;
  place-items: center;
  width: 100%;
  aspect-ratio: 4 / 3;
  /* Lets the mock-ups below size themselves in cqw, so they look identical
     on a 3-across desktop card and a full-width phone card. */
  container-type: inline-size;
  border-radius: calc(var(--radius) - 12px);
  overflow: hidden;
  background:
    radial-gradient(circle at 30% 20%, color-mix(in srgb, var(--accent) 28%, #fff) 0%, transparent 60%),
    color-mix(in srgb, var(--accent) 12%, #fff);
}

/* Plain picture answers get letterboxed and lift on hover. Mock-up answers
   (--html) draw their own images, so they are excluded from both. */
.answer-card__visual:not(.answer-card__visual--html) img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  padding: .6rem;
  transition: transform .25s cubic-bezier(.2, .9, .3, 1.2);
}
.answer-card:hover:not(:disabled) .answer-card__visual:not(.answer-card__visual--html) img {
  transform: scale(1.07) rotate(-2deg);
}

.answer-card__emoji {
  font-size: clamp(3rem, 9vw, 4.5rem);
  line-height: 1;
  filter: drop-shadow(0 8px 10px rgba(27, 16, 53, .25));
  transition: transform .25s cubic-bezier(.2, .9, .3, 1.2);
}
.answer-card:hover:not(:disabled) .answer-card__emoji { transform: scale(1.14) rotate(-6deg); }

/* Optional swatch mode — a big block of colour instead of an image */
.answer-card__swatch {
  width: 100%;
  height: 100%;
  background: var(--swatch, var(--accent));
}

.answer-card__text {
  display: flex;
  flex-direction: column;
  gap: .3rem;
}

.answer-card__label {
  font-family: 'Fredoka', system-ui, sans-serif;
  font-weight: 600;
  font-size: clamp(1rem, 2.3vw, 1.3rem);
  line-height: 1.2;
  color: var(--ink);
}

.answer-card__note {
  font-size: .85rem;
  font-weight: 700;
  color: color-mix(in srgb, var(--ink) 55%, #fff);
}

.answer-card__key {
  position: absolute;
  z-index: 1;
  top: .7rem; left: .7rem;
  width: 1.75rem; height: 1.75rem;
  display: grid;
  place-items: center;
  border-radius: .6rem;
  font-family: 'Fredoka', system-ui, sans-serif;
  font-size: .85rem;
  font-weight: 600;
  color: #fff;
  background: var(--accent);
  box-shadow: 0 3px 0 rgba(27, 16, 53, .25);
}

/* Reveal badge (✓ / ✕) */
.answer-card__badge {
  position: absolute;
  top: -.9rem; right: -.9rem;
  width: 2.9rem; height: 2.9rem;
  display: grid;
  place-items: center;
  font-size: 1.5rem;
  border-radius: 999px;
  color: #fff;
  opacity: 0;
  transform: scale(.3) rotate(-40deg);
  transition: opacity .2s ease, transform .35s cubic-bezier(.2, 1.6, .4, 1);
  box-shadow: 0 8px 18px -6px rgba(0, 0, 0, .6);
}

/* ── Mini-mockups (answer.html in questions.js) ─────────────────────────
   A tiny toolkit for drawing "what a page looks like" inside an answer card.
   Everything is sized in cqw (a % of the card's own width), so one markup
   string renders correctly at every card size.
   ────────────────────────────────────────────────────────────────────── */

.answer-card__visual--html {
  background: #fff;
  box-shadow: inset 0 0 0 1px rgba(27, 16, 53, .13);
}

.mock {
  display: flex;
  flex-direction: column;
  gap: 3cqw;
  width: 100%;
  height: 100%;
  padding: 4cqw;
  overflow: hidden;
  background: #fff;
  text-align: left;
}

/* Grey "photo" block with a sun and a mountain range */
.mock__img {
  position: relative;
  flex: 0 0 var(--h, 25%);
  border-radius: 1.6cqw;
  overflow: hidden;
  background: linear-gradient(160deg, #dde2ef 0%, #b7bfd5 100%);
}
.mock__img::before {
  content: '';
  position: absolute;
  left: 12%; top: 16%;
  width: 13%;
  aspect-ratio: 1;
  border-radius: 50%;
  background: #fff;
  opacity: .8;
}
.mock__img::after {
  content: '';
  position: absolute;
  left: -4%; right: -4%; bottom: 0;
  height: 62%;
  background: #98a2bd;
  clip-path: polygon(0 100%, 30% 20%, 54% 64%, 76% 28%, 100% 100%);
}

/* Text blocks */
.mock__lines {
  display: flex;
  flex-direction: column;
  gap: 2.2cqw;
  flex: none;
}
.mock__lines--fill { flex: 1; justify-content: space-between; }

.mock__line {
  display: block;
  height: 2.3cqw;
  width: var(--w, 100%);
  border-radius: 99px;
  background: #ccd2e0;
}
.mock__line--title { height: 3.6cqw; background: #9aa3bd; }

/* Bullet list */
.mock__list {
  display: flex;
  flex-direction: column;
  gap: 2.2cqw;
  flex: none;
}
.mock__li { display: flex; align-items: center; gap: 2.4cqw; }
.mock__li::before {
  content: '';
  flex: none;
  width: 2.6cqw;
  aspect-ratio: 1;
  border-radius: 50%;
  background: #8b95b2;
}

/* Call-to-action pill */
.mock__btn {
  flex: none;
  width: 40%;
  height: 7cqw;
  border-radius: 99px;
  background: #7c3aed;
}

/* Even-margin variant — identical gap between every block, by definition */
.mock--even { justify-content: space-between; }

/* Uneven-margin variant — deliberately ragged spacing */
.mock--uneven { gap: 0; }
.mock--uneven > :nth-child(1) { margin-bottom: 1cqw; }
.mock--uneven > :nth-child(2) { margin: 0 0 14cqw 17cqw; }
.mock--uneven > :nth-child(3) { margin: 0 21cqw .8cqw 0; }

/* Colour palette — full-bleed swatch columns */
.mock--palette { padding: 0; gap: 0; flex-direction: row; }
.mock__sw {
  flex: 1;
  box-shadow: inset 0 0 0 1px rgba(27, 16, 53, .18);
  background: var(--c, #ccc);
}

/* Vertical menu — just the items, read as a site menu on its own */
.mock--menu {
  justify-content: center;
  gap: 0;
  padding: 5cqw 6cqw;
}

.mock__menu {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 3cqw;
}

.mock__menu li {
  display: flex;
  align-items: center;
  gap: 3cqw;
  font-family: 'Nunito', system-ui, sans-serif;
  font-weight: 800;
  font-size: 5.2cqw;
  line-height: 1.1;
  color: #2f2b45;
}

.mock__menu li::before {
  content: '';
  flex: none;
  width: 2.4cqw;
  aspect-ratio: 1;
  border-radius: 50%;
  background: var(--accent, #7c3aed);
}

/* Browser window with a navigation bar */
.mock--nav { padding: 0; gap: 0; }

.mock__chrome {
  flex: none;
  display: flex;
  align-items: center;
  gap: 1.6cqw;
  padding: 2.4cqw 3cqw;
  background: #eceff6;
}
.mock__dot {
  width: 2.2cqw;
  aspect-ratio: 1;
  border-radius: 50%;
  background: #c2c8d8;
}

.mock__navbar {
  flex: none;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1.6cqw 3cqw;
  padding: 3cqw;
  background: #1b1035;
}
.mock__logo {
  flex: none;
  width: 4.6cqw;
  aspect-ratio: 1;
  border-radius: 50%;
  background: var(--accent, #7c3aed);
}
.mock__navbar em {
  font-family: 'Nunito', system-ui, sans-serif;
  font-style: normal;
  font-weight: 800;
  font-size: 4.2cqw;
  line-height: 1;
  white-space: nowrap;
  color: #fff;
}

/* Page content under the menu */
.mock--nav .mock__body {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 2.6cqw;
  padding: 3.5cqw;
}

/* Photograph, shown three ways in the first question */
.mock--photo { padding: 0; display: block; }
.mock__photo {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: 50% 34%;
}
/* Blur in cqw so it stays equally soft on a small and a large card */
.mock__photo--blur { filter: blur(.7cqw); }

/* Blown up and shoved off-centre so the heads run off the top edge.
   `max-width: none` is needed because Tailwind's preflight caps images at 100%. */
.mock__photo--crop {
  max-width: none;
  width: 190%;
  height: 190%;
  margin-left: -52%;
  margin-top: -28%;
}

/* ── Answer states ────────────────────────────────────────────────────── */

.answers.is-locked .answer-card { cursor: default; }

.answer-card.is-correct {
  --accent: var(--good);
  animation: pop-correct .55s cubic-bezier(.2, 1.5, .4, 1) both;
}
.answer-card.is-correct::before { opacity: 1; }
.answer-card.is-correct .answer-card__badge {
  opacity: 1;
  transform: none;
  background: var(--good);
}

.answer-card.is-wrong {
  --accent: var(--bad);
  animation: shake-wrong .5s cubic-bezier(.36, .07, .19, .97) both;
}
.answer-card.is-wrong::before { opacity: 1; }
.answer-card.is-wrong .answer-card__badge {
  opacity: 1;
  transform: none;
  background: var(--bad);
}

.answer-card.is-dimmed { opacity: .38; filter: grayscale(.7); }

@keyframes pop-correct {
  0%   { transform: scale(1); }
  45%  { transform: scale(1.09) rotate(1.5deg); }
  100% { transform: scale(1.03); }
}

@keyframes shake-wrong {
  10%, 90% { transform: translateX(-8px) rotate(-1deg); }
  20%, 80% { transform: translateX(8px) rotate(1deg); }
  30%, 50%, 70% { transform: translateX(-12px) rotate(-2deg); }
  40%, 60% { transform: translateX(12px) rotate(2deg); }
  100% { transform: none; }
}

/* ── Characters ───────────────────────────────────────────────────────── */

.character {
  position: fixed;
  bottom: 0;
  z-index: 30;
  width: clamp(160px, 30vw, 340px);
  pointer-events: none;
  opacity: 0;
  transition: transform .55s cubic-bezier(.2, 1.4, .4, 1), opacity .3s ease;
}

.character--correct { right: 0;  transform: translate(30%, 110%) rotate(12deg); }
.character--wrong   { left: 0;   transform: translate(-30%, 110%) rotate(-12deg); }

.character.is-in { opacity: 1; }
.character--correct.is-in { transform: translate(4%, 4%) rotate(0deg); }
.character--wrong.is-in   { transform: translate(-4%, 4%) rotate(0deg); }

.character.is-in .character__img,
.character.is-in .character__emoji {
  animation: char-hype .6s ease-in-out .25s 2 both;
}
.character--wrong.is-in .character__img,
.character--wrong.is-in .character__emoji {
  animation: char-sulk .8s ease-in-out .2s 2 both;
}

@keyframes char-hype {
  0%, 100% { transform: translateY(0) rotate(0deg) scale(1); }
  30%      { transform: translateY(-16px) rotate(-5deg) scale(1.05); }
  60%      { transform: translateY(0) rotate(4deg) scale(.98); }
}

@keyframes char-sulk {
  0%, 100% { transform: translateX(0) rotate(0deg); }
  25%      { transform: translateX(-8px) rotate(-4deg); }
  75%      { transform: translateX(8px) rotate(4deg); }
}

.character__img {
  display: block;
  width: 100%;
  height: auto;
  filter: drop-shadow(0 20px 26px rgba(0, 0, 0, .55));
}

/* Emoji stand-in, shown until a PNG is dropped into assets/characters/ */
.character__emoji {
  display: none;
  font-size: clamp(5rem, 16vw, 10rem);
  line-height: 1;
  filter: drop-shadow(0 20px 26px rgba(0, 0, 0, .55));
}
.character.no-image .character__img   { display: none; }
.character.no-image .character__emoji { display: block; text-align: center; }

.character__shout {
  position: absolute;
  /* Sits just above the character and in front of it — the picture is painted
     after the bubble in the DOM and would otherwise cover half the word. */
  bottom: calc(100% - 1.4rem);
  z-index: 2;
  padding: .6rem 1.3rem;
  border-radius: 999px 999px 999px 6px;
  font-family: 'Fredoka', system-ui, sans-serif;
  font-weight: 700;
  font-size: clamp(1.1rem, 3.2vw, 2rem);
  letter-spacing: .04em;
  white-space: nowrap;
  color: var(--ink);
  background: #fff;
  box-shadow: 0 10px 24px -8px rgba(0, 0, 0, .7);
  opacity: 0;
  transform: scale(.4);
}

/* Anchored so the bubble always grows *inwards*, never off the screen edge. */
.character--correct .character__shout {
  right: 50%; left: auto;
  border-radius: 999px 999px 6px 999px;
  color: #0b7a44;
}
.character--wrong .character__shout {
  left: 50%; right: auto;
  color: #b0142a;
}

.character.is-in .character__shout {
  animation: shout-pop .5s cubic-bezier(.2, 1.7, .4, 1) .2s both,
             shout-jiggle 1.1s ease-in-out .7s infinite;
}

@keyframes shout-pop {
  from { opacity: 0; transform: scale(.4) rotate(-12deg); }
  to   { opacity: 1; transform: scale(1) rotate(-4deg); }
}
@keyframes shout-jiggle {
  0%, 100% { transform: scale(1) rotate(-4deg); }
  50%      { transform: scale(1.06) rotate(2deg); }
}

/* ── Character style: AVATAR ────────────────────────────────────────────
   For square headshots / profile pictures. Framed in a white ring with a
   coloured halo, sitting just inside the corner instead of against the edge.
   Switch a character to this in config.js with  style: 'avatar'.
   ────────────────────────────────────────────────────────────────────── */

.character--avatar { width: clamp(130px, 20vw, 210px); }

.character--avatar.character--correct { --ring: var(--good); }
.character--avatar.character--wrong   { --ring: var(--bad); }

.character--avatar.character--correct.is-in { transform: translate(-7%, -9%); }
.character--avatar.character--wrong.is-in   { transform: translate(7%, -9%); }

.character--avatar .character__img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: 50%;
  border: .5rem solid #fff;
  filter: none;
  box-shadow:
    0 0 0 .55rem var(--ring),
    0 0 0 .8rem rgba(255, 255, 255, .35),
    0 24px 36px -14px rgba(0, 0, 0, .75);
}

.character--avatar .character__emoji {
  width: 100%;
  aspect-ratio: 1;
  place-items: center;
  font-size: clamp(3.5rem, 10vw, 6rem);
  border-radius: 50%;
  border: .5rem solid #fff;
  background: #fff;
  filter: none;
  box-shadow:
    0 0 0 .55rem var(--ring),
    0 24px 36px -14px rgba(0, 0, 0, .75);
}
.character--avatar.no-image .character__emoji { display: grid; }

.character--avatar .character__shout { bottom: calc(100% - 2.4rem); }

/* ── Confetti ─────────────────────────────────────────────────────────── */

.confetti {
  position: fixed;
  inset: 0;
  z-index: 35;
  overflow: hidden;
  pointer-events: none;
}

.confetti__piece {
  position: absolute;
  top: -8vh;
  width: var(--w, 10px);
  height: var(--h, 16px);
  background: var(--c, var(--sun));
  border-radius: var(--br, 2px);
  opacity: 0;
  animation: confetti-fall var(--dur, 2.6s) linear var(--delay, 0s) forwards;
}

@keyframes confetti-fall {
  0%   { opacity: 1; transform: translate3d(0, 0, 0) rotate(0deg); }
  100% { opacity: 0; transform: translate3d(var(--dx, 0px), 115vh, 0) rotate(var(--spin, 720deg)); }
}

/* ── End screen ───────────────────────────────────────────────────────── */

.trophy {
  position: relative;
  display: grid;
  place-items: center;
  width: clamp(9rem, 26vw, 14rem);
  height: clamp(9rem, 26vw, 14rem);
}

.trophy__icon {
  font-size: clamp(4.5rem, 14vw, 8rem);
  line-height: 1;
  animation: trophy-bounce 1.6s ease-in-out infinite;
  filter: drop-shadow(0 14px 20px rgba(0, 0, 0, .5));
}

.trophy__burst {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: conic-gradient(from 0deg,
    var(--sun) 0 12deg, transparent 12deg 30deg,
    var(--lime) 30deg 42deg, transparent 42deg 60deg,
    var(--sky) 60deg 72deg, transparent 72deg 90deg,
    var(--bubble) 90deg 102deg, transparent 102deg 120deg,
    var(--sun) 120deg 132deg, transparent 132deg 150deg,
    var(--lime) 150deg 162deg, transparent 162deg 180deg,
    var(--sky) 180deg 192deg, transparent 192deg 210deg,
    var(--bubble) 210deg 222deg, transparent 222deg 240deg,
    var(--sun) 240deg 252deg, transparent 252deg 270deg,
    var(--lime) 270deg 282deg, transparent 282deg 300deg,
    var(--sky) 300deg 312deg, transparent 312deg 330deg,
    var(--bubble) 330deg 342deg, transparent 342deg 360deg);
  opacity: .5;
  animation: spin-slow 14s linear infinite;
}

@keyframes trophy-bounce {
  0%, 100% { transform: translateY(0) rotate(-4deg); }
  50%      { transform: translateY(-18px) rotate(4deg); }
}

.end-headline {
  margin: 0;
  max-width: 20ch;
  font-family: 'Fredoka', system-ui, sans-serif;
  font-weight: 700;
  font-size: clamp(1.5rem, 5.2vw, 3.2rem);
  line-height: 1.08;
  background: linear-gradient(180deg, #fff 30%, var(--sun) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 6px 0 rgba(27, 16, 53, .4));
}

.end-score {
  margin: 0;
  font-size: clamp(1rem, 2.4vw, 1.35rem);
  font-weight: 800;
  color: rgba(255, 255, 255, .85);
}

/* ── Small screens ──────────────────────────────────────────────────────
   Cards flip to a compact row (small square visual + text beside it) so all
   the options fit on one phone screen instead of one card per scroll.
   ────────────────────────────────────────────────────────────────────── */

@media (max-width: 639px) {
  .screen {
    justify-content: flex-start;   /* never push content above the scroll top */
    padding-top: 5rem;             /* clear of the fixed sound toggle */
  }
  /* Only the quiz screen can outgrow a phone; start and end stay centred. */
  .screen--start,
  .screen--end { justify-content: center; }

  .answers { gap: .7rem; }

  .answer-card {
    flex-direction: row;
    align-items: center;
    text-align: left;
    gap: .9rem;
    padding: .7rem;
    padding-left: 2.9rem;
  }

  .answer-card__visual {
    flex: 0 0 5.25rem;
    width: 5.25rem;
    aspect-ratio: 1;
    border-radius: 1rem;
  }

  .answer-card__emoji { font-size: 2.6rem; }
  .answer-card__label { font-size: 1.05rem; }
  .answer-card__note  { font-size: .8rem; }

  .answer-card__key {
    top: 50%;
    left: .8rem;
    transform: translateY(-50%);
  }

  .answer-card__badge {
    top: -.55rem; right: -.55rem;
    width: 2.1rem; height: 2.1rem;
    font-size: 1.05rem;
  }

  /* Mockups need the full card width to stay readable, so those questions
     keep the stacked layout even on a phone. */
  .answers[data-visual="html"] .answer-card {
    flex-direction: column;
    align-items: stretch;
    text-align: center;
    padding: .8rem;
  }
  .answers[data-visual="html"] .answer-card__visual {
    flex: none;
    width: 100%;
    aspect-ratio: 4 / 3;
    border-radius: 1rem;
  }
  .answers[data-visual="html"] .answer-card__key {
    top: 1.3rem; left: 1.3rem;
    transform: none;
  }

  /* Hover lift is meaningless on touch and only fights the tap highlight */
  .answer-card:hover:not(:disabled),
  .answer-card:nth-child(even):hover:not(:disabled) { transform: none; }

  /* There is less empty margin to hide in on a phone — fade them back */
  .floaty { opacity: .2; }

  .character { width: 40vw; }
  .character__shout { font-size: 1rem; padding: .45rem 1rem; }
}

/* ── Motion-sensitive users ───────────────────────────────────────────── */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
  .character.is-in { opacity: 1; }
  .character--correct.is-in,
  .character--wrong.is-in { transform: translate(0, 4%); }
  .character.is-in .character__shout { opacity: 1; transform: none; }
}
