body {
  font-family: Arial, sans-serif;
  background: #1e1e1e;
  color: #eee;
  margin: 0;
  padding: 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

h1 {
  margin-bottom: 20px;
}

.container {
  display: flex;
  gap: 2rem;
  max-width: 1400px;
  width: 100%;
  justify-content: center;
}

canvas {
  border: 2px solid #444;
  border-radius: 12px;
  background: #111;
  box-shadow: 0 4px 12px rgba(0,0,0,0.6);
}

.controls {
  background: #2a2a2a;
  padding: 20px;
  border-radius: 12px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.5);
  width: 320px;
  overflow-y: auto;
  max-height: 90vh;
}

.controls h2 {
  margin-top: 20px;
  font-size: 18px;
  border-bottom: 1px solid #444;
  padding-bottom: 5px;
}

.controls label {
  display: block;
  margin: 10px 0;
  font-size: 14px;
}

input[type="range"] {
  width: 100%;
}

button {
  margin-top: 10px;
  padding: 10px;
  background: #4CAF50;
  border: none;
  border-radius: 8px;
  color: white;
  cursor: pointer;
  font-size: 14px;
}

button:hover {
  background: #45a049;
}

#bgColorSwatches {
  display: grid;
  grid-template-columns: repeat(6, 1fr); /* 6 columns */
  gap: 5px; /* spacing between swatches */
}
.swatch {
  width: 25px;
  height: 25px;
  cursor: pointer;
  border: 2px solid #444;
}
.swatch:hover {
  border: 2px solid white;
}

#layerList {
  list-style: none;
  padding: 0;
  margin: 0;
}

#layerList li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #333;
  padding: 5px;
  margin: 5px 0;
  border-radius: 6px;
}
#layerList li span {
  flex-grow: 1;
}
#layerList button {
  margin: 0 2px;
  padding: 4px 6px;
  font-size: 12px;
}
#avatar {
  width: 500px;   /* displayed width */
  height: 500px;  /* displayed height */
}

/* === Responsive layout for mobile === */
@media (max-width: 768px) {       /* adjust breakpoint as needed */
  .container {
    flex-direction: column;       /* stack canvas and sidebar */
    align-items: center;          /* center them horizontally */
  }

  #avatar {
    width: 90vw;                  /* scale canvas to viewport width */
    height: auto;                 /* keep aspect ratio */
    max-width: 500px;             /* don’t stretch bigger than original */
  }

  .controls {
    width: 90vw;                  /* make sidebar as wide as canvas */
    max-width: 500px;
    margin-top: 20px;             /* add space below the canvas */
    max-height: none;             /* let it expand naturally */
  }
}