* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html, body {
  width: 100%;
  height: 100%;
  min-height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  touch-action: none;
}

body {
  overflow: hidden;
  font-family: 'Arial', sans-serif;
  background: #000;
  position: fixed;
  inset: 0;
}

#gameCanvas {
  display: block;
  position: fixed;
  left: 0;
  top: 0;
  width: 100vw;
  height: 100vh;
  max-width: 100vw;
  max-height: none;
  image-rendering: auto;
  transform: translateZ(0);
  backface-visibility: hidden;
}

/* 加载界面 */
#loadingOverlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background:
    linear-gradient(180deg, rgba(2, 4, 12, 0.18) 0%, rgba(2, 4, 12, 0.26) 44%, rgba(2, 4, 12, 0.62) 100%),
    url('../assets/backgrounds/loading.webp') center center / cover no-repeat,
    linear-gradient(180deg, #02040c 0%, #071026 42%, #19072e 100%);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 9999;
  overflow: hidden;
}

#loadingOverlay::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    linear-gradient(90deg, transparent 0 10%, rgba(0, 243, 255, 0.08) 10% 10.16%, transparent 10.16% 26%, rgba(255, 0, 255, 0.06) 26% 26.14%, transparent 26.14% 54%, rgba(0, 243, 255, 0.06) 54% 54.12%, transparent 54.12% 78%, rgba(255, 216, 107, 0.055) 78% 78.12%, transparent 78.12% 100%),
    radial-gradient(circle at 22% 34%, rgba(0, 243, 255, 0.5) 0 1px, transparent 2px),
    radial-gradient(circle at 68% 24%, rgba(255, 0, 255, 0.42) 0 1px, transparent 2px),
    radial-gradient(circle at 82% 58%, rgba(255, 216, 107, 0.36) 0 1px, transparent 2px),
    repeating-linear-gradient(0deg, rgba(255,255,255,0.055) 0 1px, transparent 1px 4px),
    repeating-linear-gradient(90deg, rgba(0, 243, 255, 0.08) 0 1px, transparent 1px 34px),
    repeating-linear-gradient(0deg, rgba(255, 255, 255, 0.045) 0 1px, transparent 1px 38px);
  background-size: auto, 120px 120px, 150px 150px, 180px 180px, auto, auto, auto;
  transform: perspective(460px) rotateX(62deg) translateY(18%);
  transform-origin: center bottom;
  opacity: 0.44;
  mix-blend-mode: screen;
  animation: loading-grid-drift 6s linear infinite, loading-scanline 2.6s linear infinite;
}

#loadingOverlay::after {
  content: '';
  position: absolute;
  left: -8%;
  right: -8%;
  bottom: -2%;
  height: 31%;
  background:
    linear-gradient(0deg, rgba(0, 0, 0, 0.72), rgba(0,0,0,0.42) 42%, transparent 74%),
    radial-gradient(ellipse at 50% 8%, rgba(0, 243, 255, 0.18), transparent 46%),
    linear-gradient(90deg,
      transparent 0 5%, rgba(2, 8, 20, .86) 5% 17%, transparent 17% 21%,
      rgba(2, 8, 20, .9) 21% 35%, transparent 35% 39%, rgba(2, 8, 20, .84) 39% 51%,
      transparent 51% 56%, rgba(2, 8, 20, .9) 56% 72%, transparent 72% 78%, rgba(2, 8, 20, .82) 78% 92%, transparent 92% 100%),
    repeating-linear-gradient(90deg, transparent 0 20px, rgba(0, 243, 255, 0.08) 20px 21px, transparent 21px 56px);
  background-size: 100% 100%, 100% 100%, 100% 35%, 100% 100%;
  background-position: 0 0, 0 0, 0 64%, 0 0;
  background-repeat: no-repeat;
  border-top: 1px solid rgba(0, 243, 255, 0.22);
  box-shadow: inset 0 18px 36px rgba(0, 243, 255, 0.08), 0 -8px 30px rgba(0, 243, 255, 0.16);
  opacity: 0.72;
}

.loading-content {
  position: relative;
  z-index: 1;
  width: min(84vw, 382px);
  text-align: center;
  color: #fff;
  padding: 34px 22px 30px;
  border: 1px solid rgba(0, 243, 255, 0.38);
  border-radius: 24px;
  background:
    linear-gradient(135deg, rgba(0, 243, 255, 0.08), transparent 28%),
    linear-gradient(315deg, rgba(255, 0, 255, 0.10), transparent 32%),
    linear-gradient(180deg, rgba(4, 8, 24, 0.68), rgba(10, 4, 28, 0.38));
  box-shadow:
    0 0 42px rgba(0, 243, 255, 0.2),
    0 0 82px rgba(255, 0, 255, 0.08),
    inset 0 0 30px rgba(255,255,255,0.045),
    inset 0 0 1px rgba(255,255,255,0.5);
  backdrop-filter: blur(10px);
}

.loading-content::before,
.loading-content::after {
  content: '';
  position: absolute;
  width: 42px;
  height: 18px;
  border-color: #00f3ff;
  opacity: 0.78;
}
.loading-content::before {
  left: 13px;
  top: 13px;
  border-left: 2px solid;
  border-top: 2px solid;
}
.loading-content::after {
  right: 13px;
  bottom: 13px;
  border-right: 2px solid;
  border-bottom: 2px solid;
}

.loading-content h1.game-title {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 7px;
  margin-bottom: 30px;
  line-height: 1;
  letter-spacing: 4px;
  color: #00ffff;
  position: relative;
  text-shadow: 0 0 8px rgba(0, 255, 255, 0.95), 0 0 24px rgba(0, 170, 255, 0.76), 0 0 44px rgba(0, 243, 255, 0.38);
}

.title-main {
  font-size: clamp(44px, 12.5vw, 62px);
  font-weight: 900;
  transform: skewX(-3deg);
}

.title-sub {
  font-size: clamp(30px, 8.4vw, 43px);
  font-weight: 900;
  color: #ffd86b;
  transform: skewX(-3deg);
  text-shadow: 0 0 8px rgba(255, 216, 107, 0.9), 0 0 24px rgba(255, 170, 0, 0.72), 0 0 44px rgba(255, 0, 255, 0.18);
}

.progress-bar {
  position: relative;
  width: min(300px, 72vw);
  height: 14px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(0,243,255,.28);
  border-radius: 999px;
  overflow: hidden;
  margin: 0 auto 20px;
  box-shadow: inset 0 0 14px rgba(0,0,0,.55), 0 0 20px rgba(0,243,255,.2), 0 0 34px rgba(255,0,255,.08);
}

#progressFill {
  position: relative;
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #00f3ff, #00aaff 45%, #ff00ff);
  box-shadow: 0 0 16px rgba(0, 243, 255, 0.72);
  transition: width 0.3s;
}

#progressFill::after {
  content: '';
  position: absolute;
  top: -4px;
  bottom: -4px;
  width: 44px;
  right: -18px;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,.78), transparent);
  animation: loading-shine 1.2s linear infinite;
}

#loadingText {
  font-size: 14px;
  color: rgba(225, 235, 255, 0.76);
  text-shadow: 0 0 10px rgba(0, 243, 255, 0.22);
}

@keyframes loading-grid-drift {
  from { background-position: 0 0, 0 0, 0 0, 0 0, 0 0, 0 0, 0 0; }
  to { background-position: 0 0, 22px 28px, -26px 18px, 18px -30px, 0 12px, 34px 0, 0 38px; }
}

@keyframes loading-scanline {
  from { filter: hue-rotate(0deg) brightness(1); }
  50% { filter: hue-rotate(8deg) brightness(1.18); }
  to { filter: hue-rotate(0deg) brightness(1); }
}

@keyframes loading-shine {
  from { transform: translateX(-36px); opacity: 0.35; }
  50% { opacity: 0.95; }
  to { transform: translateX(36px); opacity: 0.35; }
}

/* 圆角矩形辅助类 */
.rounded {
  border-radius: 10px;
}

/* 霓虹文字效果 */
.neon-text {
  text-shadow: 0 0 5px currentColor, 0 0 10px currentColor, 0 0 20px currentColor;
}

/* 毛玻璃效果 */
.glass {
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.2);
}
