/* ==========================================================================
   3D GALLERY — overlay UI
   ========================================================================== */

.g3d-body{ overflow: hidden; height: 100vh; }

#g3dRoot{
  position: fixed;
  top: var(--nav-h);
  left: 0; right: 0; bottom: 0;
  background: #000;
}
#g3dCanvas{
  width: 100%; height: 100%;
  display: block;
  cursor: crosshair;
}

/* These overlays use display:flex, which would otherwise override the
   `hidden` attribute the JS toggles — keep `hidden` authoritative. */
.g3d-loading[hidden],
.g3d-intro[hidden]{ display: none; }

.g3d-loading{
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center;
  background: var(--bg);
  z-index: 5;
}
.g3d-loading h2{
  font-family: var(--f-display); font-size: 1.6rem; margin: 10px 0 0;
  color: var(--text);
}
.g3d-loading .eyebrow{ margin: 0; }

.g3d-intro{
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center;
  background: rgba(5,4,10,.88);
  backdrop-filter: blur(6px);
  z-index: 6;
  padding: 24px;
}
.g3d-intro h2{
  font-family: var(--f-display); font-size: clamp(1.6rem, 4vw, 2.4rem);
  margin: 8px 0 14px;
  background: linear-gradient(90deg, var(--cyan), var(--violet), var(--magenta));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.g3d-intro > p{ color: var(--text-dim); max-width: 46ch; margin: 0 0 22px; }
.g3d-controls-list{
  list-style: none; margin: 0 0 26px; padding: 0;
  font-family: var(--f-mono); font-size: .78rem; color: var(--text-dim);
  max-width: 52ch; display: grid; gap: 10px;
  text-align: left;
  border-top: 1px solid var(--line); border-bottom: 1px solid var(--line);
  padding: 16px 0;
}
.g3d-controls-list strong{ color: var(--cyan); }

.g3d-enter-btn{
  padding: 14px 34px;
  border: 1px solid var(--cyan);
  color: var(--cyan);
  background: var(--cyan-soft);
  border-radius: var(--radius);
  font-family: var(--f-mono); font-size: .85rem; letter-spacing: .12em; text-transform: uppercase;
  transition: box-shadow .2s ease;
}
.g3d-enter-btn:hover{ box-shadow: 0 0 24px var(--cyan-soft); }

.g3d-crosshair{
  position: absolute; top: 50%; left: 50%;
  width: 10px; height: 10px;
  transform: translate(-50%, -50%);
  border: 2px solid var(--text-dim);
  border-radius: 50%;
  pointer-events: none;
  z-index: 4;
  transition: border-color .1s ease, transform .1s ease;
}
.g3d-crosshair.hot{
  border-color: var(--cyan);
  box-shadow: 0 0 10px var(--cyan);
  transform: translate(-50%, -50%) scale(1.6);
}

.g3d-exit-btn{
  position: absolute; top: 16px; right: 16px;
  z-index: 6;
  background: rgba(13,11,23,.8);
  border: 1px solid var(--line);
  color: var(--text-dim);
  padding: 9px 16px;
  border-radius: var(--radius);
  font-family: var(--f-mono); font-size: .72rem; letter-spacing: .06em; text-transform: uppercase;
}
.g3d-exit-btn:hover{ color: var(--magenta); border-color: var(--magenta); }

.g3d-touch-zone{
  position: absolute; bottom: 0; top: 0;
  z-index: 3;
  touch-action: none;
}
.g3d-touch-move{ left: 0; width: 45%; }
.g3d-touch-look{ right: 0; width: 55%; }

/* ==========================================================================
   MOBILE MOVEMENT D-PAD — tap/hold to walk, drag elsewhere to look
   ========================================================================== */
.g3d-dpad[hidden]{ display: none; }
.g3d-dpad{
  position: absolute;
  left: 18px; bottom: 22px;
  z-index: 5;
  display: grid;
  grid-template-columns: repeat(3, 56px);
  grid-template-rows: repeat(3, 56px);
  gap: 6px;
  touch-action: none;
  user-select: none; -webkit-user-select: none;
}
.g3d-dpad-btn{
  display: flex; align-items: center; justify-content: center;
  background: rgba(13,11,23,.72);
  border: 1px solid var(--cyan);
  color: var(--cyan);
  border-radius: 12px;
  font-size: 1.2rem; line-height: 1;
  box-shadow: 0 0 12px rgba(0,240,255,.18);
  -webkit-tap-highlight-color: transparent;
  touch-action: none;
}
.g3d-dpad-btn.up{ grid-column: 2; grid-row: 1; }
.g3d-dpad-btn.left{ grid-column: 1; grid-row: 2; }
.g3d-dpad-btn.right{ grid-column: 3; grid-row: 2; }
.g3d-dpad-btn.down{ grid-column: 2; grid-row: 3; }
.g3d-dpad-btn.active{
  background: var(--cyan);
  color: #030309;
  box-shadow: 0 0 20px var(--cyan);
}

@media (max-width: 760px){
  .g3d-controls-list{ font-size: .72rem; }
}

/* ==========================================================================
   LIVE PRESENCE HUD — head count of everyone currently in the maze
   ========================================================================== */
.g3d-presence[hidden]{ display: none; }
.g3d-presence{
  position: absolute; top: 16px; left: 16px;
  z-index: 6;
  display: flex; align-items: center; gap: 9px;
  background: rgba(13,11,23,.8);
  border: 1px solid var(--line);
  padding: 8px 14px;
  border-radius: var(--radius);
  font-family: var(--f-mono); font-size: .72rem; letter-spacing: .04em;
  color: var(--text-dim);
  backdrop-filter: blur(6px);
  pointer-events: none;
}
.g3d-presence strong{ color: var(--cyan); }
.g3d-presence-dot{
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--cyan);
  box-shadow: 0 0 8px var(--cyan);
  animation: g3dPulse 1.8s ease-in-out infinite;
}
@keyframes g3dPulse{
  0%, 100%{ opacity: 1; transform: scale(1); }
  50%{ opacity: .4; transform: scale(.72); }
}

/* ==========================================================================
   COLLECTION TRACKER — scavenger-hunt progress, tucked under the head count
   ========================================================================== */
.g3d-collect[hidden]{ display: none; }
.g3d-collect{
  position: absolute; top: 64px; left: 16px;
  z-index: 6;
  display: flex; align-items: center; gap: 9px;
  background: rgba(13,11,23,.8);
  border: 1px solid var(--line);
  padding: 8px 14px;
  border-radius: var(--radius);
  font-family: var(--f-mono); font-size: .72rem; letter-spacing: .04em;
  color: var(--text-dim);
  backdrop-filter: blur(6px);
  pointer-events: none;
  transition: border-color .4s ease, box-shadow .4s ease;
}
.g3d-collect-icon{
  color: #3ddc84;
  text-shadow: 0 0 8px #3ddc84;
  font-size: .95rem; line-height: 1;
}
.g3d-collect-body{ display: flex; flex-direction: column; gap: 5px; }
.g3d-collect strong{ color: #3ddc84; }
.g3d-collect-bar{
  width: 132px; height: 4px; border-radius: 2px;
  background: rgba(255,255,255,.09);
  overflow: hidden;
}
.g3d-collect-fill{
  display: block; height: 100%; width: 0%;
  background: linear-gradient(90deg, var(--cyan), #3ddc84);
  box-shadow: 0 0 10px #3ddc84;
  transition: width .5s cubic-bezier(.22,1,.36,1);
}
/* Fully collected — the whole chip goes gold-green and glows. */
.g3d-collect.complete{
  border-color: #3ddc84;
  box-shadow: 0 0 22px rgba(61,220,132,.4);
}

/* ==========================================================================
   COLLECT TOAST — momentary banner when a piece is picked up
   ========================================================================== */
.g3d-toast[hidden]{ display: none; }
.g3d-toast{
  position: absolute; left: 50%; top: 24px;
  transform: translateX(-50%) translateY(-8px);
  z-index: 7;
  padding: 10px 20px;
  background: rgba(13,11,23,.9);
  border: 1px solid #3ddc84;
  border-radius: var(--radius);
  font-family: var(--f-mono); font-size: .74rem; letter-spacing: .04em;
  color: #eafff3;
  backdrop-filter: blur(6px);
  box-shadow: 0 0 22px rgba(61,220,132,.35);
  pointer-events: none;
  opacity: 0;
  transition: opacity .3s ease, transform .3s ease;
}
.g3d-toast.show{ opacity: 1; transform: translateX(-50%) translateY(0); }
.g3d-toast.win{
  border-color: var(--amber);
  color: #fff5e0;
  box-shadow: 0 0 26px rgba(255,176,32,.5);
}
.g3d-toast strong{ color: #3ddc84; }
.g3d-toast.win strong{ color: var(--amber); }

@media (max-width: 560px){
  .g3d-collect-bar{ width: 108px; }
  .g3d-toast{ font-size: .68rem; max-width: 80vw; text-align: center; }
}

