/* Level-up feedback uses the existing toast layer. Its top banner has a
   separate viewport anchor and never adds a clickable surface over the game. */
#levelUpToastStack > .level-up-banner-host {
  position: fixed;
  inset: var(--level-up-banner-top, calc(var(--ui-topbar-height, 56px) + 12px)) auto auto 50%;
  width: min(460px, calc(100vw - 32px));
  transform: translateX(-50%);
  pointer-events: none;
  flex: none;
  margin: 0;
  padding: 0;
}
#levelUpBannerHost,
#levelUpBannerHost * { pointer-events: none; }

.level-up-banner {
  position: relative;
  display: grid;
  grid-template-columns: 66px minmax(0, 1fr);
  align-items: center;
  gap: 18px;
  box-sizing: border-box;
  width: 100%;
  min-height: 122px;
  padding: 18px 24px 18px 19px;
  border: 1px solid #b79855;
  border-radius: 10px 4px;
  /* Use the same visibly textured material as the game's window chrome. */
  background: radial-gradient(ellipse at 15% 45%, rgba(220, 169, 71, .14), transparent 52%),
    var(--mg-surface-chrome);
  color: #f1e4bf;
  font-family: var(--font-readable, sans-serif);
  box-shadow: 0 13px 34px rgba(0, 0, 0, .5), inset 0 0 0 3px rgba(147, 114, 53, .13);
  animation: mountgateLevelBannerIn 700ms linear both;
  isolation: isolate;
}
.level-up-banner::before,
.level-up-banner::after {
  content: '';
  position: absolute;
  left: 105px;
  right: 22px;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(224, 189, 103, .68), transparent);
}
.level-up-banner::before { top: 10px; }
.level-up-banner::after { bottom: 10px; }
.level-up-banner-crest {
  position: relative;
  display: grid;
  place-items: center;
  width: 64px;
  height: 64px;
  border: 1px solid transparent;
  border-radius: 50%;
  /* A soft round medallion: square inventory-slot artwork would add a dark box. */
  background: radial-gradient(circle, rgba(178, 133, 54, .25), rgba(125, 91, 40, .18) 42%, rgba(170, 128, 58, .07) 60%, transparent 72%);
  box-shadow: none;
  animation: mountgateLevelCrest 900ms ease-out both;
}
.level-up-banner-crest::after {
  content: '';
  position: absolute;
  inset: -5px;
  border: 1px solid rgba(232, 200, 120, .76);
  border-radius: inherit;
  animation: mountgateLevelRing 1200ms ease-out 270ms both;
}
.level-up-banner-crest img { width: 44px; height: 44px; object-fit: contain; }
.level-up-banner-copy { display: grid; gap: 3px; min-width: 0; }
.level-up-banner-copy > small {
  color: #cfad68;
  font: 800 10px/1.4 var(--font-readable, sans-serif);
  letter-spacing: .16em;
  text-transform: uppercase;
}
.level-up-banner-copy > strong {
  color: #f5e8c3;
  font: 700 23px/1.15 var(--font-accent, Georgia, serif);
  overflow-wrap: anywhere;
  text-shadow: 0 2px 2px #080604;
}
.level-up-banner-level {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  column-gap: 7px;
  color: #cfc09a;
  font-size: 13px;
  line-height: 1.1;
}
.level-up-banner-level b {
  display: inline-block;
  color: #e8c675;
  font: 700 30px/1.05 var(--font-accent, Georgia, serif);
  text-shadow: 0 1px 8px rgba(229, 178, 76, .25);
  transform-origin: center 75%;
  /* Two restrained pulses begin once the banner has landed. */
  animation: mountgateLevelNumberPulse 900ms ease-in-out 700ms 2 both;
}
.level-up-banner-level em { color: #b6a580; font-size: 11px; font-style: normal; }
.level-up-banner.is-leaving { animation: mountgateLevelBannerOut 350ms ease-in both; }
.level-up-banner[hidden] { display: grid; visibility: hidden; }

/* Unlocks retain their existing readable list and explicit confirmation. */
.level-up-toast.level-up-unlock-toast {
  display: flex;
  flex-direction: column;
  box-sizing: border-box;
  max-height: calc(100dvh - var(--bottom-bar-clearance, 64px) - 32px);
  overflow: visible;
  border: 1px solid #bd9d55;
  border-radius: 12px 4px;
  background: radial-gradient(ellipse at 12% 22%, rgba(205, 150, 56, .16), transparent 56%),
    var(--mg-surface-window);
  color: #f1e4c2;
  box-shadow: 0 20px 48px rgba(0, 0, 0, .5), 0 0 0 3px rgba(181, 141, 62, .09), inset 0 0 0 3px rgba(166, 128, 57, .1);
  animation: mountgateUnlockIn 550ms cubic-bezier(.2, .8, .2, 1) both;
  backdrop-filter: none;
  will-change: auto;
  isolation: isolate;
}
.level-up-toast.level-up-unlock-toast > :not(.level-up-toast-unlocks) { flex-shrink: 0; }
.level-up-toast.level-up-unlock-toast .level-up-toast-unlocks {
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  border-top-color: rgba(203, 165, 84, .24);
  scrollbar-gutter: stable;
}
.level-up-toast.level-up-unlock-toast .level-up-toast-glow {
  inset: -16px auto auto -16px;
  width: 250px;
  height: 250px;
  opacity: 0;
  background: radial-gradient(circle, rgba(240, 190, 78, .46), transparent 67%);
  animation: mountgateUnlockGlow 1800ms ease-out both;
}
.level-up-toast.level-up-unlock-toast .level-up-toast-head,
.level-up-toast.level-up-unlock-toast .level-up-toast-hero,
.level-up-toast.level-up-unlock-toast .level-up-toast-actions { position: relative; z-index: 1; }
.level-up-toast.level-up-unlock-toast .level-up-toast-badge {
  border-color: rgba(217, 178, 89, .55);
  border-radius: 5px;
  background: rgba(153, 112, 40, .17);
  color: #e3c47b;
}
.level-up-toast.level-up-unlock-toast .level-up-toast-range,
.level-up-toast.level-up-unlock-toast .level-up-toast-copy span { color: #c6b58c; }
.level-up-toast.level-up-unlock-toast .level-up-toast-copy strong { color: #f5e6bc; }
.level-up-toast.level-up-unlock-toast .level-up-toast-skill-icon {
  border-color: transparent;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(178, 133, 54, .25), rgba(125, 91, 40, .18) 42%, rgba(170, 128, 58, .07) 60%, transparent 72%);
  box-shadow: none;
  animation: mountgateLevelCrest 1200ms ease-out both;
}
.level-up-toast.level-up-unlock-toast .level-up-toast-section-title,
.level-up-toast.level-up-unlock-toast .level-up-toast-unlock-level { color: #d9b86d; }
.level-up-toast.level-up-unlock-toast .level-up-toast-unlock-item {
  border-color: rgba(190, 158, 88, .2);
  border-radius: 6px;
  background: rgba(145, 112, 53, .08);
}
.level-up-toast.level-up-unlock-toast .level-up-toast-actions { border-top-color: rgba(203, 165, 84, .24); }
.level-up-toast.level-up-unlock-toast.is-leaving { animation: mountgateUnlockOut 300ms ease-in both; }

/* Once the finite celebration has ended, moving the shared toast layer or
   restoring a paused banner must not restart its entrance or its light ring. */
.level-up-banner.has-celebrated:not(.is-leaving),
.level-up-toast.level-up-unlock-toast.has-celebrated:not(.is-leaving),
.level-up-banner.has-celebrated .level-up-banner-crest,
.level-up-banner.has-celebrated .level-up-banner-level b,
.level-up-toast.level-up-unlock-toast.has-celebrated .level-up-toast-skill-icon { animation: none; }
.level-up-banner.has-celebrated .level-up-banner-crest::after,
.level-up-toast.level-up-unlock-toast.has-celebrated .level-up-toast-glow { animation: none; opacity: 0; }

/* A finite DOM burst; all moving properties are compositor-friendly. */
.level-up-celebration-particles {
  position: absolute;
  left: 52px;
  top: 50%;
  width: 0;
  height: 0;
  z-index: 3;
  pointer-events: none;
}
.level-up-toast.level-up-unlock-toast .level-up-celebration-particles { left: 45px; top: 96px; }
.level-up-celebration-particle {
  position: absolute;
  left: 0;
  top: 0;
  display: block;
  width: var(--spark-size, 7px);
  height: var(--spark-size, 7px);
  border-radius: 2px;
  color: #e7b54e;
  background: currentColor;
  box-shadow: 0 0 9px rgba(255, 209, 105, .8), 0 0 18px rgba(235, 176, 59, .35);
  opacity: 0;
  pointer-events: none;
  animation: mountgateLevelSpark 1450ms ease-out var(--spark-delay, 0ms) both;
}
.level-up-celebration-particle:nth-child(3n) {
  color: #fff0b7;
  clip-path: polygon(50% 0, 62% 35%, 100% 50%, 62% 64%, 50% 100%, 37% 64%, 0 50%, 37% 35%);
  border-radius: 0;
}
.level-up-celebration-particle:nth-child(4n) { color: #ce9042; }
.level-up-toast.level-up-unlock-toast .level-up-celebration-particle { animation-duration: 1600ms; }

.level-up-banner.is-paused,
.level-up-banner.is-paused *,
.level-up-banner.is-paused::before,
.level-up-banner.is-paused::after,
.level-up-banner.is-paused .level-up-banner-crest::after,
.level-up-toast.level-up-unlock-toast.is-paused,
.level-up-toast.level-up-unlock-toast.is-paused * { animation-play-state: paused; }

@keyframes mountgateLevelBannerIn {
  0% { opacity: 0; transform: translateY(-170px) scale(.96); animation-timing-function: cubic-bezier(.45, 0, .7, .5); }
  14% { opacity: 1; }
  64% { opacity: 1; transform: translateY(12px) scale(1.015); animation-timing-function: ease-out; }
  82% { opacity: 1; transform: translateY(-6px) scale(.995); animation-timing-function: ease-in-out; }
  100% { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes mountgateLevelBannerOut {
  from { opacity: 1; transform: translateY(0); }
  to { opacity: 0; transform: translateY(-16px); }
}
@keyframes mountgateLevelCrest {
  0% { opacity: .8; transform: scale(.9); }
  24% { opacity: 1; transform: scale(1.06); }
  100% { opacity: 1; transform: scale(1); }
}
@keyframes mountgateLevelNumberPulse {
  0%, 100% {
    transform: scale(1);
    text-shadow: 0 1px 8px rgba(229, 178, 76, .25);
  }
  50% {
    transform: scale(1.09);
    text-shadow: 0 1px 8px rgba(229, 178, 76, .45), 0 0 14px rgba(244, 199, 99, .45);
  }
}
@keyframes mountgateLevelRing {
  from { opacity: .8; transform: scale(.8); }
  to { opacity: 0; transform: scale(1.6); }
}
@keyframes mountgateUnlockIn {
  0% { opacity: 0; transform: translateY(42px) scale(.97); }
  72% { opacity: 1; transform: translateY(-4px) scale(1.01); }
  100% { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes mountgateUnlockOut {
  from { opacity: 1; transform: translateY(0); }
  to { opacity: 0; transform: translateY(14px); }
}
@keyframes mountgateUnlockGlow {
  0% { opacity: 0; transform: scale(.6); }
  24% { opacity: 1; transform: scale(1); }
  100% { opacity: 0; transform: scale(1.25); }
}
@keyframes mountgateLevelSpark {
  0% { opacity: 0; transform: translate(var(--spark-origin-x, 0px), var(--spark-origin-y, 0px)) scale(.45) rotate(0deg); }
  14% { opacity: 1; transform: translate(var(--spark-mid-x, 0px), var(--spark-mid-y, 0px)) scale(1.15) rotate(30deg); }
  65% { opacity: .95; }
  100% { opacity: 0; transform: translate(var(--spark-x, 0px), calc(var(--spark-y, 0px) + 20px)) scale(.55) rotate(160deg); }
}

@media (max-width: 640px) {
  .level-up-banner { min-height: 106px; grid-template-columns: 54px minmax(0, 1fr); padding: 15px; gap: 12px; }
  .level-up-banner-crest { width: 52px; height: 52px; }
  .level-up-banner-crest img { width: 36px; height: 36px; }
  .level-up-banner-copy > strong { font-size: 20px; }
  .level-up-banner-level b { font-size: 26px; }
  .level-up-banner::before, .level-up-banner::after { left: 83px; right: 15px; }
  .level-up-banner .level-up-celebration-particles { left: 42px; }
}
@media (prefers-reduced-motion: reduce) {
  .level-up-banner { animation: mountgateLevelFadeIn 120ms ease-out both; }
  .level-up-banner.is-leaving { animation: mountgateLevelFadeOut 120ms ease-in both; }
  .level-up-toast.level-up-unlock-toast { animation: mountgateLevelFadeIn 120ms ease-out both; }
  .level-up-toast.level-up-unlock-toast.is-leaving { animation: mountgateLevelFadeOut 120ms ease-in both; }
  .level-up-banner-crest,
  .level-up-banner-crest::after,
  .level-up-banner-level b,
  .level-up-toast.level-up-unlock-toast .level-up-toast-skill-icon,
  .level-up-toast.level-up-unlock-toast .level-up-toast-glow { animation: none; }
  .level-up-banner-crest::after,
  .level-up-celebration-particles { display: none; }
}
@keyframes mountgateLevelFadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes mountgateLevelFadeOut { from { opacity: 1; } to { opacity: 0; } }
