/* H5 / mobile overrides for static-site — load after style.css */

:root {
  --h5-safe-t: env(safe-area-inset-top, 0px);
  --h5-safe-b: env(safe-area-inset-bottom, 0px);
  --h5-safe-x: env(safe-area-inset-left, 0px);
  --h5-safe-r: env(safe-area-inset-right, 0px);
  --h5-radius: 16px;
  --h5-gap: 12px;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  overflow-x: hidden;
  padding-left: var(--h5-safe-x);
  padding-right: var(--h5-safe-r);
  padding-bottom: var(--h5-safe-b);
  touch-action: manipulation;
}

@media (max-width: 1100px) {
  .main-container {
    width: 100% !important;
    max-width: 100%;
    margin-left: auto;
    margin-right: auto;
    padding-left: max(12px, var(--h5-safe-x));
    padding-right: max(12px, var(--h5-safe-r));
    padding-top: 4px;
    box-sizing: border-box;
  }

  header {
    height: auto;
    min-height: 56px;
    margin-top: max(8px, var(--h5-safe-t));
  }

  header .head-hd {
    width: 100% !important;
    max-width: 100%;
    flex-wrap: wrap;
    align-items: flex-start;
    padding: 10px 12px;
    gap: 10px;
    box-sizing: border-box;
  }

  header .head-hd .head-hd-l {
    flex-direction: column;
    width: 100%;
    align-items: stretch;
    gap: 10px;
  }

  header .head-hd .head-hd-l .logo {
    width: auto;
    max-width: 132px;
    height: auto;
    align-self: flex-start;
  }

  header .head-hd .head-hd-l .logo img {
    width: 120px;
    height: auto;
    max-height: 60px;
    object-fit: contain;
  }

  header .head-hd .head-hd-l nav.site-nav {
    display: flex;
    flex-direction: column;
    margin-left: 0;
    width: 100%;
    gap: 6px;
    padding: 0 0 2px;
    overflow: visible;
    mask-image: none;
  }

  /* 每行不换行，保证分类区只有两行（3+2） */
  header .head-hd .head-hd-l .site-nav__row {
    flex-wrap: nowrap;
    justify-content: center;
    gap: 4px;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
  }

  header .head-hd .head-hd-l nav.site-nav a {
    flex: 1 1 0;
    min-width: 0;
    margin-left: 0 !important;
    min-height: 0;
    height: auto;
    padding: 5px 6px 5px 5px;
    border-radius: 999px;
    box-shadow: 0 1px 6px rgba(0, 0, 0, 0.1);
    justify-content: center;
  }

  header .head-hd .head-hd-l nav.site-nav a img {
    width: 26px;
    height: 26px;
    flex-shrink: 0;
  }

  header .head-hd .head-hd-l nav.site-nav a span {
    font-size: 11px;
    line-height: 1.15;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
    flex: 1 1 auto;
    margin-left: 2px;
  }

  header .head-hd .head-hd-l nav.site-nav a:hover {
    transform: none;
  }

  footer {
    margin-top: 32px;
  }

  footer .footer-bd {
    width: 100% !important;
    max-width: 100%;
    padding: 20px 16px 24px;
    box-sizing: border-box;
  }

  footer .footer-bd .footer-m {
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px 20px;
    margin-top: 16px;
  }

  footer .footer-bd .footer-m a {
    font-size: 15px;
    padding: 6px 0;
  }

  footer .footer-bd .footer-botttom {
    text-align: center;
    font-size: 13px;
    line-height: 1.55;
    margin-top: 12px;
  }

  /* 首页游戏：保持每行 5 个，小屏仅缩小 icon */
  #index-games.index-games {
    gap: 8px 6px;
    padding-bottom: 8px;
  }

  #index-games.index-games > a img:nth-child(1) {
    max-width: 100%;
    width: 100% !important;
    height: auto !important;
    border-radius: var(--h5-radius);
    box-shadow: 0 4px 14px rgba(139, 67, 0, 0.35);
  }

  .bread {
    height: auto;
    min-height: 28px;
    white-space: normal;
    line-height: 1.4;
    padding: 8px 0;
    font-size: 14px;
  }

  .bread a,
  .bread .active {
    font-size: 14px;
  }

  /* Detail top */
  .gameDetail {
    flex-direction: column;
    align-items: stretch;
  }

  .gameDetail .detail-m-t-l-t {
    width: 100%;
    max-width: 280px;
    margin: 0 auto 16px;
    margin-right: auto !important;
    margin-left: auto;
    height: auto;
    padding: 14px;
    border-radius: var(--h5-radius);
  }

  .gameDetail .detail-m-t-l-t img {
    width: 100%;
    max-width: 220px;
    height: auto;
    aspect-ratio: 1;
    margin: 0 auto;
    display: block;
  }

  .gameDetail .detail-m-t-l-t .game-title h2 {
    width: 100%;
    max-width: 100%;
    height: auto;
    -webkit-line-clamp: 3;
    font-size: 17px;
    line-height: 1.35;
  }

  .gameDetail-right-wrap {
    flex-direction: column !important;
    gap: 12px !important;
  }

  .game-ad-side {
    width: 100% !important;
    max-width: 100%;
    order: 2;
  }

  .game-ad-frame {
    max-width: 100%;
    height: auto;
    min-height: 200px;
    border-radius: var(--h5-radius) !important;
  }

  .game-ad-slot {
    width: min(336px, 92vw) !important;
    max-width: 100%;
    height: 260px !important;
    margin-left: auto !important;
    margin-right: auto !important;
  }

  .gameDetail-r {
    width: 100% !important;
    order: 1;
    height: auto !important;
  }

  .gameDetail .gameDetail-r .photo {
    width: 100% !important;
    height: auto !important;
    min-height: 200px;
    max-height: min(52vh, 360px);
    border-radius: var(--h5-radius);
    overflow: hidden;
  }

  .gameDetail .gameDetail-r .photo .swiper,
  .gameDetail .gameDetail-r .photo .swiper.mySwiper {
    height: 100%;
    min-height: 200px;
    max-height: min(52vh, 360px);
  }

  .gameDetail .gameDetail-r .photo img {
    width: 100%;
    height: auto;
    max-height: min(52vh, 360px);
    object-fit: contain;
    border-radius: var(--h5-radius);
  }

  .gameDetail .gameDetail-r .photo .arrow-l img,
  .gameDetail .gameDetail-r .photo .arrow-r img {
    width: 40px;
    height: 40px;
  }

  .detail {
    flex-direction: column;
    gap: 0;
  }

  .detail .detail-m {
    width: 100% !important;
    order: 1;
  }

  .detail .detail-m .introduction {
    width: 100% !important;
    box-sizing: border-box;
    border-radius: var(--h5-radius);
    padding: 14px;
  }

  .detail .detail-m .introduction .text {
    font-size: 15px;
    line-height: 1.65;
  }

  .detail .detail-m .introduction .text p {
    margin-bottom: 10px;
  }

  .download-top-ad-frame {
    border-radius: var(--h5-radius) !important;
  }

  .download-top-ad-slot {
    width: calc(100% - 20px) !important;
    max-width: 100%;
  }

  .detail .detail-m .download {
    border-radius: var(--h5-radius);
    padding: 14px;
  }

  .detail .detail-m .download .download-t {
    flex-direction: column;
    gap: 10px;
  }

  .detail .detail-m .download .download-t a {
    width: 100% !important;
    min-height: 52px;
    box-sizing: border-box;
  }

  .detail .detail-m .download .download-b {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }

  .detail .detail-m .download .download-b img {
    align-self: center;
  }

  .detail .detail-m .recommeded {
    border-radius: var(--h5-radius);
    padding: 12px 12px 18px;
  }

  .detail .detail-m .recommeded .recommeded-list {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
  }

  .detail .detail-m .recommeded .recommeded-list a {
    width: 100% !important;
    height: auto !important;
    aspect-ratio: 1 / 1;
    margin: 0 !important;
    border-radius: 14px;
  }

  .detail .detail-m .recommeded .recommeded-list a:nth-child(8n) {
    margin-right: 0 !important;
  }

  .detail .detail-m .recommeded .recommeded-list a img {
    width: 100% !important;
    height: 100% !important;
    border-radius: 14px;
  }

  .detail .detail-r {
    width: 100% !important;
    margin-left: 0 !important;
    order: 2;
    margin-top: 8px;
  }

  .detail .detail-r .game-tags {
    width: 100% !important;
    box-sizing: border-box;
    border-radius: var(--h5-radius);
  }

  .detail .detail-r .game-tags a {
    min-height: 36px;
    display: inline-flex;
    align-items: center;
    font-size: 14px;
  }

  .detail .detail-r .detail-m-t-l-m {
    width: 100% !important;
    box-sizing: border-box;
    border-radius: var(--h5-radius);
  }

  .detail .detail-r .detail-m-t-l-m .tabnav a {
    min-height: 48px;
    font-size: 15px;
  }

  .detail-r-ad-frame {
    border-radius: var(--h5-radius) !important;
  }

  .detail-r-ad-slot {
    width: min(336px, 92vw) !important;
    margin-left: auto !important;
    margin-right: auto !important;
  }

  .detail-side-games h3 {
    font-size: 22px !important;
  }

  .detail-side-games-list {
    grid-template-columns: repeat(3, 1fr) !important;
    gap: 10px !important;
  }

  .detail-leaderboard-name {
    max-width: none !important;
    flex: 1;
    min-width: 0;
  }

  .game-rating {
    font-size: 20px !important;
  }
}

@media (max-width: 360px) {
  header .head-hd .head-hd-l nav.site-nav a img {
    width: 22px;
    height: 22px;
  }

  header .head-hd .head-hd-l nav.site-nav a span {
    font-size: 10px;
  }

  header .head-hd .head-hd-l .site-nav__row {
    gap: 3px;
  }

  header .head-hd .head-hd-l nav.site-nav a {
    padding: 4px 4px 4px 3px;
  }
}

@media (max-width: 380px) {
  .detail .detail-m .recommeded .recommeded-list {
    grid-template-columns: repeat(3, 1fr);
  }
}
