html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #afa199;
}

body {
  position: fixed;
  inset: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

#scene {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  outline: none;
  cursor: grab;
  opacity: 0;
  transition: opacity 0.7s ease;
}
#scene.ready { opacity: 1; }
#scene:active { cursor: grabbing; }

/* Controls: small, low-contrast, out of the way of the scene. */
#panel {
  position: absolute;
  left: 50%;
  bottom: max(12px, env(safe-area-inset-bottom, 12px));
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 7px 14px;
  border-radius: 999px;
  background: rgba(46, 36, 30, 0.42);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.08) inset, 0 4px 14px rgba(40, 28, 20, 0.18);
  color: #fff4e2;
  font-size: 12px;
  line-height: 1;
  white-space: nowrap;
}

.ctl {
  display: flex;
  align-items: center;
  gap: 8px;
}
.ctl label {
  font-weight: 600;
  letter-spacing: 0.03em;
  min-width: 2.4em;
}
.ctl input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 112px;
  height: 18px;
  margin: 0;
  background: transparent;
  cursor: pointer;
  touch-action: none;
}
.ctl input[type="range"]::-webkit-slider-runnable-track {
  height: 4px;
  border-radius: 2px;
  background: rgba(255, 244, 226, 0.32);
}
.ctl input[type="range"]::-moz-range-track {
  height: 4px;
  border-radius: 2px;
  background: rgba(255, 244, 226, 0.32);
}
.ctl input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 14px;
  height: 14px;
  margin-top: -5px;
  border-radius: 50%;
  background: #ffc65a;
  border: 0;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.35);
}
.ctl input[type="range"]::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #ffc65a;
  border: 0;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.35);
}
.ctl input[type="range"]:focus-visible {
  outline: 2px solid rgba(255, 198, 90, 0.8);
  outline-offset: 3px;
}

#hint {
  position: absolute;
  top: max(12px, env(safe-area-inset-top, 12px));
  left: 50%;
  transform: translateX(-50%);
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(46, 36, 30, 0.34);
  color: #fff4e2;
  font-size: 12px;
  line-height: 1.2;
  white-space: nowrap;
  pointer-events: none;
  transition: opacity 0.9s ease;
}
#hint.gone { opacity: 0; }

#loading {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  text-align: center;
  color: #fff4e2;
  font-size: 15px;
  letter-spacing: 0.02em;
  pointer-events: none;
  transition: opacity 0.6s ease;
}
#loading.gone { opacity: 0; }
#loading.error { color: #3a2a22; font-weight: 600; }

@media (max-width: 560px) {
  #panel { gap: 12px; padding: 7px 12px; }
  .ctl input[type="range"] { width: 92px; }
}
@media (max-width: 380px) {
  #panel { gap: 9px; padding: 7px 10px; }
  .ctl { gap: 6px; }
  .ctl input[type="range"] { width: 74px; }
}
@media (max-height: 380px) {
  #panel { bottom: 6px; padding: 4px 12px; }
  #hint { top: 6px; }
}
