:root {
  --box-size: 400px;
  --ball-size: 20px;
  --ball-speed: 2s;
  --ball-color: #ff5722;
  --bg-color: #f7f7f7;
}

html, body {
  height: 100%;
  margin: 0;
  background: #111;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: system-ui, Segoe UI, Roboto, Helvetica, Arial;
}

.stage {
  width: var(--box-size);
  height: var(--box-size);
  background: var(--bg-color);
  border: 4px solid #222;
  border-radius: 6px;
  position: relative;
}

#ball {
  width: var(--ball-size);
  height: var(--ball-size);
  background-color: var(--ball-color);
  border-radius: 50%;
  position: absolute;
  top: 50%;
  left: 0;
  animation: bounce var(--ball-speed) linear infinite alternate;
}

@keyframes bounce {
  from {
    transform: translate(0, -50%);
  }
  to {
    transform: translate(calc(var(--box-size) - var(--ball-size)), -50%);
  }
}

.controls {
  position: absolute;
  top: 20px;
  right: 20px;
  background: #2a2a2a;
  padding: 15px;
  border-radius: 5px;
  color: white;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 320px;
  transition: opacity 0.5s ease-in-out;
}

.fade-out {
  opacity: 0;
}

.controls div {
  display: grid;
  grid-template-columns: 120px 1fr 80px;
  align-items: center;
  gap: 10px;
}

.controls label {
  font-weight: bold;
}

.controls input[type="range"] {
  width: 100%;
}

.controls input[type="color"] {
  width: 50px;
  height: 30px;
  border: none;
  padding: 0;
  background: none;
}

.controls span {
  text-align: right;
  font-family: monospace;
  font-size: 14px;
}

.button {
  grid-column: 1 / -1;
  padding: 10px;
  background: #4CAF50;
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 16px;
  margin-top: 10px;
}

#save-defaults:hover {
  background: #45a049;
}

#ball.hidden {
  opacity: 0;
}