/* 1. BODY & 過渡動畫 */
body {
  margin: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  height: 100vh;
  /* 讓背景色變化平滑過渡 */
  transition: background-color 0.5s ease;
  font-family: Arial, sans-serif;
  color: #333;
}

/* 2. 容器 (Enhanced Glassmorphism) */
.container {
  width: 90%;
  max-width: 650px;
  text-align: center;
  /* 輕微透明白色背景 */
  background: rgba(255, 255, 255, 0.5);
  padding: 20px 30px 40px;
  border-radius: 30px;
  /* 玻璃擬態模糊效果 */
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  /* 更明顯的邊框和陰影 */
  border: 1px solid rgba(255, 255, 255, 0.4);
  box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.2);
  font-size: 20px;
}

/* 3. 標題優化 */
#title {
  font-size: 40px;
  font-weight: bold;
  text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.2);
  transition: color 0.5s ease;
}

/* 4. 數值與按鈕佈局 */
.color-control {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 15px;
  padding: 0 10px;
}

/* 5. 通用按鈕樣式 */
button {
  border-radius: 8px;
  border: none;
  padding: 0.6rem 1rem;
  cursor: pointer;
  font-size: 16px;
  font-weight: 600;
  transition: background-color 0.2s, transform 0.1s;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

button:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.15);
}

/* 隨機按鈕顏色 */
.random {
  background-color: #e9ecef;
  color: #495057;
}

#random-all {
  background-color: #354295;
  color: white;
  margin-top: 20px;
  padding: 1rem 2rem;
}

/* 6. Hex Code 顯示區 */
.hex-display {
  display: flex;
  justify-content: center;
  align-items: center;
  margin: 20px 0;
  padding: 10px;
  background: rgba(0, 0, 0, 0.05);
  border-radius: 10px;
}

#hex-code-input {
  font-family: "Consolas", monospace;
  font-size: 24px;
  font-weight: bold;
  margin: 0 20px 0 0;
  padding: 5px 10px;
  border: 2px solid #ccc;
  border-radius: 5px;
  background: white;
}

#hex-code-input.error {
  border: 2px solid #dc3545 !important;
  box-shadow: 0 0 5px rgba(220, 53, 69, 0.7);
}

#copy-btn {
  background-color: #007bff;
  color: white;
  padding: 0.5rem 1rem;
}

/* 7. 滑桿美化 (Range Input Customization) */
.range {
  -webkit-appearance: none;
  appearance: none;
  width: 60%;
  height: 10px;
  border-radius: 5px;
  outline: none;
  opacity: 0.8;
  transition: opacity 0.2s;
}

.range::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  cursor: grab;
  transition: background-color 0.2s;
}

/* 滑桿顏色對應 */
#R .range {
  background: #f0c0c0;
}

#R .range::-webkit-slider-thumb {
  background: #ff0000;
  box-shadow: 0 0 5px #ff0000;
}

#G .range {
  background: #c0f0c0;
}

#G .range::-webkit-slider-thumb {
  background: #008000;
  box-shadow: 0 0 5px #008000;
}

#B .range {
  background: #c0c0f0;
}

#B .range::-webkit-slider-thumb {
  background: #0000ff;
  box-shadow: 0 0 5px #0000ff;
}

/* 8. RWD (響應式網頁設計) */
@media (max-width: 600px) {
  .container {
    width: 95%;
    padding: 15px 20px 30px;
    font-size: 18px;
    background: rgba(255, 255, 255, 0);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
  }

  #title {
    font-size: 32px;
  }

  .color-control {
    flex-direction: column;
    align-items: center;
    margin-bottom: 25px;
    gap: 10px; /* 新增間距 */
  }

  .range {
    width: 100%; /* 滑桿寬度調整 */
  }

  .hex-display {
    flex-direction: column;
    gap: 10px;
  }

  #hex-code-input {
    margin: 0;
    width: 80%;
    text-align: center;
  }

  button {
    padding: 0.5rem 0.8rem;
    font-size: 15px;
  }

  #random-all {
    padding: 0.8rem 1.5rem;
  }
}
