/* Quiz result screen. Loaded after quiz.css; every rule is scoped to the
   result screen and uses its own class names, so nothing else on the quiz
   page is affected. */

#results-screen {
  padding: 0.4rem 0 1.5rem;
}

#results-screen .rs-shell {
  --rs-ink: #0f1b3d;
  --rs-muted: #5b6b8c;
  --rs-line: #dbe6f7;
  --rs-blue: #1557f5;
  --rs-blue-deep: #0a2a8f;
  --rs-gold: #f6b721;
  position: relative;
  width: min(100%, 1180px);
  margin: 0 auto;
  border: 1px solid var(--rs-line);
  border-radius: 28px;
  background: linear-gradient(180deg, #f3f7ff 0%, #ffffff 46%);
  box-shadow: 0 28px 70px rgba(31, 72, 150, 0.18);
  overflow: hidden;
  color: var(--rs-ink);
}

/* ---------- hero ---------- */
#results-screen .rs-top {
  position: relative;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: clamp(1rem, 3vw, 2.5rem);
  min-height: 250px;
  padding: clamp(1.4rem, 3vw, 2.2rem) clamp(1.2rem, 4vw, 3rem) clamp(3rem, 5vw, 3.8rem);
  background:
    radial-gradient(circle at 12% 30%, rgba(88, 140, 255, 0.55), transparent 34%),
    radial-gradient(circle at 88% 20%, rgba(120, 170, 255, 0.5), transparent 38%),
    linear-gradient(135deg, #0a1f73 0%, #123bb8 55%, #1b56e6 100%);
  color: #ffffff;
  overflow: hidden;
}

#results-screen .rs-top__copy {
  position: relative;
  z-index: 2;
  text-align: center;
  min-width: 0;
}

#results-screen .rs-kicker {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1.1rem;
  border-radius: 999px;
  background: linear-gradient(180deg, #ffe08a, #f6b721);
  box-shadow: 0 8px 20px rgba(246, 183, 33, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.7);
  color: #2a1c00;
  font-weight: 800;
  font-size: 0.95rem;
  line-height: 1;
}

#results-screen .rs-kicker lucide-icon {
  width: 1.05em;
  height: 1.05em;
}

#results-screen .rs-top h2 {
  margin: 0.9rem 0 0.6rem;
  color: #ffffff;
  font-size: clamp(2rem, 5.2vw, 3.6rem);
  font-weight: 800;
  line-height: 1.05;
  letter-spacing: -0.01em;
  text-shadow: 0 6px 22px rgba(4, 16, 70, 0.45);
  overflow-wrap: anywhere;
}

#results-screen .rs-top h2 em {
  font-style: normal;
  background: linear-gradient(180deg, #fff1b8 0%, #f6b721 70%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

#results-screen .rs-shell:not(.is-passed) .rs-top h2 em {
  background: linear-gradient(180deg, #ffffff 0%, #c9dbff 80%);
  -webkit-background-clip: text;
  background-clip: text;
}

#results-screen .rs-top h2 small {
  display: block;
  margin-top: 0.45rem;
  color: #dbe7ff;
  font-size: 0.34em;
  font-weight: 700;
  letter-spacing: 0;
  text-shadow: none;
}

#results-screen #result-summary-copy {
  max-width: 62ch;
  margin: 0 auto;
  color: #e6eeff;
  font-size: clamp(0.92rem, 1.5vw, 1.05rem);
  line-height: 1.6;
}

#results-screen .rs-mascot {
  position: relative;
  z-index: 2;
  align-self: end;
  width: clamp(150px, 20vw, 240px);
  height: auto;
  margin-bottom: clamp(-3.8rem, -5vw, -3rem);
  filter: drop-shadow(0 16px 26px rgba(4, 16, 70, 0.4));
}

/* medal */
#results-screen .rs-medal {
  position: relative;
  z-index: 2;
  width: clamp(120px, 15vw, 190px);
  aspect-ratio: 1;
  display: grid;
  place-items: center;
}

#results-screen .rs-medal__ribbon {
  position: absolute;
  left: 50%;
  bottom: -22%;
  width: 46%;
  height: 52%;
  transform: translateX(-50%);
  background: linear-gradient(180deg, #3d78ff, #1746d1);
  clip-path: polygon(0 0, 100% 0, 100% 100%, 50% 74%, 0 100%);
  filter: drop-shadow(0 8px 12px rgba(4, 16, 70, 0.35));
}

#results-screen .rs-medal__disc {
  position: relative;
  display: grid;
  place-items: center;
  width: 82%;
  aspect-ratio: 1;
  border-radius: 50%;
  background: radial-gradient(circle at 34% 28%, #fff3bd 0%, #ffcf4a 38%, #f0a40c 72%, #d98a00 100%);
  box-shadow:
    0 0 0 7px rgba(255, 221, 120, 0.55),
    0 0 46px rgba(255, 199, 64, 0.6),
    inset 0 -10px 18px rgba(170, 100, 0, 0.35),
    inset 0 6px 12px rgba(255, 255, 255, 0.6);
  color: #fff7d6;
}

#results-screen .rs-medal__disc lucide-icon {
  width: 46%;
  height: 46%;
  filter: drop-shadow(0 3px 4px rgba(150, 90, 0, 0.5));
}

/* confetti */
#results-screen .rs-confetti i {
  position: absolute;
  z-index: 1;
  width: 10px;
  height: 18px;
  border-radius: 3px;
  background: var(--rs-gold);
  opacity: 0.9;
}

#results-screen .rs-confetti i:nth-child(1) { top: 12%; left: 4%; transform: rotate(24deg); background: #5c8dff; }
#results-screen .rs-confetti i:nth-child(2) { top: 62%; left: 9%; transform: rotate(-32deg); }
#results-screen .rs-confetti i:nth-child(3) { top: 20%; left: 30%; width: 8px; height: 8px; border-radius: 50%; background: #ffe08a; }
#results-screen .rs-confetti i:nth-child(4) { top: 70%; left: 33%; transform: rotate(58deg); background: #ff8b6b; width: 8px; height: 14px; }
#results-screen .rs-confetti i:nth-child(5) { top: 10%; right: 26%; transform: rotate(-18deg); }
#results-screen .rs-confetti i:nth-child(6) { top: 58%; right: 30%; transform: rotate(40deg); background: #5c8dff; width: 8px; height: 14px; }
#results-screen .rs-confetti i:nth-child(7) { top: 8%; right: 3%; transform: rotate(52deg); background: #ffe08a; }
#results-screen .rs-confetti i:nth-child(8) { top: 44%; right: 1.5%; transform: rotate(-40deg); }

/* ---------- stats ---------- */
#results-screen .rs-figures {
  position: relative;
  z-index: 3;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: clamp(0.7rem, 1.4vw, 1.1rem);
  margin: -2.2rem clamp(0.9rem, 2.6vw, 2rem) 0;
  padding: clamp(0.9rem, 2vw, 1.5rem);
  border: 1px solid var(--rs-line);
  border-radius: 24px;
  background: #ffffff;
  box-shadow: 0 18px 40px rgba(31, 72, 150, 0.1);
}

#results-screen .rs-figure {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  min-width: 0;
  padding: clamp(0.8rem, 1.6vw, 1.15rem);
  border: 1px solid var(--rs-line);
  border-radius: 18px;
  background: linear-gradient(180deg, #ffffff, #f7faff);
}

#results-screen .rs-figure__icon {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: clamp(46px, 5vw, 62px);
  aspect-ratio: 1;
  border-radius: 50%;
  background: #e6efff;
  color: var(--rs-blue);
}

#results-screen .rs-figure__icon lucide-icon {
  width: 52%;
  height: 52%;
}

#results-screen .rs-figure--accuracy .rs-figure__icon { background: #f1e7ff; color: #8b3cf0; }
#results-screen .rs-figure--ge .rs-figure__icon { background: #dff7ee; color: #12a37a; }
#results-screen .rs-figure--xp .rs-figure__icon { background: #ffeadf; color: #f06a1d; }
#results-screen .rs-figure--streak .rs-figure__icon { background: #fff1d8; color: #f29a0b; }

#results-screen .rs-figure__text {
  flex: 1 1 auto;
  min-width: 0;
}

#results-screen .rs-figure__text span {
  display: block;
  color: var(--rs-ink);
  font-size: 0.92rem;
  font-weight: 700;
}

#results-screen .rs-figure__text strong {
  display: block;
  margin-top: 0.1rem;
  color: var(--rs-ink);
  font-size: clamp(1.45rem, 2.6vw, 2rem);
  font-weight: 800;
  line-height: 1.15;
  white-space: nowrap;
}

#results-screen .rs-bars {
  flex: 0 0 auto;
  display: flex;
  align-items: flex-end;
  gap: 5px;
  height: 44px;
}

#results-screen .rs-bars i {
  width: 9px;
  border-radius: 4px;
  background: #c9dcfb;
}

#results-screen .rs-bars i:nth-child(1) { height: 22%; }
#results-screen .rs-bars i:nth-child(2) { height: 46%; }
#results-screen .rs-bars i:nth-child(3) { height: 72%; }
#results-screen .rs-bars i:nth-child(4) { height: 100%; }

#results-screen .rs-ring {
  --rs-pct: 0;
  flex: 0 0 auto;
  width: 54px;
  aspect-ratio: 1;
  border-radius: 50%;
  background: conic-gradient(#a855f7 calc(var(--rs-pct) * 1%), #ece3fb 0);
  -webkit-mask: radial-gradient(circle, transparent 54%, #000 56%);
  mask: radial-gradient(circle, transparent 54%, #000 56%);
}

#results-screen .rs-figure__art {
  flex: 0 0 auto;
  width: 52px;
  height: 52px;
  object-fit: contain;
}

#results-screen .rs-xp-mark {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: 52px;
  aspect-ratio: 1;
  border-radius: 50%;
  background: radial-gradient(circle at 34% 28%, #ffd27a, #f58a12 70%);
  box-shadow: inset 0 -5px 8px rgba(160, 70, 0, 0.3), 0 6px 14px rgba(245, 138, 18, 0.3);
  color: #fff6e0;
  font-weight: 800;
  font-size: 1rem;
}

#results-screen .rs-flame {
  flex: 0 0 auto;
  width: 48px;
  aspect-ratio: 1;
  color: #ffd9c2;
}

#results-screen .rs-flame lucide-icon {
  width: 100%;
  height: 100%;
}

/* ---------- rank ---------- */
#results-screen .rs-rank {
  position: relative;
  display: flex;
  align-items: center;
  gap: clamp(1rem, 2.6vw, 2rem);
  margin: clamp(0.9rem, 2vw, 1.4rem) clamp(0.9rem, 2.6vw, 2rem) 0;
  padding: clamp(1rem, 2.2vw, 1.5rem) clamp(1rem, 2.6vw, 2rem);
  border: 1px solid #cfe0fb;
  border-radius: 24px;
  background: linear-gradient(120deg, #eaf2ff 0%, #f6faff 60%, #e3eefe 100%);
  overflow: hidden;
}

#results-screen .rs-rank__emblem {
  position: relative;
  z-index: 1;
  flex: 0 0 auto;
  width: clamp(92px, 12vw, 150px);
  height: auto;
  aspect-ratio: 1;
  object-fit: contain;
}

#results-screen .rs-rank__body {
  position: relative;
  z-index: 1;
  flex: 1 1 auto;
  min-width: 0;
}

#results-screen .rs-rank h3 {
  margin: 0;
  color: var(--rs-ink);
  font-size: clamp(1.5rem, 3vw, 2.2rem);
  font-weight: 800;
  line-height: 1.15;
}

#results-screen #result-rank-copy {
  margin: 0.3rem 0 0.9rem;
  max-width: 46ch;
  color: var(--rs-muted);
  font-size: clamp(0.92rem, 1.5vw, 1.05rem);
  line-height: 1.45;
}

#results-screen .rs-progress {
  height: 14px;
  border-radius: 999px;
  background: #d5dfef;
  box-shadow: inset 0 1px 2px rgba(15, 27, 61, 0.12);
  overflow: hidden;
}

#results-screen .rs-progress__fill {
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #0b43e0, #3b82f6);
  transition: width 0.6s ease;
}

#results-screen .rs-rank__meta {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 0.6rem;
  color: var(--rs-ink);
  font-weight: 700;
  font-size: 0.98rem;
}

#results-screen .rs-rank__next {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  color: #2f6fe0;
  font-weight: 600;
  white-space: nowrap;
}

#results-screen .rs-rank__next lucide-icon {
  width: 1.1em;
  height: 1.1em;
}

#results-screen .rs-rank__level {
  position: absolute;
  z-index: 2;
  top: 1rem;
  right: 1.2rem;
  padding: 0.35rem 0.9rem;
  border-radius: 999px;
  background: #cfe6fb;
  color: #1576c7;
  font-weight: 700;
  font-size: 0.92rem;
}

#results-screen .rs-rank__peak {
  position: absolute;
  right: 3%;
  bottom: 30%;
  width: clamp(150px, 26vw, 330px);
  height: auto;
  opacity: 0.85;
  pointer-events: none;
}

/* ---------- actions ---------- */
#results-screen .rs-actions {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(0, 1fr);
  gap: clamp(0.6rem, 1.4vw, 1rem);
  margin: clamp(0.9rem, 2vw, 1.4rem) clamp(0.9rem, 2.6vw, 2rem) 0;
}

#results-screen .rs-act {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  min-height: 60px;
  padding: 0.8rem 1.2rem;
  border: 1.5px solid #cfdcf3;
  border-radius: 999px;
  background: #ffffff;
  box-shadow: 0 8px 20px rgba(31, 72, 150, 0.08);
  color: #1d55e8;
  font: inherit;
  font-size: clamp(0.98rem, 1.5vw, 1.12rem);
  font-weight: 700;
  line-height: 1.2;
  text-decoration: none;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease, background-color 0.15s ease;
}

#results-screen .rs-act lucide-icon {
  flex: 0 0 auto;
  width: 1.25em;
  height: 1.25em;
}

#results-screen .rs-act:hover {
  transform: translateY(-1px);
  box-shadow: 0 12px 26px rgba(31, 72, 150, 0.14);
}

#results-screen .rs-act:focus-visible {
  outline: 3px solid #93b4ff;
  outline-offset: 3px;
}

/* The main action is filled: Play Next Level when the level was passed,
   otherwise Return Home. */
#results-screen .rs-act--next,
#results-screen .rs-shell:not(.is-passed) .rs-act--home,
#results-screen .rs-act--login {
  border-color: transparent;
  background: linear-gradient(180deg, #2f6dff, #0b43e0);
  box-shadow: 0 14px 30px rgba(11, 67, 224, 0.32);
  color: #ffffff;
}

#results-screen .rs-act--next:hover,
#results-screen .rs-shell:not(.is-passed) .rs-act--home:hover,
#results-screen .rs-act--login:hover {
  box-shadow: 0 18px 36px rgba(11, 67, 224, 0.4);
}

/* ---------- account ---------- */
#results-screen .rs-account {
  display: flex;
  align-items: center;
  gap: clamp(0.8rem, 2vw, 1.4rem);
  margin: clamp(0.9rem, 2vw, 1.4rem) clamp(0.9rem, 2.6vw, 2rem) clamp(1rem, 2.4vw, 1.8rem);
  padding: clamp(0.9rem, 2vw, 1.3rem) clamp(1rem, 2.4vw, 1.6rem);
  border: 1px solid var(--rs-line);
  border-radius: 22px;
  background: #ffffff;
}

#results-screen .rs-account__icon {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: 58px;
  aspect-ratio: 1;
  border-radius: 50%;
  background: #eef4ff;
  color: #1d55e8;
}

#results-screen .rs-account__icon lucide-icon {
  width: 54%;
  height: 54%;
}

#results-screen .rs-account__text {
  flex: 1 1 auto;
  min-width: 0;
}

#results-screen .rs-account__title {
  margin: 0 0 0.3rem;
  color: var(--rs-ink);
  font-size: 1.08rem;
  font-weight: 800;
}

#results-screen .rs-account__note {
  margin: 0;
  color: var(--rs-muted);
  font-size: 0.95rem;
  line-height: 1.55;
}

#results-screen .rs-act--login {
  flex: 0 0 auto;
  min-height: 54px;
  border-radius: 14px;
  padding-inline: 1.5rem;
}

#results-screen .rs-act--login[hidden] {
  display: none;
}

/* ---------- tablet ---------- */
@media (max-width: 980px) {
  #results-screen .rs-medal {
    display: none;
  }

  #results-screen .rs-top {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  #results-screen .rs-top__copy {
    text-align: left;
  }

  #results-screen #result-summary-copy {
    margin: 0;
  }

  #results-screen .rs-figures {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  /* On two columns the rewards sit above the time, as in the phone layout. */
  #results-screen .rs-figure--ge { order: 3; }
  #results-screen .rs-figure--xp { order: 4; }
  #results-screen .rs-figure--time { order: 5; }
  #results-screen .rs-figure--streak { order: 6; }
}

/* ---------- phone ---------- */
@media (max-width: 640px) {
  #results-screen .rs-shell {
    border-radius: 22px;
  }

  #results-screen .rs-top {
    min-height: 0;
    gap: 0.4rem;
    padding: 1.2rem 1rem 3.2rem;
  }

  #results-screen .rs-top h2 em {
    display: block;
  }

  #results-screen .rs-top h2 {
    font-size: clamp(1.9rem, 9.5vw, 2.6rem);
  }

  #results-screen #result-summary-copy {
    font-size: 0.9rem;
  }

  #results-screen .rs-mascot {
    width: clamp(112px, 34vw, 160px);
    margin-right: -0.6rem;
    margin-bottom: -3.2rem;
  }

  #results-screen .rs-kicker {
    font-size: 0.82rem;
    padding: 0.45rem 0.85rem;
  }

  #results-screen .rs-figures {
    margin: -2rem 0.6rem 0;
    padding: 0.6rem;
    gap: 0.55rem;
    border-radius: 20px;
  }

  #results-screen .rs-figure {
    gap: 0.55rem;
    padding: 0.7rem 0.6rem;
    border-radius: 16px;
  }

  #results-screen .rs-figure__icon {
    width: 40px;
  }

  #results-screen .rs-figure__text span {
    font-size: 0.8rem;
  }

  #results-screen .rs-figure__text strong {
    font-size: 1.3rem;
  }

  #results-screen .rs-bars {
    height: 30px;
    gap: 3px;
  }

  #results-screen .rs-bars i {
    width: 6px;
  }

  #results-screen .rs-ring,
  #results-screen .rs-xp-mark,
  #results-screen .rs-figure__art,
  #results-screen .rs-flame {
    width: 36px;
    height: 36px;
  }

  #results-screen .rs-xp-mark {
    font-size: 0.78rem;
  }

  #results-screen .rs-rank,
  #results-screen .rs-actions,
  #results-screen .rs-account {
    margin-inline: 0.6rem;
  }

  #results-screen .rs-rank {
    gap: 0.8rem;
    padding: 1rem 0.9rem;
    border-radius: 20px;
  }

  #results-screen .rs-rank__emblem {
    width: 84px;
  }

  #results-screen #result-rank-copy {
    margin-bottom: 0.7rem;
    padding-right: 0;
  }

  #results-screen .rs-rank h3 {
    padding-right: 5.2rem;
  }

  #results-screen .rs-rank__peak {
    width: 120px;
    right: 2%;
    bottom: 34%;
    opacity: 0.6;
  }

  #results-screen .rs-rank__meta {
    font-size: 0.86rem;
  }

  #results-screen .rs-rank__level {
    top: 0.8rem;
    right: 0.8rem;
    font-size: 0.8rem;
  }

  /* Main action on its own row, the others side by side beneath it. */
  #results-screen .rs-actions {
    grid-auto-flow: row;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  #results-screen .rs-act {
    min-height: 54px;
    padding: 0.7rem 0.6rem;
    gap: 0.4rem;
    font-size: 0.95rem;
  }

  #results-screen .rs-act--next,
  #results-screen .rs-shell:not(.is-passed) .rs-act--home {
    order: -1;
    grid-column: 1 / -1;
  }

  #results-screen .rs-shell.is-passed .rs-act--home {
    grid-column: 1 / -1;
  }

  #results-screen .rs-account {
    flex-wrap: wrap;
    border-radius: 18px;
  }

  #results-screen .rs-account__icon {
    width: 44px;
  }

  #results-screen .rs-account__text {
    flex: 1 1 60%;
  }

  #results-screen .rs-act--login {
    flex: 1 1 100%;
  }
}

@media (max-width: 360px) {
  #results-screen .rs-figure__icon {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  #results-screen .rs-act,
  #results-screen .rs-progress__fill {
    transition: none;
  }
}

/* ---------- guards against the site's shared rules ---------- */
/* The shared stylesheets set a text size where a font name is expected, which
   drops body text to a serif face. The result screen names its fonts itself. */
#results-screen .rs-shell,
#results-screen .rs-shell :where(p, span, strong, small, em, a, button) {
  font-family: "Inter", "Segoe UI", Roboto, Arial, sans-serif;
}

#results-screen .rs-shell :where(h2, h3),
#results-screen .rs-figure__text strong,
#results-screen .rs-act,
#results-screen .rs-kicker,
#results-screen .rs-account__title {
  font-family: "Manrope", "Inter", "Segoe UI", Roboto, Arial, sans-serif;
}

/* Confetti is decoration laid over the banner, not a column in its layout. */
#results-screen .rs-confetti {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

/* An older rule draws a divider above this paragraph by its id. */
#results-screen #result-account-note.rs-account__note {
  margin: 0;
  padding: 0;
  border: 0;
  color: var(--rs-muted);
  font-size: 0.95rem;
  font-weight: 400;
  line-height: 1.55;
  text-align: left;
}

#results-screen .rs-rank__peak {
  bottom: 42%;
  width: clamp(130px, 22vw, 280px);
  opacity: 0.7;
}

@media (max-width: 640px) {
  #results-screen .rs-rank__peak {
    width: 96px;
    bottom: 46%;
    opacity: 0.45;
  }

  #results-screen #result-account-note.rs-account__note {
    font-size: 0.88rem;
  }
}

/* ---------- buttons: older id rules ---------- */
/* An older rule hid Play Next Level on this screen for everyone and always
   filled Return Home. Here the next level is offered once the level is passed
   (25% correct), and whichever button is the main action is the filled one. */
#results-screen .rs-shell.is-passed #next-level-btn {
  display: inline-flex;
}

#results-screen .rs-shell:not(.is-passed) #next-level-btn {
  display: none;
}

#results-screen .rs-shell.is-passed #back-to-home-btn {
  border-color: #cfdcf3;
  background: #ffffff;
  box-shadow: 0 8px 20px rgba(31, 72, 150, 0.08);
  color: #1d55e8;
}

#results-screen .rs-shell:not(.is-passed) #back-to-home-btn,
#results-screen .rs-shell.is-passed #next-level-btn {
  border-color: transparent;
  background: linear-gradient(180deg, #2f6dff, #0b43e0);
  box-shadow: 0 14px 30px rgba(11, 67, 224, 0.32);
  color: #ffffff;
}

/* ---------- phone refinements ---------- */
@media (max-width: 640px) {
  #results-screen .rs-top {
    align-items: end;
  }

  #results-screen .rs-top__copy {
    align-self: center;
  }

  #results-screen .rs-mascot {
    width: clamp(118px, 36vw, 170px);
    margin-right: 0;
  }

  #results-screen .rs-figure {
    gap: 0.4rem;
    padding: 0.65rem 0.5rem;
  }

  #results-screen .rs-figure__icon {
    width: 34px;
  }

  #results-screen .rs-figure__text span {
    font-size: 0.74rem;
    white-space: nowrap;
  }

  #results-screen .rs-figure__text strong {
    font-size: 1.18rem;
  }

  #results-screen .rs-ring,
  #results-screen .rs-xp-mark,
  #results-screen .rs-figure__art,
  #results-screen .rs-flame {
    width: 28px;
    height: 28px;
  }

  #results-screen .rs-xp-mark {
    font-size: 0.62rem;
  }

  #results-screen .rs-bars {
    height: 24px;
    gap: 2px;
  }

  #results-screen .rs-bars i {
    width: 5px;
  }
}

/* Very narrow phones: the small decorations give way to the numbers. */
@media (max-width: 374px) {
  #results-screen .rs-figure__icon {
    display: grid;
  }

  #results-screen .rs-bars,
  #results-screen .rs-ring,
  #results-screen .rs-xp-mark,
  #results-screen .rs-figure__art,
  #results-screen .rs-flame {
    display: none;
  }
}

/* ---------- final sizing ---------- */
#results-screen .rs-top h2 small {
  font-size: clamp(0.84rem, 0.36em, 1.05rem);
  line-height: 1.4;
}

@media (min-width: 641px) and (max-width: 980px) {
  #results-screen .rs-mascot {
    width: clamp(170px, 26vw, 220px);
  }
}

/* =====================================================================
   Rank badges (Spark, Core, Apex, Prime crests) and the guest warning.
   ===================================================================== */

/* ---------- badge on the result screen ---------- */
/* The crests are taller than they are wide and carry their own name, so the
   badge keeps its shape instead of being forced into a square. */
#results-screen .rs-rank__emblem {
  width: clamp(88px, 10.5vw, 132px);
  height: auto;
  aspect-ratio: auto;
  max-height: 200px;
  object-fit: contain;
  filter: drop-shadow(0 10px 18px rgba(21, 87, 245, 0.28));
  animation: rk-float 4.6s ease-in-out infinite;
  transform-origin: 50% 70%;
}

/* Played each time a result is shown (the script re-adds the class). */
#results-screen .rs-rank__emblem.is-arriving {
  animation: rk-arrive 900ms cubic-bezier(.2, .8, .2, 1) both, rk-float 4.6s ease-in-out 900ms infinite;
}

@keyframes rk-arrive {
  0% { opacity: 0; transform: translateY(18px) scale(.55) rotate(-10deg); filter: drop-shadow(0 0 0 rgba(120, 190, 255, 0)) brightness(1.6); }
  55% { opacity: 1; transform: translateY(-4px) scale(1.1) rotate(2deg); filter: drop-shadow(0 0 30px rgba(120, 190, 255, .95)) brightness(1.25); }
  100% { opacity: 1; transform: none; filter: drop-shadow(0 10px 18px rgba(21, 87, 245, .28)) brightness(1); }
}

@keyframes rk-float {
  0%, 100% { transform: translateY(0); filter: drop-shadow(0 10px 18px rgba(21, 87, 245, .28)); }
  50% { transform: translateY(-6px); filter: drop-shadow(0 16px 26px rgba(60, 140, 255, .5)); }
}

@media (max-width: 640px) {
  #results-screen .rs-rank__emblem { width: 76px; }
}

/* ---------- rank-up popup: the old badge gives way to the new one ---------- */
#rankup-modal .rankup-modal-content {
  background:
    radial-gradient(circle at 50% 38%, rgba(90, 150, 255, 0.3), transparent 46%),
    linear-gradient(180deg, #ffffff 0%, #eef4ff 100%);
  text-align: center;
}

/* The shared stylesheets drop this popup to a serif face; it names its own. */
#rankup-modal .rankup-modal-content,
#rankup-modal .rankup-modal-content :where(p, span, strong) {
  font-family: "Inter", "Segoe UI", Roboto, Arial, sans-serif;
}

#rankup-modal .rankup-modal-content :where(h2, .hero-kicker, .rankup-track span) {
  font-family: "Manrope", "Inter", "Segoe UI", Roboto, Arial, sans-serif;
  font-weight: 800;
}

#rankup-modal .rk-stage {
  position: relative;
  display: grid;
  place-items: center;
  width: min(100%, 260px);
  height: 250px;
  isolation: isolate;
}

#rankup-modal .rk-crest {
  grid-area: 1 / 1;
  width: auto;
  height: 232px;
  max-width: 100%;
  object-fit: contain;
  background: none;
  filter: drop-shadow(0 14px 24px rgba(21, 87, 245, 0.35));
}

/* Rotating light behind the badge. */
#rankup-modal .rk-rays {
  position: absolute;
  inset: -8%;
  z-index: -1;
  border-radius: 50%;
  background: repeating-conic-gradient(from 0deg, rgba(64, 140, 255, 0.34) 0deg 9deg, transparent 9deg 24deg);
  -webkit-mask-image: radial-gradient(closest-side, #000 30%, transparent 78%);
  mask-image: radial-gradient(closest-side, #000 30%, transparent 78%);
  opacity: 0;
}

/* The sequence starts when the popup opens: old badge, flash, new badge. */
#rankup-modal.active .rk-crest--from {
  animation: rk-old-out 1250ms cubic-bezier(.4, 0, .6, 1) both;
}

#rankup-modal.active .rk-crest--to {
  animation: rk-new-in 950ms cubic-bezier(.2, .8, .2, 1) 1050ms both, rk-float 4.6s ease-in-out 2000ms infinite;
}

#rankup-modal.active .rk-rays {
  animation: rk-rays-in 700ms ease-out 1100ms both, rk-rays-turn 16s linear 1100ms infinite;
}

@keyframes rk-old-out {
  0% { opacity: 0; transform: scale(.8); }
  18%, 55% { opacity: 1; transform: none; filter: drop-shadow(0 14px 24px rgba(21, 87, 245, .35)) brightness(1); }
  78% { opacity: 1; transform: scale(1.06); filter: drop-shadow(0 0 34px rgba(255, 255, 255, 1)) brightness(2.2); }
  100% { opacity: 0; transform: scale(.35) rotate(-14deg); filter: brightness(3); }
}

@keyframes rk-new-in {
  0% { opacity: 0; transform: scale(.3) rotate(14deg); filter: drop-shadow(0 0 40px rgba(255, 255, 255, 1)) brightness(3); }
  55% { opacity: 1; transform: scale(1.12) rotate(-2deg); filter: drop-shadow(0 0 36px rgba(120, 190, 255, 1)) brightness(1.3); }
  100% { opacity: 1; transform: none; filter: drop-shadow(0 14px 24px rgba(21, 87, 245, .35)) brightness(1); }
}

@keyframes rk-rays-in { from { opacity: 0; scale: .5; } to { opacity: 1; scale: 1; } }
@keyframes rk-rays-turn { to { rotate: 360deg; } }

@media (max-height: 700px) {
  #rankup-modal .rk-stage { height: 190px; }
  #rankup-modal .rk-crest { height: 176px; }
}

/* ---------- guest warning ---------- */
/* Shown to guests only (the script hides it for signed-in learners). It is a
   warning, so it is red: the GE on this screen is not being kept. */
#results-screen .rs-account[hidden] { display: none; }

#results-screen .rs-account--alert {
  position: relative;
  border: 1px solid #f3a9b4;
  border-left: 6px solid #e11d48;
  background: linear-gradient(120deg, #fff0f2 0%, #fff7f8 100%);
  box-shadow: 0 10px 26px rgba(225, 29, 72, 0.14);
  animation: rs-alert-in 420ms cubic-bezier(.2, .7, .25, 1) 500ms both;
}

#results-screen .rs-account--alert .rs-account__icon {
  background: #ffdfe4;
  color: #e11d48;
  animation: rs-alert-beat 1.8s ease-in-out 1s 3;
}

#results-screen .rs-account--alert .rs-account__title { color: #be123c; }
#results-screen .rs-account--alert #result-account-note.rs-account__note { color: #7f1d2d; }

#results-screen .rs-account--alert .rs-act--login {
  border-color: transparent;
  background: linear-gradient(180deg, #f43f5e 0%, #be123c 100%);
  box-shadow: 0 12px 24px rgba(225, 29, 72, 0.32);
  color: #ffffff;
}

@keyframes rs-alert-in {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}

@keyframes rs-alert-beat {
  0%, 100% { transform: none; box-shadow: 0 0 0 0 rgba(225, 29, 72, 0); }
  40% { transform: scale(1.1); box-shadow: 0 0 0 8px rgba(225, 29, 72, .16); }
}

@media (prefers-reduced-motion: reduce) {
  #results-screen .rs-rank__emblem,
  #results-screen .rs-rank__emblem.is-arriving,
  #rankup-modal.active .rk-crest--to,
  #rankup-modal.active .rk-rays,
  #results-screen .rs-account--alert,
  #results-screen .rs-account--alert .rs-account__icon {
    animation: none;
  }

  #rankup-modal.active .rk-crest--from { animation: none; opacity: 0; }
  #rankup-modal .rk-rays { opacity: 1; }
}

/* ---------- rank card finish ---------- */
/* A soft plate of light under the badge seats it in the card, and the card is
   only as tall as the badge needs. */
#results-screen .rs-rank {
  padding-block: clamp(0.7rem, 1.6vw, 1.1rem);
  background:
    radial-gradient(circle at clamp(70px, 9vw, 120px) 50%, rgba(120, 175, 255, 0.4), transparent clamp(110px, 15vw, 190px)),
    linear-gradient(120deg, #eaf2ff 0%, #f6faff 60%, #e3eefe 100%);
}

#results-screen .rs-rank__body { align-self: center; }
#results-screen .rs-rank__meta { margin-top: 0.7rem; }

/* On phones the level chip sits on the title line, clear of the text below it. */
@media (max-width: 640px) {
  #results-screen .rs-rank__level {
    top: 0.75rem;
    right: 0.75rem;
    padding: 0.2rem 0.7rem;
    font-size: 0.74rem;
  }

  #results-screen .rs-rank h3 { padding-right: 4.6rem; font-size: 1.35rem; }
  #results-screen #result-rank-copy { margin-top: 0.5rem; }
}
