@font-face {
  font-family: "QuizLoader";
  src: url("../assets/assets/fonts/Nunito-ExtraBold.ttf") format("truetype");
  font-weight: 800;
  font-display: swap;
}

html,
body {
  margin: 0;
  height: 100%;
  background: #070f33;
}

#quiz-loader {
  position: fixed;
  inset: 0;
  z-index: 2147483000;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background:
    radial-gradient(ellipse 70% 45% at 50% 40%, rgba(64, 120, 255, 0.35), transparent 70%),
    radial-gradient(ellipse 120% 80% at 50% 30%, #1b3c96 0%, #0d1f62 48%, #070f33 100%);
  font-family: "QuizLoader", "Nunito", -apple-system, "Segoe UI", Roboto, sans-serif;
  color: #fff;
  user-select: none;
  -webkit-user-select: none;
  transition: opacity 0.5s ease, transform 0.5s ease;
}

#quiz-loader.ql-done {
  opacity: 0;
  transform: scale(1.04);
  pointer-events: none;
}

.ql-sky,
.ql-sky::after {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.ql-sky::after {
  content: "";
  width: 2px;
  height: 2px;
  border-radius: 50%;
  background: transparent;
  box-shadow:
    8vw 12vh #fff, 22vw 6vh rgba(255,255,255,.7), 37vw 18vh #fff,
    55vw 9vh rgba(255,255,255,.6), 71vw 15vh #fff, 88vw 7vh rgba(255,255,255,.8),
    14vw 30vh rgba(255,255,255,.5), 80vw 33vh rgba(255,255,255,.6),
    93vw 24vh #fff, 4vw 44vh rgba(255,255,255,.5), 63vw 27vh rgba(255,255,255,.5);
  animation: ql-twinkle 3.2s ease-in-out infinite alternate;
}

.ql-snow i {
  position: absolute;
  top: -12px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: radial-gradient(circle, #fff 0%, rgba(255,255,255,.75) 45%, rgba(255,255,255,0) 72%);
  animation: ql-fall linear infinite;
  opacity: 0.85;
}

.ql-snow i:nth-child(1) { left: 6%; animation-duration: 9s; animation-delay: -1s; }
.ql-snow i:nth-child(2) { left: 14%; width: 4px; height: 4px; animation-duration: 12s; animation-delay: -6s; }
.ql-snow i:nth-child(3) { left: 23%; width: 9px; height: 9px; animation-duration: 8s; animation-delay: -3s; }
.ql-snow i:nth-child(4) { left: 31%; animation-duration: 11s; animation-delay: -8s; }
.ql-snow i:nth-child(5) { left: 40%; width: 4px; height: 4px; animation-duration: 13s; animation-delay: -2s; }
.ql-snow i:nth-child(6) { left: 48%; width: 8px; height: 8px; animation-duration: 9.5s; animation-delay: -5s; }
.ql-snow i:nth-child(7) { left: 57%; animation-duration: 10s; animation-delay: -9s; }
.ql-snow i:nth-child(8) { left: 65%; width: 5px; height: 5px; animation-duration: 12.5s; animation-delay: -4s; }
.ql-snow i:nth-child(9) { left: 73%; width: 9px; height: 9px; animation-duration: 8.5s; animation-delay: -7s; }
.ql-snow i:nth-child(10) { left: 81%; animation-duration: 11.5s; animation-delay: -1.5s; }
.ql-snow i:nth-child(11) { left: 89%; width: 4px; height: 4px; animation-duration: 14s; animation-delay: -10s; }
.ql-snow i:nth-child(12) { left: 95%; width: 7px; height: 7px; animation-duration: 9s; animation-delay: -3.5s; }
.ql-snow i:nth-child(13) { left: 2%; width: 5px; height: 5px; animation-duration: 10.5s; animation-delay: -11s; }
.ql-snow i:nth-child(14) { left: 52%; width: 3px; height: 3px; animation-duration: 15s; animation-delay: -12s; }

.ql-stage {
  position: relative;
  width: min(64vw, 40vh, 300px);
  aspect-ratio: 480 / 600;
  /*
   * Keep the tree at one size throughout loading.
   * Mobile browsers can change the dynamic viewport height when their
   * browser chrome expands/collapses; svh uses the stable small viewport.
   */
  flex: 0 0 auto;
}

@supports (height: 1svh) {
  .ql-stage {
    width: min(64vw, 40svh, 300px);
  }
}

.ql-halo {
  position: absolute;
  left: 50%;
  top: 52%;
  width: 150%;
  aspect-ratio: 1;
  transform: translate(-50%, -50%);
  background: radial-gradient(circle, rgba(255, 214, 120, 0.28) 0%, rgba(120, 170, 255, 0.12) 38%, transparent 66%);
  animation: ql-breathe 3.6s ease-in-out infinite;
}

.ql-tree {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  animation: ql-sway 5s ease-in-out infinite;
  transform-origin: 50% 92%;
  filter: drop-shadow(0 10px 18px rgba(0, 8, 40, 0.45));
}

.ql-canvas {
  position: absolute;
  left: 0;
  top: -25%;
  width: 100%;
  height: 125%;
  animation: ql-sway 5s ease-in-out infinite;
  transform-origin: 50% 93.6%;
}

.ql-progress {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.4vh;
  margin-top: 2.6vh;
}

.ql-bar {
  position: relative;
  width: min(62vw, 240px);
  height: 22px;
  padding: 3px;
  box-sizing: border-box;
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(8, 20, 70, 0.85), rgba(22, 46, 120, 0.85));
  box-shadow:
    inset 0 2px 5px rgba(0, 0, 0, 0.55),
    0 0 0 1.5px rgba(190, 215, 255, 0.35),
    0 4px 14px rgba(0, 10, 50, 0.45);
}

.ql-fill {
  position: relative;
  width: 0%;
  min-width: 16px;
  height: 100%;
  border-radius: 999px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.55) 0%, rgba(255, 255, 255, 0) 45%, rgba(0, 0, 0, 0.18) 100%),
    repeating-linear-gradient(-45deg, #e8243c 0 8px, #fff6f2 8px 16px);
  background-size: 100% 100%, 22.6px 22.6px;
  box-shadow:
    inset 0 -2px 3px rgba(120, 0, 20, 0.35),
    0 0 10px rgba(255, 90, 110, 0.45);
  animation: ql-candy 0.9s linear infinite;
}

.ql-fill::after {
  content: "";
  position: absolute;
  right: -5px;
  top: 50%;
  width: 14px;
  height: 14px;
  transform: translateY(-50%);
  border-radius: 50%;
  background: radial-gradient(circle, #ffffff 0%, rgba(255, 236, 170, 0.9) 35%, rgba(255, 200, 80, 0) 72%);
  animation: ql-glint 1.1s ease-in-out infinite;
}

.ql-percent {
  text-align: center;
  font-size: clamp(30px, 5.4vh, 44px);
  font-weight: 800;
  line-height: 1;
  letter-spacing: 0.5px;
  background: linear-gradient(180deg, #fff6d2 0%, #ffd45a 55%, #f39a1a 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 2px 8px rgba(255, 190, 60, 0.45));
  font-variant-numeric: tabular-nums;
}

.ql-label {
  margin-top: 1vh;
  min-height: 1.3em;
  font-size: clamp(14px, 2.1vh, 17px);
  font-weight: 800;
  color: rgba(214, 232, 255, 0.82);
  text-shadow: 0 1px 6px rgba(0, 20, 80, 0.6);
}

.ql-error {
  display: none;
  margin-top: 2vh;
  text-align: center;
  font-size: 15px;
  color: #d6e8ff;
}

.ql-retry {
  display: inline-block;
  margin-top: 12px;
  padding: 12px 28px;
  border: 0;
  border-radius: 24px;
  font: inherit;
  font-weight: 800;
  color: #fff;
  background: linear-gradient(180deg, #6fe04a, #24a313);
  box-shadow: 0 4px 0 #157a08, 0 6px 16px rgba(0, 0, 0, 0.35);
}

#quiz-loader.ql-failed .ql-error { display: block; }
#quiz-loader.ql-failed .ql-label,
#quiz-loader.ql-failed .ql-progress { display: none; }

@keyframes ql-fall {
  from { transform: translate3d(0, -2vh, 0); }
  50% { transform: translate3d(2vw, 50vh, 0); }
  to { transform: translate3d(-1vw, 104vh, 0); }
}

@keyframes ql-candy {
  from { background-position: 0 0, 0 0; }
  to { background-position: 0 0, 22.6px 0; }
}

@keyframes ql-glint {
  0%, 100% { opacity: 0.65; transform: translateY(-50%) scale(0.85); }
  50% { opacity: 1; transform: translateY(-50%) scale(1.25); }
}

@keyframes ql-twinkle {
  from { opacity: 0.35; }
  to { opacity: 1; }
}

@keyframes ql-breathe {
  0%, 100% { opacity: 0.75; transform: translate(-50%, -50%) scale(0.96); }
  50% { opacity: 1; transform: translate(-50%, -50%) scale(1.04); }
}

@keyframes ql-sway {
  0%, 100% { transform: rotate(-0.8deg); }
  50% { transform: rotate(0.8deg); }
}

@media (prefers-reduced-motion: reduce) {
  .ql-snow, .ql-tree, .ql-canvas, .ql-halo, .ql-sky::after,
  .ql-fill, .ql-fill::after { animation: none; }
}
