* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #131c1a;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  color: #f3f7f6;
  touch-action: none;
}

#app {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

#stage {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}

/* ================= 顶栏 ================= */
#hud-top {
  position: absolute;
  top: max(10px, env(safe-area-inset-top));
  left: 10px;
  right: 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  pointer-events: none;
  z-index: 10;
}

.glass-seg,
.glass-pill,
.glass-chip,
.compare-seg {
  pointer-events: auto;
  background: rgba(16, 26, 28, 0.62);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.16);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.28), inset 0 1px 0 rgba(255, 255, 255, 0.14);
}

.glass-seg {
  display: inline-flex;
  align-items: center;
  padding: 3px;
  border-radius: 999px;
  gap: 2px;
  flex-shrink: 0;
}

.seg-btn {
  appearance: none;
  border: none;
  background: transparent;
  color: rgba(235, 245, 244, 0.78);
  font-size: 13px;
  font-weight: 600;
  min-width: 34px;
  height: 30px;
  padding: 0 10px;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.16s ease, color 0.16s ease;
  white-space: nowrap;
}

.seg-btn.active {
  background: linear-gradient(180deg, rgba(246, 252, 251, 0.96), rgba(214, 236, 234, 0.9));
  color: #102528;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

.glass-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 11px;
  border-radius: 999px;
  font-size: 12px;
  line-height: 1.15;
  white-space: nowrap;
  max-width: calc(100% - 122px);
  overflow: hidden;
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #4ce39a;
  box-shadow: 0 0 8px rgba(76, 227, 154, 0.8);
  flex-shrink: 0;
}

.status-dot.warn {
  background: #f5b942;
  box-shadow: 0 0 8px rgba(245, 185, 66, 0.8);
}

.status-dot.bad {
  background: #f26161;
  box-shadow: 0 0 8px rgba(242, 97, 97, 0.8);
}

#fps-main {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: #f4fbfa;
}

#fps-detail {
  font-size: 11px;
  color: rgba(215, 234, 232, 0.82);
  font-variant-numeric: tabular-nums;
}

/* ================= 底栏 ================= */
#hud-bottom {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: max(14px, env(safe-area-inset-bottom));
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 10px;
  pointer-events: none;
  z-index: 10;
}

#joystick-zone {
  width: 106px;
  height: 106px;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: auto;
  flex-shrink: 0;
}

#joy-base {
  width: 92px;
  height: 92px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, rgba(255, 255, 255, 0.14), rgba(14, 24, 26, 0.48));
  border: 1.5px solid rgba(255, 255, 255, 0.24);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.32), inset 0 1px 0 rgba(255, 255, 255, 0.18);
  display: flex;
  align-items: center;
  justify-content: center;
}

#joy-knob {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #ffffff, #cad9d7);
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.36);
  will-change: transform;
}

#bottom-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
  pointer-events: none;
  max-width: calc(100% - 116px);
}

.glass-chip {
  padding: 5px 11px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
  color: rgba(240, 249, 248, 0.92);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.compare-seg {
  display: inline-flex;
  align-items: center;
  padding: 4px;
  border-radius: 999px;
  gap: 4px;
  border-color: rgba(162, 232, 224, 0.35);
}

.cmp-btn {
  appearance: none;
  border: none;
  background: transparent;
  color: rgba(235, 246, 245, 0.82);
  font-size: 14px;
  font-weight: 700;
  height: 40px;
  padding: 0 14px;
  border-radius: 999px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.16s ease, color 0.16s ease, box-shadow 0.16s ease;
}

.cmp-btn.active[data-mode="new"] {
  background: linear-gradient(180deg, #54e0c8, #28a99e);
  color: #072221;
  box-shadow: 0 3px 12px rgba(52, 212, 192, 0.42);
}

.cmp-btn.active[data-mode="ref"] {
  background: linear-gradient(180deg, #f3e4c2, #d4b882);
  color: #241b0c;
  box-shadow: 0 3px 12px rgba(224, 194, 132, 0.38);
}

/* 375px 窄屏紧凑适配，确保按钮不越界、文字不折行不截断 */
@media (max-width: 384px) {
  #hud-top {
    left: 8px;
    right: 8px;
    gap: 6px;
  }
  .seg-btn {
    min-width: 30px;
    padding: 0 8px;
    font-size: 12px;
    height: 28px;
  }
  .glass-pill {
    padding: 5px 9px;
    font-size: 11px;
    gap: 5px;
    max-width: calc(100% - 104px);
  }
  #fps-detail {
    font-size: 10px;
  }
  #joystick-zone {
    width: 92px;
    height: 92px;
  }
  #joy-base {
    width: 82px;
    height: 82px;
  }
  #joy-knob {
    width: 36px;
    height: 36px;
  }
  #bottom-right {
    max-width: calc(100% - 102px);
  }
  .cmp-btn {
    font-size: 13px;
    height: 38px;
    padding: 0 11px;
  }
}

/* ================= 加载遮罩 ================= */
#splash {
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 50% 42%, #1d3533, #0e1819);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 40;
  transition: opacity 0.18s ease;
}

#splash.hidden {
  opacity: 0;
  pointer-events: none;
}

.splash-card {
  width: 260px;
  padding: 20px 22px;
  border-radius: 18px;
  background: rgba(15, 26, 28, 0.78);
  border: 1px solid rgba(255, 255, 255, 0.14);
  text-align: center;
}

.splash-title {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.5px;
  margin-bottom: 14px;
}

.splash-bar {
  width: 100%;
  height: 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.14);
  overflow: hidden;
  margin-bottom: 10px;
}

#splash-fill {
  width: 12%;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #4ad9c2, #8ff0de);
  transition: width 0.2s ease;
}

#splash-text {
  font-size: 12px;
  color: rgba(220, 238, 236, 0.8);
}
