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: #e8f2ff;
  background-color: #123a7a;

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

  display: flex;
  flex-direction: column;

  /* fix bug: https://github.com/cocos-creator/2d-tasks/issues/791 */
  /* overflow cannot be applied in Cocos2dGameContainer, 
  otherwise child elements will be hidden when Cocos2dGameContainer rotated 90 deg */
  overflow: hidden;
}

#Cocos2dGameContainer {
  position: absolute;
  margin: 0;
  left: 0px;
  top: 0px;
  width: 100%;
  height: 100%;

  display: -webkit-box;
  -webkit-box-orient: horizontal;
  -webkit-box-align: center;
  -webkit-box-pack: center;

  /* Hide until first scene — WebGL clears to black otherwise */
  visibility: hidden;
}

#GameCanvas {
  position: absolute;
  left: 0;
  top: 0;
  width: 100% !important;
  height: 100% !important;
  display: block;
  background-color: #123a7a;
  visibility: hidden;
}

body.game-ready #GameCanvas,
body.game-ready #Cocos2dGameContainer {
  visibility: visible;
}

/* Facebook Instant Games profile overlay host (Meta iframe goes inside) */
#fb-profile-overlay {
  position: absolute;
  top: max(12px, env(safe-area-inset-top, 0px));
  left: max(12px, env(safe-area-inset-left, 0px));
  z-index: 40;
  /* Room for pill + shadow; do not clip (was causing cut-off right edge) */
  width: min(280px, 72vw);
  height: 64px;
  display: none;
  pointer-events: none;
  overflow: visible;
  background: transparent;
}

#fb-profile-overlay.is-visible {
  display: block;
}

#fb-profile-overlay iframe {
  width: 100% !important;
  height: 100% !important;
  border: none !important;
  background: transparent !important;
  pointer-events: none;
  overflow: visible !important;
}

#fb-profile-overlay .fb-profile-local {
  display: flex;
  align-items: center;
  gap: 8px;
  width: fit-content;
  max-width: 100%;
  height: 44px;
  margin: 4px;
  padding: 5px 16px 5px 5px;
  box-sizing: border-box;
  background: linear-gradient(
    165deg,
    rgba(28, 52, 110, 0.92) 0%,
    rgba(10, 24, 58, 0.94) 100%
  );
  border-radius: 22px;
  border: 1.5px solid rgba(255, 255, 255, 0.28);
  box-shadow:
    0 6px 16px rgba(0, 12, 40, 0.35),
    inset 0 1px 0 rgba(255, 255, 255, 0.12);
}

#fb-profile-overlay .fb-profile-local-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(145deg, #5ec4ff, #1a4fad);
  border: 2px solid #fff;
  box-sizing: border-box;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
  flex-shrink: 0;
}

#fb-profile-overlay .fb-profile-local-name {
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: 0.02em;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
  padding-right: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 140px;
}

/* —— Splash —— */
#splash {
  --splash-blue: #1a4fad;
  --splash-deep: #0c2a5c;
  --c1: #ff5a6a;
  --c2: #ffb84d;
  --c3: #5ce08a;
  --c4: #4db7ff;
  --c5: #c47bff;

  position: absolute;
  inset: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  pointer-events: none;
  font-family: "Fredoka", "Segoe UI", sans-serif;
}

#splash .splash-bg {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 90% 60% at 50% 18%, rgba(90, 160, 255, 0.45), transparent 55%),
    radial-gradient(ellipse 70% 50% at 80% 85%, rgba(70, 120, 255, 0.22), transparent 50%),
    linear-gradient(165deg, #1f5fc4 0%, var(--splash-blue) 42%, var(--splash-deep) 100%);
}

#splash .splash-grid {
  position: absolute;
  inset: -20%;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.06) 1px, transparent 1px);
  background-size: 48px 48px;
  transform: perspective(600px) rotateX(58deg) scale(1.35);
  transform-origin: center 65%;
  opacity: 0.55;
  animation: splash-grid-drift 18s linear infinite;
  mask-image: linear-gradient(to bottom, transparent 0%, #000 28%, #000 72%, transparent 100%);
  -webkit-mask-image: linear-gradient(to bottom, transparent 0%, #000 28%, #000 72%, transparent 100%);
}

#splash .splash-core {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 24px;
  animation: splash-rise 0.7s cubic-bezier(0.22, 1, 0.36, 1) both;
}

#splash .splash-blocks {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 7px;
  width: min(148px, 36vw);
  margin-bottom: 18px;
  filter: drop-shadow(0 14px 28px rgba(0, 0, 0, 0.35));
}

#splash .splash-blocks .b {
  aspect-ratio: 1;
  border-radius: 10px;
  box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, 0.45),
    inset 0 -3px 0 rgba(0, 0, 0, 0.18);
  animation: splash-block-pop 1.8s ease-in-out infinite;
}

#splash .b1 { background: var(--c1); animation-delay: 0s; }
#splash .b2 { background: var(--c2); animation-delay: 0.08s; }
#splash .b3 { background: var(--c4); animation-delay: 0.16s; }
#splash .b4 { background: var(--c5); animation-delay: 0.12s; }
#splash .b5 { background: var(--c3); animation-delay: 0.2s; }
#splash .b6 { background: var(--c1); animation-delay: 0.28s; }
#splash .b7 { background: var(--c4); animation-delay: 0.24s; }
#splash .b8 { background: var(--c2); animation-delay: 0.32s; }
#splash .b9 { background: var(--c5); animation-delay: 0.36s; }

#splash .splash-brand {
  font-size: clamp(34px, 9vw, 52px);
  font-weight: 700;
  letter-spacing: 0.02em;
  line-height: 1.05;
  color: #fff;
  text-shadow:
    0 3px 0 rgba(8, 30, 70, 0.35),
    0 12px 32px rgba(0, 0, 0, 0.35);
}

#splash .splash-tag {
  margin-top: -2px;
  padding: 5px 14px;
  font-size: clamp(13px, 3.5vw, 16px);
  font-weight: 600;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: #0c2a5c;
  background: linear-gradient(180deg, #ffe56a, #ffc83a);
  border-radius: 999px;
  box-shadow:
    0 2px 0 rgba(180, 110, 0, 0.45),
    0 8px 18px rgba(0, 0, 0, 0.2);
}

#splash .splash-load {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 22px;
  font-size: 14px;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.88);
}

#splash .splash-ring {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2.5px solid rgba(255, 255, 255, 0.25);
  border-top-color: #fff;
  animation: splash-spin 0.75s linear infinite;
}

@keyframes splash-rise {
  from {
    opacity: 0;
    transform: translateY(18px) scale(0.96);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes splash-block-pop {
  0%,
  100% {
    transform: translateY(0) scale(1);
  }
  40% {
    transform: translateY(-5px) scale(1.06);
  }
  55% {
    transform: translateY(0) scale(0.98);
  }
}

@keyframes splash-grid-drift {
  from {
    background-position: 0 0, 0 0;
  }
  to {
    background-position: 0 48px, 48px 0;
  }
}

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

@media (prefers-reduced-motion: reduce) {
  #splash .splash-grid,
  #splash .splash-blocks .b,
  #splash .splash-ring,
  #splash .splash-core {
    animation: none !important;
  }
}

body.game-ready #splash {
  display: none !important;
}

canvas {
  background-color: transparent;
}

a:link,
a:visited {
  color: #666;
}

a:active,
a:hover {
  color: #666;
}

p.header {
  font-size: small;
}

p.footer {
  font-size: x-small;
}
