:root {
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  color-scheme: dark;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
    "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  overscroll-behavior: none;
  background:
    radial-gradient(circle at 50% 15%, #122e46 0, #07111f 42%, #02060d 100%);
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  touch-action: none;
  user-select: none;
}

button,
a,
canvas {
  outline: none;
  -webkit-tap-highlight-color: transparent;
}

button,
a {
  touch-action: manipulation;
}

#game-shell,
#GameDiv,
#Cocos3dGameContainer,
#GameCanvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

#game-shell {
  isolation: isolate;
  overflow: hidden;
}

#GameDiv {
  background: #02060d;
}

#GameCanvas {
  display: block;
  background: transparent;
  touch-action: none;
}

.game-controls {
  position: fixed;
  z-index: 20;
  top: calc(10px + var(--safe-top));
  right: calc(10px + var(--safe-right));
  left: calc(10px + var(--safe-left));
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  pointer-events: none;
}

.game-controls__right {
  display: flex;
  gap: 8px;
}

.shell-button {
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid rgba(125, 211, 252, 0.36);
  border-radius: 999px;
  padding: 0 14px;
  color: #ecfeff;
  background: rgba(2, 10, 20, 0.78);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.28);
  font: 800 12px/1 ui-sans-serif, system-ui, sans-serif;
  letter-spacing: 0.035em;
  text-decoration: none;
  backdrop-filter: blur(12px);
  pointer-events: auto;
}

.shell-button:focus-visible {
  box-shadow: 0 0 0 3px rgba(34, 211, 238, 0.7);
}

.shell-button--quiet {
  border-color: rgba(255, 255, 255, 0.18);
  color: #d1d5db;
}

.shell-button--icon {
  min-width: 84px;
  border-color: rgba(253, 224, 71, 0.32);
  color: #fef9c3;
}

.shell-overlay {
  position: fixed;
  z-index: 40;
  inset: 0;
  display: grid;
  place-items: center;
  padding:
    calc(24px + var(--safe-top))
    calc(24px + var(--safe-right))
    calc(24px + var(--safe-bottom))
    calc(24px + var(--safe-left));
  background:
    radial-gradient(circle at 50% 20%, rgba(14, 116, 144, 0.3), transparent 42%),
    linear-gradient(180deg, #07111f 0%, #02060d 100%);
}

.shell-overlay--loading {
  transition: opacity 220ms ease, visibility 220ms ease;
}

.shell-overlay--hidden {
  visibility: hidden;
  opacity: 0;
  pointer-events: none;
}

.loading-card,
.orientation-card {
  width: min(100%, 420px);
  text-align: center;
}

.loading-card__eyebrow {
  color: #67e8f9;
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.22em;
}

.loading-card h1,
.orientation-card h1 {
  margin: 12px 0 8px;
  color: #fff;
  font-size: clamp(32px, 11vw, 58px);
  font-style: italic;
  font-weight: 1000;
  letter-spacing: -0.045em;
}

.loading-card p,
.orientation-card p {
  margin: 0;
  color: #a5b4c7;
  font-size: 14px;
  line-height: 1.55;
}

.loading-track {
  width: 100%;
  height: 7px;
  margin: 24px 0 16px;
  overflow: hidden;
  border: 1px solid rgba(103, 232, 249, 0.18);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
}

.loading-track span {
  display: block;
  width: 8%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #06b6d4, #67e8f9, #fef08a);
  box-shadow: 0 0 18px rgba(34, 211, 238, 0.6);
  transition: width 260ms ease;
}

.loading-card .loading-card__tip {
  margin-top: 28px;
  color: #d1d5db;
  font-size: 12px;
}

.shell-overlay--error .loading-track span {
  background: #fb7185;
}

.shell-overlay--orientation {
  z-index: 60;
  display: none;
  background:
    radial-gradient(circle at 50% 50%, rgba(8, 145, 178, 0.26), transparent 40%),
    rgba(2, 6, 13, 0.97);
}

.landscape-blocked .shell-overlay--orientation {
  display: grid;
}

.landscape-blocked .game-controls {
  visibility: hidden;
}

.phone-turn {
  position: relative;
  width: 82px;
  height: 120px;
  margin: 0 auto 18px;
  border: 4px solid #67e8f9;
  border-radius: 18px;
  box-shadow: 0 0 30px rgba(34, 211, 238, 0.34);
  animation: phone-pulse 1.8s ease-in-out infinite;
}

.phone-turn span {
  position: absolute;
  right: 26px;
  bottom: 7px;
  width: 22px;
  height: 4px;
  border-radius: 999px;
  background: #67e8f9;
}

@keyframes phone-pulse {
  0%,
  100% {
    transform: rotate(90deg) scale(0.88);
    opacity: 0.65;
  }
  50% {
    transform: rotate(0deg) scale(1);
    opacity: 1;
  }
}

@media (max-width: 420px) {
  .shell-button {
    min-height: 38px;
    padding-inline: 11px;
    font-size: 11px;
  }

  .shell-button--quiet {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
