/* 3D view: full-screen WebGL canvas with the HTML HUD on top. */
body.w3d { overflow: hidden; height: 100dvh; }
#gl {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  cursor: grab;
  outline: none;
}
.w3d #fx { z-index: 40; }

.hud {
  position: fixed;
  top: 0;
  left: 50%;
  translate: -50% 0;
  z-index: 5;
  width: min(900px, 100%);
  padding: calc(env(safe-area-inset-top, 0px) + 12px) 16px 0;
  pointer-events: none;
  transition: opacity 0.6s;
}
body.w3d:not(.entered) .hud { opacity: 0; }
body.card-open .hud, body.closeup .hud, body.zoomed .hud { opacity: 0; }
body.previewing .hud { top: 46px; }

.tool-text {
  display: grid;
  place-items: center;
  color: var(--ink);
  font-weight: 900;
  font-size: 0.85rem;
  text-decoration: none;
}

.hint3d {
  position: fixed;
  left: 50%;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 70px);
  translate: -50% 10px;
  z-index: 6;
  margin: 0;
  padding: 9px 18px;
  border-radius: 999px;
  background: rgba(20, 16, 40, 0.75);
  color: #fff;
  font-weight: 800;
  font-size: 0.9rem;
  text-align: center;
  width: max-content;
  max-width: calc(100vw - 32px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.5s, translate 0.5s;
}
.hint3d.show { opacity: 1; translate: -50% 0; }

.loading3d {
  position: fixed;
  left: 50%;
  bottom: 18%;
  translate: -50% 0;
  z-index: 31;
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 10px 18px;
  border-radius: 999px;
  background: rgba(20, 16, 40, 0.7);
  color: #fff;
  font-weight: 800;
  transition: opacity 0.4s;
}
.loading3d span {
  width: 16px;
  height: 16px;
  border: 3px solid rgba(255, 255, 255, 0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
.loading3d.done { opacity: 0; pointer-events: none; }
#splashGo:disabled { opacity: 0.6; cursor: wait; animation: none; }

/* the splash in 3D sits over the live, slowly drifting scene */
.w3d #splash { backdrop-filter: blur(4px); }

/* Background mode (editor backdrop): just the world */
body.bgmode .hud, body.bgmode .toolbar, body.bgmode #splash, body.bgmode .credit, body.bgmode .hint3d,
body.bgmode .loading3d, body.bgmode #toast, body.bgmode .kbd-hint, body.bgmode .preview-bar { display: none !important; }
body.bgmode #gl { pointer-events: none; cursor: default; }
