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

: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);
  --panel-border: rgba(167, 225, 255, 0.18);
  --text-main: #f6fbff;
  --text-soft: #bfd7e6;
  --accent-gold: #ffd16f;
  --accent-coral: #ff7e6b;
  --accent-ice: #86ebff;
  --button-shadow: rgba(255, 126, 107, 0.38);
  --promo-bg:
    radial-gradient(circle at top left, rgba(255, 126, 107, 0.22), transparent 34%),
    radial-gradient(circle at top right, rgba(134, 235, 255, 0.16), transparent 28%),
    linear-gradient(180deg, #0b2130 0%, #08131d 46%, #050b12 100%);
}

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

button,
a {
  -webkit-tap-highlight-color: rgba(0, 0, 0, 0);
}

input::-webkit-outer-spin-button,
input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
}

body {
  position: relative;
  color: var(--text-main);
  text-align: center;
  font-family: "Trebuchet MS", "Avenir Next", "Segoe UI", sans-serif;
  background: var(--promo-bg);
}

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

.game-shell,
#Cocos3dGameContainer,
#GameCanvas {
  width: 100%;
  height: 100%;
}

.game-shell {
  position: fixed;
  inset: 0;
  background: #000;
  z-index: 0;
}

.game-shell.is-hidden,
.welcome-screen.is-hidden,
.launch-overlay.is-hidden,
.launch-info-popup.is-hidden,
.launch-overlay__close.is-hidden {
  display: none;
}

.welcome-screen,
.launch-overlay {
  position: fixed;
  inset: 0;
}

.welcome-screen {
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: auto;
  background: var(--promo-bg);
  padding:
    calc(18px + var(--safe-top))
    calc(18px + var(--safe-right))
    calc(18px + var(--safe-bottom))
    calc(18px + var(--safe-left));
  box-sizing: border-box;
}

.welcome-orb {
  position: absolute;
  border-radius: 999px;
  filter: blur(14px);
  opacity: 0.72;
  pointer-events: none;
}

.welcome-orb--left {
  width: 36vw;
  max-width: 240px;
  aspect-ratio: 1;
  left: 4%;
  top: 8%;
  background: radial-gradient(circle, rgba(255, 126, 107, 0.4), transparent 70%);
}

.welcome-orb--right {
  width: 44vw;
  max-width: 280px;
  aspect-ratio: 1;
  right: 2%;
  bottom: 12%;
  background: radial-gradient(circle, rgba(134, 235, 255, 0.28), transparent 72%);
}

.welcome-card {
  position: relative;
  width: min(100%, 540px);
  min-height: min(100%, 930px);
  aspect-ratio: 9 / 16;
  padding: 26px 22px 24px;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  gap: 18px;
  text-align: left;
  background: linear-gradient(180deg, rgba(16, 39, 52, 0.95) 0%, rgba(7, 19, 29, 0.97) 100%);
  border: 1px solid var(--panel-border);
  border-radius: 30px;
  box-shadow:
    0 28px 70px rgba(0, 0, 0, 0.42),
    inset 0 1px 0 rgba(255, 255, 255, 0.06);
  overflow: hidden;
}

.welcome-card::before,
.welcome-card::after {
  content: "";
  position: absolute;
  pointer-events: none;
}

.welcome-card::before {
  inset: auto -10% 62% auto;
  width: 210px;
  height: 210px;
  border-radius: 999px;
  background: radial-gradient(circle, rgba(255, 209, 111, 0.2), transparent 70%);
}

.welcome-card::after {
  inset: 58% auto auto -14%;
  width: 180px;
  height: 180px;
  border-radius: 999px;
  background: radial-gradient(circle, rgba(134, 235, 255, 0.14), transparent 70%);
}

.welcome-hero,
.welcome-preview,
.welcome-launch {
  position: relative;
  z-index: 1;
}

.welcome-eyebrow {
  margin: 0 0 10px;
  color: var(--accent-ice);
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.2em;
  text-transform: uppercase;
}

.welcome-title {
  margin: 0;
  font-size: clamp(2.45rem, 7.8vw, 4.3rem);
  line-height: 0.92;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.welcome-preview {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.preview-device {
  width: min(100%, 356px);
  padding: 12px;
  border-radius: 30px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.18), rgba(255, 255, 255, 0.05));
  box-shadow:
    0 20px 34px rgba(0, 0, 0, 0.28),
    inset 0 1px 0 rgba(255, 255, 255, 0.22);
}

.preview-device__screen {
  border-radius: 24px;
  padding: 16px;
  background:
    radial-gradient(circle at top right, rgba(255, 209, 111, 0.18), transparent 34%),
    linear-gradient(180deg, #132f46 0%, #0c1f30 54%, #0a1621 100%);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.preview-device__topbar,
.preview-device__bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.preview-device__bottom {
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 14px;
}

.preview-pill,
.preview-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 22px;
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--text-main);
  font-size: 0.82rem;
  font-weight: 700;
}

.preview-pill--accent {
  color: #1b2831;
  background: linear-gradient(135deg, var(--accent-gold), #fff1ba);
  border-color: transparent;
}

.preview-board {
  margin-top: 16px;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  padding: 14px;
  border-radius: 24px;
  background: linear-gradient(180deg, rgba(7, 18, 27, 0.72), rgba(5, 11, 18, 0.92));
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.preview-tile {
  position: relative;
  aspect-ratio: 1;
  border-radius: 18px;
  box-shadow:
    0 8px 14px rgba(0, 0, 0, 0.18),
    inset 0 1px 0 rgba(255, 255, 255, 0.34);
}

.preview-tile::after {
  content: "";
  position: absolute;
  inset: 18% 22% auto;
  height: 22%;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.28);
  filter: blur(1px);
}

.preview-tile--amber {
  background: linear-gradient(135deg, #ffd677, #ff9e48);
}

.preview-tile--mint {
  background: linear-gradient(135deg, #90ffd1, #31d7ab);
}

.preview-tile--violet {
  background: linear-gradient(135deg, #b8adff, #7569fb);
}

.preview-tile--sky {
  background: linear-gradient(135deg, #a8f0ff, #4ebee8);
}

.preview-tile--coral {
  background: linear-gradient(135deg, #ffb19a, #ff6b74);
}

.welcome-launch {
  margin-top: auto;
  display: grid;
  gap: 12px;
  justify-items: center;
  text-align: center;
}

.launch-actions {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  width: min(100%, 380px);
}

.launch-button {
  appearance: none;
  border: 0;
  flex: 1 1 auto;
  min-height: 58px;
  padding: 18px 26px;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--accent-coral), var(--accent-gold));
  color: #1a1e24;
  font-size: 1.06rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
  box-shadow:
    0 16px 34px var(--button-shadow),
    inset 0 1px 0 rgba(255, 255, 255, 0.46);
  transition:
    transform 0.2s ease,
    box-shadow 0.2s ease,
    opacity 0.2s ease;
}

.launch-button:hover,
.launch-button:focus-visible {
  transform: translateY(-2px);
  box-shadow:
    0 20px 40px rgba(255, 126, 107, 0.46),
    inset 0 1px 0 rgba(255, 255, 255, 0.46);
}

.launch-button:disabled {
  opacity: 0.7;
  cursor: progress;
  transform: none;
}

.launch-info {
  position: relative;
  flex: 0 0 auto;
}

.launch-info-button {
  appearance: none;
  width: 58px;
  height: 58px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-main);
  font-size: 1.2rem;
  font-weight: 900;
  cursor: pointer;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.12);
}

.launch-info-button:hover,
.launch-info-button:focus-visible {
  background: rgba(255, 255, 255, 0.14);
}

.launch-info-popup {
  position: absolute;
  right: 0;
  bottom: calc(100% + 12px);
  width: min(260px, 76vw);
  padding: 12px 14px;
  border-radius: 16px;
  background: rgba(8, 18, 30, 0.96);
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 14px 28px rgba(0, 0, 0, 0.28);
  color: var(--text-soft);
  font-size: 0.9rem;
  line-height: 1.45;
  text-align: left;
}

.launch-info-popup::after {
  content: "";
  position: absolute;
  right: 18px;
  top: 100%;
  border-width: 10px 8px 0 8px;
  border-style: solid;
  border-color: rgba(8, 18, 30, 0.96) transparent transparent transparent;
}

.launch-status {
  margin: 0;
  width: min(100%, 380px);
  min-height: 1.45em;
  color: var(--accent-ice);
  font-size: 0.92rem;
  line-height: 1.45;
}

.launch-overlay {
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  padding:
    calc(20px + var(--safe-top))
    calc(20px + var(--safe-right))
    calc(20px + var(--safe-bottom))
    calc(20px + var(--safe-left));
  box-sizing: border-box;
  background: rgba(2, 8, 13, 0.84);
  backdrop-filter: blur(16px);
}

.launch-overlay__panel {
  position: relative;
  width: min(100%, 420px);
  padding: 24px 20px 22px;
  box-sizing: border-box;
  border-radius: 26px;
  background: linear-gradient(180deg, rgba(16, 39, 52, 0.96), rgba(8, 18, 30, 0.98));
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: 0 24px 50px rgba(0, 0, 0, 0.36);
  text-align: left;
}

.launch-overlay__close {
  position: absolute;
  top: 14px;
  right: 14px;
  appearance: none;
  width: 42px;
  height: 42px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-main);
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
}

.launch-overlay__close:hover,
.launch-overlay__close:focus-visible {
  background: rgba(255, 255, 255, 0.16);
}

.launch-overlay__badge {
  margin: 0 56px 14px 0;
  display: inline-flex;
  align-items: center;
  min-height: 18px;
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(134, 235, 255, 0.1);
  border: 1px solid rgba(134, 235, 255, 0.16);
  color: var(--accent-ice);
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.launch-overlay__title {
  margin: 0 0 10px;
  color: var(--text-main);
  font-size: clamp(1.7rem, 6vw, 2.3rem);
  line-height: 1.02;
}

.launch-overlay__text {
  margin: 0;
  color: var(--text-soft);
  font-size: 0.98rem;
  line-height: 1.55;
}

@media (max-width: 640px) {
  .welcome-screen {
    padding:
      calc(12px + var(--safe-top))
      calc(12px + var(--safe-right))
      calc(12px + var(--safe-bottom))
      calc(12px + var(--safe-left));
  }

  .welcome-card {
    width: 100%;
    min-height: auto;
    padding: 20px 16px 18px;
    border-radius: 24px;
  }

  .launch-actions {
    width: 100%;
  }

  .launch-button {
    min-height: 54px;
    padding: 16px 20px;
  }

  .launch-info-button {
    width: 54px;
    height: 54px;
  }
}

@media (max-height: 760px) {
  .welcome-card {
    gap: 14px;
  }

  .welcome-title {
    font-size: clamp(2.1rem, 7vw, 3.3rem);
  }

  .preview-device {
    width: min(100%, 316px);
  }

  .preview-board {
    gap: 8px;
    padding: 12px;
  }
}

.promo-game-frame {
  position: fixed;
  inset: 0;
  z-index: 0;
  width: 100%;
  height: 100%;
  border: 0;
  opacity: 1;
  pointer-events: none;
  background: #000;
}

body.is-game-visible {
  background: #000;
}

body.is-game-visible .promo-game-frame {
  pointer-events: auto;
}

body.is-game-visible .welcome-screen,
body.is-game-visible .launch-overlay {
  display: none;
}
