:root {
  --bg-deep: #0b0919;
  --bg-mid: #171434;
  --accent-pink: #ff7ec3;
  --accent-cyan: #6be4ff;
  --accent-gold: #ffd56b;
  --text-main: #ffffff;
  --text-sub: rgba(226, 232, 255, 0.78);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}

html,
body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: radial-gradient(circle at 50% 20%, #1d1842 0%, #0e0c22 60%, #080714 100%);
  color: var(--text-main);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", "Segoe UI", Roboto, sans-serif;
  touch-action: none;
  overscroll-behavior: none;
}

#app {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: env(safe-area-inset-top, 0px) env(safe-area-inset-right, 0px)
    env(safe-area-inset-bottom, 0px) env(safe-area-inset-left, 0px);
  overflow: hidden;
}

#stage-wrap {
  position: relative;
  width: min(100vw, calc(100dvh * 9 / 16));
  height: min(100dvh, calc(100vw * 16 / 9));
  max-width: 100%;
  max-height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 60px rgba(107, 228, 255, 0.14), 0 0 120px rgba(0, 0, 0, 0.65);
  border-radius: 0;
  overflow: hidden;
  background: #121026;
}

@media (min-aspect-ratio: 10/16) {
  #stage-wrap {
    border-radius: 18px;
    border: 1px solid rgba(255, 255, 255, 0.14);
  }
}

#game-canvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  cursor: pointer;
}

/* Mandatory Preloader Overlay */
#loader-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: radial-gradient(circle at 50% 25%, #241d52 0%, #13102b 58%, #0a0818 100%);
  pointer-events: all;
  opacity: 1;
  transition: opacity 0.36s ease;
}

#loader-overlay.is-hidden {
  opacity: 0;
  pointer-events: none;
}

.loader-card {
  width: min(420px, 92vw);
  padding: 32px 26px 28px;
  border-radius: 26px;
  background: linear-gradient(180deg, rgba(36, 30, 76, 0.94) 0%, rgba(19, 16, 44, 0.97) 100%);
  border: 1.5px solid rgba(125, 210, 255, 0.42);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6), 0 0 36px rgba(130, 195, 255, 0.16);
  text-align: center;
}

.loader-badge {
  display: inline-block;
  padding: 5px 14px;
  border-radius: 999px;
  background: rgba(119, 204, 238, 0.14);
  border: 1px solid rgba(119, 204, 238, 0.4);
  color: var(--accent-cyan);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 1px;
  margin-bottom: 12px;
}

.loader-title {
  font-size: 24px;
  font-weight: 800;
  letter-spacing: 0.5px;
  margin-bottom: 6px;
}

.loader-subtitle {
  font-size: 13px;
  color: var(--text-sub);
  margin-bottom: 24px;
}

.loader-spinner {
  position: relative;
  width: 78px;
  height: 78px;
  margin: 0 auto 24px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.ring {
  position: absolute;
  border-radius: 50%;
  border: 3px solid transparent;
}

.ring-outer {
  inset: 0;
  border-top-color: var(--accent-cyan);
  border-right-color: var(--accent-pink);
  animation: spin 1.3s linear infinite;
}

.ring-inner {
  inset: 10px;
  border-bottom-color: var(--accent-gold);
  border-left-color: #b695ff;
  animation: spin-rev 1.8s linear infinite;
}

.star-core {
  font-size: 26px;
  color: #fff6c2;
  text-shadow: 0 0 14px rgba(255, 213, 107, 0.85);
  animation: pulse 1.2s ease-in-out infinite;
}

.loader-bar-wrap {
  width: 100%;
  height: 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.14);
  margin-bottom: 12px;
}

.loader-bar-fill {
  width: 0%;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #ff7ec3 0%, #9f7bff 50%, #6be4ff 100%);
  box-shadow: 0 0 14px rgba(107, 228, 255, 0.65);
  transition: width 0.16s ease-out;
}

.loader-stats {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
  font-weight: 700;
  color: #eef3ff;
  margin-bottom: 6px;
}

#loader-percent {
  color: var(--accent-gold);
  font-variant-numeric: tabular-nums;
}

.loader-detail {
  font-size: 12px;
  color: rgba(208, 216, 255, 0.68);
  margin-bottom: 14px;
}

.loader-lock-tip {
  font-size: 12px;
  color: rgba(255, 213, 107, 0.85);
  padding: 6px 12px;
  border-radius: 10px;
  background: rgba(255, 213, 107, 0.1);
  border: 1px solid rgba(255, 213, 107, 0.25);
}

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

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

@keyframes pulse {
  0%,
  100% {
    transform: scale(0.92);
    opacity: 0.85;
  }
  50% {
    transform: scale(1.1);
    opacity: 1;
  }
}
