*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --bg-clear:    linear-gradient(135deg, #56ccf2 0%, #2f80ed 100%);
  --bg-cloudy:   linear-gradient(135deg, #bdc3c7 0%, #7f8c8d 100%);
  --bg-rain:     linear-gradient(135deg, #4b6cb7 0%, #182848 100%);
  --bg-snow:     linear-gradient(135deg, #e0eafc 0%, #cfdef3 100%);
  --bg-storm:    linear-gradient(135deg, #232526 0%, #414345 100%);
  --bg-fog:      linear-gradient(135deg, #c9d6df 0%, #52616b 100%);
  --bg-night:    linear-gradient(135deg, #0f2027 0%, #203a43 50%, #2c5364 100%);
  --bg-default:  linear-gradient(135deg, #56ccf2 0%, #2f80ed 100%);

  --card-bg: rgba(255, 255, 255, 0.15);
  --text-primary: #fff;
  --text-secondary: rgba(255, 255, 255, 0.75);
  --shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
  --radius: 24px;
}

body {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg-default);
  transition: background 1s ease;
  padding: 16px;
}

.app {
  width: 100%;
  max-width: 380px;
}

.card {
  background: var(--card-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 32px 28px;
  position: relative;
  min-height: 340px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-primary);
}

/* ── States ── */
.state {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  text-align: center;
}

.state.hidden { display: none; }

/* Loading */
.spinner {
  width: 44px;
  height: 44px;
  border: 3px solid rgba(255, 255, 255, 0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* Error */
.error-icon {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.25);
  font-size: 28px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

#retry-btn {
  margin-top: 8px;
  padding: 10px 24px;
  background: rgba(255, 255, 255, 0.3);
  border: 1px solid rgba(255, 255, 255, 0.5);
  border-radius: 50px;
  color: #fff;
  font-size: 15px;
  cursor: pointer;
  transition: background 0.2s;
}

#retry-btn:hover { background: rgba(255, 255, 255, 0.45); }

/* ── Weather layout ── */
#state-weather {
  gap: 0;
  align-items: stretch;
}

/* Header */
.weather-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 28px;
}

.location {
  font-size: 17px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 5px;
}

.pin { font-size: 13px; opacity: 0.8; }

.updated {
  font-size: 12px;
  color: var(--text-secondary);
  padding-top: 3px;
}

/* Main */
.weather-main {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  margin-bottom: 32px;
}

.weather-icon {
  font-size: 80px;
  line-height: 1;
  filter: drop-shadow(0 4px 12px rgba(0,0,0,0.2));
  user-select: none;
}

.temperature {
  display: flex;
  align-items: flex-start;
  line-height: 1;
  margin-top: 4px;
}

#temp-value {
  font-size: 80px;
  font-weight: 200;
  letter-spacing: -4px;
}

.unit {
  font-size: 28px;
  font-weight: 300;
  margin-top: 10px;
  opacity: 0.85;
}

.condition {
  font-size: 18px;
  font-weight: 500;
  color: var(--text-secondary);
  text-transform: capitalize;
}

/* Footer stats */
.weather-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(255, 255, 255, 0.12);
  border-radius: 16px;
  padding: 16px 20px;
}

.stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  flex: 1;
}

.stat-icon { font-size: 18px; }

.stat-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
}

.stat-value {
  font-size: 15px;
  font-weight: 600;
}

.stat-divider {
  width: 1px;
  height: 40px;
  background: rgba(255, 255, 255, 0.2);
  margin: 0 4px;
}

/* Refresh button */
.refresh-btn {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 36px;
  height: 36px;
  background: rgba(255, 255, 255, 0.2);
  border: none;
  border-radius: 50%;
  color: #fff;
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s, transform 0.3s;
}

.refresh-btn:hover { background: rgba(255, 255, 255, 0.35); }
.refresh-btn.spinning { animation: spin 0.6s linear; }

/* ── Background themes ── */
body.clear   { background: var(--bg-clear); }
body.cloudy  { background: var(--bg-cloudy); }
body.rain    { background: var(--bg-rain); }
body.snow    { background: var(--bg-snow); }
body.snow    { --text-primary: #1a2a4a; --text-secondary: rgba(26,42,74,0.7); --card-bg: rgba(255,255,255,0.4); }
body.storm   { background: var(--bg-storm); }
body.fog     { background: var(--bg-fog); }
body.night   { background: var(--bg-night); }

/* Mobile tweak */
@media (max-width: 400px) {
  .card { padding: 24px 20px; }
  #temp-value { font-size: 64px; }
  .weather-icon { font-size: 64px; }
}
