html {
  -ms-touch-action: none;
}

body, canvas, div {
  display: block;
  outline: none;
  -webkit-tap-highlight-color: rgba(0, 0, 0, 0);

  user-select: none;
  -moz-user-select: none;
  -webkit-user-select: none;
  -ms-user-select: none;
  -khtml-user-select: none;
  -webkit-tap-highlight-color: rgba(0, 0, 0, 0);
}

/* Remove spin of input type number */
input::-webkit-outer-spin-button,
input::-webkit-inner-spin-button {
    /* display: none; <- Crashes Chrome on hover */
    -webkit-appearance: none;
    margin: 0; /* <-- Apparently some margin are still there even though it's hidden */
}

body {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  padding: 0;
  border: 0;
  margin: 0;

  cursor: default;
  color: #888;
  background-color: #03040b;

  text-align: center;
  font-family: Helvetica, Verdana, Arial, sans-serif;

  display: flex;
  flex-direction: column;
}

canvas {
  background-color: rgba(0, 0, 0, 0);
}

#GameDiv, #Cocos3dGameContainer, #GameCanvas {
  width: 100%;
  height: 100%;
}

/* Desktop: the game plays in a portrait column in the middle of the window (services/ScreenFit.ts
   adds .column). Around it: deep space, a faint glow behind the column and a sparse starfield in
   tiles of different sizes, so the pattern does not visibly repeat. Static, so free to draw. */
body.column {
  background-color: #02030a;
  background-image:
    radial-gradient(ellipse 50% 75% at 50% 50%, rgba(34, 62, 140, 0.34), rgba(34, 62, 140, 0) 72%),
    radial-gradient(circle at 23px 41px, rgba(255, 255, 255, 0.4) 0.5px, rgba(255, 255, 255, 0) 1.2px),
    radial-gradient(circle at 131px 97px, rgba(185, 215, 255, 0.45) 0.6px, rgba(185, 215, 255, 0) 1.4px),
    radial-gradient(circle at 74px 168px, rgba(255, 255, 255, 0.3) 0.5px, rgba(255, 255, 255, 0) 1.1px),
    radial-gradient(circle at 211px 29px, rgba(255, 228, 196, 0.5) 0.7px, rgba(255, 228, 196, 0) 1.6px),
    radial-gradient(circle at 57px 233px, rgba(255, 255, 255, 0.35) 0.5px, rgba(255, 255, 255, 0) 1.2px),
    radial-gradient(circle at 263px 119px, rgba(200, 225, 255, 0.55) 0.7px, rgba(200, 225, 255, 0) 1.6px),
    radial-gradient(circle at 389px 302px, rgba(150, 200, 255, 0.75) 1px, rgba(150, 200, 255, 0) 2.2px),
    radial-gradient(circle at 151px 487px, rgba(255, 240, 220, 0.8) 1.1px, rgba(255, 240, 220, 0) 2.6px);
  background-size: 100% 100%, 137px 137px, 181px 181px, 229px 229px, 263px 263px, 311px 311px, 353px 353px, 467px 467px, 593px 593px;
  background-repeat: no-repeat, repeat, repeat, repeat, repeat, repeat, repeat, repeat, repeat;
}

/* A thin cyan rim and a soft halo set the column off from the backdrop. */
body.column #Cocos3dGameContainer {
  box-shadow:
    0 0 0 1px rgba(110, 190, 255, 0.22),
    0 0 48px 2px rgba(40, 140, 255, 0.22),
    0 0 220px 30px rgba(30, 70, 170, 0.28);
}

/* Loading splash (index.ejs): the logo over a faint glow and a running bar, from the first paint
   until the first scene is up. The iPhone launch screens (splash/launch-*.png) draw the same
   picture, so an installed app goes launch screen → splash → menu without a jump. */
#splash {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 10;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background-color: #03040b;
  background-image: radial-gradient(ellipse 70% 40% at 50% 50%, rgba(34, 62, 140, 0.3), rgba(34, 62, 140, 0) 70%);
  transition: opacity 0.5s ease-out;
}

#splash.gone {
  opacity: 0;
  pointer-events: none;
}

#splash .logo {
  width: min(82vw, 460px);
  height: auto;
}

#splash .bar {
  width: min(36vw, 180px);
  height: 3px;
  margin-top: 28px;
  border-radius: 2px;
  background: rgba(90, 210, 255, 0.14);
  overflow: hidden;
}

#splash .bar i {
  display: block;
  width: 45%;
  height: 100%;
  background: linear-gradient(90deg, rgba(90, 210, 255, 0), #5ad2ff, rgba(90, 210, 255, 0));
  animation: splash-run 1.2s ease-in-out infinite;
}

@keyframes splash-run {
  from { transform: translateX(-100%); }
  to { transform: translateX(230%); }
}

:root {
  --safe-top: env(safe-area-inset-top);
  --safe-right: env(safe-area-inset-right);
  --safe-bottom: env(safe-area-inset-bottom);
  --safe-left: env(safe-area-inset-left);
}
