:root {
  --fs-field-bg: #efedec;
  --fs-field-border: #282929;
  --fs-text: rgba(255, 255, 255, 0.92);
  --fs-error: #ffb4b4;
  --fs-play-red: #f15b6c;
  --fs-grass: #3d8c40;
  --splash-inline-padding: clamp(1rem, 4vw, 1.5rem);
  --splash-block-padding: clamp(1rem, 2.5vh, 1.5rem);
  --splash-section-gap: clamp(0.75rem, 2.5vh, 1.75rem);
}

html,
body {
  background-color: var(--fs-grass);
}

.splash:not(.splash--hidden) {
  z-index: 100;
}

.splash {
  position: relative;
  z-index: 2;
  box-sizing: border-box;
  display: grid;
  grid-template-areas: "splash-stack";
  min-height: 100dvh;
  overflow: hidden;
  background-color: var(--fs-grass);
  color: var(--fs-text);
  font-family: "Pixel Code", monospace;
}

.splash__terrain,
.splash__logo-graphic,
.splash__units,
.splash__layout {
  grid-area: splash-stack;
}

.splash__terrain {
  position: absolute;
  inset: 0;
  z-index: 0;
  width: 100%;
  height: 100%;
  display: block;
  opacity: 0;
}

.splash__terrain--ready {
  opacity: 1;
}

.splash__units {
  position: absolute;
  inset: 0;
  z-index: 2;
  overflow: hidden;
  pointer-events: none;
}

.splash__logo-graphic {
  z-index: 1;
  pointer-events: none;
}

.splash__logo-graphic:not(.splash__logo-graphic--ready) .splash__logo-back {
  visibility: hidden;
}

.splash__logo-graphic .splash__layout {
  pointer-events: none;
}

.splash__form-spacer {
  width: min(420px, 100%);
  flex-shrink: 0;
}

.splash__units canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.splash__layout {
  position: relative;
  z-index: 3;
  box-sizing: border-box;
  display: grid;
  grid-template-rows: minmax(0, 1fr);
  gap: var(--splash-section-gap);
  width: 100%;
  min-height: 100dvh;
  padding:
    var(--splash-block-padding) var(--splash-inline-padding)
    max(var(--splash-block-padding), env(safe-area-inset-bottom, 0px));
}

.splash__main {
  display: flex;
  min-height: 0;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--splash-section-gap);
}


.splash--hidden {
  display: none;
}

.splash--loading .splash__form {
  opacity: 0.85;
}

.splash__logo {
  position: relative;
  flex-shrink: 1;
  width: min(959px, 100%);
  height: min(328px, calc(100vw * 328 / 959), 34dvh);
  min-height: 120px;
  animation: splash-bounce 2s ease-in-out infinite;
}

.splash__logo * {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  pointer-events: none;
  user-select: none;
}

.splash__logo-back {
  animation: splash-rotate 5s ease-in-out infinite alternate-reverse;
}

.splash__logo-text {
  animation: splash-bounce-small 2s ease-in-out infinite;
  animation-delay: 0.5s;
}

.splash__logo img {
  display: block;
  height: auto;
}

.splash__shimmer {
  -webkit-mask: linear-gradient(-60deg, #000 30%, #0005, #000 70%) 300% / 300%
    100%;
  mask: linear-gradient(-60deg, #000 30%, #0005, #000 70%) 300% / 300% 100%;
  animation: splash-shimmer 8s infinite;
}

.splash__form {
  display: flex;
  width: min(420px, 100%);
  flex-shrink: 0;
  flex-direction: column;
  gap: 1rem;
}

.splash__field {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.splash__field label {
  font-weight: 600;
}

.splash__field input,
.splash__field select {
  padding: 1rem 1.25rem;
  border: 5px solid var(--fs-field-border);
  border-radius: 0;
  background-color: var(--fs-field-bg);
  font: inherit;
}

.splash__field input:focus-visible,
.splash__field select:focus-visible,
.splash__play-button:focus-visible {
  outline: 3px solid #ffffff;
  outline-offset: 2px;
}

.splash__error {
  min-height: 1.25rem;
  margin: 0;
  color: var(--fs-error);
  font-weight: 600;
}

.splash__status {
  position: fixed;
  z-index: 140;
  bottom: var(--app-controls-inset);
  left: 50%;
  width: max-content;
  max-width: none;
  margin: 0;
  transform: translateX(-50%);
  text-align: center;
  font-weight: 600;
  white-space: nowrap;
  pointer-events: none;
}

.splash__status:empty {
  display: none;
}

.splash__play-button {
  align-self: center;
  margin-top: 0.5rem;
  padding: 1rem 2rem;
  border: 5px solid var(--fs-field-border);
  border-radius: 0;
  background-color: var(--fs-play-red);
  color: #ffffff;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.splash__play-button:hover:not(:disabled) {
  opacity: 0.85;
}

.splash__play-button:disabled {
  cursor: not-allowed;
  opacity: 0.7;
}

@keyframes splash-bounce {
  0%,
  100% {
    transform: translateY(0);
  }

  50% {
    transform: translateY(-10px);
  }
}

@keyframes splash-bounce-small {
  0%,
  100% {
    transform: translateY(0);
  }

  50% {
    transform: translateY(-5px);
  }
}

@keyframes splash-rotate {
  0% {
    transform: rotate(-2deg);
  }

  100% {
    transform: rotate(2deg);
  }
}

@keyframes splash-shimmer {
  0% {
    -webkit-mask-position: right;
    mask-position: right;
  }

  10%,
  100% {
    -webkit-mask-position: left;
    mask-position: left;
  }
}

@media (max-height: 720px) {
  .splash__logo {
    height: min(240px, 28dvh);
    min-height: 96px;
  }

  .splash__form {
    gap: 0.75rem;
  }

  .splash__field input,
  .splash__field select,
  .splash__play-button {
    padding-top: 0.75rem;
    padding-bottom: 0.75rem;
  }
}

@media (max-height: 560px) {
  .splash__layout {
    gap: 0.75rem;
  }

  .splash__main {
    gap: 0.75rem;
  }

  .splash__logo {
    height: min(160px, 22dvh);
    min-height: 72px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .splash__logo,
  .splash__logo-back,
  .splash__logo-text,
  .splash__shimmer {
    animation: none;
  }

  .splash__units {
    display: none;
  }
}
