* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: 'Poppins', sans-serif;
}

body {
  height: 100vh;
  background-image: url(https://4kwallpapers.com/images/wallpapers/sunset-evening-sky-clouds-sun-behind-clouds-dramatic-4480x2520-9158.jpg);
  background-size: 400% 400%;
  background-position: 50% 50%;
  animation: backgroundMove 30s ease infinite;
  display: flex;
  justify-content: center;
  align-items: center;
  color: #fff;
  overflow: hidden;
}

@keyframes backgroundMove {
  0% { background-position: 0% 0%; }
  50% { background-position: 100% 100%; }
  100% { background-position: 0% 0%; }
}

.card {
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(15px);
  border-radius: 20px;
  padding: 30px 25px;
  width: 90%;
  max-width: 700px;
  text-align: center;
  box-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.37);
  animation: fadeIn 1s ease forwards;
  position: relative;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
  z-index: 10;
  margin: 0 auto;
  max-height: 90vh;
  overflow-y: auto; /* Allow vertical scrolling for overflow */
  padding-bottom: 50px; /* Ensure padding for scroll */
}

.card:hover {
  transform: scale(1.05);
  box-shadow: 0 16px 64px rgba(31, 38, 135, 0.47);
}

.search {
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 20px;
}

.search input {
  flex: 1;
  padding: 12px 20px;
  border: none;
  border-radius: 50px;
  outline: none;
  font-size: 16px;
  background: rgba(255, 255, 255, 0.2);
  color: #fff;
  transition: background 0.3s ease, transform 0.2s ease;
}

.search input::placeholder {
  color: #ddd;
}

.search input:focus {
  background: rgba(255, 255, 255, 0.3);
}

.search button {
  background: #fff;
  border: none;
  outline: none;
  padding: 14px;
  margin-left: -50px;
  border-radius: 50%;
  cursor: pointer;
  transition: background 0.3s ease, transform 0.3s ease, box-shadow 0.3s ease;
}

.search button:hover {
  background: #e0e0e0;
  transform: scale(1.1);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
}

.search button img {
  width: 20px;
  height: 20px;
}

.error {
  background: rgba(255, 0, 0, 0.2);
  padding: 10px;
  border-radius: 10px;
  margin-bottom: 20px;
  display: none;
  animation: fadeInError 0.3s ease;
}

@keyframes fadeInError {
  from { opacity: 0; transform: translateY(-20px); }
  to { opacity: 1; transform: translateY(0); }
}

.error p {
  color: #ff4d4d;
  font-size: 14px;
}

.weather {
  display: none;
  animation: fadeInWeather 0.5s ease forwards;
}

@keyframes fadeInWeather {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

.weather-icon {
  width: 150px;
  height: 150px;
  margin-bottom: 20px;
  transition: all 0.3s ease-in-out;
}

.temp {
  font-size: 60px;
  font-weight: 500;
  margin-bottom: 10px;
}

.city {
  font-size: 30px;
  font-weight: 400;
  margin-bottom: 20px;
  text-transform: capitalize;
}

.details {
  display: flex;
  justify-content: space-around;
  margin-top: 20px;
  gap: 10px;
}

.col {
  display: flex;
  align-items: center;
  gap: 10px;
}

.col img {
  width: 30px;
  height: 30px;
}

.col div {
  text-align: left;
}

.col p {
  margin: 2px 0;
}

.humidity, .wind, .snow {
  font-size: 20px;
  font-weight: 500;
}

.forecast {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  margin-top: 30px;
  gap: 30px;
  height: 100%;
}

.forecast h3 {
  margin-bottom: 15px;
  font-size: 24px;
  font-weight: 600;
}

.forecast-wrapper {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.forecast-row {
  display: flex;
  justify-content: space-between;
  gap: 10px;
}

.forecast-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 12px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  text-align: center;
  width: 18%;
  min-width: 120px;
}

.forecast-item img {
  width: 50px;
  height: 50px;
}

.forecast-item span {
  margin-top: 5px;
  font-size: 14px;
}

@media (max-width: 768px) {
  .forecast-row {
      flex-direction: column;
      align-items: center;
  }

  .forecast-item {
      margin-bottom: 15px;
      width: 90%;
  }
}

@media (max-width: 480px) {
  .forecast-item {
      width: 100%;
      margin-bottom: 10px;
  }
}

.loading {
  display: none;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: #fff;
  text-align: center;
}

.spinner {
  border: 4px solid rgba(255, 255, 255, 0.3);
  border-top: 4px solid #fff;
  border-radius: 50%;
  width: 40px;
  height: 40px;
  animation: spin 1s linear infinite;
  margin-bottom: 10px;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

@media (max-width: 768px) {
  .card {
    width: 80%;
    padding: 20px;
  }

  .search input {
    font-size: 14px;
    padding: 10px;
  }

  .search button {
    padding: 12px;
  }

  .weather-icon {
    width: 120px;
    height: 120px;
  }

  .temp {
    font-size: 50px;
  }

  .city {
    font-size: 25px;
  }

  .forecast-top, .forecast-bottom {
    flex-direction: column;
    align-items: center;
  }

  .forecast-item {
    margin-bottom: 15px;
  }
}

@media (max-width: 480px) {
  .card {
    width: 95%;
    padding: 15px;
  }

  .search input {
    font-size: 12px;
    padding: 8px;
    height: 50px;
  }

  .search button {
    padding: 10px;
    margin-left: -43px;
  }

  .weather-icon {
    width: 100px;
    height: 100px;
  }

  .temp {
    font-size: 45px;
  }

  .city {
    font-size: 22px;
  }

  .forecast-top, .forecast-bottom {
    flex-direction: column;
    align-items: center;
  }

  .forecast-item {
    margin-bottom: 10px;
  }
}
