:root {
  --hud-blue: #4a80dc;
  --hud-blue-dark: #2f5fb3;
}

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

html,
body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #ffffff;
  font-family: "Microsoft YaHei", "PingFang SC", "Source Han Sans CN", sans-serif;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}

/* 3D 画布 */
#stage {
  position: fixed;
  inset: 0;
  z-index: 1;
  touch-action: none;
  cursor: grab;
}
#stage.dragging {
  cursor: grabbing;
}
#stage canvas {
  display: block;
}

/* 屏幕线框：铺满屏幕，置于最上层，但不拦截手势 */
#frame {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: fill;
  z-index: 10;
  pointer-events: none;
}

/* 缩放按钮：正方形，中心对齐线框左侧方块
   方块中心取自 屏幕线框.png 实测：x = 3.411%，第 1 块 y = 65.129%，第 3 块 y = 74.270% */
.hud-btn {
  --size: clamp(40px, min(3.4vw, 6vh), 76px);
  position: fixed;
  left: 3.411%;
  z-index: 20;
  width: var(--size);
  height: var(--size);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 2px solid #fff;
  outline: 1.5px solid var(--hud-blue);
  outline-offset: 0;
  color: #fff;
  background: var(--hud-blue);
  cursor: pointer;
  transform: translate(-50%, -50%);
  transition: background 0.15s, transform 0.1s, outline-offset 0.15s;
  touch-action: manipulation;
}
#btn-zoom-in {
  top: 65.129%;
}
#btn-zoom-out {
  top: 74.27%;
}
/* 下一个模型在第 5 块（y = 83.411%），上一个模型在第 7 块（y = 92.552%） */
#btn-next-model {
  top: 83.411%;
}
#btn-prev-model {
  top: 92.552%;
}
.hud-btn[hidden] {
  display: none;
}

.hud-btn svg {
  width: 58%;
  height: 58%;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.6;
  stroke-linecap: square;
  pointer-events: none;
}

@media (hover: hover) {
  .hud-btn:not(:disabled):hover {
    background: #5b90ea;
    outline-offset: 3px;
  }
}

.hud-btn:not(:disabled):active,
.hud-btn.pressing {
  background: var(--hud-blue-dark);
  transform: translate(-50%, -50%) scale(0.92);
}

.hud-btn:disabled {
  background: #b7c6de;
  outline-color: #b7c6de;
  cursor: default;
}

.hud-btn:focus-visible {
  outline-offset: 3px;
}

/* 触摸点显示：最上层，不拦截触摸 */
#touch-debug {
  position: fixed;
  inset: 0;
  z-index: 100;
  pointer-events: none;
  overflow: hidden;
}
.touch-dot {
  position: absolute;
  left: 0;
  top: 0;
  width: 90px;
  height: 90px;
  border: 2px solid rgba(70, 190, 100, 0.85);
  border-radius: 50%;
  background: rgba(140, 230, 160, 0.35);
  will-change: transform;
}
/* 断触等待重连中 */
.touch-dot.is-lost {
  opacity: 0.4;
}
/* 被过滤掉的原始点（分裂点 / 待确认） */
.touch-raw {
  position: absolute;
  left: 0;
  top: 0;
  width: 36px;
  height: 36px;
  border: 2px dashed rgba(120, 120, 120, 0.8);
  border-radius: 50%;
  will-change: transform;
}

/* 右上角触摸数量：放在线框右上角点阵的左侧 */
#touch-count {
  position: fixed;
  top: 5%;
  right: 6.5%;
  z-index: 100;
  padding: 0.4em 1em;
  border: 1.5px solid var(--hud-blue);
  background: rgba(255, 255, 255, 0.85);
  color: var(--hud-blue);
  font-size: clamp(16px, 1.4vw, 32px);
  font-weight: bold;
  letter-spacing: 1px;
  pointer-events: none;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
#touch-count small {
  margin-left: 0.6em;
  font-size: 0.65em;
  font-weight: normal;
  color: #888;
}
#touch-count small:empty {
  display: none;
}
#touch-count.is-active {
  border-color: rgba(70, 190, 100, 0.9);
  background: rgba(140, 230, 160, 0.35);
  color: #2f8a4a;
}

/* 加载层 */
#loader {
  position: fixed;
  inset: 0;
  z-index: 5;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  background: #fff;
  color: var(--hud-blue);
  font-size: 16px;
  letter-spacing: 2px;
  transition: opacity 0.6s;
}
#loader.hide {
  opacity: 0;
  pointer-events: none;
}
.loader-ring {
  width: 56px;
  height: 56px;
  border: 3px solid rgba(74, 128, 220, 0.2);
  border-top-color: var(--hud-blue);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}
