/* Level Up: the golden banner, the mini-profile glow + badge and the notification panel (see levelup.js).
   Everything is CSS-driven; nothing here loops in JavaScript. */

/* ---------------------------------------------------------------- banner */
#levelup-banner{
  position: fixed;
  left: 50%;
  top: clamp(70px, 20vh, 220px);
  z-index: 13950;
  width: min(92vw, 640px);
  height: 220px;
  margin-left: calc(min(92vw, 640px) / -2);
  pointer-events: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  animation: lu-banner 5.5s cubic-bezier(.2, .9, .25, 1) both;
  font-family: Georgia, "Times New Roman", serif;
}
#levelup-banner .lu-title{
  position: relative;
  z-index: 3;
  font: 900 clamp(38px, 8vw, 78px)/1 Georgia, "Times New Roman", serif;
  letter-spacing: 0.03em;
  color: #fff3b0;
  background: linear-gradient(180deg, #fffbd0 0%, #ffd34a 46%, #ff9c1a 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  -webkit-text-stroke: 7px #6b2d08;
  paint-order: stroke fill;
  filter: drop-shadow(0 4px 0 #4a1c05) drop-shadow(0 0 22px rgba(255, 196, 64, 0.85));
  animation: lu-title 5.5s cubic-bezier(.2, .9, .25, 1) both;
}
#levelup-banner .lu-level{
  position: relative;
  z-index: 3;
  margin-top: 6px;
  padding: 3px 22px 5px;
  border: 3px solid #4a2a10;
  border-radius: 12px;
  background: linear-gradient(180deg, #d79a58 0%, #b87438 52%, #8d5226 100%);
  box-shadow: 0 4px 0 #2a1608, 0 0 18px rgba(255, 196, 64, 0.6), inset 0 2px 0 rgba(255, 224, 170, 0.5);
  color: #fff;
  font: 900 clamp(16px, 3vw, 26px)/1.1 Georgia, serif;
  letter-spacing: 0.08em;
  -webkit-text-stroke: 4px #0a1c3c;
  paint-order: stroke fill;
  text-shadow: 0 3px 0 rgba(10, 28, 60, 0.9);
  animation: lu-level 5.5s ease both;
}
#levelup-banner .lu-level b{ color: #ffe27a; }
/* light rays behind the title */
#levelup-banner .lu-rays{
  position: absolute;
  z-index: 0;
  left: 50%;
  top: 50%;
  width: 520px;
  height: 520px;
  margin: -260px 0 0 -260px;
  border-radius: 50%;
  background: repeating-conic-gradient(from 0deg, rgba(255, 224, 120, 0.55) 0 7deg, rgba(255, 224, 120, 0) 7deg 22deg);
  -webkit-mask-image: radial-gradient(circle, #000 0, rgba(0, 0, 0, 0.55) 38%, transparent 70%);
  mask-image: radial-gradient(circle, #000 0, rgba(0, 0, 0, 0.55) 38%, transparent 70%);
  animation: lu-rays 5.5s linear both;
}
/* two soft vertical beams */
#levelup-banner .lu-beam{
  position: absolute;
  z-index: 1;
  top: -60px;
  bottom: -90px;
  width: 70px;
  background: linear-gradient(180deg, rgba(255, 236, 160, 0), rgba(255, 220, 110, 0.55) 55%, rgba(255, 200, 70, 0));
  filter: blur(6px);
  opacity: 0;
  animation: lu-beam 4.5s ease-out both;
}
#levelup-banner .lu-beam-a{ left: calc(50% - 150px); }
#levelup-banner .lu-beam-b{ left: calc(50% + 80px); animation-delay: 120ms; }
/* four-point sparkles */
#levelup-banner .lu-spark{
  position: absolute;
  z-index: 2;
  left: 50%;
  top: 50%;
  width: 22px;
  height: 22px;
  margin: -11px 0 0 -11px;
  background: radial-gradient(circle, #fffbe0 0 22%, #ffd34a 24% 60%, rgba(255, 211, 74, 0) 62%);
  clip-path: polygon(50% 0, 62% 38%, 100% 50%, 62% 62%, 50% 100%, 38% 62%, 0 50%, 38% 38%);
  filter: drop-shadow(0 0 6px rgba(255, 220, 110, 0.9));
  opacity: 0;
  animation: lu-spark 3.2s ease-out var(--d, 0ms) both;
}
/* arrows rising out of the title */
#levelup-banner .lu-arrow{
  position: absolute;
  z-index: 2;
  left: calc(50% + var(--ax, 0px));
  top: 62%;
  width: 26px;
  height: 34px;
  margin-left: -13px;
  background: linear-gradient(180deg, #fff1a6, #ffb42e);
  clip-path: polygon(50% 0, 100% 46%, 70% 46%, 70% 100%, 30% 100%, 30% 46%, 0 46%);
  filter: drop-shadow(0 0 7px rgba(255, 200, 70, 0.9));
  opacity: 0;
  animation: lu-arrow 3.6s ease-out var(--ad, 0ms) both;
}
@keyframes lu-banner{
  0%{ opacity: 0; }
  8%{ opacity: 1; }
  78%{ opacity: 1; }
  100%{ opacity: 0; }
}
@keyframes lu-title{
  0%{ transform: scale(0.3); opacity: 0; }
  16%{ transform: scale(1.22); opacity: 1; }
  26%{ transform: scale(0.96); }
  34%{ transform: scale(1); }
  78%{ transform: scale(1.03); }
  100%{ transform: scale(1.08) translateY(-10px); opacity: 0; }
}
@keyframes lu-level{
  0%, 20%{ transform: translateY(14px) scale(0.7); opacity: 0; }
  38%{ transform: translateY(0) scale(1.08); opacity: 1; }
  48%{ transform: scale(1); }
  100%{ transform: scale(1); opacity: 1; }
}
@keyframes lu-rays{
  0%{ transform: rotate(0deg) scale(0.4); opacity: 0; }
  18%{ opacity: 1; }
  100%{ transform: rotate(70deg) scale(1.15); opacity: 0; }
}
@keyframes lu-beam{
  0%{ opacity: 0; transform: scaleY(0.4); }
  30%{ opacity: 1; transform: scaleY(1); }
  100%{ opacity: 0; transform: scaleY(1.1); }
}
@keyframes lu-spark{
  0%{ opacity: 0; transform: translate(0, 0) scale(0); }
  25%{ opacity: 1; }
  100%{ opacity: 0; transform: translate(var(--x, 0), var(--y, 0)) scale(var(--s, 1)) rotate(90deg); }
}
@keyframes lu-arrow{
  0%{ opacity: 0; transform: translateY(18px) scale(0.7); }
  25%{ opacity: 1; }
  100%{ opacity: 0; transform: translateY(-96px) scale(1); }
}

/* ---------------------------------------------------------------- mini-profile glow + badge */
/* hud.css forces position: static !important on the HUD panels; the badge needs the panel as its anchor */
body #hud-layer #mini-profile{ position: relative !important; }
body #hud-layer #mini-profile.has-levelup-unread{
  border-color: rgba(255, 211, 74, 0.85) !important;
  box-shadow: 0 0 6px 1px rgba(255, 211, 74, 0.35);
}
/* The glow used to animate box-shadow itself (main-thread paint + a big blur re-rastered every
   frame: ~16% of main-thread time on a throttled phone). The strong glow is now a static
   shadow on a pseudo-element and only its opacity animates (compositor-only). Same look. */
body #hud-layer #mini-profile.has-levelup-unread::after{
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  box-shadow: 0 0 0 2px rgba(255, 211, 74, 0.35), 0 0 20px 5px rgba(255, 211, 74, 0.7);
  opacity: 0;
  will-change: opacity;
  animation: lu-glow 1.9s ease-in-out infinite;
}
@keyframes lu-glow{
  0%, 100%{ opacity: 0; }
  50%{ opacity: 1; }
}
/* Low-end devices: no infinite decorative animation at all (the static glow above stays). */
body.perf-low #hud-layer #mini-profile.has-levelup-unread::after{ animation: none; opacity: 0.6; will-change: auto; }
body.perf-low .lu-chip.is-unread{ animation: none; }
.lu-chip{
  position: absolute;
  top: -9px;
  right: -9px;
  z-index: 6;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-width: 24px;
  height: 24px;
  padding: 0 6px;
  box-sizing: border-box;
  border: 2px solid #0b2c5e;
  border-radius: 999px;
  background: linear-gradient(180deg, #4aa6ff 0%, #2677e6 52%, #1757bd 100%);
  box-shadow: 0 2px 0 #061a38, inset 0 2px 0 rgba(255, 255, 255, 0.4);
  color: #fff;
  font: 900 12px/1 Georgia, serif;
  cursor: pointer;
  user-select: none;
}
.lu-chip[hidden]{ display: none; }
.lu-chip.is-unread{
  border-color: #7a1f10;
  background: linear-gradient(180deg, #ffd34a 0%, #ff9c1a 55%, #e0710c 100%);
  color: #3b1c05;
  animation: lu-chip-pulse 1.9s ease-in-out infinite;
}
.lu-chip-icon{ font-size: 13px; }
.lu-chip-count[hidden]{ display: none; }
.lu-chip:focus-visible{ outline: 3px solid #ffe27a; outline-offset: 2px; }
@keyframes lu-chip-pulse{
  0%, 100%{ transform: scale(1); }
  50%{ transform: scale(1.14); }
}

/* ---------------------------------------------------------------- notification panel */
#levelup-panel{
  position: fixed;
  z-index: 13900;
  box-sizing: border-box;
  width: min(92vw, 360px);
  max-height: min(70vh, 480px);
  display: flex;
  flex-direction: column;
  border: 3px solid #2f93ff;
  border-radius: 16px;
  background: linear-gradient(180deg, #123c72 0%, #0b2750 52%, #081b38 100%);
  box-shadow: 0 0 0 2px #082f66, 0 14px 34px rgba(0, 0, 0, 0.55), inset 0 0 0 1px rgba(150, 210, 255, 0.3);
  color: #e3f1ff;
  font-family: Georgia, "Times New Roman", serif;
}
#levelup-panel[hidden]{ display: none; }
.lu-panel-head{
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px 6px 14px;
  border-bottom: 2px solid rgba(120, 190, 255, 0.3);
}
.lu-panel-title{
  font: 900 15px/1 Georgia, serif;
  letter-spacing: 0.06em;
  color: #ffd34a;
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.6);
  text-transform: uppercase;
}
.lu-panel-close{
  width: 28px;
  height: 28px;
  border: 2px solid #fff;
  border-radius: 9px;
  background: linear-gradient(180deg, #ff6a5c 0%, #d3201a 52%, #a31410 100%);
  color: #fff;
  font: 900 17px/1 Georgia, serif;
  cursor: pointer;
}
.lu-panel-list{
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: #2f93ff rgba(0, 0, 0, 0.25);
}
.lu-item{
  border: 2px solid rgba(120, 190, 255, 0.35);
  border-radius: 12px;
  background: linear-gradient(180deg, #0c2144, #081a38);
  overflow: hidden;
}
.lu-row{
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 9px 10px;
  border: 0;
  background: none;
  color: inherit;
  font: 800 14px/1.2 Georgia, serif;
  text-align: left;
  cursor: pointer;
}
.lu-row:hover{ background: rgba(120, 190, 255, 0.1); }
.lu-row:focus-visible{ outline: 3px solid #ffe27a; outline-offset: -3px; }
.lu-row-text{ flex: 1 1 auto; }
.lu-row-text b{ color: #ffe27a; }
.lu-dot{ width: 9px; height: 9px; border-radius: 50%; background: rgba(150, 190, 230, 0.35); flex: 0 0 auto; }
.lu-row.is-unread .lu-dot{ background: #ffd34a; box-shadow: 0 0 8px 2px rgba(255, 211, 74, 0.8); }
.lu-row.is-unread{ background: linear-gradient(90deg, rgba(255, 211, 74, 0.14), transparent 70%); }
.lu-row-state{
  font: 900 10px/1 Georgia, serif;
  letter-spacing: 0.08em;
  color: #3b1c05;
  background: #ffd34a;
  border-radius: 6px;
  padding: 2px 6px;
}
.lu-row-state:empty{ display: none; }
.lu-details{ padding: 4px 12px 12px; border-top: 1px solid rgba(120, 190, 255, 0.25); animation: lu-open 160ms ease-out both; }
@keyframes lu-open{ from{ opacity: 0; transform: translateY(-4px); } to{ opacity: 1; transform: none; } }
.lu-headline{ margin-top: 8px; font: 900 17px/1.1 Georgia, serif; color: #ffd34a; text-shadow: 0 2px 0 rgba(0, 0, 0, 0.6); }
.lu-levelline{ margin-top: 3px; font-weight: 800; color: #cfe9ff; }
.lu-levelline b{ color: #ffe27a; }
.lu-section{ margin-top: 10px; font: 900 12px/1 Georgia, serif; letter-spacing: 0.06em; color: #8fd2ff; text-transform: uppercase; }
.lu-stat{ display: flex; justify-content: space-between; gap: 8px; margin-top: 5px; padding: 4px 8px; border-radius: 8px; background: rgba(3, 14, 32, 0.6); font-weight: 800; }
.lu-stat-vals i{ font-style: normal; }
.lu-details .is-up{ color: #6bf07a; }
.lu-details .is-down{ color: #ff8a80; }
.lu-reward{ display: flex; align-items: center; gap: 8px; margin-top: 5px; padding: 4px 8px; border-radius: 8px; background: rgba(3, 14, 32, 0.6); font-weight: 800; }
.lu-reward-note{ margin-left: auto; font-size: 11px; color: #ffb36b; }
.lu-icon{ display: inline-flex; width: 30px; height: 30px; flex: 0 0 auto; align-items: center; justify-content: center; }
.lu-icon > *{ max-width: 100%; max-height: 100%; }
.lu-coin{ color: #ffd34a; font-size: 20px; }
.lu-none{ margin-top: 6px; padding: 6px 8px; font-weight: 700; color: #b9d3ee; }

@media (max-width: 560px){
  #levelup-banner{ top: clamp(60px, 16vh, 160px); height: 170px; }
  #levelup-banner .lu-rays{ width: 380px; height: 380px; margin: -190px 0 0 -190px; }
  #levelup-banner .lu-title{ -webkit-text-stroke-width: 5px; }
}
@media (prefers-reduced-motion: reduce){
  #levelup-banner{ animation-duration: 4s; }
  #levelup-banner .lu-rays, #levelup-banner .lu-beam, #levelup-banner .lu-spark, #levelup-banner .lu-arrow{ animation: none; opacity: 0; }
  body #hud-layer #mini-profile.has-levelup-unread, .lu-chip.is-unread{ animation: none; }
}
