/* Page shell: the room, the loader, the corner controls, and the 2D fallback. */

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: #05060a;
  color: #ffb000;
  font-family: 'VT323', 'Courier New', monospace;
  overflow: hidden;
  overscroll-behavior: none;
}

#stage { position: fixed; inset: 0; }

/* CSS3D layer sits underneath; the WebGL canvas punches a hole through to it
   with a NoBlending plane, so desk objects still occlude the screen correctly. */
#css3d {
  position: absolute;
  inset: 0;
  z-index: 1;
}

#webgl {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
}

/* Drag-to-orbit surface, only live when pulled back from the desk. */
#grab {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: none;
  cursor: grab;
}

body.view-room #grab { display: block; }
body.view-room #grab.dragging { cursor: grabbing; }

/* ---------- 2D fallback ---------- */

#flat {
  position: fixed;
  inset: 0;
  z-index: 1;
  display: none;
  padding: clamp(0px, 2.4vmin, 34px);
  background: #05060a;
}

body.mode-2d #stage { display: none; }
body.mode-2d #flat { display: block; }

body.mode-2d .screen {
  width: 100%;
  height: 100%;
  font-size: clamp(13px, 1.55vw + 0.35rem, 21px);
  border-radius: clamp(4px, 1vmin, 14px);
  box-shadow: 0 0 60px rgba(255, 176, 0, 0.09), inset 0 0 90px rgba(0, 0, 0, 0.75);
  border: 1px solid #1c1710;
}

/* ---------- loader ---------- */

#loader {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: #05060a;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1.1rem;
  transition: opacity 0.7s ease;
  font-size: clamp(12px, 1.4vw, 17px);
  letter-spacing: 0.12em;
  color: #a8741a;
}

#loader.gone { opacity: 0; pointer-events: none; }

#loader-bar {
  width: min(280px, 56vw);
  height: 3px;
  background: #1c1710;
  overflow: hidden;
}

#loader-fill {
  height: 100%;
  width: 0%;
  background: #ffb000;
  box-shadow: 0 0 10px rgba(255, 176, 0, 0.7);
  transition: width 0.3s ease;
}

/* ---------- corner controls ---------- */

#controls {
  position: fixed;
  right: clamp(10px, 2vw, 22px);
  bottom: clamp(10px, 2vw, 22px);
  z-index: 50;
  display: flex;
  gap: 0.5rem;
  font-size: clamp(12px, 1.2vw, 16px);
}

.ctl {
  background: rgba(10, 7, 4, 0.82);
  border: 1px solid #533a0d;
  color: #ffb000;
  font: inherit;
  letter-spacing: 0.08em;
  padding: 0.35em 0.85em;
  cursor: pointer;
  backdrop-filter: blur(3px);
  transition: background 0.15s ease, color 0.15s ease;
}

.ctl:hover, .ctl:focus-visible {
  background: #ffb000;
  color: #0a0704;
  outline: none;
}

.ctl[aria-pressed='true'] { border-color: #ffb000; }

/* A one-time nudge that the room is explorable. */
#hint {
  position: fixed;
  left: 50%;
  bottom: clamp(10px, 2vw, 22px);
  transform: translateX(-50%);
  z-index: 50;
  color: #6b4a10;
  font-size: clamp(11px, 1.1vw, 15px);
  letter-spacing: 0.14em;
  pointer-events: none;
  transition: opacity 0.6s ease;
}

#hint.gone { opacity: 0; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 720px) {
  #hint { display: none; }
}
