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

/* BASE */
html,
body {
  height: 100%;
  margin: 0;
  padding: 0;
  overflow-x: hidden;
  font-family: "Montserrat", Arial, Helvetica, sans-serif;
}

@keyframes scroll-desktop {
  0% {
    transform: translateX(0);
  }
  100% {
    transform: translateX(calc(-1 * (10 * (clamp(140px, 16vw, 220px) + 18px))));
  }
}

@keyframes scroll-mobile {
  0% {
    transform: translateX(0);
  }
  100% {
    transform: translateX(calc(-1 * (10 * (clamp(130px, 40vw, 180px) + 14px))));
  }
}

/* ==========================================================================
   DESKTOP / TABLET LAYOUT
   Fluid layout: no fixed per-device breakpoints. Everything scales with
   clamp()/%/vw so it never breaks between the .mobile cutoff (767px) and
   large desktop screens.
   ========================================================================== */

.desktop {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  width: 100%;
  background: url("../image/bg-pc.webp") no-repeat center center;
  background-size: cover;
  background-color: #161920;
  position: relative;
}

.menu-container {
  display: flex;
  flex: 1;
  flex-direction: column;
  align-items: center;
  /* Centers content vertically when it's shorter than the viewport, instead
     of stacking from the top and leaving a lopsided gap at the bottom. If
     content is taller than the viewport it just overflows and scrolls
     normally, so this only kicks in when everything fits in one frame. */
  justify-content: center;
  width: 100%;
  max-width: 1920px;
  margin: 0 auto;
  padding-top: clamp(16px, 3vh, 40px);
  /* Left and right padding are kept equal so content stays visually centered.
     Both sides reserve enough room for the fixed .social-icons sidebar
     (right: 2vw + its own width) so content never renders underneath it,
     at any viewport width. */
  padding-left: calc(clamp(12px, 3vw, 48px) + clamp(50px, 4vw, 70px) + 2vw + 12px);
  padding-right: calc(clamp(12px, 3vw, 48px) + clamp(50px, 4vw, 70px) + 2vw + 12px);
  padding-bottom: 40px;
  gap: clamp(24px, 4vh, 56px);
}

/* Title */
.title-group {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.title-img {
  width: clamp(160px, 18vw, 300px);
  height: auto;
}

/* Link box (promo banner + link cards + download banner) */
.linkbox-section {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
}

.frame-section {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: clamp(16px, 2.5vw, 32px);
}

.frame-section > img {
  width: 100%;
  height: auto;
  display: block;
}

.container {
  width: 100%;
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: clamp(4px, 1.2vw, 20px);
}

.circle-item {
  position: relative;
  width: 100%;
  aspect-ratio: 190 / 185;
  cursor: pointer;
  transition: transform 0.3s ease;
}

.circle-item:hover {
  transform: translateY(-4px);
}

.circle-item > img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.circle-content {
  position: absolute;
  inset: 0;
  z-index: 10;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding-top: 34%;
  gap: clamp(2px, 0.6vw, 6px);
  text-align: center;
  color: white;
}

.circle-content .title {
  font-weight: 700;
  font-size: clamp(13px, 1.6vw, 22px);
  color: #7b6c00;
  position: absolute;
  top: 24%;
}

.circle-content .timing {
  font-size: clamp(14px, 1.8vw, 24px);
  font-weight: bold;
  color: #7b6c00;
  margin-top: 10px;
}

.signal-bar {
  height: clamp(14px, 1.6vw, 22px);
  width: auto;
  display: flex;
  justify-content: center;
  align-items: center;
}

.signal-bar img {
  height: 100%;
  width: auto;
  object-fit: contain;
}

/* Download banner: buttons overlay the vacant area of 50k.png (roughly
   33%-75% of its width is empty background), positioned with % so they
   stay inside the artwork at any size instead of stacking below it. */
.frame-download {
  position: relative;
  width: 100%;
}

.frame-download > img {
  width: 100%;
  height: auto;
  display: block;
}

.download-buttons-row {
  position: absolute;
  top: 60%;
  left: 35%;
  width: 38%;
  transform: translateY(-50%);
  display: flex;
  justify-content: center;
  align-items: center;
  gap: clamp(8px, 1.6vw, 20px);
}

.button-download-ios img,
.button-download-android img {
  width: clamp(70px, 9.5vw, 170px);
  height: auto;
  display: block;
}

/* Social icons (fixed sidebar) */
.social-icons {
  position: fixed;
  right: 2vw;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  flex-direction: column;
  gap: clamp(4px, 1vh, 10px);
  z-index: 100;
}

.social-icon {
  width: clamp(50px, 4vw, 70px);
  height: clamp(50px, 4vw, 70px);
  cursor: pointer;
  transition: transform 0.3s ease;
}

.social-icon:hover {
  transform: scale(1.1);
}

.social-icon img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

/* Games carousel */
.games-container {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  /* .carousel-wrapper already shrinks safely (flex-shrink + min-width: 0 +
     overflow: hidden), so keep the badge and carousel on one row instead of
     wrapping the badge onto its own centered line at narrow tablet widths. */
  flex-wrap: nowrap;
  align-items: center;
  justify-content: center;
  gap: clamp(12px, 2vw, 24px);
}

.games-frame {
  flex: 0 0 auto;
  width: clamp(180px, 22vw, 320px);
  height: clamp(50px, 5vw, 70px);
  border-radius: 12px;
  overflow: hidden;
}

.games-title {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: left center;
  display: block;
}

.carousel-wrapper {
  flex: 1 1 400px;
  min-width: 0;
  overflow: hidden;
}

.carousel {
  display: flex;
  gap: clamp(12px, 2vw, 24px);
  animation: scroll-desktop 60s linear infinite;
}

.carousel:hover {
  animation-play-state: paused;
}

.game-item {
  flex: 0 0 clamp(140px, 16vw, 220px);
  aspect-ratio: 3 / 1;
  border-radius: 12px;
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.3s ease;
}

.game-item:hover {
  transform: scale(1.06);
}

.game-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* END DESKTOP CSS */

/* TABLET CSS */
@media screen and (min-width: 768px) and (max-width: 1024px) {
  .title-img {
    width: clamp(190px, 22vw, 300px);
  }

  .circle-content .timing {
    margin-top: 6px;
    font-size: clamp(12px, 1.1vw, 24px);
  }

  .button-download-ios img, .button-download-android img {
    width: clamp(90px, 14vw, 170px);
    height: auto;
    display: block;
  }

  .circle-content {
    gap: clamp(3px, 0.8vw, 3px);
  }

  .circle-content .title {
    font-weight: 700;
    font-size: clamp(10px, 1vw, 22px);
    color: #7b6c00;
    position: absolute;
    top: 22%;
  }

  .signal-bar {
    height: clamp(16px, 2vw, 22px);
  }
}

/* END TABLET CSS */

/* ==========================================================================
   MOBILE LAYOUT
   Everything below flows top-to-bottom with a flex column + gap instead of
   position:absolute + hand-tuned "top" offsets per device. This is what
   lets the page adapt to any phone width/height without breaking.
   ========================================================================== */

.mobile {
  display: none;
}

@media (max-width: 767px) {
  .desktop {
    display: none !important;
  }

  .mobile {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    min-height: 100vh;
    position: relative;
    background-color: #161920;
    scroll-behavior: smooth;
    padding: clamp(20px, 6vw, 40px) clamp(12px, 4vw, 20px) clamp(40px, 10vw, 60px);
    font-family: "Montserrat", Arial, Helvetica, sans-serif;
  }

  .mobile::before {
    content: "";
    position: fixed;
    inset: 0;
    background-image: url("../image/bg-mobile.webp");
    background-repeat: no-repeat;
    background-position: top center;
    background-size: cover;
    z-index: -1;
    pointer-events: none;
  }

  .mobile-container {
    width: 100%;
    max-width: 480px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: clamp(20px, 5vw, 36px);
  }

  .mobile-title-img {
    width: clamp(140px, 45vw, 220px);
    height: auto;
  }

  .mobile-section-1,
  .mobile-section-4,
  .mobile-section-5,
  .mobile-section-6,
  .mobile-carousel-section,
  .link-frame-mobile,
  .download-btn-mobile {
    width: 100%;
  }

  .mobile-section-1 {
    text-align: center;
  }

  .mobile-banner-img {
    width: 100%;
    height: auto;
    display: block;
  }

  /* Link cards over the decorative character artwork */
  .link-frame-mobile {
    position: relative;
    border-radius: 10px;
    overflow: hidden;
  }

  .mobile-character-img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    z-index: 0;
    filter: drop-shadow(0 8px 20px rgba(0, 0, 0, 0.5));
  }

  .link-mobile-section {
    position: relative;
    z-index: 1;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    row-gap: clamp(6px, 2vw, 10px);
    column-gap: clamp(10px, 3vw, 18px);
    padding: clamp(16px, 5vw, 28px);
  }

  .circle-item-mobile {
    position: relative;
    width: 100%;
    /* Matches link-circle.png's real ratio (380/240) so object-fit: contain
       stops letterboxing top/bottom inside a forced-square cell — that
       baked-in empty space, not the grid gap, was most of the visible gap
       between rows. */
    aspect-ratio: 380 / 240;
    cursor: pointer;
    transition: transform 0.3s ease;
  }

  .circle-item-mobile:active {
    transform: scale(0.97);
  }

  .circle-bg-mobile {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
    z-index: 1;
  }

  .circle-content-mobile {
    position: absolute;
    inset: 0;
    z-index: 2;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: clamp(2px, 1vw, 6px);
    text-align: center;
    color: #7b6c00;
    padding: 10%;
  }

  .circle-content-mobile .title-mobile {
    font-weight: bold;
    font-size: clamp(13px, 4vw, 18px);
    position: absolute;
    top: 14%;
  }

  .circle-content-mobile .timing-mobile {
    font-weight: bold;
    font-size: clamp(14px, 4.5vw, 20px);
    margin-top: clamp(14px, 4vw, 20px);
  }

  .signal-bar-mobile {
    height: clamp(12px, 4vw, 20px);
    width: auto;
    display: flex;
    justify-content: center;
    align-items: center;
  }

  .signal-bar-mobile img {
    height: 100%;
    width: auto;
    object-fit: contain;
  }

  /* Download banner: buttons overlay the vacant bottom-left area of
     50.png (below the text, left of the character artwork). */
  .mobile-section-5 {
    position: relative;
    width: 100%;
  }

  .mobile-section-5 > img {
    width: 100%;
    height: auto;
    display: block;
  }

  .download-btn-mobile {
    position: absolute;
    top: 78%;
    left: 7%;
    width: 50%;
    transform: translateY(-50%);
    display: flex;
    justify-content: center;
    gap: clamp(6px, 2.5vw, 14px);
  }

  .btn-ios-mobile,
  .btn-android-mobile {
    width: clamp(55px, 25vw, 100px);
    height: auto;
  }

  /* Games carousel: title badge and scrolling carousel sit on the same row */
  .mobile-carousel-section {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: clamp(8px, 2vw, 14px);
  }

  .game-frame-mobile {
    flex: 0 0 auto;
    width: clamp(100px, 30vw, 160px);
    height: clamp(36px, 9vw, 56px);
    border-radius: 10px;
    overflow: hidden;
  }

  .frame-carousel {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: left center;
    display: block;
  }

  .carousel-wrapper-mobile {
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
  }

  .carousel-mobile {
    display: flex;
    gap: clamp(10px, 3vw, 18px);
    animation: scroll-mobile 60s linear infinite;
  }

  .carousel-mobile:hover {
    animation-play-state: paused;
  }

  .game-item-mobile {
    flex: 0 0 clamp(130px, 40vw, 180px);
    aspect-ratio: 3 / 1;
    border-radius: 10px;
    overflow: hidden;
    transition: transform 0.3s ease;
  }

  .game-item-mobile:hover {
    transform: scale(1.1);
  }

  .game-item-mobile img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
  }

  /* Social buttons */
  .mobile-social-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: clamp(10px, 3vw, 16px);
    width: 100%;
  }

  .mobile-social-btn {
    display: block;
    transition: transform 0.3s ease;
  }

  .mobile-social-btn img {
    width: 100%;
    height: auto;
    display: block;
  }

  .mobile-social-btn:hover {
    transform: scale(1.05);
  }

  .mobile-social-btn:active {
    transform: scale(0.95);
  }
}
