/* Loading screen + background scene for Ragdoll Archers */

:root {
  --sky-top: #0d1030;
  --sky-mid: #3a2457;
  --sky-low: #c2546a;
  --horizon: #ffb46b;
  --cream: #f4ecd8;
  --red: #d64545;
  --gold: #ffc94a;
}

html, body {
  background: var(--sky-top);
  overflow: hidden;
}

/* ---------- Background scene ---------- */

#scene {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
  transition: opacity .8s ease;
}

body.loaded #scene {
  opacity: 0;
  visibility: hidden;
  transition: opacity .8s ease, visibility 0s .8s;
}

.sky {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 80% 45% at 50% 100%, rgba(255, 180, 107, .55), transparent 70%),
    linear-gradient(to bottom, var(--sky-top) 0%, var(--sky-mid) 45%, var(--sky-low) 78%, var(--horizon) 100%);
}

.stars {
  position: absolute;
  inset: 0 0 40% 0;
  background-image:
    radial-gradient(1.5px 1.5px at 12% 18%, #fff, transparent),
    radial-gradient(1px 1px at 24% 42%, #fff, transparent),
    radial-gradient(1.5px 1.5px at 37% 12%, #fff, transparent),
    radial-gradient(1px 1px at 48% 30%, #fff, transparent),
    radial-gradient(2px 2px at 63% 8%, #fff, transparent),
    radial-gradient(1px 1px at 71% 36%, #fff, transparent),
    radial-gradient(1.5px 1.5px at 83% 20%, #fff, transparent),
    radial-gradient(1px 1px at 92% 44%, #fff, transparent),
    radial-gradient(1px 1px at 6% 52%, #fff, transparent),
    radial-gradient(1.5px 1.5px at 56% 50%, #fff, transparent);
  opacity: .8;
  animation: twinkle 4s ease-in-out infinite alternate;
}

.moon {
  position: absolute;
  top: 9%;
  right: 12%;
  width: clamp(50px, 8vw, 110px);
  aspect-ratio: 1;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #fffbe9, #f6dfa8 70%);
  box-shadow: 0 0 60px 18px rgba(255, 230, 170, .25);
}

.hills {
  position: absolute;
  left: 0;
  bottom: 0;
  width: 100%;
}
.hills.back  { height: 46%; fill: #4a2a5c; }
.hills.mid   { height: 36%; fill: #2b1a3f; }
.hills.front { height: 24%; fill: #150e24; }

/* Arrows streaking across the sky */
.flyer {
  position: absolute;
  left: -15%;
  width: 90px;
  height: 2px;
  background: linear-gradient(to right, transparent, rgba(255, 255, 255, .85));
  border-radius: 2px;
  animation: fly 7s linear infinite;
}
.flyer::after {
  content: "";
  position: absolute;
  right: -8px;
  top: -4px;
  border-left: 10px solid #fff;
  border-top: 5px solid transparent;
  border-bottom: 5px solid transparent;
}
.flyer.f1 { top: 22%; animation-delay: 0s; }
.flyer.f2 { top: 38%; animation-delay: 2.6s; animation-duration: 8.5s; transform: scale(.7); }
.flyer.f3 { top: 14%; animation-delay: 5s; animation-duration: 6s; transform: scale(.5); }

.vignette {
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at center, transparent 55%, rgba(0, 0, 0, .55));
}

/* ---------- Game canvas ---------- */

#unity-container { z-index: 1; }
#unity-canvas { background: transparent; }

/* ---------- Loading cover ---------- */

#loading-cover {
  z-index: 2;
  font-family: "Nunito", system-ui, sans-serif;
  color: var(--cream);
  transition: opacity .6s ease, transform .6s ease;
}
#loading-cover.done {
  opacity: 0;
  transform: scale(1.04);
  pointer-events: none;
}

#unity-loading-bar {
  gap: clamp(18px, 4vh, 36px);
  padding: 24px;
  margin-bottom: 8vh;
}

#unity-logo {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}

#unity-logo .target {
  width: clamp(70px, 12vw, 120px);
  filter: drop-shadow(0 8px 18px rgba(0, 0, 0, .45));
  animation: bob 3s ease-in-out infinite;
}

#unity-logo h1 {
  margin: 0;
  font-family: "Lilita One", "Nunito", sans-serif;
  font-weight: 400;
  font-size: clamp(2.4rem, 7vw, 4.8rem);
  line-height: .95;
  letter-spacing: .03em;
  text-transform: uppercase;
  text-align: center;
  color: var(--cream);
  text-shadow: 0 4px 0 #6b2335, 0 10px 24px rgba(0, 0, 0, .5);
}
#unity-logo h1 span {
  display: block;
  color: var(--gold);
  text-shadow: 0 4px 0 #a2521d, 0 10px 24px rgba(0, 0, 0, .5);
}

.progress-spinner-container {
  flex-direction: column;
  align-items: stretch;
  width: min(460px, 80vw);
  gap: 10px;
}

#unity-progress-bar-empty {
  height: 18px;
  padding: 3px;
  border-radius: 999px;
  background: rgba(10, 6, 24, .55);
  border: 2px solid rgba(244, 236, 216, .25);
  box-shadow: inset 0 2px 6px rgba(0, 0, 0, .5), 0 6px 20px rgba(0, 0, 0, .3);
  backdrop-filter: blur(4px);
}

#unity-progress-bar-full {
  position: relative;
  min-width: 8px;
  border-radius: 999px;
  background:
    repeating-linear-gradient(-45deg, rgba(255, 255, 255, .18) 0 8px, transparent 8px 16px),
    linear-gradient(to right, var(--red), #f07a3c, var(--gold));
  background-size: 22.6px 22.6px, 100% 100%;
  box-shadow: 0 0 14px rgba(255, 201, 74, .55);
  transition: width .35s ease-out;
  animation: stripes .8s linear infinite;
}

/* Arrowhead riding the front of the bar */
#unity-progress-bar-full .arrowhead {
  position: absolute;
  right: -12px;
  top: 50%;
  transform: translateY(-50%);
  border-left: 14px solid var(--cream);
  border-top: 9px solid transparent;
  border-bottom: 9px solid transparent;
  filter: drop-shadow(0 0 4px rgba(255, 255, 255, .6));
}

.progress-meta {
  display: flex;
  justify-content: space-between;
  font-weight: 800;
  font-size: .95rem;
  letter-spacing: .02em;
  text-shadow: 0 2px 6px rgba(0, 0, 0, .6);
}
#loading-percent {
  color: var(--gold);
  font-variant-numeric: tabular-nums;
}

#loading-tip {
  margin: 0;
  max-width: min(460px, 80vw);
  min-height: 1.4em;
  text-align: center;
  font-weight: 600;
  font-size: .95rem;
  color: rgba(244, 236, 216, .8);
  text-shadow: 0 2px 6px rgba(0, 0, 0, .6);
  opacity: 0;
  transform: translateY(4px);
  transition: opacity .3s ease, transform .3s ease;
}
#loading-tip.show {
  opacity: 1;
  transform: none;
}

#loading-cover.error #unity-progress-bar-full {
  background: #7a2a3a;
  box-shadow: none;
  animation: none;
}
#loading-cover.error #loading-status { color: #ff8a8a; }

/* ---------- Animations ---------- */

@keyframes twinkle { from { opacity: .45; } to { opacity: .9; } }
@keyframes bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-8px); } }
@keyframes stripes { to { background-position: 22.6px 0, 0 0; } }
@keyframes fly {
  0%   { left: -15%; opacity: 0; }
  10%  { opacity: 1; }
  90%  { opacity: 1; }
  100% { left: 115%; opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .stars, .flyer, #unity-logo .target, #unity-progress-bar-full { animation: none; }
  .flyer { display: none; }
}
