/* ─── 全局重置與基礎樣式 ─────────────────────────── */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
  }
  
  body {
    font-family: Arial, sans-serif;
    background: linear-gradient(135deg, #141e30, #243b55);
    color: #fff;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 15px; /* 減少填充以增加小屏幕的可用空間 */
    overflow-x: hidden;
  }
  
  /* ─── 主要容器與卡片樣式 ─────────────────────────── */
  .container {
    width: 100%;
    max-width: 900px;
    margin: 0 auto;
    text-align: center;
  }
  
  .card {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 15px; /* 稍微減小圓角 */
    padding: 20px; /* 減少填充以增加內容空間 */
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.25);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
  }
  
  .card:hover {
    transform: translateY(-5px); /* 降低懸停效果，更適合移動設備 */
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
  }
  
  /* ─── 標題與按鈕 ─────────────────────────── */
  h1#title {
    font-size: 1.6em; /* 稍微減小字體尺寸 */
    margin-bottom: 15px;
    font-weight: bold;
    color: #ffeb3b;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
    cursor: pointer;
  }
  
  .button-group {
    display: flex;
    justify-content: center;
    flex-wrap: wrap; /* 允許按鈕在小屏幕上換行 */
    gap: 8px; /* 減少按鈕間距 */
    margin-bottom: 15px;
  }
  
  .button-group button {
    padding: 8px 12px; /* 調整按鈕尺寸 */
    background-color: #4caf50;
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 0.95em; /* 稍微減小字體 */
    cursor: pointer;
    transition: background-color 0.3s, transform 0.2s;
  }
  
  .button-group button:hover {
    background-color: #45a049;
    transform: scale(1.05); /* 降低懸停放大效果 */
  }
  
  /* ─── 搜尋框 ─────────────────────────── */
  .search-box {
    display: flex;
    justify-content: center;
    flex-wrap: wrap; /* 允許在小屏幕上換行 */
    gap: 8px;
    margin-bottom: 20px;
  }
  
  .search-box input {
    padding: 8px;
    width: 100%; /* 在小屏幕上佔滿寬度 */
    max-width: 300px; /* 但在較大屏幕上限制寬度 */
    border: none;
    border-radius: 8px;
    font-size: 0.95em;
    transition: box-shadow 0.3s ease;
  }
  
  .search-box input:focus {
    box-shadow: 0 0 10px rgba(255, 235, 59, 0.8);
    outline: none;
  }
  
  .search-box button {
    padding: 8px 12px;
    background-color: #ffeb3b;
    color: #333;
    border: none;
    border-radius: 8px;
    font-size: 0.95em;
    cursor: pointer;
    transition: background-color 0.3s, transform 0.2s;
  }
  
  .search-box button:hover {
    background-color: #ffd700;
    transform: scale(1.05); /* 降低懸停放大效果 */
  }
  
  /* ─── 天氣資訊與卡片 ─────────────────────────── */
  .weather-info {
    margin-bottom: 20px;
  }
  
  .weather-info h2 {
    font-size: 1.3em; /* 減小標題尺寸 */
    margin-bottom: 12px;
    color: #ffeb3b;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
  }
  
  .weather-card {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 12px;
    padding: 15px; /* 減少填充 */
    margin-bottom: 12px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
  }
  
  .weather-card:hover {
    transform: scale(1.03); /* 降低懸停放大效果 */
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
  }
  
  .weather-card h3 {
    font-size: 1.2em;
    color: #ffeb3b;
  }
  
  .weather-card p {
    font-size: 1em;
    margin: 6px 0;
    color: #fff;
  }
  
  /* ─── 冷知識 ─────────────────────────── */
  #dailyFact {
    font-size: 1em;
    color: #ffeb3b;
    margin-top: 12px;
    animation: fadeIn 1s ease-in-out;
  }
  
  /* ─── 趨勢區域：時間選擇滾輪與圖表容器 ─────────────────────────── */
  .weather-trend {
    display: flex;
    flex-direction: column; /* 在所有屏幕尺寸上預設為列布局 */
    gap: 15px;
    margin-top: 15px;
  }
  
  /* 時間選擇器 */
  .time-selector {
    width: 100%; /* 佔滿寬度 */
    max-width: 100%; /* 移除最大寬度限制 */
    text-align: center;
  }
  
  .time-selector h3 {
    font-size: 1.1em;
    color: #ffeb3b;
    margin-bottom: 8px;
  }
  
  .time-list {
    max-height: 150px; /* 減小高度以適應小屏幕 */
    overflow-y: auto;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    padding: 8px;
  }
  
  .time-item {
    padding: 6px;
    font-size: 0.9em;
    color: #fff;
    cursor: pointer;
    transition: background-color 0.2s;
  }
  
  .time-item:hover {
    background-color: rgba(255, 235, 59, 0.3);
  }
  
  .time-item.selected {
    background-color: #ffeb3b;
    color: #333;
    font-weight: bold;
  }
  
  /* 圖表容器 */
  .chart-container {
    width: 100%;
    height: 250px; /* 為小屏幕減小高度 */
    margin: 0 auto;
    display: block;
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 8px;
    background: #fff;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
  }
  
  .chart-container:hover {
    transform: scale(1.02); /* 降低懸停放大效果 */
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
  }
  
  /* 圖表 Canvas */
  canvas#weatherChart {
    width: 100% !important;
    height: 100% !important;
    object-fit: contain; /* 確保圖表正確縮放 */
    border-radius: 8px;
  }
  
  /* ─── 動畫效果 ─────────────────────────── */
  @keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
  }
  
  .fall {
    animation: drop 1s ease forwards;
    position: relative;
  }
  
  @keyframes drop {
    0% { transform: translateY(0) rotate(0deg); opacity: 1; }
    100% { transform: translateY(100vh) rotate(360deg); opacity: 0; }
  }
  
  .flash {
    text-shadow: 0 0 10px #ffeb3b, 0 0 20px #ffeb3b, 0 0 30px #ffeb3b;
  }
  
  .refresh-message {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 1.3em; /* 減小字體尺寸 */
    color: #ffeb3b;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
    animation: fadeIn 1s ease-in-out;
  }
  
  /* ─── 響應式設計調整 ─────────────────────────── */
  @media (min-width: 601px) {
    /* 中等及以上屏幕的佈局調整 */
    .weather-trend {
      flex-direction: row; /* 在較大屏幕上恢復為行佈局 */
    }
    
    .time-selector {
      flex: 1;
      max-width: 200px; /* 恢復最大寬度 */
    }
    
    .chart-container {
      flex: 2;
      height: 300px; /* 較大的高度 */
    }
    
    .time-list {
      max-height: 300px; /* 較大的列表高度 */
    }
  }
  
  @media (max-width: 600px) {
    .container {
      width: 95%;
    }
    
    .card {
      padding: 15px; /* 進一步減少填充 */
    }
    
    .search-box input,
    .search-box button {
      width: 100%; /* 在較小的屏幕上，讓輸入框和按鈕佔滿寬度 */
    }
  }
  
  /* 特別針對Pixel 4a尺寸的設備 (約360x800px) */
  @media (max-width: 380px) {
    body {
      padding: 10px; /* 減少體外填充 */
    }
    
    h1#title {
      font-size: 1.4em;
    }
    
    .card {
      padding: 12px;
      border-radius: 12px;
    }
    
    .weather-card {
      padding: 12px;
    }
    
    .chart-container {
      height: 200px; /* 進一步減小圖表高度 */
      padding: 6px;
    }
    
    .time-list {
      max-height: 120px; /* 進一步減小時間列表高度 */
    }
  }