/* Basic full-screen mobile layout for Cocos Creator web builds.
 *
 * Layout follows the v.hitclub.pl pattern so iPhone Safari is able to
 * collapse its URL bar / tab bar:
 *   - body is position: absolute (not fixed) so it participates in the
 *     scroll context and can grow taller than the viewport.
 *   - body has touch-action: pan-x pan-y so the browser handles native
 *     pan gestures (this is what triggers Safari's chrome-hide animation).
 *   - canvas and #Cocos2dGameContainer are position: absolute too, so
 *     they live in the same scroll context as body. The Cocos engine
 *     repositions them on resize.
 *   - JS swaps body height between 100% (fullscreen) and 110vh
 *     (chrome-visible) at runtime.
 */

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;
}

/* Remove spin of input type number */
input::-webkit-outer-spin-button,
input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

body {
  margin: 0;
  padding: 0;
  position: absolute;
  top: 0;
  left: 0;
  width: 100lvw;
  width: 100vw;
  height: 100lvh;
  height: 100vh;
  background-color: #000;
  text-align: center;
  font-family: Helvetica, Verdana, Arial, sans-serif;
  touch-action: pan-x pan-y;
}

#game-shell {
  position: absolute;
  left: var(--app-offset-left, 0);
  top: var(--app-offset-top, 0);
  width: var(--app-width, 100vw);
  height: var(--app-height, 100vh);
  height: var(--app-height, 100dvh);
  box-sizing: border-box;
}

/* Canvas is always sized to the viewport (NOT 100% of body) so the body
 * can grow taller than the viewport for the iPhone Safari scroll trick
 * without the canvas stretching and leaving a black gap below it.
 * mobile-fullscreen.0424c.js updates --app-* from visualViewport on iOS Safari. */
#GameCanvas,
#Cocos2dGameContainer,
#play-root {
  position: absolute;
  left: var(--app-offset-left, 0);
  top: var(--app-offset-top, 0);
  width: var(--app-width, 100vw);
  height: var(--app-height, 100vh);
  height: var(--app-height, 100dvh);
  box-sizing: border-box;
}

#game-shell #GameCanvas,
#game-shell #Cocos2dGameContainer,
#game-shell #play-root {
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
}

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

/* Splash screen covers the whole viewport as well */
#splash {
  position: fixed;
  left: var(--app-offset-left, 0);
  top: var(--app-offset-top, 0);
  width: var(--app-width, 100vw);
  height: var(--app-height, 100dvh);
  margin: 0;
  padding: 0;
  background: #171717 url(./splash.6d95d.png) no-repeat center;
  background-size: 100%;
}

.progress-bar {
  position: absolute;
  left: 27.5%;
  top: 80%;
  height: 3px;
  padding: 2px;
  width: 45%;
  border-radius: 7px;
  box-shadow:
    0 1px 5px #000 inset,
    0 1px 0 #444;
}

.progress-bar span {
  display: block;
  height: 100%;
  border-radius: 3px;
  transition: width 0.4s ease-in-out;
  background-color: #3dc5de;
}

.stripes span {
  background-size: 30px 30px;
  background-image: linear-gradient(
    135deg,
    rgba(255, 255, 255, 0.15) 25%,
    transparent 25%,
    transparent 50%,
    rgba(255, 255, 255, 0.15) 50%,
    rgba(255, 255, 255, 0.15) 75%,
    transparent 75%,
    transparent
  );
  animation: animate-stripes 1s linear infinite;
}

@keyframes animate-stripes {
  0% {
    background-position: 0 0;
  }
  100% {
    background-position: 60px 0;
  }
}

#mobile-fs-mask {
  background-color: rgb(19, 19, 19);
  box-sizing: border-box;
  display: none;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  height: 100%;
  left: 0;
  opacity: 0.5;
  pointer-events: none;
  position: fixed;
  top: 0;
  width: 100%;
  z-index: 100000;
}

#mobile-fs-tip {
  color: #ff3b3b;
  font-size: 18px;
  font-weight: 700;
  left: 0;
  letter-spacing: 0.02em;
  margin: 0;
  padding: 0 16px;
  pointer-events: none;
  position: absolute;
  right: 0;
  text-align: center;
  text-shadow: 0 1px 8px #000;
  top: 10%;
  z-index: 1;
}

#mobile-fs-swipe {
  background: #000 url(fsc/swipe.gif) no-repeat center;
  background-size: min(42vmin, 220px);
  height: 100%;
  left: 0;
  pointer-events: none;
  position: absolute;
  top: 0;
  width: 100%;
}

.mobile-fs-mask-close {
  background: transparent;
  border: 0;
  cursor: pointer;
  padding: 0;
  pointer-events: auto;
  position: absolute;
  right: 10px;
  top: 10px;
  z-index: 2;
}

.mobile-fs-mask-close img {
  display: block;
  height: 40px;
  width: 40px;
}

@media (orientation: portrait) {
  #mobile-fs-mask {
    display: none !important;
  }
}

/* iPhone: document can scroll to collapse Safari chrome, but the game
   stays pinned so the canvas does not slide / flicker with the swipe. */
html.fs-chrome-show,
html.fs-chrome-show body {
  overflow-x: hidden;
  overflow-y: scroll;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: none;
}

html.fs-chrome-show #game-shell,
html.fs-chrome-show #GameCanvas,
html.fs-chrome-show #Cocos2dGameContainer,
html.fs-chrome-show #splash,
html.fs-chrome-show #play-root {
  pointer-events: none;
  position: fixed !important;
  left: var(--app-offset-left, 0) !important;
  top: var(--app-offset-top, 0) !important;
  right: auto !important;
  bottom: auto !important;
  width: var(--app-width, 100vw) !important;
  height: var(--app-height, 100dvh) !important;
  transform: none !important;
}

/* PWA standalone: lock body scroll; game uses full viewport (no safe-area inset). */
html.pwa-standalone body {
  overflow: hidden;
  position: fixed;
  height: 100%;
  width: 100%;
}
