/* CtrlAltDefeat homepage mobile polish — iPhone + Android */

@media (max-width: 760px) {
  html,
  body {
    width: 100%;
    max-width: 100%;
    overflow-x: clip;
  }

  html {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
    scroll-padding-top: 118px;
  }

  body {
    background-attachment: scroll;
  }

  a,
  button,
  summary {
    -webkit-tap-highlight-color: rgba(159, 220, 255, 0.16);
    touch-action: manipulation;
  }

  main {
    width: 100%;
    max-width: 100%;
    padding:
      calc(118px + env(safe-area-inset-top))
      max(12px, env(safe-area-inset-right))
      calc(48px + env(safe-area-inset-bottom))
      max(12px, env(safe-area-inset-left));
  }

  /* Keep the two utility controls out of the content flow and clear of notches. */
  .home-tools-nav {
    position: fixed;
    top: max(8px, env(safe-area-inset-top));
    left: max(8px, env(safe-area-inset-left));
    min-height: 44px;
    padding: 6px 10px 6px 6px;
    gap: 6px;
    z-index: 140;
  }

  .home-tools-icon {
    width: 30px;
    height: 30px;
    flex-basis: 30px;
  }

  .home-tools-label {
    font-size: 0.68rem;
  }

  .home-tools-cue {
    display: none;
  }

  .top-action-stack {
    position: fixed;
    top: max(8px, env(safe-area-inset-top));
    right: max(8px, env(safe-area-inset-right));
    width: 164px;
    max-width: calc(100vw - 116px - env(safe-area-inset-left) - env(safe-area-inset-right));
    margin: 0;
    z-index: 135;
  }

  .music-button,
  .music-mute-button,
  .referral-float {
    min-height: 44px;
  }

  .music-control {
    grid-template-columns: 44px minmax(0, 1fr);
  }

  .music-button,
  .music-mute-button {
    padding: 7px 8px;
  }

  .referral-float {
    padding: 6px 7px;
    font-size: 0.54rem;
    letter-spacing: 0.025em;
  }

  .referral-icon {
    width: 26px;
    height: 26px;
    flex-basis: 26px;
  }

  /* Compact the hero without changing its desktop visual identity. */
  .hero {
    margin-bottom: 34px;
    padding: 24px 14px 22px;
    border-radius: 18px;
  }

  .hero::before,
  .hero::after {
    border-radius: 18px;
  }

  .hero-banner {
    width: 100%;
    max-width: 100%;
    margin-bottom: 16px;
    border-radius: 14px;
  }

  .tagline {
    font-size: 0.68rem;
    line-height: 1.5;
    letter-spacing: 0.07em;
  }

  .hero-pitch {
    margin-top: 14px;
    margin-bottom: 18px;
    padding: 14px 12px;
    border-radius: 14px;
  }

  .hero-pitch-kicker {
    margin-bottom: 7px;
    font-size: 0.70rem;
    line-height: 1.45;
    letter-spacing: 0.07em;
  }

  .hero-pitch .intro,
  .intro {
    font-size: 0.90rem;
    line-height: 1.55;
    text-wrap: pretty;
  }

  .hero-highlight-row {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
    margin-top: 12px;
  }

  .hero-highlight-row span {
    width: 100%;
    min-height: 32px;
    padding: 5px 6px;
    font-size: 0.59rem;
    line-height: 1.25;
    letter-spacing: 0.06em;
  }

  .hero-brand-seal {
    margin: 18px auto;
    font-size: clamp(1.65rem, 9vw, 2.35rem);
    letter-spacing: 0.08em;
  }

  /* Match the One Piece builder: compact, swipeable gold action rails on phones. */
  .link-row.primary,
  .link-row.secondary {
    display: flex;
    grid-template-columns: none;
    flex-wrap: nowrap;
    width: 100%;
    max-width: none;
    gap: 0.5rem;
    overflow-x: auto;
    overflow-y: hidden;
    overscroll-behavior-inline: contain;
    scroll-snap-type: x proximity;
    scrollbar-width: thin;
    -webkit-overflow-scrolling: touch;
    padding: 0 0 0.28rem;
  }

  .link-row.primary {
    margin-top: 14px;
  }

  .link-row.primary .button,
  .link-row.secondary .button {
    flex: 0 0 clamp(132px, 38vw, 170px);
    min-width: 0;
    min-height: 52px;
    padding: 0.62rem 0.7rem;
    border-radius: 10px;
    font-size: 0.68rem;
    line-height: 1.25;
    letter-spacing: 0.065em;
    text-align: center;
    scroll-snap-align: start;
  }

  .link-row.primary .button-label,
  .link-row.secondary .button-label {
    max-width: 100%;
    white-space: normal;
    overflow-wrap: anywhere;
  }

  /* Make update notices swipe instead of stacking into another tall block. */
  .latest-updates {
    margin: -12px auto 38px;
    padding: 12px;
  }

  .latest-updates-list {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    overscroll-behavior-inline: contain;
    scroll-snap-type: x proximity;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 2px;
  }

  .latest-updates-list::-webkit-scrollbar {
    display: none;
  }

  .latest-updates-list span {
    flex: 0 0 min(82vw, 330px);
    min-height: 44px;
    scroll-snap-align: start;
    align-items: center;
  }

  h2 {
    margin-top: 44px;
    margin-bottom: 10px;
    font-size: clamp(1.18rem, 6vw, 1.5rem);
    line-height: 1.35;
    letter-spacing: 0.07em;
  }

  .section-intro {
    margin-bottom: 22px;
    padding-inline: 2px;
    font-size: 0.92rem;
    line-height: 1.55;
  }

  .cards,
  .cards.two,
  .cards.free-modules {
    grid-template-columns: minmax(0, 1fr);
    width: 100%;
    max-width: 100%;
    gap: 16px;
  }

  .card,
  .cards.free-modules .card,
  .cards:not(.free-modules):not(.play-tables) .card {
    min-width: 0;
    min-height: 0;
    padding: 16px;
    border-radius: 14px;
  }

  .card-img-wrapper,
  .cards.free-modules .card-img-wrapper,
  .play-tables .card .card-img-wrapper,
  #ctrlaltdefeat-tools-section .card-img-wrapper {
    height: clamp(158px, 46vw, 190px);
    border-radius: 11px;
  }

  .play-tables .card {
    min-height: 0;
    grid-template-rows: auto auto auto auto;
  }

  .card h3,
  .cards.free-modules .card h3 {
    margin-top: 12px;
    font-size: 1.02rem;
    line-height: 1.35;
  }

  .card p,
  .cards.free-modules .card p {
    font-size: 0.90rem;
    line-height: 1.55;
  }

  .card > p:last-child a,
  .game-link-list a,
  .card-action-stack a,
  .support-actions a {
    min-height: 46px;
    padding: 10px 11px;
    font-size: 0.88rem;
    line-height: 1.3;
    white-space: normal;
    text-align: center;
  }

  .game-link-list,
  .card-action-stack {
    gap: 7px;
  }

  .support-block,
  .note {
    margin-top: 42px;
    padding: 18px 14px;
    border-radius: 14px;
  }

  .support-actions {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .faq-grid {
    gap: 10px;
  }

  .faq-grid summary {
    min-height: 48px;
    padding: 13px 14px;
    font-size: 0.92rem;
    line-height: 1.4;
  }

  .faq-grid details p {
    padding: 0 14px 15px;
    font-size: 0.90rem;
  }

  .footer-secondary-links {
    flex-wrap: wrap;
    gap: 7px 10px;
    margin-top: 28px;
    font-size: 0.70rem;
    line-height: 1.5;
  }

  footer {
    margin-top: 30px;
    padding-inline: 4px;
    font-size: 0.76rem;
    line-height: 1.55;
  }

  /* Avoid mobile sticky-hover states and off-screen preview windows. */
  .site-preview,
  .button::before,
  .button::after {
    display: none;
  }

  img,
  video,
  iframe {
    max-width: 100%;
  }

  section,
  .card,
  .hero,
  .latest-updates,
  .support-block,
  .note {
    scroll-margin-top: 118px;
  }
}

@media (max-width: 390px) {
  main {
    padding-left: max(10px, env(safe-area-inset-left));
    padding-right: max(10px, env(safe-area-inset-right));
  }

  .home-tools-nav {
    padding-right: 8px;
  }

  .home-tools-label {
    font-size: 0.64rem;
  }

  .top-action-stack {
    width: 158px;
  }

  .referral-float {
    font-size: 0.50rem;
  }

  .hero {
    padding: 18px 10px 20px;
  }

  .hero-pitch {
    padding: 12px 10px;
  }

  .link-row.primary,
  .link-row.secondary {
    gap: 0.45rem;
  }

  .link-row.primary .button,
  .link-row.secondary .button {
    flex-basis: 138px;
    min-height: 50px;
    font-size: 0.66rem;
    letter-spacing: 0.055em;
  }

  .latest-updates-list span {
    flex-basis: 86vw;
  }
}

@media (max-width: 330px) {
  .link-row.primary .button,
  .link-row.secondary .button {
    flex-basis: 132px;
  }

  .top-action-stack {
    width: 150px;
  }
}

@media (hover: none) and (pointer: coarse) {
  .button:hover,
  .card:hover,
  .home-tools-nav:hover,
  .music-button:hover,
  .music-mute-button:hover,
  .referral-float:hover,
  .card > p:last-child a:hover,
  .game-link-list a:hover,
  .card-action-stack a:hover {
    transform: none;
  }

  /* Keep the gold button aura/moonlight sequence alive on touch devices. */
  .hero,
  .hero::after,
  .hero-banner,
  .hero-banner::before,
  .referral-float::before {
    animation: none;
  }
}
