.hm-challenge-actions, .hm-challenge-settings {
    display: flex;
    flex-wrap: wrap;
    align-items: end;
    gap: .5rem;
}
.hm-challenge-settings { margin: .65rem 0 .25rem; }
.hm-challenge-settings label { display: grid; gap: .2rem; font-size: .86rem; flex: 1 1 10rem; }
.hm-challenge-settings label:last-of-type { flex: 0 1 5rem; }
.hm-challenge-scopes { margin: .35rem 0; padding-left: 1.2rem; }
.hm-challenge-scopes .btn { min-height: 0; }
.hm-challenge-report { margin-bottom: 1rem; padding: .8rem; border: 1px solid #d3dfea; border-radius: .65rem; background: #fff; color: #18243a; }
.hm-challenge-report h4 { margin: 0 0 .4rem; font-size: 1.08rem; }
.hm-challenge-report p { margin: 0 0 .5rem; font-size: .85rem; }
.hm-challenge-report-header { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .4rem 1rem; margin-bottom: .55rem; }
.hm-challenge-report-header p { margin: 0; }
.hm-challenge-table { overflow-x: auto; }
.hm-challenge-table table { width: 100%; border-collapse: collapse; }
.hm-challenge-table th, .hm-challenge-table td { padding: .25rem .38rem; border-bottom: 1px solid #e5eaf1; text-align: center; white-space: nowrap; }
.hm-challenge-table th:first-child { text-align: left; }
.hm-challenge-cell { display: inline-grid; gap: 0; width: 100%; min-width: 3rem; padding: .1rem .2rem; border-radius: .4rem; border: 2px solid transparent; color: #172138; background: #eef0f5; }
.hm-challenge-cell small { font-size: .7rem; }
.hm-challenge-cell.correct { background: #c7f2d6; }
.hm-challenge-cell.incorrect { background: #ffdad9; }
.hm-challenge-cell.timeout { background: #eef0f5; }
.hm-challenge-cell.win { border-color: #087536; }
.hm-challenge-cell.loss { border-color: #bd283a; }
.hm-challenge-cell.tie { border-color: #786241; }
.hm-challenge-detail { margin-bottom: .65rem; padding: .65rem; border-left: .24rem solid #eab308; background: #f9f5e9; }
.hm-challenge-detail p:last-child { margin-bottom: 0; }
.hm-challenge-report .hm-challenge-winners { margin-top: .55rem; }

.hm-challenge-student { z-index: 2147483000; overscroll-behavior: contain; }
.hm-challenge-arena { max-width: 72rem; min-height: 100%; margin: auto; padding: max(1rem, env(safe-area-inset-top)) max(1rem, env(safe-area-inset-right)) max(1rem, env(safe-area-inset-bottom)) max(1rem, env(safe-area-inset-left)); }
.hm-challenge-main { max-width: 58rem; margin: 0 auto; padding: clamp(1rem, 5vh, 4rem) 0 2rem; text-align: center; }
.hm-challenge-main h1 { margin: .2rem 0 .7rem; font-size: clamp(1.6rem, 5.2vw, 3.6rem); font-weight: 900; }
.hm-challenge-main h2 { margin: 0; font-size: clamp(1.25rem, 3.6vw, 2.7rem); font-weight: 800; }
.hm-challenge-main p { margin: .6rem 0 1.1rem; }
.hm-challenge-main .hm-challenge-actions { justify-content: center; margin: .7rem 0; }
.hm-challenge-button { color: #101b2b; background: #f5bf35; border: 1px solid #f5bf35; border-radius: .55rem; padding: .72rem 1.1rem; font-weight: 800; min-height: 44px; }
.hm-challenge-button.secondary { color: #fff; background: #152d46; border-color: #47627d; }
.hm-challenge-button:disabled { opacity: .58; }
.hm-challenge-student button:focus-visible { outline: 3px solid #f8d478; outline-offset: 3px; }
.hm-challenge-choices { display: grid; gap: .7rem; margin: 1.15rem auto 0; max-width: 44rem; text-align: left; }
.hm-challenge-choices button { display: flex; align-items: center; gap: .8rem; text-align: left; }
.hm-challenge-choices button span { color: #f5bf35; flex: 0 0 1.1rem; }
.hm-challenge-prompt { color: #d1deeb; }
.hm-challenge-main .hm-game-mode-options-grid { margin-top: 1rem; }
.hm-challenge-avatar { flex: none; position: relative; display: block; width: 4rem; height: 4rem; object-fit: contain; overflow: hidden; border-radius: .6rem; background: #27435f; }
.hm-challenge-avatar img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }
.hm-challenge-next-option { margin-top: 1rem; }
.hm-challenge-main .hm-game-mode-option.hm-challenge-option-selected { background: #f3c25f; border-color: #d59a25; }
.hm-challenge-main .hm-game-mode-option.hm-challenge-option-correct { background: #baf1ce; border-color: #2d945c; box-shadow: none; }
.hm-challenge-main .hm-game-mode-option.hm-challenge-option-incorrect { background: #f9baba; border-color: #be414a; box-shadow: none; }
.hm-challenge-bounce { animation: hmChallengeBounce .55s ease-in-out; }
.hm-challenge-shake { animation: hmChallengeShake .45s ease-in-out; }
@keyframes hmChallengeBounce {
    0%, 100% { transform: translateY(0); }
    35% { transform: translateY(-12px); }
    65% { transform: translateY(4px); }
}
@keyframes hmChallengeShake {
    0%, 100% { transform: translateX(0); }
    20%, 60% { transform: translateX(-8px); }
    40%, 80% { transform: translateX(8px); }
}
.hm-challenge-contest {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 2.5fr) minmax(0, 1fr);
    gap: clamp(.6rem, 2vw, 1.5rem);
    align-items: start;
    margin: 1rem auto;
}
.hm-challenge-contestant { display: grid; justify-items: center; gap: .5rem; overflow-wrap: anywhere; }
.hm-challenge-round-points { font-size: clamp(2rem, 6vw, 4.5rem); line-height: 1; font-variant-numeric: tabular-nums; }
.hm-challenge-contestant .hm-challenge-avatar { width: min(100%, 10rem); height: auto; aspect-ratio: 4 / 5; }
.hm-challenge-contestant.is-won .hm-challenge-avatar { background: #239963; }
.hm-challenge-contestant.is-lost .hm-challenge-avatar { background: #c84854; }
.hm-challenge-contestant.is-tie .hm-challenge-avatar { background: #d5a13e; }
.hm-challenge-speed-bonus { color: #f8d478; font-size: .85em; font-weight: 800; line-height: 1.2; min-height: 1.2em; }
.hm-challenge-contest-centre { display: grid; gap: .65rem; }
.hm-challenge-contest-centre .hm-challenge-outcome { padding: .7rem .4rem; border-radius: .5rem; font-size: clamp(1.15rem, 3.2vw, 2rem); color: #142033; }
.hm-challenge-outcome.is-won, .hm-challenge-contest-answer.correct { background: #baf1ce; }
.hm-challenge-outcome.is-tie { background: #f3c25f; }
.hm-challenge-outcome.is-lost, .hm-challenge-contest-answer.incorrect { background: #f9baba; }
.hm-challenge-contest-answer.neutral { background: #e3e7ee; }
.hm-challenge-contest-question { font-weight: 800; }
.hm-challenge-contest-answer { padding: .55rem .7rem; border-radius: .4rem; color: #142033; overflow-wrap: anywhere; }
.hm-challenge-contest-answer small { display: block; font-weight: 800; margin-bottom: .2rem; }
.hm-challenge-progress-marker {
    display: inline-grid;
    place-items: center;
    width: 1.25rem;
    height: 1.25rem;
    margin-right: .35rem;
    border-radius: .25rem;
    color: #fff;
    font-size: .8rem;
    font-weight: 800;
}
.hm-challenge-progress-marker.is-chosen { background: #2168b2; }
.hm-challenge-progress-marker.is-answered { background: #087536; }
.hm-challenge-table th > button { border: 0; background: none; color: inherit; font: inherit; }
.hm-challenge-table th[aria-sort] > button { text-decoration: underline; text-underline-offset: .2em; }
.hm-challenge-lobby-players { display: flex; flex-wrap: wrap; gap: .45rem; padding: 0; margin: .5rem 0; list-style: none; }
.hm-challenge-lobby-players li { border: 1px solid currentColor; border-radius: .45rem; padding: .25rem .55rem; font-weight: 650; }
.hm-challenge-main .hm-challenge-prize { color: #f8d478; font-weight: 900; }
.hm-challenge-lobby-choice {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.55fr);
    align-items: center;
    gap: clamp(.7rem, 3vw, 2.5rem);
    max-width: 49rem;
    margin: 1rem auto;
    text-align: left;
}
.hm-challenge-lobby-choice .hm-challenge-avatar, .hm-challenge-lobby-self .hm-challenge-avatar {
    width: min(100%, 17rem);
    height: auto;
    aspect-ratio: 4 / 5;
    justify-self: center;
}
.hm-challenge-lobby-self .hm-challenge-avatar { width: min(48vw, 17rem); margin: 0 auto; }
.hm-challenge-lobby-buttons { display: grid; gap: .6rem; }

.hm-challenge-projector { position: fixed; inset: 0; z-index: 2147483500; overflow: auto; color: #fff; }
.hm-challenge-projector-controls { display: flex; justify-content: end; gap: .5rem; position: absolute; top: .8rem; right: .8rem; z-index: 4; }
.hm-challenge-projector-controls[hidden] { display: none; }
.hm-challenge-projector-controls .hm-game-mode-projector-audio-unlock { position: static; }
.hm-challenge-podium { position: relative; isolation: isolate; max-width: 100%; }
.hm-challenge-podium > div:last-child { display: flex; flex-wrap: wrap; justify-content: center; gap: .8rem; }
.hm-challenge-podium article { flex: 0 1 calc((100% - 1.6rem) / 3); min-width: min(100%, 13rem); overflow-wrap: anywhere; animation: podiumRise .65s cubic-bezier(.19, 1, .22, 1) both; }
.hm-challenge-podium .hm-challenge-avatar { width: min(100%, clamp(7rem, 14vw, 11rem)); height: auto; aspect-ratio: 4 / 5; margin: .55rem auto; }
.hm-challenge-projector .hm-challenge-podium .hm-challenge-avatar { width: min(100%, clamp(8rem, 21vh, 14rem)); }
.hm-challenge-podium > .hm-challenge-fireworks { display: block; position: absolute; inset: -5rem 0 0; z-index: -1; pointer-events: none; }
.hm-challenge-fireworks i {
    position: absolute;
    inset: var(--top, 4%) auto auto var(--left, 14%);
    width: clamp(5rem, 18vw, 17rem);
    aspect-ratio: 1;
    color: var(--spark, #ffd16b);
    border-radius: 50%;
    background:
        radial-gradient(circle at 50% 10%, currentColor 1%, transparent 2.4%),
        radial-gradient(circle at 71% 16%, currentColor 1.3%, transparent 2.7%),
        radial-gradient(circle at 84% 30%, currentColor .8%, transparent 2.3%),
        radial-gradient(circle at 92% 50%, currentColor 1.3%, transparent 2.8%),
        radial-gradient(circle at 83% 68%, currentColor 1.1%, transparent 2.6%),
        radial-gradient(circle at 70% 80%, currentColor .9%, transparent 2.5%),
        radial-gradient(circle at 50% 92%, currentColor 1.3%, transparent 2.9%),
        radial-gradient(circle at 28% 83%, currentColor .9%, transparent 2.3%),
        radial-gradient(circle at 15% 71%, currentColor 1.3%, transparent 2.8%),
        radial-gradient(circle at 7% 51%, currentColor 1%, transparent 2.5%),
        radial-gradient(circle at 16% 29%, currentColor 1.2%, transparent 2.8%),
        radial-gradient(circle at 32% 18%, currentColor .8%, transparent 2.2%),
        radial-gradient(circle at 61% 31%, currentColor .7%, transparent 2%),
        radial-gradient(circle at 36% 65%, currentColor .7%, transparent 2%);
    filter: drop-shadow(0 0 .25rem currentColor);
    animation: hmChallengeFirework 3.6s var(--delay, 0s) ease-out 2 both;
}
.hm-challenge-fireworks i:nth-child(2) { --top: 1%; --left: 66%; --spark: #f4a7f5; --delay: .38s; }
.hm-challenge-fireworks i:nth-child(3) { --top: 48%; --left: 1%; --spark: #6ff6eb; --delay: .8s; }
.hm-challenge-fireworks i:nth-child(4) { --top: 38%; --left: 77%; --spark: #a4baff; --delay: 1.15s; }
@keyframes hmChallengeFirework {
    0% { opacity: 0; transform: translate(-25%, 32%) scale(.08); }
    12% { opacity: 1; }
    45% { opacity: .8; }
    74%, 100% { opacity: 0; transform: translate(-25%, -32%) scale(1); }
}
.avatar-modal-overlay.avatar-modal-variant-challenge-reward { z-index: 2147483647; }
@media (min-width: 1024px) and (hover: hover) and (pointer: fine) {
    .hm-challenge-arena:has(.hm-challenge-contest) { max-width: 104rem; }
    .hm-challenge-main:has(.hm-challenge-contest) { max-width: 95rem; }
    .hm-challenge-contest { font-size: clamp(1.15rem, 1.5vw, 1.65rem); }
    .hm-challenge-contestant .hm-challenge-avatar { width: min(100%, clamp(13rem, 19vw, 23rem)); }
    .hm-challenge-round-points { font-size: clamp(4.5rem, 6.5vw, 7rem); }
    .hm-challenge-contest-centre .hm-challenge-outcome { font-size: clamp(2rem, 3vw, 3.2rem); }
}
@media (max-width: 560px) {
    .hm-challenge-main .hm-game-mode-options-grid { grid-template-columns: 1fr; }
    .hm-challenge-main .hm-game-mode-option { min-height: 3.7rem; }
    .hm-challenge-podium article { flex-basis: 100%; }
    .hm-challenge-contest { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
    .hm-challenge-contest-centre { grid-column: 1 / -1; grid-row: 2; }
    .hm-challenge-contestant .hm-challenge-avatar { width: min(100%, 6rem); }
}
@media (prefers-reduced-motion: reduce) {
    .hm-challenge-podium article, .hm-challenge-student .is-revealing, .hm-challenge-bounce, .hm-challenge-shake { animation: none; }
    .hm-challenge-fireworks i { animation: none; opacity: .7; transform: translate(-25%, -25%); }
}
