html,
body {
  width: var(--h5-adapt-vw, 100vw);
  height: var(--h5-adapt-vh, 100vh);
  min-height: var(--h5-adapt-vh, 100vh);
  margin: 0;
  overscroll-behavior: none;
  background: #000;
  overflow: hidden;
}

html {
  min-height: calc(100% + constant(safe-area-inset-top));
  min-height: calc(100% + env(safe-area-inset-top, 0px));
}

body {
  display: grid;
  grid-template-areas: "stage";
  grid-template-columns: var(--h5-adapt-vw, 100vw);
  grid-template-rows: var(--h5-adapt-vh, 100vh);
}

body > #GameDiv,
body > #splash-overlay {
  grid-area: stage;
  position: fixed;
  top: 0;
  left: 0;
  min-width: 0;
  min-height: 0;
}

#splash-overlay {
  position: relative;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  width: var(--h5-adapt-vw, 100vw);
  height: var(--h5-adapt-vh, 100vh);
  overflow: hidden;
  box-sizing: border-box;
  isolation: isolate;
  background: #010202;
  opacity: 1;
  transition: opacity 0.9s ease;
}

#splash-overlay::before,
#splash-overlay::after {
  position: absolute;
  inset: 0;
  content: "";
  pointer-events: none;
}

#splash-overlay::before {
  z-index: 0;
  background:
    repeating-linear-gradient(45deg, transparent 0 24px, rgba(186, 210, 207, 0.045) 24px 29px, transparent 29px 54px),
    repeating-linear-gradient(-45deg, transparent 0 24px, rgba(255, 255, 255, 0.026) 24px 30px, transparent 30px 55px),
    repeating-linear-gradient(90deg, transparent 0 68px, rgba(255, 255, 255, 0.014) 68px 73px, transparent 73px 136px);
  background-size:
    132px 132px,
    132px 132px,
    272px 272px;
  filter: contrast(1.25);
  opacity: 0;
  transform: scale(1.22);
  background-position:
    0 0,
    0 0,
    0 0;
  animation:
    splash-pattern-open 2s linear forwards,
    splash-pattern-drift 72s linear 2s infinite;
}

#splash-overlay::after {
  z-index: 3;
  background:
    radial-gradient(ellipse at center, transparent 0 34%, rgba(0, 0, 0, 0.32) 63%, rgba(0, 0, 0, 0.9) 100%),
    linear-gradient(90deg, rgba(0, 0, 0, 0.45), transparent 18%, transparent 82%, rgba(0, 0, 0, 0.45));
}

#splash-overlay.fade-out {
  opacity: 0;
  pointer-events: none;
}

.splash-content {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: min(980px, calc(100% - 48px));
  aspect-ratio: 1280 / 576;
  box-sizing: border-box;
  padding: 0 24px;
  color: #fff;
  text-align: center;
  text-transform: uppercase;
  user-select: none;
  transform: scale(0.7);
  opacity: 0;
  filter: blur(6px) drop-shadow(0 0 0 rgba(255, 255, 255, 0));
  animation: splash-logo-steps 2s cubic-bezier(0.2, 0.86, 0.18, 1) forwards;
}

.splash-content::before {
  position: absolute;
  inset: -55% -34%;
  z-index: -1;
  content: "";
  background:
    radial-gradient(ellipse at center, rgba(255, 255, 255, 0.3), rgba(205, 229, 225, 0.11) 18%, rgba(255, 255, 255, 0.035) 36%, transparent 58%),
    linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.09), transparent);
  opacity: 0;
  transform: scaleX(0.3) scaleY(0.6);
  animation:
    splash-center-light 2s ease-out forwards,
    splash-center-pulse 10.5s ease-in-out 2.4s infinite;
}

.splash-title {
  position: relative;
  display: inline-block;
  overflow: visible;
  background: none;
  -webkit-text-fill-color: currentColor;
  will-change: text-shadow;
}

.splash-title::before,
.splash-title::after {
  position: absolute;
  inset: 0;
  content: attr(data-splash-text);
  pointer-events: none;
  line-height: inherit;
  letter-spacing: inherit;
  white-space: inherit;
  background: none;
  background-clip: border-box;
  opacity: 0;
  mix-blend-mode: screen;
  will-change: opacity, mask-position, -webkit-mask-position;
}

.splash-title::before {
  color: #fff;
  -webkit-text-fill-color: #fff;
  text-shadow:
    0 0 4px rgba(255, 255, 255, 0.86),
    0 0 12px rgba(222, 241, 238, 0.5);
  filter: blur(0.18px);
  -webkit-mask-image: linear-gradient(90deg, transparent 0%, #000 44%, #000 49%, transparent 56%);
  mask-image: linear-gradient(90deg, transparent 0%, #000 44%, #000 49%, transparent 56%);
  -webkit-mask-position: -34% 0;
  mask-position: -34% 0;
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
  -webkit-mask-size: 22% 100%;
  mask-size: 22% 100%;
  animation: splash-text-blade-reveal 1.75s cubic-bezier(0.18, 0.84, 0.22, 1) 0.78s forwards;
}

.splash-title::after {
  color: rgba(255, 255, 255, 0.82);
  -webkit-text-fill-color: rgba(255, 255, 255, 0.82);
  text-shadow:
    0 0 7px rgba(255, 255, 255, 0.72),
    0 0 20px rgba(218, 238, 235, 0.34);
  filter: blur(3.6px);
  -webkit-mask-image: linear-gradient(90deg, transparent 0%, #000 22%, #000 70%, transparent 100%);
  mask-image: linear-gradient(90deg, transparent 0%, #000 22%, #000 70%, transparent 100%);
  -webkit-mask-position: -50% 0;
  mask-position: -50% 0;
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
  -webkit-mask-size: 42% 100%;
  mask-size: 42% 100%;
  animation: splash-text-mist-reveal 2.1s cubic-bezier(0.2, 0.76, 0.26, 1) 0.62s forwards;
}

.splash-title {
  max-width: 100%;
  font-family: "Arial Black", Impact, Arial, sans-serif;
  font-size: 88px;
  font-weight: 900;
  line-height: 0.9;
  letter-spacing: 0;
  color: #fff;
  white-space: nowrap;
  text-shadow:
    0 0 4px rgba(255, 255, 255, 0.62),
    0 0 18px rgba(255, 255, 255, 0.24);
  animation: splash-title-glow 10s ease-in-out 2.6s infinite;
}

@media (max-width: 900px), (max-height: 520px) {
  .splash-content {
    width: min(720px, calc(100% - 32px));
    padding: 0 16px;
  }

  .splash-title {
    font-size: 58px;
  }
}

@media (max-width: 620px), (max-height: 380px) {
  .splash-title {
    font-size: 42px;
  }
}

@media (orientation: portrait) {
  .splash-content {
    width: min(92dvh, 720px);
    max-width: none;
    transform-origin: center;
    animation-name: splash-logo-steps-portrait;
  }
}

@keyframes splash-pattern-open {
  0%,
  6% {
    opacity: 0;
    transform: scale(1.22);
  }

  9% {
    opacity: 0.16;
  }

  14% {
    opacity: 0.46;
    transform: scale(1.12);
  }

  25% {
    opacity: 0.74;
    transform: scale(1.06);
  }

  45% {
    opacity: 0.88;
    transform: scale(1.02);
  }

  66%,
  100% {
    opacity: 0.92;
    transform: scale(1);
  }
}

@keyframes splash-pattern-drift {
  0% {
    background-position:
      0 0,
      0 0,
      0 0;
  }

  100% {
    background-position:
      36px 36px,
      -36px 36px,
      22px 0;
  }
}

@keyframes splash-center-light {
  0%,
  6% {
    opacity: 0;
    transform: scaleX(0.3) scaleY(0.6);
  }

  10% {
    opacity: 0.9;
    transform: scaleX(0.62) scaleY(0.86);
  }

  18% {
    opacity: 0.82;
    transform: scaleX(0.9) scaleY(1);
  }

  32% {
    opacity: 0.58;
    transform: scaleX(1.08) scaleY(1.08);
  }

  58% {
    opacity: 0.33;
    transform: scaleX(1.18) scaleY(1.12);
  }

  100% {
    opacity: 0.22;
    transform: scaleX(1.22) scaleY(1.14);
  }
}

@keyframes splash-center-pulse {
  0%,
  100% {
    opacity: 0.2;
    transform: scaleX(1.22) scaleY(1.14);
  }

  50% {
    opacity: 0.26;
    transform: scaleX(1.27) scaleY(1.17);
  }
}

@keyframes splash-text-blade-reveal {
  0% {
    opacity: 0;
    -webkit-mask-position: -34% 0;
    mask-position: -34% 0;
  }

  7% {
    opacity: 0.72;
  }

  78% {
    opacity: 0.66;
  }

  100% {
    opacity: 0;
    -webkit-mask-position: 134% 0;
    mask-position: 134% 0;
  }
}

@keyframes splash-text-mist-reveal {
  0% {
    opacity: 0;
    -webkit-mask-position: -50% 0;
    mask-position: -50% 0;
  }

  10% {
    opacity: 0.24;
  }

  76% {
    opacity: 0.2;
  }

  100% {
    opacity: 0;
    -webkit-mask-position: 118% 0;
    mask-position: 118% 0;
  }
}

@keyframes splash-title-glow {
  0%,
  100% {
    text-shadow:
      0 0 3px rgba(255, 255, 255, 0.54),
      0 0 14px rgba(255, 255, 255, 0.16);
  }

  50% {
    text-shadow:
      0 0 4px rgba(255, 255, 255, 0.62),
      0 0 18px rgba(218, 238, 235, 0.22);
  }
}

@keyframes splash-logo-steps {
  0%,
  6% {
    opacity: 0;
    transform: scale(0.58);
    filter: blur(7px) drop-shadow(0 0 0 rgba(255, 255, 255, 0));
  }

  9% {
    opacity: 0.62;
    transform: scale(1.16);
    filter: blur(2px) drop-shadow(0 0 8px rgba(255, 255, 255, 0.42));
  }

  14% {
    opacity: 1;
    transform: scale(1.08);
    filter:
      blur(0.2px)
      drop-shadow(0 0 8px rgba(255, 255, 255, 0.65))
      drop-shadow(0 0 26px rgba(255, 255, 255, 0.36));
  }

  28% {
    opacity: 1;
    transform: scale(1);
  }

  42% {
    opacity: 0.98;
    transform: scale(0.94);
  }

  66%,
  100% {
    opacity: 1;
    transform: scale(0.92);
    filter:
      blur(0)
      drop-shadow(0 0 4px rgba(255, 255, 255, 0.62))
      drop-shadow(0 0 18px rgba(255, 255, 255, 0.24));
  }
}

@keyframes splash-logo-steps-portrait {
  0%,
  6% {
    opacity: 0;
    transform: rotate(90deg) scale(0.58);
    filter: blur(7px) drop-shadow(0 0 0 rgba(255, 255, 255, 0));
  }

  9% {
    opacity: 0.62;
    transform: rotate(90deg) scale(1.16);
    filter: blur(2px) drop-shadow(0 0 8px rgba(255, 255, 255, 0.42));
  }

  14% {
    opacity: 1;
    transform: rotate(90deg) scale(1.08);
    filter:
      blur(0.2px)
      drop-shadow(0 0 8px rgba(255, 255, 255, 0.65))
      drop-shadow(0 0 26px rgba(255, 255, 255, 0.36));
  }

  28% {
    opacity: 1;
    transform: rotate(90deg) scale(1);
  }

  42% {
    opacity: 0.98;
    transform: rotate(90deg) scale(0.94);
  }

  66%,
  100% {
    opacity: 1;
    transform: rotate(90deg) scale(0.92);
    filter:
      blur(0)
      drop-shadow(0 0 4px rgba(255, 255, 255, 0.62))
      drop-shadow(0 0 18px rgba(255, 255, 255, 0.24));
  }
}

@media (prefers-reduced-motion: reduce) {
  #splash-overlay::before,
  .splash-content,
  .splash-content::before,
  .splash-title,
  .splash-title::before,
  .splash-title::after {
    animation: none;
  }

  #splash-overlay::before {
    opacity: 0.92;
    transform: scale(1);
  }

  .splash-content {
    opacity: 1;
    transform: scale(0.92);
    filter:
      blur(0)
      drop-shadow(0 0 4px rgba(255, 255, 255, 0.62))
      drop-shadow(0 0 18px rgba(255, 255, 255, 0.24));
  }

  .splash-content::before {
    opacity: 0.22;
    transform: scaleX(1.22) scaleY(1.14);
  }

  .splash-title::before,
  .splash-title::after {
    opacity: 0;
  }
}
