/* Shared quiz controls with colors specific to the pending action. */
#mathQuizOverlay {
  --quiz-top:#65dcff; --quiz-middle:#65ffe0; --quiz-bottom:#c4ff64;
  --quiz-dark:#004eab; --quiz-button:#a5ff22; --quiz-panel:#03b5ff;
  box-sizing:border-box; width:100%;height:100%;max-width:none;max-height:none;
  margin:0;border:0;color:#fff;
  background:rgba(20,28,35,.25);backdrop-filter:blur(3px);
}
#mathQuizOverlay:not([open]) { display:none; }
/* Keep the original quiz layout, with a small action badge in its corner. */
#mathQuizOverlay {--quiz-icon:url('../assets/icons/gameplay-ai/growing-eggs-menu.webp');}
#mathQuizOverlay .math-quiz-modal::after {
  content:"";position:absolute;top:19px;left:20px;z-index:2;
  width:62px;height:62px;box-sizing:border-box;
  border:2px solid #526e60;border-radius:19px;transform:rotate(-7deg);
  background:var(--quiz-icon) center/82% 82% no-repeat,linear-gradient(145deg,#fffdf1,#f5ffe4);
  box-shadow:inset 0 3px 0 white,0 4px 0 #23583a33;pointer-events:none;
}
#mathQuizOverlay[data-quiz-mode="forest"] {--quiz-icon:url('../assets/icons/gameplay-ai/quiz-forest-ai.webp');}
#mathQuizOverlay[data-quiz-mode="chest"] {--quiz-icon:url('../assets/icons/gameplay-ai/quiz-coin-chest-ai.webp');}
#mathQuizOverlay[data-quiz-mode="sell"] {--quiz-icon:url('../assets/icons/gameplay-ai/coins-roblox-vector.webp');}
#mathQuizOverlay:is([data-quiz-mode="training"],[data-quiz-mode="treadmill"],[data-quiz-mode="treadmillUpgrade"]) {--quiz-icon:url('../assets/icons/treadmills/diamond.webp');}
#mathQuizOverlay[data-quiz-mode="penUpgrade"] {--quiz-icon:url('../assets/icons/pen-assistance/upgrade.webp');}
#mathQuizOverlay:is([data-quiz-mode="skin"],[data-quiz-mode="skinColor"]) {--quiz-icon:url('../assets/icons/gameplay-ai/character-button-straw-hat-ai.webp');}
#mathQuizOverlay[data-quiz-mode="trail"] {--quiz-icon:url('../assets/icons/trails-runner-button.png');}
html.has-touch-controls #mathQuizOverlay .math-quiz-modal::after {width:40px;height:40px;top:12px;left:12px;border-radius:12px;}
@media (orientation:landscape) and (max-height:600px) {
  html.has-touch-controls #mathQuizOverlay .math-quiz-modal::after {width:28px;height:28px;top:7px;left:8px;border-radius:9px;}
}
#mathQuizOverlay::backdrop { background:transparent; }
#mathQuizOverlay .math-quiz-modal {
  box-sizing:border-box;width:min(620px,calc(100vw - 28px));padding:24px 26px 22px;
  background:radial-gradient(circle at 15% 18%,rgba(255,255,255,.55),transparent 16%),
    repeating-linear-gradient(-24deg,rgba(255,255,255,.14) 0 10px,transparent 10px 24px),
    linear-gradient(150deg,var(--quiz-top) 0%,var(--quiz-middle) 48%,var(--quiz-bottom) 100%);
}
html:not(.has-touch-controls) #mathQuizOverlay .math-quiz-modal h2 {margin-bottom:6px;}
#mathQuizOverlay .math-quiz-modal h2 {transform:translateY(0) scale(.94);transform-origin:center;}
#mathQuizOverlay .math-quiz-kicker {display:none;}
#mathQuizOverlay .math-quiz-progress {
  box-sizing:border-box;width:max-content;max-width:100%;margin-inline:auto;
  align-self:center;justify-self:center;padding:.12em .55em;
  transform:translateY(4px) scale(.9);transform-origin:center;
  border:2px solid #170812;border-radius:10px;line-height:1.15;
  background:linear-gradient(180deg,#fff,var(--quiz-top));
  box-shadow:inset 0 2px 0 rgba(255,255,255,.65),0 3px 0 rgba(23,8,18,.22);
}
html:not(.has-touch-controls) #mathQuizOverlay .math-quiz-question {margin:10px auto;padding-block:12px 10px;}
html:not(.has-touch-controls) #mathQuizOverlay .math-quiz-feedback {min-height:26px;margin-top:6px;}
html:not(.has-touch-controls) #mathQuizOverlay .math-quiz-dots {margin-top:4px;}
#mathQuizOverlay .math-quiz-kicker::before {
  content:"";
  position:absolute;
  inset:-.2em -.9em;
  z-index:-1;
  border:2px solid #07162f;
  border-radius:999px;
  background:linear-gradient(180deg,#fff,var(--quiz-top) 58%,var(--quiz-middle));
  box-shadow:inset 0 2px 0 rgba(255,255,255,.52),0 2px 0 rgba(7,22,47,.2);
  pointer-events:none;
}
#mathQuizOverlay .math-quiz-close { background:linear-gradient(145deg,#ff6868,#e52236); }
#mathQuizOverlay .math-quiz-question { background:linear-gradient(180deg,#ffffff,color-mix(in srgb,var(--quiz-top) 30%,white)); }
#mathQuizOverlay .math-quiz-form button { background:linear-gradient(180deg,var(--quiz-button),var(--quiz-panel)); }
#mathQuizOverlay .math-quiz-keypad button { background:linear-gradient(180deg,#fff,var(--quiz-top)); }
#mathQuizOverlay .math-quiz-dots span.done { background:var(--quiz-button); }
:where(html.has-touch-controls) #mathQuizOverlay .math-quiz-keypad { display:grid;grid-template-columns:repeat(3,minmax(0,1fr)); }
.quiz-confetti {
  position: fixed;
  z-index: 120;
  width: var(--confetti-w, 20px);
  height: var(--confetti-h, 34px);
  border: 2px solid rgba(23, 8, 18, 0.42);
  border-radius: 4px;
  pointer-events: none;
  will-change: transform, opacity;
  animation: quiz-confetti-burst var(--confetti-duration, 1900ms) cubic-bezier(0.16, 0.72, 0.24, 1) var(--confetti-delay, 0ms) forwards;
}

@keyframes quiz-confetti-burst {
  0% {
    opacity: 0;
    transform: translate(0, 0) rotate(0deg) scale(0.62);
  }
  12% {
    opacity: 1;
    transform: translate(var(--confetti-pop-x), var(--confetti-pop-y)) rotate(var(--confetti-pop-rot)) scale(var(--confetti-scale, 1));
  }
  64% {
    opacity: 1;
    transform: translate(var(--confetti-float-x), var(--confetti-float-y)) rotate(var(--confetti-mid-rot)) scale(var(--confetti-scale, 1));
  }
  100% {
    opacity: 0;
    transform: translate(var(--confetti-x), var(--confetti-y)) rotate(var(--confetti-rot)) scale(0.72);
  }
}

#mathQuizOverlay .math-quiz-feedback.bad {color:#ff404e;-webkit-text-fill-color:#ff404e;-webkit-text-stroke:3px #111;paint-order:stroke fill;}

#mathQuizOverlay .math-quiz-answer-field.is-wrong::after {color:#ff404e;-webkit-text-fill-color:#ff404e;}

/* Distinct bright hues keep the gradient visible while matching each action. */
#mathQuizOverlay[data-quiz-mode="forest"] {--quiz-top:#e6ff70;--quiz-middle:#77ff8c;--quiz-bottom:#28e9c5;--quiz-button:#edff79;--quiz-panel:#32e895;}
#mathQuizOverlay:is([data-quiz-mode="chest"],[data-quiz-mode="sell"]) {--quiz-top:#fff88a;--quiz-middle:#ffce43;--quiz-bottom:#ff884d;--quiz-button:#fff49a;--quiz-panel:#ffad32;}
#mathQuizOverlay:is([data-quiz-mode="training"],[data-quiz-mode="treadmill"],[data-quiz-mode="treadmillUpgrade"]) {--quiz-top:#82fff0;--quiz-middle:#55d9ff;--quiz-bottom:#8d9aff;--quiz-button:#adffed;--quiz-panel:#39bcff;}
#mathQuizOverlay[data-quiz-mode="penUpgrade"] {--quiz-top:#d7ff79;--quiz-middle:#6dffd0;--quiz-bottom:#43dfff;--quiz-button:#e1ff89;--quiz-panel:#35e7ba;}
#mathQuizOverlay:is([data-quiz-mode="skin"],[data-quiz-mode="skinColor"],[data-quiz-mode="trail"]) {--quiz-top:#ffc0f1;--quiz-middle:#d99aff;--quiz-bottom:#86c6ff;--quiz-button:#ffdaf6;--quiz-panel:#be83ff;}
#mathQuizOverlay:is([data-quiz-mode="hatch"],[data-quiz-mode="stickers"]) {--quiz-top:#fff495;--quiz-middle:#ffb68d;--quiz-bottom:#ff85d6;--quiz-button:#fff6aa;--quiz-panel:#ffac68;}
