: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);
  background-color: #eadfff;
}

html {
  -ms-touch-action: none;
  position: fixed;
  inset: 0;
  width: 100%;
  min-width: 100%;
  height: 100%;
  min-height: 100%;
  padding: 0;
  margin: 0;
  overflow: hidden;
  overscroll-behavior: none;
  background-color: #eadfff;
}

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;
}

input::-webkit-outer-spin-button,
input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

body {
  position: fixed;
  inset: 0;
  box-sizing: border-box;
  width: 100vw;
  min-width: 100%;
  height: 100vh;
  min-height: 100%;
  padding: 0;
  border: 0;
  margin: 0;
  overflow: hidden;
  overscroll-behavior: none;
  cursor: default;
  color: #888;
  background-color: #eadfff;
  background-image: none;
  text-align: center;
  font-family: Helvetica, Verdana, Arial, sans-serif;
  display: flex;
  flex-direction: column;
}

#GameDiv {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
}

#GameDiv,
#Cocos3dGameContainer {
  background-color: #eadfff !important;
}

#GameCanvas {
  background-color: transparent !important;
  background-image: none !important;
}

#GameDiv, #Cocos3dGameContainer, #GameCanvas {
  box-sizing: border-box;
  width: 100vw !important;
  min-width: 100% !important;
  height: 100vh !important;
  min-height: 100% !important;
  padding: 0 !important;
  border: 0 !important;
  margin: 0 !important;
}

#MazeLoading {
  position: fixed;
  inset: 0;
  z-index: 2147483647;
  display: grid;
  place-items: center;
  box-sizing: border-box;
  width: 100vw;
  min-width: 100%;
  height: 100vh;
  min-height: 100%;
  padding: max(24px, env(safe-area-inset-top)) max(20px, env(safe-area-inset-right))
    max(24px, env(safe-area-inset-bottom)) max(20px, env(safe-area-inset-left));
  pointer-events: auto;
  opacity: 1;
  background: #eadfff;
  transition: opacity 0.32s ease;
}

#MazeLoading.is-finished {
  opacity: 0;
  pointer-events: none;
}

.maze-loading-panel {
  width: min(78vw, 560px);
  padding: 24px 24px 20px;
  border: 4px solid #d79216;
  border-radius: 28px;
  box-sizing: border-box;
  color: #8c4a13;
  background: rgba(255, 247, 184, 0.94);
  box-shadow: 0 12px 30px rgba(113, 66, 26, 0.25), inset 0 0 0 3px rgba(255, 255, 255, 0.5);
}

.maze-loading-title {
  margin-bottom: 24px;
  font-size: clamp(20px, 4.8vw, 30px);
  line-height: 1.2;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-shadow: 0 2px 0 #fff;
}

.maze-loading-track {
  position: relative;
  height: 24px;
  margin: 46px 40px 16px;
  border: 4px solid #d79216;
  border-radius: 999px;
  background: #fff4a6;
  box-shadow: inset 0 3px 6px rgba(126, 73, 20, 0.18);
}

.maze-loading-fill {
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #ffb52b, #ffdf4d);
  transition: width 0.28s ease-out;
}

.maze-loading-cat,
.maze-loading-mouse {
  position: absolute;
  bottom: -21px;
  width: 82px;
  height: 82px;
  transform-origin: 50% 100%;
}

.maze-loading-cat {
  left: 0;
  background: url('./loading-cat-strip.png') 0 0 / 800% 100% no-repeat;
  transform: translateX(-50%);
  animation: maze-cat-run 0.8s steps(7) infinite;
  transition: left 0.28s ease-out;
}

.maze-loading-mouse {
  right: 0;
  background: url('./loading-mouse.png') center / contain no-repeat;
  transform: translateX(50%);
  transition: opacity 0.16s ease, transform 0.16s ease;
}

.maze-loading-percent {
  font-size: 18px;
  line-height: 1;
  font-weight: 800;
}

#MazeLoading.is-caught .maze-loading-cat {
  left: 100% !important;
  animation: maze-cat-caught 0.5s ease-out both;
}

#MazeLoading.is-caught .maze-loading-mouse {
  opacity: 0;
  transform: translateX(50%) scale(0.2);
}

#MazeLoading.is-error .maze-loading-title {
  color: #b83c27;
}

@keyframes maze-cat-run {
  from { background-position-x: 0%; }
  to { background-position-x: 100%; }
}

@keyframes maze-cat-caught {
  0% { transform: translateX(-50%) translateY(0) scale(1); }
  45% { transform: translateX(-50%) translateY(-28px) scale(1.08); }
  75% { transform: translateX(-50%) translateY(0) scale(0.98); }
  100% { transform: translateX(-50%) translateY(-8px) scale(1); }
}

@media (max-width: 520px) {
  .maze-loading-panel {
    width: min(88vw, 430px);
    padding: 20px 14px 16px;
  }

  .maze-loading-track {
    margin-right: 34px;
    margin-left: 34px;
  }

  .maze-loading-cat,
  .maze-loading-mouse {
    width: 72px;
    height: 72px;
  }
}

@supports (height: 100dvh) {
  body,
  #GameDiv,
  #Cocos3dGameContainer,
  #GameCanvas,
  #MazeLoading {
    height: 100dvh !important;
  }
}
