html, body { height: 100%; }

body {
  margin: 0;
  background: #000;
  color: #dbe6f5;
  font-family: system-ui, "Segoe UI", "Microsoft YaHei", sans-serif;
  overflow: hidden;
  -webkit-user-select: none;
  user-select: none;
  overscroll-behavior: none;
}

#view {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  cursor: grab;
}
#view:active { cursor: grabbing; }

#hud {
  position: fixed;
  top: calc(10px + env(safe-area-inset-top));
  left: calc(14px + env(safe-area-inset-left));
  pointer-events: none;
  text-shadow: 0 0 12px rgba(111, 183, 255, .55);
}
#hud h1 {
  font-size: clamp(18px, 3.4vw, 26px);
  margin: 0;
  letter-spacing: .35em;
  font-weight: 600;
}
#hud p {
  margin: 2px 0 0;
  font-size: 10px;
  letter-spacing: .42em;
  color: #8fa8c8;
}
#fps {
  margin-top: 8px;
  font-size: 11px;
  color: #6f87a8;
  font-variant-numeric: tabular-nums;
  letter-spacing: .08em;
}

#gear {
  position: fixed;
  top: calc(10px + env(safe-area-inset-top));
  right: calc(12px + env(safe-area-inset-right));
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 1px solid rgba(140, 180, 240, .28);
  background: rgba(8, 12, 22, .55);
  color: #bcd2f0;
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  cursor: pointer;
  z-index: 5;
}

#back {
  position: fixed;
  top: calc(58px + env(safe-area-inset-top));
  right: calc(12px + env(safe-area-inset-right));
  color: #8fa8c8;
  text-decoration: none;
  font-size: 12px;
  letter-spacing: .12em;
  padding: 8px 16px;
  border: 1px solid rgba(140, 180, 240, .28);
  border-radius: 999px;
  background: rgba(8, 12, 22, .55);
  backdrop-filter: blur(8px);
  transition: color .2s, border-color .2s, background .2s;
  z-index: 20;
}
#back:hover { color: #fff; border-color: rgba(140, 180, 240, .65); background: rgba(14, 22, 40, .7); }

#panel {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(12px + env(safe-area-inset-bottom));
  width: min(430px, 94vw);
  background: rgba(8, 12, 22, .72);
  border: 1px solid rgba(140, 180, 240, .16);
  border-radius: 16px;
  padding: 12px 16px 14px;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  box-shadow: 0 12px 40px rgba(0, 0, 0, .5);
  transition: opacity .25s, transform .25s;
  z-index: 4;
}
#panel.hidden {
  opacity: 0;
  transform: translateX(-50%) translateY(20px);
  pointer-events: none;
}

.row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 7px 0;
  font-size: 12px;
  color: #aec3e2;
}
.row label {
  width: 64px;
  flex: none;
  letter-spacing: .06em;
}
.chk {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
}

input[type=range] {
  flex: 1;
  accent-color: #6fb7ff;
  height: 22px;
  background: transparent;
}
input[type=checkbox] {
  accent-color: #6fb7ff;
  width: 16px;
  height: 16px;
}
select {
  background: #0d1526;
  color: #dbe6f5;
  border: 1px solid rgba(140, 180, 240, .25);
  border-radius: 8px;
  padding: 4px 8px;
  font-size: 12px;
}

.btns {
  display: flex;
  gap: 10px;
  margin-top: 10px;
}
button.act {
  flex: 1;
  padding: 9px 0;
  border-radius: 10px;
  border: 1px solid rgba(140, 180, 240, .3);
  background: rgba(111, 183, 255, .10);
  color: #dbeaff;
  font-size: 13px;
  letter-spacing: .15em;
  cursor: pointer;
}
button.act:active { background: rgba(111, 183, 255, .22); }

.hidden { display: none; }
#fallback.hidden { display: none; }
#fallback {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #000;
  color: #cf5f5f;
  font-size: 15px;
  text-align: center;
  line-height: 2;
  padding: 24px;
  z-index: 9;
}

@media (max-width: 520px) {
  .row label { width: 56px; }
  #hud h1 { letter-spacing: .22em; }
}
