/* ═══════════════════════════════════════════════════
   LEVEL MAP CELEBRATION OVERLAY
   Shown instead of fireworks when a level is passed.
═══════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Fredoka+One&family=Nunito:wght@700;900&display=swap');

#levelmap-overlay {
  position: fixed;
  inset: 0;
  z-index: 99999;
  display: none; /* shown via JS */
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 20px 16px;
  overflow: hidden;
}

/* ── background ── */
#levelmap-overlay .lm-bg {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 60% 40% at 20% 15%, rgba(120,60,255,0.18) 0%, transparent 60%),
    radial-gradient(ellipse 50% 40% at 80% 80%, rgba(255,80,30,0.15) 0%, transparent 60%),
    radial-gradient(ellipse 40% 50% at 75% 15%, rgba(0,200,150,0.10) 0%, transparent 60%),
    linear-gradient(160deg, #0b0a2e 0%, #131340 50%, #1a1230 100%);
}

#levelmap-overlay .lm-bg::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image:
    radial-gradient(1.5px 1.5px at  8% 12%, rgba(255,255,255,0.85) 0%, transparent 100%),
    radial-gradient(1px   1px   at 22% 68%, rgba(255,255,255,0.60) 0%, transparent 100%),
    radial-gradient(2px   2px   at 38% 28%, rgba(255,220,120,0.75) 0%, transparent 100%),
    radial-gradient(1px   1px   at 55% 82%, rgba(255,255,255,0.70) 0%, transparent 100%),
    radial-gradient(1.5px 1.5px at 70% 10%, rgba(255,255,255,0.80) 0%, transparent 100%),
    radial-gradient(1px   1px   at 82% 50%, rgba(200,180,255,0.70) 0%, transparent 100%),
    radial-gradient(2px   2px   at 92% 30%, rgba(255,220,120,0.60) 0%, transparent 100%),
    radial-gradient(1px   1px   at 15% 90%, rgba(255,255,255,0.50) 0%, transparent 100%),
    radial-gradient(1.5px 1.5px at 48% 55%, rgba(180,220,255,0.60) 0%, transparent 100%),
    radial-gradient(1px   1px   at 65% 42%, rgba(255,255,255,0.70) 0%, transparent 100%);
  animation: lm-twinkle 3.5s ease-in-out infinite alternate;
}

@keyframes lm-twinkle { from { opacity: .5 } to { opacity: 1 } }

/* ── title ── */
#levelmap-overlay .lm-title {
  position: relative;
  z-index: 2;
  font-family: 'Fredoka One', cursive;
  font-size: clamp(1.6rem, 4vw, 2.4rem);
  color: #fff;
  text-shadow: 0 0 24px rgba(120,180,255,0.8), 0 2px 4px rgba(0,0,0,0.5);
  margin-bottom: 24px;
  letter-spacing: 2px;
  text-align: center;
  animation: lm-slide-down 0.5s cubic-bezier(.34,1.56,.64,1) 0.15s both;
}

#levelmap-overlay .lm-title .lm-gold { color: #FFD700; text-shadow: 0 0 18px rgba(255,215,0,.8); }

/* ── vertical track ── */
#levelmap-overlay .lm-track {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* ── connector dots ── */
#levelmap-overlay .lm-connector {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  padding: 6px 0;
}

#levelmap-overlay .lm-connector span {
  display: block;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: rgba(255,255,255,0.3);
  animation: lm-fade-in 0.4s ease 0.75s both;
}

/* ── card base ── */
#levelmap-overlay .lm-card {
  position: relative;
  width: 420px;
  max-width: 92vw;
}

#levelmap-overlay .lm-card-inner {
  width: 100%;
  border-radius: 24px;
  display: flex;
  align-items: center;
  padding: 18px 22px 18px 18px;
  gap: 18px;
  position: relative;
}

/* gloss sheen */
#levelmap-overlay .lm-card-inner::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 24px;
  background: linear-gradient(160deg, rgba(255,255,255,0.12) 0%, transparent 50%);
  pointer-events: none;
}

/* ── next (top) — teal ── */
#levelmap-overlay .lm-card-next .lm-card-inner {
  background: linear-gradient(135deg, #0e8f62 0%, #0ba857 55%, #087a3e 100%);
  border: 2px solid rgba(80,220,140,0.4);
  box-shadow:
    0 8px 0 rgba(0,0,0,0.35),
    0 10px 25px rgba(0,0,0,0.45),
    inset 0 1px 0 rgba(255,255,255,0.15);
  width: 88%;
  margin: 0 auto;
  opacity: 0.92;
}

/* ── current (middle) — orange, full width, glowing ── */
#levelmap-overlay .lm-card-current .lm-card-inner {
  background: linear-gradient(135deg, #e8620a 0%, #f58e20 50%, #d44f00 100%);
  border: 2.5px solid rgba(255,210,80,0.65);
  box-shadow:
    0 10px 0 rgba(0,0,0,0.4),
    0 14px 30px rgba(0,0,0,0.5),
    0 0 40px rgba(255,140,30,0.45),
    0 0 80px rgba(255,80,0,0.2),
    inset 0 1px 0 rgba(255,255,255,0.25);
  animation: lm-glow 2.5s ease-in-out 1.2s infinite;
}

/* ── prev (bottom) — purple ── */
#levelmap-overlay .lm-card-prev .lm-card-inner {
  background: linear-gradient(135deg, #3d2d8c 0%, #2a1e6e 60%, #1e165a 100%);
  border: 2px solid rgba(160,130,255,0.4);
  box-shadow:
    0 8px 0 rgba(0,0,0,0.35),
    0 10px 25px rgba(0,0,0,0.45),
    inset 0 1px 0 rgba(255,255,255,0.15);
  width: 88%;
  margin: 0 auto;
  opacity: 0.92;
}

@keyframes lm-glow {
  0%,100% { box-shadow: 0 10px 0 rgba(0,0,0,.4), 0 14px 30px rgba(0,0,0,.5), 0 0 40px rgba(255,140,30,.45), 0 0 80px rgba(255,80,0,.2),  inset 0 1px 0 rgba(255,255,255,.25); }
  50%      { box-shadow: 0 10px 0 rgba(0,0,0,.4), 0 14px 30px rgba(0,0,0,.5), 0 0 65px rgba(255,140,30,.75), 0 0 130px rgba(255,80,0,.35), inset 0 1px 0 rgba(255,255,255,.25); }
}

/* ── avatar ── */
#levelmap-overlay .lm-avatar-wrap {
  flex-shrink: 0;
  position: relative;
}

#levelmap-overlay .lm-avatar-img {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  object-fit: cover;
  display: block;
  border: 3px solid rgba(255,255,255,0.3);
  box-shadow: 0 4px 14px rgba(0,0,0,0.4);
}

#levelmap-overlay .lm-card-current .lm-avatar-img {
  width: 88px;
  height: 88px;
  border-color: rgba(255,215,0,0.7);
  box-shadow: 0 0 20px rgba(255,200,50,0.5), 0 4px 14px rgba(0,0,0,0.4);
}

#levelmap-overlay .lm-avatar-ring {
  position: absolute;
  inset: -5px;
  border-radius: 50%;
  border: 2px dashed rgba(255,255,255,0.25);
  animation: lm-spin 8s linear infinite;
}

#levelmap-overlay .lm-card-current .lm-avatar-ring {
  border-style: solid;
  border-color: rgba(255,215,0,0.5);
  animation: lm-spin 4s linear infinite;
}

@keyframes lm-spin { to { transform: rotate(360deg); } }

/* ── card text ── */
#levelmap-overlay .lm-card-info {
  flex: 1;
  min-width: 0;
}

#levelmap-overlay .lm-row-label {
  font-family: 'Nunito', sans-serif;
  font-size: 0.6rem;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 2px;
  color: rgba(255,255,255,0.9);
  text-shadow: 0 1px 3px rgba(0,0,0,0.6);
  margin-bottom: 2px;
}

#levelmap-overlay .lm-level-id {
  font-family: 'Fredoka One', cursive;
  font-size: 2rem;
  color: #fff;
  line-height: 1;
  text-shadow: 0 2px 8px rgba(0,0,0,0.7), 0 1px 2px rgba(0,0,0,0.9);
}

#levelmap-overlay .lm-card-current .lm-level-id {
  font-size: 2.4rem;
  color: #fff;
  text-shadow: 0 2px 10px rgba(0,0,0,0.8), 0 1px 2px rgba(0,0,0,1);
}

#levelmap-overlay .lm-unit {
  font-family: 'Nunito', sans-serif;
  font-size: 0.72rem;
  font-weight: 700;
  color: rgba(255,255,255,0.7);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#levelmap-overlay .lm-vdivider {
  width: 1px;
  height: 52px;
  background: rgba(255,255,255,0.2);
  flex-shrink: 0;
  align-self: center;
}

#levelmap-overlay .lm-card-current .lm-vdivider {
  height: 64px;
}

#levelmap-overlay .lm-player {
  flex-shrink: 0;
  text-align: right;
  max-width: 35%;
}

#levelmap-overlay .lm-player-label {
  font-family: 'Nunito', sans-serif;
  font-size: 0.58rem;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: rgba(255,255,255,0.85);
  margin-bottom: 4px;
  text-shadow: 0 1px 3px rgba(0,0,0,0.6);
}

#levelmap-overlay .lm-player-name {
  font-family: 'Nunito', sans-serif;
  font-size: 1.2rem;
  font-weight: 900;
  color: #fff;
  text-shadow: 0 2px 8px rgba(0,0,0,0.7), 0 1px 2px rgba(0,0,0,0.9);
  white-space: nowrap;
}

#levelmap-overlay .lm-card-current .lm-player-name {
  font-size: 1.6rem;
  text-shadow: 0 2px 10px rgba(0,0,0,0.8), 0 1px 2px rgba(0,0,0,1);
}

#levelmap-overlay .lm-school {
  font-family: 'Nunito', sans-serif;
  font-size: 0.82rem;
  font-weight: 700;
  color: rgba(255,255,255,0.9);
  text-shadow: 0 1px 4px rgba(0,0,0,0.7);
  margin-top: 3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 120px;
}

/* ── badges ── */
#levelmap-overlay .lm-badge {
  position: absolute;
  font-family: 'Nunito', sans-serif;
  font-size: 0.58rem;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  padding: 4px 12px;
  border-radius: 20px;
  white-space: nowrap;
  top: -11px;
  left: 50%;
  transform: translateX(-50%);
}

#levelmap-overlay .lm-badge-next {
  background: #007538;
  color: #fff;
}

#levelmap-overlay .lm-badge-current {
  top: -13px;
  background: linear-gradient(135deg, #FFD700, #FFA500);
  color: #7a3d00;
  box-shadow: 0 2px 10px rgba(255,165,0,.55);
}

#levelmap-overlay .lm-badge-prev {
  background: #5a4ab0;
  color: #fff;
}

/* ── continue button ── */
#levelmap-overlay .lm-continue-btn {
  position: relative;
  z-index: 2;
  margin-top: 28px;
  padding: 13px 52px;
  background: linear-gradient(135deg, #FFD700 0%, #FFA500 100%);
  color: #7a3d00;
  font-family: 'Fredoka One', cursive;
  font-size: 1.15rem;
  letter-spacing: 1px;
  border: none;
  border-radius: 50px;
  cursor: pointer;
  box-shadow: 0 6px 0 #b36b00, 0 8px 22px rgba(255,165,0,.4);
  transition: transform .12s ease, box-shadow .12s ease;
  animation: lm-slide-down 0.5s ease 1.1s both;
}

#levelmap-overlay .lm-continue-btn:hover  { transform: translateY(-2px); box-shadow: 0 8px 0 #b36b00, 0 12px 28px rgba(255,165,0,.5); }
#levelmap-overlay .lm-continue-btn:active { transform: translateY(4px);  box-shadow: 0 2px 0 #b36b00, 0 4px 10px rgba(255,165,0,.3); }

/* ── entrance animations ── */
@keyframes lm-fade-in    { from { opacity:0 }                        to { opacity:1 } }
@keyframes lm-slide-down { from { opacity:0; transform:translateY(-28px) } to { opacity:1; transform:translateY(0) } }
@keyframes lm-pop-in     { 0%{opacity:0;transform:scale(.5)} 70%{transform:scale(1.06)} 100%{opacity:1;transform:scale(1)} }
@keyframes lm-slide-up   { from { opacity:0; transform:translateY(28px) } to { opacity:1; transform:translateY(0) } }

#levelmap-overlay.lm-visible .lm-title       { animation: lm-slide-down 0.5s cubic-bezier(.34,1.56,.64,1) 0.15s both; }
#levelmap-overlay.lm-visible .lm-card-next    { animation: lm-slide-down 0.55s cubic-bezier(.34,1.56,.64,1) 0.40s both; }
#levelmap-overlay.lm-visible .lm-card-current { animation: lm-pop-in     0.60s cubic-bezier(.34,1.56,.64,1) 0.58s both; }
#levelmap-overlay.lm-visible .lm-card-prev    { animation: lm-slide-up   0.55s cubic-bezier(.34,1.56,.64,1) 0.40s both; }
#levelmap-overlay.lm-visible .lm-connector    { animation: lm-fade-in    0.40s ease 0.75s both; }
#levelmap-overlay.lm-visible .lm-continue-btn { animation: lm-slide-down 0.50s ease 1.10s both; }
