html,
body {
  overflow: hidden;
}

.stage-loading {
  position: absolute;
  inset: 0;
  z-index: 8;
  display: grid;
  place-items: center;
  background: #161b16;
  opacity: 1;
  transition: opacity .4s ease;
}
.stage-loading[hidden] { display: none; }
.ambient-firefly-canvas { position: absolute; inset: 0; width: 100%; height: 100%; z-index: 6; pointer-events: none; }
.stage-loading.is-finished { opacity: 0; pointer-events: none; }
.stage-loading-content { display: grid; justify-items: center; gap: 15px; }
.stage-loading video { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.stage-loading canvas { width: min(84vw, 440px); height: auto; aspect-ratio: 16/9; }
.stage-loading p { margin: 0; color: #eee9d9; font-size: 16px; letter-spacing: .13em; }
.loading-dots { animation: loading-breathe 1.2s ease-in-out infinite; }
@keyframes loading-breathe { 50% { opacity: .3; } }
.topbar { z-index: 12 !important; }
.route-sheet { z-index: 20 !important; }
.stage-pending .scene-actions,
.stage-pending .demo-controls,
.stage-pending .layout-toggle { visibility: hidden; }
@media (prefers-reduced-motion: reduce) {
  .loading-dots { animation: none; }
  .stage-loading { transition: none; }
}

.hero {
  overflow: clip;
  background:
    radial-gradient(circle at 50% 48%, #53654b 0, #293a2e 42%, #111a14 100%);
}

.visual {
  inset: 0;
  transform: none;
  transition: none;
}

/* The orthographic camera already flattens perspective like a miniature set.
   A restrained tilt-shift falloff finishes the diorama effect while keeping
   the character, crystal and goal corner crisp. */
.visual::after {
  content: "";
  position: absolute;
  inset: -3%;
  z-index: 5;
  pointer-events: none;
  backdrop-filter: blur(2.35px) saturate(1.04);
  -webkit-backdrop-filter: blur(2.35px) saturate(1.04);
  mask-image: linear-gradient(
    to bottom,
    #000 0%,
    rgba(0, 0, 0, .72) 10%,
    transparent 27%,
    transparent 70%,
    rgba(0, 0, 0, .6) 87%,
    #000 100%
  );
  -webkit-mask-image: linear-gradient(
    to bottom,
    #000 0%,
    rgba(0, 0, 0, .72) 10%,
    transparent 27%,
    transparent 70%,
    rgba(0, 0, 0, .6) 87%,
    #000 100%
  );
}

.scene {
  z-index: 0;
  transition: opacity .65s ease, filter .65s ease, transform .65s ease;
}

.foreground {
  position: absolute;
  inset: 0;
  z-index: 4;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  pointer-events: none;
  /* Slight optical defocus feathers the alpha edge into the 3D tree while
     keeping the foreground foliage recognisable and naturally closer. */
  filter:
    brightness(.83)
    saturate(.9)
    blur(1.15px)
    drop-shadow(0 -2px 5px rgba(54, 72, 39, .2));
  opacity: .985;
}

.model-canvas {
  position: absolute;
  inset: 0;
  z-index: 2;
  width: 100%;
  height: 100%;
  pointer-events: none;
  opacity: 0;
  transition: opacity .65s ease;
}

.models-ready .model-canvas {
  opacity: 1;
}

.models-ready .scene {
  opacity: 1;
  filter: brightness(.82) saturate(.88) contrast(1.025);
  transform: scale(1.035);
}

.models-unavailable .scene {
  opacity: 1;
  filter: none;
  transform: none;
}

.edge-shade {
  z-index: 3;
  background:
    radial-gradient(ellipse at 50% 48%, transparent 42%, rgba(5, 10, 7, .22) 80%, rgba(3, 7, 5, .48) 100%),
    linear-gradient(0deg, rgba(4, 8, 5, .31), transparent 24%, rgba(7, 11, 8, .08));
}

.identity,
.hero-footer,
.clean-plate,
.character-breath,
.crystal-light,
.eye-light,
.goal-state,
.fireflies {
  display: none !important;
}

.topbar {
  background: linear-gradient(rgba(8, 13, 9, .34), transparent);
  backdrop-filter: blur(3px);
}

.wood-hotspot {
  display: grid;
  place-items: center;
  width: 110px;
  height: 48px;
  border-radius: 10px;
  background: transparent;
  color: #2f1d0f;
  text-decoration: none;
  text-align: center;
  text-shadow: 0 1px rgba(255, 235, 184, .18);
}

.wood-hotspot span {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.wood-hotspot:hover {
  outline: none;
  background: transparent;
}

.wood-hotspot:focus-visible,
.object-button:focus-visible {
  outline: 2px solid rgba(255, 226, 153, .9);
  outline-offset: 3px;
}

.object-button {
  padding: 6px 9px;
  background: rgba(15, 20, 14, .58);
}

.layout-toggle {
  position: absolute;
  z-index: 9;
  left: 28px;
  bottom: 28px;
  min-height: 38px;
  padding: 0 15px;
  border: 1px solid rgba(255, 238, 190, .28);
  border-radius: 999px;
  background: rgba(15, 21, 15, .78);
  color: #f2ead0;
  box-shadow: 0 12px 34px rgba(0, 0, 0, .28);
  backdrop-filter: blur(14px);
  font: 600 12px/1 system-ui, sans-serif;
  cursor: pointer;
}

.layout-toggle:hover {
  border-color: rgba(255, 218, 126, .58);
  background: rgba(35, 39, 25, .9);
}

.layout-editor {
  position: absolute;
  z-index: 12;
  top: 104px;
  left: 24px;
  bottom: 78px;
  width: min(340px, calc(100vw - 48px));
  overflow: auto;
  padding: 18px;
  border: 1px solid rgba(255, 246, 213, .2);
  border-radius: 16px;
  background: rgba(12, 18, 13, .92);
  color: #f2eedc;
  box-shadow: 0 28px 80px rgba(0, 0, 0, .46);
  backdrop-filter: blur(18px);
}

.layout-editor-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.layout-editor-head span,
.layout-editor-head strong {
  display: block;
}

.layout-editor-head span {
  margin-bottom: 5px;
  color: #929d87;
  font-size: 11px;
  letter-spacing: .14em;
}

.layout-editor-head strong {
  font: 400 22px/1.15 Georgia, serif;
}

.layout-editor-head button {
  width: 32px;
  height: 32px;
  border: 0;
  background: transparent;
  color: #c9cfbc;
  font-size: 24px;
  cursor: pointer;
}

.layout-target-label {
  display: block;
  margin-bottom: 7px;
  color: #aab39e;
  font-size: 12px;
}

#layout-target {
  width: 100%;
  min-height: 40px;
  padding: 0 11px;
  border: 1px solid rgba(255, 255, 255, .15);
  border-radius: 9px;
  background: #242d24;
  color: #f2eedc;
  font-size: 14px;
}

.layout-fields {
  display: grid;
  gap: 12px;
  margin-top: 18px;
}

.layout-field {
  display: grid;
  grid-template-columns: 86px minmax(80px, 1fr) 68px;
  align-items: center;
  gap: 9px;
}

.layout-field > label {
  color: #c4cab8;
  font-size: 12px;
}

.layout-field input[type="range"] {
  width: 100%;
  accent-color: #d2bc6c;
}

.layout-number {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  min-height: 34px;
  padding-right: 7px;
  border: 1px solid rgba(255, 255, 255, .12);
  border-radius: 7px;
  background: rgba(255, 255, 255, .055);
}

.layout-number input {
  min-width: 0;
  width: 100%;
  padding: 7px 2px 7px 8px;
  border: 0;
  outline: 0;
  background: transparent;
  color: #efe9cf;
  font: 12px/1 ui-monospace, SFMono-Regular, Menlo, monospace;
}

.layout-number span {
  color: #899280;
  font-size: 11px;
}

.layout-hint {
  margin: 18px 0 0;
  color: #8f9989;
  font-size: 12px;
  line-height: 1.55;
}

.layout-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 7px;
  margin-top: 16px;
}

.layout-actions button {
  min-height: 38px;
  padding: 7px 9px;
  border: 1px solid rgba(255, 255, 255, .13);
  border-radius: 8px;
  background: rgba(255, 255, 255, .06);
  color: #dfe4d2;
  font-size: 12px;
  cursor: pointer;
}

.layout-actions button:hover {
  background: rgba(255, 255, 255, .11);
}

.layout-actions .layout-primary {
  border-color: rgba(231, 204, 112, .34);
  background: #d7c178;
  color: #20251c;
  font-weight: 700;
}

.layout-status {
  min-height: 34px;
  margin: 13px 0 0;
  padding-top: 12px;
  border-top: 1px solid rgba(255, 255, 255, .09);
  color: #aeb7a3;
  font-size: 12px;
  line-height: 1.45;
}

.layout-mode .projects-hotspot,
.layout-mode .playground-hotspot {
  outline: 1px dashed rgba(255, 224, 137, .46);
  outline-offset: 2px;
}

.layout-mode .object-button {
  box-shadow: 0 0 0 1px rgba(255, 224, 137, .28), 0 9px 28px rgba(0, 0, 0, .25);
}

.models-loading .demo-controls::before {
  content: "Loading 3D room…";
  display: block;
  margin: 0 0 10px;
  color: rgba(235, 222, 176, .66);
  font-size: 9px;
  letter-spacing: .08em;
}

@media (max-width: 760px) {
  .model-canvas {
    display: none;
  }

  .models-ready .scene {
    opacity: 1;
    filter: brightness(.82) saturate(.88);
    transform: scale(1.035);
  }

  .wood-hotspot {
    display: none;
  }

  .layout-toggle,
  .layout-editor {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .model-canvas,
  .scene {
    transition: none;
  }
}
