:root { --match-loading-card-height: min(232px, calc(100svh - 40px)); }

/* Keep loading covers independent of the page scrollbar during screen changes. */
:is(#startup-screen, #app-loading, #card-preload) {
  width: 100vw;
}

#startup-screen {
  position: fixed;
  z-index: 10000;
  inset: 0;
  display: grid;
  place-items: center;
  padding: max(1rem, env(safe-area-inset-top)) 1rem max(1rem, env(safe-area-inset-bottom));
  background: #07111c;
  color: #f2f5f7;
  box-sizing: border-box;
  font: 400 16px/1.5 "Segoe UI", system-ui, sans-serif;
  opacity: 1;
  visibility: visible;
  transition: opacity 210ms ease, visibility 0s linear 210ms;
}

#startup-screen > div {
  width: min(100%, 30rem);
  padding: clamp(1.25rem, 5vw, 2.25rem);
  border: 1px solid #344754;
  border-radius: 16px;
  background: #101e2a;
  text-align: center;
}

#startup-screen[data-match-entry="true"] {
  padding-inline: max(20px, env(safe-area-inset-left)) max(20px, env(safe-area-inset-right));
  background: #070f0f;
  font-family: "Segoe UI", system-ui, sans-serif;
}

#startup-screen[data-match-entry="true"] > div {
  display: grid;
  justify-items: center;
  gap: .65rem;
  width: min(100%, 22.5rem);
  min-block-size: var(--match-loading-card-height);
  padding: 1.6rem 1.5rem;
  border-color: rgba(152, 237, 187, .34);
  border-radius: 16px;
  background: rgba(14, 26, 26, .98);
  box-shadow: 0 20px 55px rgba(0, 0, 0, .46);
}

#startup-screen[data-match-entry="true"] > div::before {
  color: #98edbb;
  content: "MONSTRUOS DE COMBATE";
  font-size: .58rem;
  font-weight: 900;
  letter-spacing: .14em;
}

#startup-screen[data-match-entry="true"] h1 {
  font-size: 1rem;
}

#startup-screen[data-match-entry="true"] #startup-screen-status {
  min-height: 0;
  margin: 0;
  color: #98edbb;
  font-size: .88rem;
  font-weight: 800;
  line-height: 1.4;
  text-wrap: balance;
}

#startup-screen[data-match-entry="true"] .startup-screen__progress {
  width: 28px;
  height: 28px;
  margin-top: .3rem;
  border: 3px solid rgba(152, 237, 187, .2);
  border-top-color: #98edbb;
  border-radius: 50%;
  background: transparent;
  animation: startup-match-spin .8s linear infinite;
}

#startup-screen[data-match-entry="true"] .startup-screen__progress::after {
  display: none;
}

#startup-screen h1 {
  margin: 0;
  color: #f2f5f7;
  font-size: clamp(1.45rem, 5vw, 2rem);
  line-height: 1.2;
  font-weight: 700;
  letter-spacing: -.02em;
  max-width: none;
}

#startup-screen-status {
  min-height: 1.5em;
  margin: .85rem 0 1.25rem;
  color: #c5d1d8;
  line-height: 1.5;
}

.startup-screen__progress {
  width: min(100%, 17rem);
  height: 4px;
  margin: 0 auto;
  overflow: hidden;
  border-radius: 999px;
  background: #263744;
}

.startup-screen__progress::after {
  display: block;
  width: 38%;
  height: 100%;
  border-radius: inherit;
  background: #f4c542;
  content: "";
  animation: startup-progress 1.35s ease-in-out infinite alternate;
}

#startup-screen-retry {
  min-width: 44px;
  min-height: 44px;
  margin-top: .4rem;
  border-color: #d6a916;
  background: #f4c542;
  color: #101820;
  font-weight: 700;
  padding: .6rem 1rem;
  border: 1px solid #d6a916;
  border-radius: 8px;
  font: inherit;
}

#startup-screen-retry:hover:not(:disabled) {
  background: #ffda68;
}

body[data-startup="loading"] .shell,
body[data-startup="loading"] .protected-shell,
body[data-startup="error"] .shell,
body[data-startup="error"] .protected-shell {
  visibility: hidden;
  opacity: 0;
}

body[data-startup="auth"] #startup-screen,
body[data-startup="ready"] #startup-screen {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

body[data-tutorial-entry="true"]:not([data-startup="error"]) #startup-screen,
body[data-tutorial-entry="true"][data-startup="error"] #app-loading {
  display: none;
}

body[data-startup="auth"] .shell,
body[data-startup="auth"] .protected-shell,
body[data-startup="ready"] .shell,
body[data-startup="ready"] .protected-shell {
  visibility: visible;
  opacity: 1;
  transition: opacity 210ms ease;
}

@keyframes startup-progress {
  from { transform: translateX(-5%); }
  to { transform: translateX(170%); }
}

@keyframes startup-match-spin {
  to { transform: rotate(360deg); }
}

body:not([data-startup="loading"]) .startup-screen__progress::after,
#startup-screen[data-paused="true"] .startup-screen__progress::after { animation-play-state: paused; }

@media (max-width: 480px) {
  #startup-screen { padding-right: .75rem; padding-left: .75rem; }
  #startup-screen > div { padding: 1.25rem 1rem; }
}

@media (prefers-reduced-motion: reduce) {
  #startup-screen,
  body[data-startup="auth"] .shell,
  body[data-startup="auth"] .protected-shell,
  body[data-startup="ready"] .shell,
  body[data-startup="ready"] .protected-shell {
    transition: none;
  }
  .startup-screen__progress::after {
    width: 100%;
    animation: none;
    transform: none;
  }
  #startup-screen[data-match-entry="true"] .startup-screen__progress { animation: none; }
}
