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

body {
  background: #101820;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: "Courier New", monospace;
}

.wrap {
  position: relative;
  text-align: center;
}

/* WebGL 容器:16:10 横屏 */
#glwrap {
  position: relative;
  width: min(96vw, calc((100vh - 110px) * 1.6));
  aspect-ratio: 16 / 10;
  border: 3px solid #3a4a5a;
  border-radius: 6px;
  overflow: hidden;
  background: #aed6f0;
}

#glwrap canvas {
  position: absolute;
  inset: 0;
  z-index: 0;
  display: block;
  touch-action: none;
}

/* ===== HUD ===== */
#hud {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 2;
  padding: 10px 14px;
  color: #e8f0ff;
  font-size: 16px;
  font-weight: bold;
  text-shadow: 0 1px 3px rgba(10, 30, 50, 0.7);
  pointer-events: none;
}

.hud-left { float: left; }
.hud-center { color: #9fb2d8; }
.hud-right { float: right; color: #ffd76e; }
.hud-right b { font-size: 22px; }

.hud-lives {
  position: absolute;
  top: 34px;
  left: 14px;
  color: #ff5a6e;
  letter-spacing: 2px;
}

/* ===== 覆盖层(标题/暂停/结束/错误) ===== */
.overlay {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  background: rgba(8, 14, 22, 0.62);
  color: #c8d6f0;
  font-size: 15px;
}

.overlay h1 {
  color: #7ec8ff;
  font-size: 46px;
}

.overlay h2 { color: #ffffff; font-size: 32px; }
.overlay h2.danger { color: #ff6060; }
.overlay .sub { color: #4a7ea8; font-size: 18px; font-weight: bold; }
.overlay .big { color: #e8f0ff; font-size: 22px; font-weight: bold; }
.overlay .hi { color: #ffd76e; }

.blink { animation: blink 1.1s steps(2, start) infinite; color: #ffffff; font-weight: bold; }
@keyframes blink { to { visibility: hidden; } }

.hint {
  color: #8fa3b8;
  margin-top: 12px;
  font-size: 14px;
}

.hint-touch { display: none; }

/* ===== 触屏控制(仅触屏设备显示) ===== */
.touch-controls {
  display: none;
  margin-top: 14px;
  justify-content: space-between;
  align-items: center;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}

.touch-tip {
  color: #8fa3b8;
  font-size: 14px;
}

.tbtn {
  width: 58px;
  height: 58px;
  font-size: 20px;
  font-family: inherit;
  color: #eee;
  background: rgba(90, 110, 130, 0.55);
  border: 2px solid #5a6a7a;
  border-radius: 10px;
  touch-action: none;
}

.tbtn:active { background: rgba(150, 170, 190, 0.75); }

.tbtn.small {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  font-size: 17px;
}

@media (pointer: coarse) {
  .touch-controls { display: flex; }
  .hint { display: none; }
  .hint-touch { display: block; }
  #glwrap {
    /* 给底部控制区预留 ~90px(兼容不支持 dvh 的浏览器) */
    width: min(96vw, calc((100vh - 90px) * 1.6));
    width: min(96vw, calc((100dvh - 90px) * 1.6));
  }
}

/* 调试:?touch=1 强制显示触屏控制(桌面预览用) */
.force-touch .touch-controls { display: flex; }
.force-touch .hint { display: none; }
.force-touch .hint-touch { display: block; }
.force-touch #glwrap {
  width: min(96vw, calc((100vh - 90px) * 1.6));
  width: min(96vw, calc((100dvh - 90px) * 1.6));
}
