/* 基础样式 */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html {
  width: 100%;
  height: 100%;
  scroll-behavior: smooth;
  font-size: min(1vw, 12px);
  transform: translateZ(0);
  -webkit-transform: translateZ(0);
  overflow: hidden;
}

body {
  width: 100%;
  height: 100%;
  font-family: 'Microsoft YaHei', Inter, Helvetica Neue, Arial, sans-serif;
  background-color: #f8f9fa;
  color: #212529;
  line-height: 1.6;
  padding: 0 !important;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

body, img {
  contain: layout style paint;
}

img {
  max-width: 100%;
  height: auto;
  image-rendering: optimizeSpeed;
  image-rendering: -webkit-optimize-contrast;
  image-rendering: crisp-edges;
}

a {
  color: inherit;
  text-decoration: none;
}

button {
  border: none;
  background: none;
  cursor: pointer;
  font-family: inherit;
  contain: layout style paint;
  touch-action: manipulation;
}

input {
  contain: layout style paint;
  touch-action: manipulation;
}

/* 主容器 */
.home-container {
  display: flex;
  flex-direction: column;
  background-image: linear-gradient(-45deg, #031215, #261857);
  width: 100%;
  height: 100vh;
  max-width: 768px;
  margin: 0 auto;
  overflow: hidden;
}

/* Header 样式 */
.home-header {
  position: relative;
  flex-shrink: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.5rem 3rem;
  transition: all 0.3s ease;
}

.home-header.on-scrolling {
  box-shadow: 0 3rem 2rem rgba(0, 0, 0, 0.2);
}

.home-header-left {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.home-hamburger-menu {
  background: #f3f4f6;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 0.8rem 1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #333;
  transition: all 0.2s ease;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.home-hamburger-menu:hover {
  background: #e5e7eb;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.15);
  transform: translateY(-1px);
}

.home-logo {
  display: flex;
  width: 24rem;
  height: 8rem;
  background: url(/assets/logo.svg) no-repeat 50%;
  background-size: 100% 100%;
  text-indent: -9999px;
  text-decoration: none;
  padding: 0;
}

.home-header-right {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.home-search-container {
  display: flex;
  align-items: center;
}

.home-search-form {
  display: flex;
  align-items: center;
  background: #36346c;
  border-radius: 4rem;
  height: 4rem;
  box-shadow: 0 0.2rem 1rem rgba(0, 0, 0, 0.1);
  backdrop-filter: blur(10px);
}

.home-search-input {
  border: none;
  outline: none;
  background: transparent;
  height: 4rem;
  padding: 0 1.5rem;
  font-size: 1.6rem;
  color: #fff;
  width: 20rem;
  font-family: 'Microsoft YaHei';
}

.home-search-input::placeholder {
  color: #a4a8bc;
  font-size: 1.6rem;
}

.home-search-button {
  color: #fff;
  border: none;
  height: 4rem;
  width: 4.6rem;
  padding: 0;
  font-size: 0;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.home-search-button:before {
  display: inline-block;
  content: "";
  width: 2.2rem;
  height: 2.2rem;
  background: url(/assets/icon_search2.webp) no-repeat 50%;
  background-size: 100% 100%;
}

/* Main 内容区域 */
.home-main {
  flex: 1;
  overflow: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
  -webkit-overflow-scrolling: touch;
  will-change: scroll-position;
  transform: translateZ(0);
  overscroll-behavior: contain;
}

.home-main::-webkit-scrollbar {
  display: none;
}

.home-game-list-container {
  width: 100%;
  box-sizing: border-box;
}

/* 历史游戏区域 */
.home-history {
  display: flex;
  align-items: center;
  background-color: #494874;
  height: 11rem;
  margin: 2rem 3rem 1rem;
  box-sizing: border-box;
  border-radius: 2rem;
}

.home-history-grid {
  flex: 1;
  flex-shrink: 0;
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  padding: 0 20px;
}

.home-history-game-item {
  position: relative;
  cursor: pointer;
  border-radius: 1rem;
  margin: 0 1.5rem;
  transition: transform 0.2s ease-out;
}

.home-history-game-item:active {
  transform: scale(1.15);
}

.home-history-game-image-container {
  width: 8rem;
  height: 8rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.home-history-game-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 0.8rem;
}

.home-history-game-recommend {
  position: absolute;
  right: -1rem;
  top: -1.3rem;
  width: 2.3rem;
  height: 2.3rem;
  text-indent: -9999px;
  background: url(/assets/icon_recommend.webp) no-repeat 50%;
  background-size: 100% 100%;
}

/* 游戏列表 */
.home-game-list {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
}

.home-search-results-header {
  display: flex;
  align-items: center;
  background-color: #494874;
  height: 11rem;
  margin: 2rem 3rem 1rem;
  box-sizing: border-box;
  border-radius: 2rem;
  flex-direction: column;
  justify-content: center;
  padding: 2rem;
  text-align: center;
}

.home-search-results-title {
  font-family: 'Microsoft YaHei';
  font-size: 2.4rem;
  color: #fff;
  font-weight: 700;
  margin: 0 0 1rem 0;
}

.home-search-results-subtitle {
  font-family: 'Microsoft YaHei';
  font-size: 1.6rem;
  color: #ccc;
  margin: 0;
}

.home-category-section {
  width: 100%;
  margin-bottom: 4rem;
}

.home-category-title {
  font-family: 'Microsoft YaHei';
  font-size: 4rem;
  font-weight: 700;
  color: #fff;
  margin: 1rem 0;
  padding: 0 3rem;
  text-align: left;
}

.home-game-list-ul {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  list-style: none;
  margin: 0;
  padding: 0;
}

.home-game-list-item-li {
  list-style: none;
  margin: 0;
  padding: 0;
  width: calc((100% - 60px) / 2);
}

.home-game-list-item-li.odd {
  margin-left: 20px;
}

.home-game-list-item-li.even {
  margin-right: 20px;
}

.home-game-list-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  cursor: pointer;
  margin: 10px 0;
  padding: 15px;
  transition: all 0.3s ease;
  border-radius: 10px;
  border: 1px solid #5363fe;
  background-color: #36346c;
}

.home-game-list-item:active {
  transform: translateY(-5px);
  box-shadow: 0 12px 35px hsla(0, 0%, 100%, 0.3);
}

.home-game-animation-container {
  width: 324px;
  height: 172.8px;
  border-radius: 10px;
  overflow: hidden;
  margin-bottom: 2.5rem;
  background: hsla(0, 0%, 100%, 0.9);
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

.home-game-animation {
  width: 100%;
  height: 100%;
  transition: transform 0.3s ease;
  object-fit: cover;
}

.home-game-name-text {
  display: flex;
  justify-content: center;
  align-items: center;
  font-family: 'Microsoft YaHei';
  font-size: 2rem;
  font-weight: 600;
  color: #fff;
  text-align: center;
  text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.7);
  word-wrap: break-word;
  width: 20rem;
  height: 6rem;
  line-height: 1;
  padding: 0 2rem;
  box-sizing: border-box;
  background: #5363fe;
  border-radius: 6rem;
}

.home-game-description {
  display: block;
  width: 100%;
  max-height: 14.5vh;
  overflow-y: auto;
  font-size: 16px;
  line-height: 1.5;
  color: #fff;
  text-align: left;
  margin-top: 1rem;
  padding: 0.5rem;
  font-family: 'Microsoft YaHei';
}

.home-game-description::-webkit-scrollbar {
  width: 4px;
}

.home-game-description::-webkit-scrollbar-track {
  background: rgba(150, 99, 63, 0.2);
  border-radius: 2px;
}

.home-game-description::-webkit-scrollbar-thumb {
  background: rgba(150, 99, 63, 0.6);
  border-radius: 2px;
}

.home-game-description::-webkit-scrollbar-thumb:hover {
  background: rgba(150, 99, 63, 0.8);
}

.home-more-games-coming-soon {
  display: block;
  width: 100%;
  font-family: 'Microsoft YaHei';
  font-size: 3rem;
  color: #fff;
  text-align: center;
  padding: 2rem;
}

/* Footer */
.home-footer {
  flex-shrink: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 2rem 0 5rem;
}

.home-footer-item {
  margin: 0 2rem;
  font-family: 'Microsoft YaHei';
  font-size: 2rem;
  color: #fff;
  text-decoration: underline;
  transition: color 0.3s ease;
}

.home-footer-item:hover {
  color: #fff;
}

/* Bottom Animation */
.home-bottom-animation {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 2rem 0;
  width: 100%;
}

.home-bottom-animation-link {
  display: inline-block;
  cursor: pointer;
  transition: all 0.3s ease;
  background-color: #fff;
  border: 1px solid #e0e0e0;
  border-radius: 12px;
  padding: 1rem;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.home-bottom-animation-link:hover {
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
  transform: translateY(-2px);
}

.home-bottom-animation img {
  width: 280px;
  height: auto;
  display: block;
}

/* 侧边菜单 */
.home-side-menu-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 9999;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
}

.home-side-menu-overlay.open {
  opacity: 1;
  visibility: visible;
}

.home-side-menu {
  position: fixed;
  top: 0;
  left: -60vw;
  width: 60vw;
  height: 100vh;
  box-shadow: 2px 0 10px rgba(0, 0, 0, 0.1);
  z-index: 10000;
  transition: left 0.3s ease;
  display: flex;
  flex-direction: column;
  background-color: #36346c;
}

.home-side-menu.open {
  left: 0;
}

.home-side-menu-close {
  background: none;
  border: none;
  padding: 1.5rem;
  cursor: pointer;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.2s ease;
  align-self: flex-end;
}

.home-side-menu-close:hover {
  opacity: 0.7;
}

.home-side-menu-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 2rem 0;
}

.home-side-menu-item {
  padding: 3rem 4rem;
  color: #fff;
  text-decoration: none;
  font-size: 1.6rem;
  font-weight: 500;
  border-bottom: 1px solid #4b5396;
  display: block;
  cursor: pointer;
}

.home-side-menu-item.active {
  color: #333;
  background: #f3f4f6;
  font-weight: 600;
}

.home-side-menu-item:last-child {
  border-bottom: none;
}

.home-hidden {
  display: none !important;
}

.ad-container {
  flex-shrink: 0;
  width: 100%;
  height: 250px;
  margin: 20px 0;
  background: url(/assets/ads.png) no-repeat center center;
  background-size: 300px 250px;
}

.ads_img {
  width: 300px;
  height: 250px;
  margin: 0 auto;
}

/* 响应式设计 */
@media (max-width: 768px) {
  .home-header {
    padding: 3rem;
  }

  .home-header-left {
    gap: 2rem;
  }

  .home-side-menu {
    left: -70vw;
    width: 70vw;
  }

  .home-side-menu-item {
    font-size: 3.6rem;
  }

  .home-search-form {
    height: 8rem;
    padding: 0 0.5rem;
    border-radius: 8rem;
  }

  .home-search-input {
    width: 32rem;
    height: 8rem;
    font-size: 2.8rem;
    box-sizing: border-box;
  }

  .home-search-input::placeholder {
    font-size: 2.8rem;
  }

  .home-search-button {
    width: 6rem;
    height: 8rem;
  }

  .home-search-button:before {
    width: 3.4rem;
    height: 3.4rem;
  }

  .home-search-results-title {
    font-size: 3.2rem;
  }

  .home-search-results-subtitle {
    font-size: 2.4rem;
  }

  .home-category-title {
    font-size: 3.2rem;
  }

  .home-game-animation-container {
    width: 40.5vw;
    height: 21.6vw;
  }

  .home-history {
    height: 18rem;
    margin: 4rem 3rem;
  }

  .home-search-results-header {
    height: auto;
    min-height: 18rem;
    margin: 4rem 3rem 1rem;
    padding: 3rem 2rem;
  }

  .home-history-grid {
    justify-content: center;
    padding: 0;
  }

  .home-history-game-item {
    margin: 0 1.5rem;
  }

  .home-history-game-image-container {
    width: 12rem;
    height: 12rem;
  }

  .home-history-game-recommend {
    width: 3rem;
    height: 3rem;
    right: -1.5rem;
    top: -1.5rem;
  }

  .home-game-list-item-li {
    width: 45.5vw;
  }

  .home-game-list-item {
    width: 45.5vw;
    margin: 1.8vw 0;
    padding: 2.5vw;
  }

  .home-game-list-item-li.odd {
    margin-left: 3vw;
  }

  .home-game-list-item-li.even {
    margin-right: 3vw;
  }

  .home-game-name-text {
    width: 30vw;
    height: 9vw;
    line-height: 1.2;
    font-size: 2.5vw;
  }

  .home-game-description {
    max-height: 18vw;
    font-size: 2.8vw;
  }

  .home-more-games-coming-soon {
    font-size: 4.2rem;
  }

  .home-footer {
    padding: 2rem 0 9rem;
  }

  .home-footer-item {
    font-size: 3.2rem;
  }
}

@media (max-width: 360px) {
  .home-game-name-text {
    font-size: 2.3vw;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
  img {
    image-rendering: -webkit-optimize-contrast;
  }
}

