* { box-sizing: border-box; font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif; }
body { margin: 0; background: #0f1115; color: #e6e6e6; }
.wrap { max-width: 960px; margin: 40px auto; padding: 0 20px; }
h1 { margin-bottom: 24px; text-align: center; }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 16px;
}

.card {
  background: #161a22;
  border: 1px solid #262b36;
  border-radius: 12px;
  padding: 20px;
}

label { display: block; margin: 10px 0 6px; font-size: 14px; opacity: .85; }

input[type="text"], input[type="number"], input:not([type]) {
  width: 100%; padding: 10px 12px; border-radius: 8px;
  border: 1px solid #2a3140; background: #0f1218; color: #e6e6e6;
}

.row { display: flex; gap: 8px; align-items: center; margin-top: 6px; }
.row input[type="number"] { flex: 1; text-align: center; font-size: 18px; }
.row.buttons-row { margin-top: 12px; }

button {
  border: 1px solid #394154; background: #1c2230; color: #e6e6e6;
  padding: 10px 14px; border-radius: 8px; cursor: pointer;
  font-weight: 500; transition: 0.2s;
}
button:hover { background: #232a3b; }

#apply { background: #1e6fff; border-color: #1e6fff; }
#apply:hover { background: #3b7cff; }

#reset { background: #2a2f3d; }
#status { margin-top: 12px; font-size: 12px; opacity: .7; }

#ball-controls h2 { margin-bottom: 12px; }
#ball-controls {
  margin-top: 16px; /* Menambahkan spasi di bagian atas kartu kontrol bola */
}
.ball-grid {
  display: grid;
  /* Membuat 4 kolom untuk tampilan desktop, dan akan menyesuaikan secara otomatis */
  grid-template-columns: repeat(auto-fill, minmax(60px, 1fr));
  gap: 10px;
  justify-items: center;
  align-items: center;
  margin-top: 16px;
  margin-bottom: 16px;

  padding: 10px;
  border: 1px solid #2a3140;
  border-radius: 8px;
}

.ball-btn {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  background-size: cover;
  background-position: center;
  cursor: pointer;
  transition: transform 0.2s, filter 0.3s;
}

.ball-btn:active {
  transform: scale(0.9);
}

.ball-btn.disabled {
  filter: brightness(30%); /* bikin gelap */
}

.reset-ball {
  background: crimson;
  border-color: crimson;
  width: 100%;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}
.reset-ball:hover { background: #ff4c4c; }

.overlay-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
  font-size: 14px;
}

/* Saklar custom */
.switch {
  position: relative;
  display: inline-block;
  width: 46px;
  height: 24px;
}
.switch input { display: none; }
.slider {
  position: absolute;
  cursor: pointer;
  background-color: #ccc;
  border-radius: 34px;
  top: 0; left: 0; right: 0; bottom: 0;
  transition: .4s;
}
.slider:before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  border-radius: 50%;
  transition: .4s;
}
input:checked + .slider { background-color: #1e6fff; }
input:checked + .slider:before { transform: translateX(22px); }
.slider.round { border-radius: 34px; }
.slider.round:before { border-radius: 50%; }

/* Styles untuk hide/show ball controls dengan slide animation */
.ball-controls-content {
  max-height: 500px; /* Adjust sesuai kebutuhan */
  overflow: hidden;
  transition: max-height 0.4s ease, opacity 0.3s ease, padding 0.3s ease;
  opacity: 1;
}

.ball-controls-content.hidden {
  max-height: 0;
  opacity: 0;
  padding-top: 0;
  padding-bottom: 0;
}

/* Ball type selection styles */
.ball-type-selection {
  margin-bottom: 16px;
  padding: 12px;
  background: #0f1218;
  border-radius: 8px;
  border: 1px solid #2a3140;
}

.ball-type-label {
  display: block;
  margin-bottom: 8px;
  font-size: 14px;
  font-weight: 500;
  color: #e6e6e6;
}

.radio-group {
  display: flex;
  gap: 16px;
}

.radio-option {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 14px;
  color: #e6e6e6;
  transition: color 0.2s;
}

.radio-option:hover {
  color: #1e6fff;
}

.radio-option input[type="radio"] {
  display: none;
}

.radio-custom {
  width: 16px;
  height: 16px;
  border: 2px solid #394154;
  border-radius: 50%;
  position: relative;
  transition: border-color 0.2s;
}

.radio-custom:before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0);
  width: 8px;
  height: 8px;
  background: #1e6fff;
  border-radius: 50%;
  transition: transform 0.2s;
}

.radio-option input[type="radio"]:checked + .radio-custom {
  border-color: #1e6fff;
}

.radio-option input[type="radio"]:checked + .radio-custom:before {
  transform: translate(-50%, -50%) scale(1);
}
/* WebSocket connection status visuals */
.conn-status { display: inline-flex; align-items: center; gap: 6px; padding: 4px 8px; border-radius: 999px; font-weight: 600; }
.conn-status::before { content: ""; width: 10px; height: 10px; border-radius: 50%; background: #f44336; display: inline-block; }
.conn-status.connected { color: #0b5; background: rgba(0, 128, 0, 0.08); }
.conn-status.connected::before { background: #4caf50; animation: conn-pulse 1.2s ease-in-out infinite; }
.conn-status.disconnected { color: #e53935; background: rgba(255, 0, 0, 0.08); }
.conn-status.disconnected::before { background: #f44336; animation: conn-blink 0.8s linear infinite; }

@keyframes conn-blink { 0%, 100% { opacity: 1 } 50% { opacity: 0.2 } }
@keyframes conn-pulse { 0% { transform: scale(1); opacity: .9 } 50% { transform: scale(1.2); opacity: 1 } 100% { transform: scale(1); opacity: .9 } }

/* Ensure connected state wins over disconnected, even if both present */
.conn-status.connected { color: #0b5 !important; background: rgba(0, 128, 0, 0.08) !important; }
.conn-status.connected::before { background: #4caf50 !important; animation: conn-pulse 1.2s ease-in-out infinite !important; }
