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

:root {
  --primary-color: #2563eb;
  --secondary-color: #1e40af;
  --accent-color: #3b82f6;
  --text-primary: #1f2937;
  --text-secondary: #6b7280;
  --bg-primary: #ffffff;
  --bg-secondary: #f9fafb;
  --border-color: #e5e7eb;
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
  --ad-background: #111827;
  --ad-text: #f9fafb;
  --ad-accent: #f59e0b;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
  line-height: 1.6;
  color: var(--text-primary);
  background-color: var(--bg-secondary);
  min-height: 100vh;
}

.container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 24px;
}

.header {
  background-color: var(--bg-primary);
  box-shadow: var(--shadow-sm);
  padding: 24px 0;
  position: sticky;
  top: 0;
  z-index: 100;
}

.header .container {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 32px;
  flex-wrap: wrap;
}

.logo {
  font-size: 28px;
  font-weight: 700;
  color: var(--primary-color);
  letter-spacing: -0.5px;
}

.search-bar {
  display: flex;
  gap: 8px;
  flex: 1;
  max-width: 500px;
}

.search-input {
  flex: 1;
  padding: 12px 16px;
  border: 2px solid var(--border-color);
  border-radius: 8px;
  font-size: 15px;
  transition: all 0.2s ease;
  outline: none;
}

.search-input:focus {
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.search-btn {
  padding: 12px 24px;
  background-color: var(--primary-color);
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.search-btn:hover {
  background-color: var(--secondary-color);
  transform: translateY(-1px);
}

.category-nav {
  background-color: var(--bg-primary);
  border-bottom: 1px solid var(--border-color);
  padding: 16px 0;
  position: sticky;
  top: 88px;
  z-index: 99;
}

.category-nav .container {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  scrollbar-width: none;
}

.category-nav .container::-webkit-scrollbar {
  display: none;
}

.category-btn {
  padding: 10px 20px;
  background-color: transparent;
  color: var(--text-secondary);
  border: none;
  border-radius: 24px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.category-btn:hover {
  background-color: var(--bg-secondary);
  color: var(--text-primary);
}

.category-btn.active {
  background-color: var(--primary-color);
  color: white;
}

.main-content {
  padding: 32px 0;
  min-height: calc(100vh - 300px);
}

.stats {
  margin-bottom: 24px;
  color: var(--text-secondary);
  font-size: 14px;
}

.wallpaper-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 24px;
  margin-bottom: 40px;
}

.wallpaper-card {
  background-color: var(--bg-primary);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: var(--shadow-md);
  cursor: pointer;
  transition: all 0.3s ease;
}

.wallpaper-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-xl);
}

.wallpaper-image {
  width: 100%;
  height: 400px;
  object-fit: cover;
  display: block;
}

.wallpaper-info {
  padding: 16px;
}

.wallpaper-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 8px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.wallpaper-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
  color: var(--text-secondary);
}

.wallpaper-category {
  padding: 4px 12px;
  background-color: var(--bg-secondary);
  border-radius: 12px;
  font-weight: 500;
}

.loading {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-secondary);
  font-size: 16px;
}

.load-more-container {
  text-align: center;
  margin: 40px 0;
}

.load-more-btn {
  padding: 14px 40px;
  background-color: var(--bg-primary);
  color: var(--primary-color);
  border: 2px solid var(--primary-color);
  border-radius: 8px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.load-more-btn:hover {
  background-color: var(--primary-color);
  color: white;
}

.load-more-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1000;
}

.modal.active {
  display: block;
}

.modal-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(4px);
}

.modal-content {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background-color: var(--bg-primary);
  border-radius: 16px;
  max-width: 900px;
  width: 90%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-xl);
}

.modal-close {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 40px;
  height: 40px;
  background-color: rgba(0, 0, 0, 0.5);
  color: white;
  border: none;
  border-radius: 50%;
  font-size: 28px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  z-index: 1;
}

.modal-close:hover {
  background-color: rgba(0, 0, 0, 0.7);
}

.modal-image {
  width: 100%;
  max-height: 500px;
  object-fit: cover;
  display: block;
}

.modal-info {
  padding: 32px;
}

.modal-title {
  font-size: 24px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 16px;
}

.modal-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  flex-wrap: wrap;
  gap: 12px;
}

.modal-category {
  padding: 6px 16px;
  background-color: var(--primary-color);
  color: white;
  border-radius: 16px;
  font-size: 14px;
  font-weight: 500;
}

.modal-stats {
  color: var(--text-secondary);
  font-size: 14px;
}

.modal-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 24px;
}

.tag {
  padding: 6px 12px;
  background-color: var(--bg-secondary);
  color: var(--text-secondary);
  border-radius: 12px;
  font-size: 13px;
}

.download-btn {
  width: 100%;
  padding: 16px;
  background-color: var(--primary-color);
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.download-btn:hover {
  background-color: var(--secondary-color);
  transform: translateY(-2px);
}

.footer {
  background-color: var(--bg-primary);
  border-top: 1px solid var(--border-color);
  padding: 32px 0;
  text-align: center;
  color: var(--text-secondary);
  font-size: 14px;
}

/* Ad Page Styles */
.ad-content {
  background-color: var(--ad-background);
  color: var(--ad-text);
  max-width: 800px;
}

.ad-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 24px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.ad-header h2 {
  font-size: 24px;
  font-weight: 600;
}

.skip-countdown {
  font-size: 14px;
  color: rgba(255, 255, 255, 0.7);
}

.ad-body {
  padding: 32px;
  text-align: center;
}

.ad-placeholder {
  margin: 0 auto;
  max-width: 100%;
  overflow: hidden;
  border-radius: 8px;
}

.ad-placeholder img {
  width: 100%;
  height: auto;
  display: block;
}

.ad-footer {
  padding: 24px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  text-align: center;
}

.skip-ad-btn {
  padding: 12px 32px;
  background-color: var(--ad-accent);
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.skip-ad-btn:hover:not(:disabled) {
  background-color: #d97706;
  transform: translateY(-1px);
}

.skip-ad-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

@media (max-width: 768px) {
  .container {
    padding: 0 16px;
  }

  .header .container {
    flex-direction: column;
    gap: 16px;
  }

  .logo {
    font-size: 24px;
  }

  .wallpaper-grid {
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 16px;
  }

  .wallpaper-image {
    height: 280px;
  }

  .modal-content {
    width: 95%;
  }

  .modal-info {
    padding: 20px;
  }

  .modal-title {
    font-size: 20px;
  }

  .ad-content {
    width: 95%;
  }

  .ad-header,
  .ad-body,
  .ad-footer {
    padding: 16px;
  }

  .ad-header h2 {
    font-size: 20px;
  }
}
