:root {
  --gate-bg: #0b0d12;
  --gate-fg: #e6e8ee;
  --gate-accent: #4073fa;
  --gate-dur: 5200ms;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; }

body {
  font: 15px/1.6 -apple-system, BlinkMacSystemFont, "PingFang SC", sans-serif;
  background: var(--gate-bg);
  color: var(--gate-fg);
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

.bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  background:
    radial-gradient(circle at 50% 18%, #1b2740 0%, #0f1420 45%, #07090d 100%);
}

.bg .bg-blur {
  position: absolute;
  inset: -40px;
  width: calc(100% + 80px);
  height: calc(100% + 80px);
  object-fit: cover;
  filter: blur(42px) brightness(.9) saturate(1.2);
  transform: scale(1.08);
  opacity: .95;
}

.bg .bg-main {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center;
  display: block;

  filter: saturate(1.05);
}

.bg img[data-broken] { display: none; }

.bg-mask {
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background: linear-gradient(
    to bottom,
    rgba(0, 0, 0, .55) 0%,
    rgba(0, 0, 0, .18) 18%,
    rgba(0, 0, 0, 0) 34%,
    rgba(0, 0, 0, 0) 66%,
    rgba(0, 0, 0, .22) 84%,
    rgba(0, 0, 0, .60) 100%
  );
}

.gate {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;

  background: transparent;
  z-index: 30;
  transition: opacity .35s ease;
}
.gate.hide { opacity: 0; pointer-events: none; }

.gate-inner { text-align: center; }

.gate-spin {
  width: 38px;
  height: 38px;
  margin: 0 auto 18px;
  border: 2pt solid rgba(255,255,255,.14);
  border-top-color: var(--gate-accent);
  border-radius: 50%;
  animation: gate-rotate 1s linear infinite;
}
@keyframes gate-rotate {
  to { transform: rotate(360deg); }
}

.gate-text {
  font-size: 14px;
  letter-spacing: .5px;
  opacity: .92;
  margin-bottom: 14px;

  text-shadow: 0 1px 3px rgba(0, 0, 0, .55), 0 0 12px rgba(0, 0, 0, .35);
}

.gate-bar {
  width: 168px;
  height: 3px;
  margin: 0 auto;
  background: rgba(255,255,255,.10);
  border-radius: 2px;
  overflow: hidden;
}
.gate-bar > i {
  display: block;
  width: 0;
  height: 100%;
  background: var(--gate-accent);
  border-radius: 2px;
  transition: width linear;
}

[hidden] { display: none !important; }

.wifi {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: #07090d;
  text-align: center;
}
.wifi[hidden] { display: none; }
.wifi-inner { max-width: 320px; }
.wifi-icon { color: #ff7a45; margin-bottom: 18px; }
.wifi-title {
  font-size: 19px;
  font-weight: 600;
  color: #f2f4f8;
  margin-bottom: 12px;
  text-shadow: 0 1px 3px rgba(0, 0, 0, .5);
}
.wifi-tip {
  font-size: 13.5px;
  line-height: 1.9;
  color: #a8b0c0;
  margin-bottom: 22px;
}
.wifi-btn {
  appearance: none;
  border: 0;
  border-radius: 22px;
  padding: 11px 26px;
  font-size: 14px;
  font-weight: 600;
  color: #fff;
  background: linear-gradient(135deg, #4073fa, #2b5ce0);
  box-shadow: 0 6px 18px rgba(64, 115, 250, .35);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.wifi-btn:active { transform: translateY(1px); }

.content {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: auto;
  animation: content-in .45s ease both;
}
@keyframes content-in {
  from { opacity: 0; transform: scale(.985); }
  to   { opacity: 1; transform: none; }
}

.content-slot {
  width: 100%;
  max-width: 680px;
  padding: 18px;
}

/* ===== 自适应（断点统一三档：≤400 / ≤640 / ≥768） ===== */

/* 超宽屏：内容不要被拉得过分宽 */
@media (min-width: 768px) {
  .gate-inner { max-width: 520px; padding: 0 8px; }
  .content-slot { max-width: 720px; padding: 32px; }
  .gate-spin { width: 42px; height: 42px; margin-bottom: 22px; }
  .gate-text { font-size: 15px; margin-bottom: 18px; }
  .gate-bar { width: 200px; height: 4px; }
  .wifi { padding: 32px; }
  .wifi-inner { max-width: 360px; }
}

/* 常规窄屏 */
@media (max-width: 640px) {
  .content-slot { max-width: 100%; padding: 16px; }
  .wifi { padding: 20px; }
}

/* 极小屏（≤400px）：只压缩留白和容器，字号/转圈维持基准，
   避免 390px（最主流手机宽）字比基准还小 */
@media (max-width: 400px) {
  .gate-inner { max-width: 100%; padding: 0 12px; }
  .gate-spin { width: 34px; height: 34px; margin-bottom: 15px; }
  .gate-text { font-size: 13.5px; margin-bottom: 12px; }
  .gate-bar { width: 148px; }
  .content-slot { padding: 12px; }
  .wifi { padding: 16px; }
  .wifi-inner { max-width: 100%; }
  .wifi-title { font-size: 17px; margin-bottom: 10px; }
  .wifi-tip { font-size: 12.5px; margin-bottom: 18px; }
}

/* 矮屏（横屏 / 小窗）：不要垂直居中，否则 spinner 会被裁掉一半 */
@media (max-height: 500px) {
  .gate { align-items: flex-start; padding: calc(env(safe-area-inset-top, 0px) + 14vh) 16px 16px; }
  .gate-spin { width: 30px; height: 30px; margin-bottom: 12px; }
  .gate-text { font-size: 13px; margin-bottom: 10px; }
  .gate-bar { width: 150px; }
  .content { align-items: flex-start; }
  .content-slot { padding-top: 24px; }
}

/* 横屏时 gate-inner 也要让位（宽而矮） */
@media (orientation: landscape) and (max-height: 500px) {
  .gate { padding-top: calc(env(safe-area-inset-top, 0px) + 10vh); }
  .gate-inner { max-width: 420px; }
}
