/* ===== 1. 变量与基础设置 ===== */
:root {
  --color-primary: #ef4444;
  --color-primary-dark: #dc2626;
  --color-primary-light: #f87171;
  --color-bg-light: #fef2f2;
  --color-bg-dark: #121212;
  --color-text-dark: #1f2937;
  --color-text-light: #fff;
  --color-text-muted: #6b7280;
  --color-accent: #8b5cf6;
  --color-accent-light: #a78bfa;

  --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.1);
  --shadow-md: 0 4px 8px rgba(0, 0, 0, 0.12);
  --shadow-lg: 0 8px 16px rgba(0, 0, 0, 0.15);
  --shadow-primary: 0 4px 12px rgba(3, 98, 241, 0.3);
  --shadow-accent: 0 4px 12px rgba(255, 107, 0, 0.3);

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-full: 999px;

  --transition-fast: 0.2s ease;
  --transition-normal: 0.3s ease;
  --transition-bounce: 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);

  --container-width: 1000px;
  --container-padding: 16px;
}

/* ===== 2. 重置与基础样式 ===== */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

body {
  color: var(--color-text-dark);
  background-color: #fff;
  line-height: 1.5;
}

a {
  text-decoration: none;
  color: inherit;
}

img {
  max-width: 100%;
  display: block;
  object-fit: cover;
  transition: transform var(--transition-fast);
}

button {
  cursor: pointer;
  border: none;
  background: none;
}

h1 {
  font-size: 22px;
  font-weight: 700;
  color: #fff;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

h2 {
  font-size: 18px;
  margin-bottom: 8px;
}

/* ===== 3. 滚动条样式 ===== */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  border-radius: 4px;
  background: #f1f1f1;
}

::-webkit-scrollbar-thumb {
  border-radius: 4px;
  background: #c1c1c1;
}

::-webkit-scrollbar-thumb:hover {
  background: #a8a8a8;
}

/* ===== 4. 容器与布局 ===== */
.container {
  width: 100%;
  max-width: var(--container-width);
  margin: 0 auto;
  padding: var(--container-padding) 0;
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 24px 0 16px;
}

.more-link {
  color: var(--color-primary);
  font-weight: 600;
  transition: opacity var(--transition-fast);
}

.more-link:hover {
  opacity: 0.8;
}

/* ===== 5. 头部组件样式 ===== */
header {
  background-color: var(--color-primary);
  position: sticky;
  top: 0;
  z-index: 10;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.header-container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 15px 20px;
  width: 100%;
  max-width: var(--container-width);
  margin: 0 auto;
}

.logo {
  width: 36px;
  height: 36px;
  cursor: pointer;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.2));
  transition: transform 0.3s ease;
}

.logo:hover {
  transform: scale(1.1);
}

.site-title {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* ===== 6. 菜单组件样式 ===== */
.menu-overlay,
.search-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(5px);
  z-index: 100;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.menu-overlay.active,
.search-overlay.active {
  opacity: 1;
  visibility: visible;
}

.menu-modal,
.search-modal {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.9);
  background-color: #fff;
  border-radius: var(--radius-lg);
  padding: 30px;
  width: 90%;
  max-width: 600px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
  z-index: 101;
  opacity: 0;
  visibility: hidden;
  transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.menu-modal.active,
.search-modal.active {
  opacity: 1;
  visibility: visible;
  transform: translate(-50%, -50%) scale(1);
}

.menu-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  padding-bottom: 15px;
  border-bottom: 1px solid #eee;
}

.menu-title {
  font-size: 24px;
  font-weight: 700;
  color: var(--color-text-dark);
}

.close-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background-color: #f5f5f5;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background-color 0.3s ease, transform 0.3s ease;
}

.close-btn:hover {
  background-color: #e0e0e0;
  transform: rotate(90deg);
}

.menu-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.menu-item {
  padding: 12px 16px;
  border-radius: var(--radius-md);
  font-size: 18px;
  font-weight: 500;
  color: var(--color-text-dark);
  transition: background-color 0.3s ease, transform 0.2s ease;
  display: flex;
  align-items: center;
}

.menu-item:hover {
  background-color: #f5f7ff;
  transform: translateX(5px);
  color: var(--color-primary);
}

.menu-item.active {
  background-color: var(--color-primary);
  color: #fff;
}

/* ===== 7. 搜索组件样式 ===== */
.search-icon {
  filter: brightness(0.8);
  width: 20px;
  height: 20px;
}

.search-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  padding-bottom: 15px;
  border-bottom: 1px solid #eee;
}

.search-input-container {
  position: relative;
  display: flex;
  width: 100%;
  gap: 12px;
}

.search-input-wrapper {
  position: relative;
  flex: 1;
}

.search-input-icon {
  position: absolute;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  width: 20px;
  height: 20px;
  opacity: 0.5;
}

.search-input-container input {
  width: 100%;
  padding: 14px 16px 14px 18px;
  border: 2px solid rgba(0, 0, 0, 0.1);
  border-radius: 12px;
  font-size: 16px;
  outline: none;
  transition: all 0.3s ease;
  background: rgba(255, 255, 255, 0.9);
}

.search-input-container input:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 4px rgba(255, 107, 0, 0.1);
}

.search-button {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 24px;
  height: 48px;
  background: var(--color-primary);
  border: none;
  border-radius: 12px;
  color: white;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  white-space: nowrap;
}

.search-button:hover {
  background: var(--color-primary-light);
  transform: translateY(-1px);
}

.search-button:active {
  transform: translateY(1px);
}

.search-button-text {
  font-size: 16px;
}

.search-button-icon {
  display: flex;
  align-items: center;
}

.search-icon {
  filter: brightness(10);
  width: 18px;
  height: 18px;
}

.search-results {
  margin-top: 20px;
  max-height: 400px;
  overflow-y: auto;
}

/* ===== 8. 页脚组件样式 ===== */
footer {
  background-color: #f8f9fa;
  border-top: 1px solid #e6e6e6;
  padding: 32px 0;
}

.footer-container {
  max-width: var(--container-width);
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 30px;
  padding: 0 20px;
}

footer img {
  width: 60px;
  height: 60px;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.1));
  transition: transform 0.3s ease;
}

footer img:hover {
  transform: scale(1.05);
}

.footer-content {
  display: flex;
  flex-direction: column;
  gap: 15px;
}

footer nav {
  display: flex;
  gap: 24px;
}

footer nav a {
  font-size: 16px;
  font-weight: 500;
  transition: color 0.3s ease, transform 0.2s ease;
  position: relative;
}

footer nav a:hover {
  color: var(--color-primary);
  transform: translateY(-2px);
}

footer nav a::after {
  content: "";
  position: absolute;
  bottom: -4px;
  left: 0;
  width: 0;
  height: 2px;
  background-color: var(--color-primary);
  transition: width 0.3s ease;
}

footer nav a:hover::after {
  width: 100%;
}

footer p {
  font-size: 14px;
  color: var(--color-text-muted);
}

/* ===== 9. 游戏部分通用样式 ===== */
.game-section {
  margin-bottom: 32px;
}

.game-grid {
  display: grid;
  gap: 16px;
}

.game-title {
  font-size: 14px;
  color: var(--color-text-dark);
  font-weight: 600;
  text-align: center;
  line-height: 1.3;
  max-width: 160px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ===== 10. 游戏卡片样式 ===== */
.game-card {
  position: relative;
  border-radius: var(--radius-md);
  overflow: hidden;
  transition: all var(--transition-fast);
  box-shadow: var(--shadow-sm);
  background: #fff;
}

.game-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
}

.game-card img {
  width: 100%;
  height: 140px;
  object-fit: cover;
}

.card-info {
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.card-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--color-text-dark);
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.card-category {
  font-size: 12px;
  color: var(--color-text-muted);
}

.card-rating {
  position: absolute;
  top: 8px;
  right: 8px;
  background: rgba(0, 0, 0, 0.6);
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  padding: 4px 8px;
  border-radius: var(--radius-full);
  z-index: 1;
}

.card-rating span {
  color: #ffcc00;
  margin-right: 2px;
}

/* ===== 11. 水平滚动区域 ===== */
.game-scroll {
  display: flex;
  gap: 16px;
  overflow-x: auto;
  padding: 8px 4px;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
}

.game-scroll::-webkit-scrollbar {
  height: 6px;
}

/* ===== 12. 游戏缩略图样式 ===== */
.game-thumb {
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
  flex: 0 0 160px;
}

.game-thumb img {
  width: 160px;
  height: 120px;
  border-radius: var(--radius-md);
  transition: transform var(--transition-fast), box-shadow var(--transition-fast);
  box-shadow: var(--shadow-sm);
}

.game-thumb:hover img {
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
}

/* ===== 13. 加载更多按钮 ===== */
.load-more-container {
  text-align: center;
  margin-top: 24px;
}

#loadMoreBtn {
  background-color: var(--color-primary);
  color: #fff;
  padding: 12px 32px;
  border-radius: var(--radius-full);
  font-weight: 700;
  transition: background-color var(--transition-fast), transform var(--transition-bounce);
  box-shadow: var(--shadow-primary);
}

#loadMoreBtn:hover {
  background-color: var(--color-primary-dark);
  transform: translateY(-3px);
}

/* ===== 14. 特色布局 ===== */
.featured-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.featured-game {
  position: relative;
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: var(--shadow-md);
}

.featured-game img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.featured-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.8) 0%, rgba(0, 0, 0, 0.4) 50%, rgba(0, 0, 0, 0.1) 100%);
  display: flex;
  align-items: flex-end;
  padding: 24px;
}

.featured-meta {
  color: #fff;
  max-width: 90%;
}

.featured-category {
  display: inline-block;
  background: var(--color-primary);
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  margin-bottom: 8px;
}

.featured-title {
  font-size: 24px;
  font-weight: 700;
  margin-bottom: 8px;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.6);
}

.featured-desc {
  font-size: 14px;
  opacity: 0.9;
  line-height: 1.4;
}

/* ===== 15. 最新游戏侧边栏 ===== */
.latest-side-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr 1fr;
  gap: 16px;
  height: 100%;
}

.latest-card {
  position: relative;
  border-radius: var(--radius-md);
  overflow: hidden;
  transition: transform var(--transition-fast);
  box-shadow: var(--shadow-sm);
  height: 100%;
}

.latest-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
}

.latest-card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.latest-meta {
  position: absolute;
  left: 12px;
  bottom: 12px;
  color: var(--color-text-light);
  width: calc(100% - 24px);
}

.latest-title {
  font-size: 14px;
  font-weight: 600;
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.6);
  background: rgba(0, 0, 0, 0.5);
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ===== 16. 瀑布流网格 ===== */
.masonry-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  grid-auto-rows: 120px;
  gap: 16px;
}

.masonry-item {
  position: relative;
  border-radius: var(--radius-md);
  overflow: hidden;
  transition: transform var(--transition-fast), box-shadow var(--transition-fast);
  box-shadow: var(--shadow-sm);
}

.masonry-item:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
}

/* Video component styles moved to index.html */

.masonry-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.masonry-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.7) 0%, rgba(0, 0, 0, 0.3) 50%, rgba(0, 0, 0, 0.1) 100%);
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: 16px;
  opacity: 0;
  transition: opacity var(--transition-fast);
}

.masonry-item:hover .masonry-overlay {
  opacity: 1;
}

.masonry-title {
  color: #fff;
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 4px;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.6);
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.masonry-category {
  color: rgba(255, 255, 255, 0.9);
  font-size: 12px;
}

.size-1 {
  grid-column: span 2;
  grid-row: span 1;
}

.size-2 {
  grid-column: span 2;
  grid-row: span 2;
}

.size-3 {
  grid-column: span 3;
  grid-row: span 2;
}

/* ===== 17. AllList 页面样式 ===== */
.page-header {
  margin-bottom: 2rem;
  text-align: center;
}

.page-header h1 {
  font-size: 2.5rem;
  margin-bottom: 1.5rem;
  color: var(--text-color);
}

.category-filter {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.5rem;
  margin-bottom: 2rem;
}

.category-btn {
  padding: 0.5rem 1rem;
  background-color: var(--card-bg);
  color: var(--text-color);
  border-radius: 20px;
  font-size: 0.9rem;
  transition: all 0.3s ease;
  text-decoration: none;
}

.category-btn:hover {
  background-color: var(--accent-color);
  color: #fff;
}

.category-btn.active {
  background-color: var(--accent-color);
  color: #fff;
}

.all-list-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1.5rem;
  margin-bottom: 2rem;
}

/* ===== 18. 响应式样式 ===== */
/* Trending Now 响应式 */
.trending-grid {
  grid-template-columns: repeat(5, 1fr);
}

@media (max-width: 1024px) {
  .trending-grid {
    grid-template-columns: repeat(4, 1fr);
  }

  .all-games-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
  }

  .masonry-grid {
    grid-template-columns: repeat(4, 1fr);
  }

  .size-3 {
    grid-column: span 2;
  }
}

@media (max-width: 768px) {
  .all-list-grid {
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 1rem;
  }

  .trending-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .game-card img {
    height: 160px;
  }

  .all-games-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
  }

  .all-game-card {
    height: 180px;
  }

  .masonry-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .size-2,
  .size-3 {
    grid-column: span 2;
    grid-row: span 1;
  }

  .section-header {
    margin: 20px 0 12px;
  }

  .section-header h2 {
    font-size: 16px;
  }

  .more-link {
    font-size: 14px;
  }

  footer nav {
    flex-direction: column;
  }

  .container {
    padding: 16px;
  }

  .featured-layout {
    grid-template-columns: 1fr;
    gap: 20px;
  }

  .featured-game {
    height: 240px;
  }

  .latest-side-grid {
    grid-template-columns: repeat(2, 1fr);
    grid-template-rows: repeat(2, 160px);
  }

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

  .featured-desc {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }

  .menu-modal {
    width: 95%;
    padding: 20px;
  }

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

  .menu-item {
    font-size: 16px;
    padding: 10px 14px;
  }
}

@media (max-width: 640px) {
  .search-button-text {
    display: none;
  }

  .search-button {
    padding: 0;
    width: 48px;
  }

  .search-button-icon {
    margin: 0 auto;
  }
}

@media (max-width: 480px) {
  .trending-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
  }

  .game-card {
    max-width: 100%;
  }

  .game-card img {
    height: 140px;
  }

  .card-info {
    padding: 8px;
  }

  .card-title {
    font-size: 12px;
    -webkit-line-clamp: 1;
  }

  .all-games-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
  }

  .all-game-card {
    height: 120px;
  }

  .card-overlay {
    padding: 8px;
  }

  .all-game-card .card-overlay {
    display: none;
  }

  .card-title {
    font-size: 12px;
    margin-bottom: 2px;
    display: none; /* 移动端隐藏游戏卡片标题 */
  }

  .card-category {
    font-size: 10px;
  }

  .latest-side-grid {
    grid-template-columns: 1fr;
    grid-template-rows: repeat(4, 140px);
  }

  .featured-game {
    height: 200px;
  }
}
