/* V1.55 non-blocking battle handoff: opponent framing, mode identity and restrained cadence. */
html body:not(.maintenance-mode) #battleIntroOverlay.battle-intro-overlay {
  position: fixed;
  z-index: 185;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  overflow: hidden;
  pointer-events: none;
  isolation: isolate;
}

html body:not(.maintenance-mode) #battleIntroOverlay.battle-intro-overlay[hidden] {
  display: none !important;
}

html body:not(.maintenance-mode) #battleIntroOverlay.battle-intro-overlay::before {
  content: "";
  position: absolute;
  z-index: -2;
  inset: 0;
  background:
    linear-gradient(110deg, rgba(7, 30, 42, 0.91) 0 42%, rgba(3, 8, 13, 0.7) 49% 51%, rgba(40, 16, 18, 0.91) 58% 100%),
    rgba(2, 6, 10, 0.84);
  backdrop-filter: blur(5px) saturate(0.76);
}

html body:not(.maintenance-mode) #battleIntroOverlay.battle-intro-overlay::after {
  content: "";
  position: absolute;
  z-index: -1;
  left: 50%;
  top: -20%;
  width: 2px;
  height: 140%;
  background: linear-gradient(180deg, transparent, rgba(228, 243, 249, 0.72) 32%, rgba(242, 202, 104, 0.84) 50%, rgba(228, 243, 249, 0.72) 68%, transparent);
  box-shadow: 0 0 24px rgba(166, 221, 239, 0.45), 0 0 60px rgba(232, 194, 92, 0.2);
  transform: rotate(8deg);
  transform-origin: center;
}

html body:not(.maintenance-mode) #battleIntroOverlay .battle-intro-stage {
  width: min(1120px, calc(100vw - 44px));
  min-height: min(460px, calc(100dvh - 80px));
  display: grid;
  grid-template-columns: minmax(0, 1fr) clamp(96px, 10vw, 132px) minmax(0, 1fr);
  align-items: center;
  gap: clamp(12px, 2vw, 28px);
}

html body:not(.maintenance-mode) #battleIntroOverlay .battle-intro-side {
  position: relative;
  min-width: 0;
  height: min(430px, calc(100dvh - 112px));
  display: grid;
  grid-template-rows: 1fr auto auto;
  align-items: end;
  padding: 22px clamp(18px, 2.4vw, 34px) 28px;
  overflow: hidden;
  border: 1px solid rgba(207, 233, 242, 0.34);
  border-radius: 22px 6px 22px 6px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.035), transparent 24%),
    linear-gradient(150deg, rgba(18, 47, 61, 0.82), rgba(4, 12, 18, 0.96));
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.045), 0 26px 74px rgba(0, 0, 0, 0.48);
}

html body:not(.maintenance-mode) #battleIntroOverlay .battle-intro-side.opponent-side {
  border-color: rgba(229, 144, 132, 0.4);
  border-radius: 6px 22px 6px 22px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.035), transparent 24%),
    linear-gradient(210deg, rgba(66, 27, 30, 0.82), rgba(13, 7, 12, 0.96));
}

html body:not(.maintenance-mode) #battleIntroOverlay .battle-intro-portrait {
  position: absolute;
  inset: 0;
  display: block;
  background:
    linear-gradient(180deg, transparent 42%, rgba(3, 9, 14, 0.15) 60%, rgba(3, 9, 14, 0.96) 91%),
    var(--battle-intro-art) center 20% / cover no-repeat;
  filter: saturate(0.9) contrast(1.04);
}

html body:not(.maintenance-mode) #battleIntroOverlay .opponent-side .battle-intro-portrait {
  transform: scaleX(-1);
}

html body:not(.maintenance-mode) #battleIntroOverlay .battle-intro-side small,
html body:not(.maintenance-mode) #battleIntroOverlay .battle-intro-side strong {
  position: relative;
  z-index: 2;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

html body:not(.maintenance-mode) #battleIntroOverlay .battle-intro-side small {
  margin-bottom: 5px;
  color: rgba(199, 231, 242, 0.76);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.16em;
}

html body:not(.maintenance-mode) #battleIntroOverlay .opponent-side small {
  color: rgba(255, 199, 190, 0.78);
  text-align: right;
}

html body:not(.maintenance-mode) #battleIntroOverlay .battle-intro-side strong {
  color: #effaff;
  font-size: clamp(30px, 3.3vw, 48px);
  line-height: 1.08;
  text-shadow: 0 3px 12px rgba(0, 0, 0, 0.92), 0 0 24px rgba(119, 210, 237, 0.25);
}

html body:not(.maintenance-mode) #battleIntroOverlay .opponent-side strong {
  color: #ffe0d9;
  text-align: right;
  text-shadow: 0 3px 12px rgba(0, 0, 0, 0.92), 0 0 24px rgba(218, 101, 90, 0.25);
}

html body:not(.maintenance-mode) #battleIntroOverlay .battle-intro-center {
  position: relative;
  z-index: 3;
  display: grid;
  justify-items: center;
  gap: 8px;
  text-align: center;
}

html body:not(.maintenance-mode) #battleIntroOverlay .battle-intro-center small,
html body:not(.maintenance-mode) #battleIntroOverlay .battle-intro-center em {
  color: rgba(226, 242, 248, 0.82);
  font-size: 11px;
  font-style: normal;
  font-weight: 1000;
  letter-spacing: 0.15em;
}

html body:not(.maintenance-mode) #battleIntroOverlay .battle-intro-center b {
  position: relative;
  width: clamp(76px, 7.4vw, 104px);
  height: clamp(76px, 7.4vw, 104px);
  display: grid;
  place-items: center;
  border: 1px solid rgba(246, 211, 119, 0.72);
  border-radius: 50%;
  background: radial-gradient(circle, rgba(226, 194, 98, 0.22), rgba(3, 9, 14, 0.92) 66%);
  color: #fff0b3;
  font-size: clamp(31px, 3.4vw, 46px);
  font-style: italic;
  line-height: 1;
  letter-spacing: -0.08em;
  text-indent: -0.08em;
  text-shadow: 0 0 18px rgba(246, 204, 92, 0.52), 0 3px 8px rgba(0, 0, 0, 0.9);
  box-shadow: inset 0 0 18px rgba(246, 204, 92, 0.12), 0 0 32px rgba(142, 208, 229, 0.22);
}

html body:not(.maintenance-mode) #battleIntroOverlay.battle-intro-revealed {
  animation: battle-intro-curtain 1750ms linear both;
}

html body:not(.maintenance-mode) #battleIntroOverlay.battle-intro-revealed .self-side {
  animation: battle-intro-self 720ms cubic-bezier(0.14, 0.86, 0.2, 1) both;
}

html body:not(.maintenance-mode) #battleIntroOverlay.battle-intro-revealed .opponent-side {
  animation: battle-intro-opponent 720ms cubic-bezier(0.14, 0.86, 0.2, 1) both;
}

html body:not(.maintenance-mode) #battleIntroOverlay.battle-intro-revealed .battle-intro-center {
  animation: battle-intro-versus 760ms 110ms cubic-bezier(0.16, 0.9, 0.22, 1) both;
}

@keyframes battle-intro-curtain {
  0% { opacity: 0; }
  10%, 76% { opacity: 1; }
  100% { opacity: 0; }
}

@keyframes battle-intro-self {
  0% { opacity: 0; transform: translateX(-34px); filter: saturate(0.55); }
  100% { opacity: 1; transform: translateX(0); filter: saturate(1); }
}

@keyframes battle-intro-opponent {
  0% { opacity: 0; transform: translateX(34px); filter: saturate(0.55); }
  100% { opacity: 1; transform: translateX(0); filter: saturate(1); }
}

@keyframes battle-intro-versus {
  0% { opacity: 0; transform: scale(0.7); filter: blur(4px); }
  64% { opacity: 1; transform: scale(1.08); filter: blur(0); }
  100% { opacity: 1; transform: scale(1); filter: blur(0); }
}

@media (max-width: 720px) {
  html body:not(.maintenance-mode) #battleIntroOverlay.battle-intro-overlay {
    padding: 12px;
  }

  html body:not(.maintenance-mode) #battleIntroOverlay .battle-intro-stage {
    width: min(100%, 430px);
    min-height: min(520px, calc(100dvh - 32px));
    grid-template-columns: minmax(0, 1fr) 56px minmax(0, 1fr);
    gap: 6px;
  }

  html body:not(.maintenance-mode) #battleIntroOverlay .battle-intro-side {
    height: min(420px, calc(100dvh - 96px));
    padding: 14px 9px 20px;
    border-radius: 15px 4px 15px 4px;
  }

  html body:not(.maintenance-mode) #battleIntroOverlay .battle-intro-side.opponent-side {
    border-radius: 4px 15px 4px 15px;
  }

  html body:not(.maintenance-mode) #battleIntroOverlay .battle-intro-portrait {
    background-position: center 20%, center 20%;
  }

  html body:not(.maintenance-mode) #battleIntroOverlay .battle-intro-side strong {
    font-size: clamp(20px, 7vw, 30px);
  }

  html body:not(.maintenance-mode) #battleIntroOverlay .battle-intro-side small {
    font-size: 9px;
    letter-spacing: 0.08em;
  }

  html body:not(.maintenance-mode) #battleIntroOverlay .battle-intro-center {
    gap: 6px;
  }

  html body:not(.maintenance-mode) #battleIntroOverlay .battle-intro-center b {
    width: 52px;
    height: 52px;
    font-size: 24px;
  }

  html body:not(.maintenance-mode) #battleIntroOverlay .battle-intro-center small,
  html body:not(.maintenance-mode) #battleIntroOverlay .battle-intro-center em {
    font-size: 8px;
    letter-spacing: 0.06em;
  }
}

@media (prefers-reduced-motion: reduce) {
  html body:not(.maintenance-mode) #battleIntroOverlay.battle-intro-overlay,
  html body:not(.maintenance-mode) #battleIntroOverlay.battle-intro-overlay *,
  html body:not(.maintenance-mode) #battleIntroOverlay.battle-intro-overlay::before,
  html body:not(.maintenance-mode) #battleIntroOverlay.battle-intro-overlay::after {
    animation: none !important;
    transition: none !important;
  }
}
