/* CtrlAltDefeat MMAid mobile polish — iPhone + Android
   Mobile-only overrides. Desktop presentation remains unchanged. */

@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: calc(76px + env(safe-area-inset-top));
  }

  body {
    background-attachment: scroll;
  }

  body::before {
    position: absolute;
  }

  button,
  input,
  select,
  textarea {
    font-size: 16px;
  }

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

  /* Compact sticky header matching the main CtrlAltDefeat mobile treatment. */
  .site-header {
    top: 0;
    min-height: 64px;
    padding:
      max(8px, env(safe-area-inset-top))
      max(10px, env(safe-area-inset-right))
      8px
      max(10px, env(safe-area-inset-left));
    gap: 8px;
    align-items: center;
    box-shadow:
      0 10px 26px rgba(0, 0, 0, 0.48),
      0 0 16px rgba(93, 184, 255, 0.07),
      0 0 14px rgba(214, 169, 74, 0.05);
  }

  .brand {
    min-width: 0;
    gap: 8px;
    flex: 1 1 auto;
  }

  .brand-mark {
    width: 40px;
    height: 40px;
    flex: 0 0 40px;
    border-radius: 10px;
    font-size: 0.76rem;
  }

  .brand > div:last-child {
    min-width: 0;
  }

  .brand h1 {
    max-width: 100%;
    font-size: 15px;
    line-height: 1.18;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .brand p {
    display: none;
  }

  nav {
    display: none;
  }

  .header-referral {
    flex: 0 0 auto;
    min-height: 44px;
    margin-left: 0;
    padding: 7px 9px;
    border-radius: 10px;
    font-size: 0.68rem;
    line-height: 1.15;
    text-align: center;
    white-space: normal;
    animation: none;
  }

  /* Match the One Piece builder: full-width shell with a swipeable gold link rail. */
  .cad-top-hub {
    width: 100%;
    max-width: 100%;
    margin: 0 auto 18px;
    padding: 0;
  }

  .cad-top-hub-inner {
    padding: 0.72rem 0.75rem 0.78rem;
    border-width: 0 0 1px;
    border-radius: 0;
    overflow: hidden;
  }

  .cad-top-hub-inner::before,
  .cad-top-hub-inner::after {
    border-radius: 0;
  }

  .cad-brand-seal {
    margin: 0 0 0.55rem;
    font-size: clamp(1.2rem, 6vw, 1.55rem);
    line-height: 1.05;
    letter-spacing: 0.10em;
  }

  .cad-link-row {
    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;
  }

  .cad-button {
    flex: 0 0 clamp(132px, 38vw, 170px);
    min-width: 0;
    min-height: 46px;
    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;
  }

  .cad-button-label {
    max-width: 100%;
    white-space: normal;
    overflow-wrap: anywhere;
  }

  .cad-site-preview {
    display: none !important;
  }

  /* Main MMAid content */
  main {
    width: 100%;
    max-width: 100%;
    margin: 16px auto calc(42px + env(safe-area-inset-bottom));
    padding:
      0
      max(10px, env(safe-area-inset-right))
      0
      max(10px, env(safe-area-inset-left));
  }

  .panel {
    margin-bottom: 16px;
    padding: 18px 14px;
    border-radius: 15px;
  }

  .panel::after {
    width: 14rem;
    height: 14rem;
    right: -10rem;
    top: -10rem;
  }

  .hero {
    grid-template-columns: 1fr;
    gap: 16px;
  }

  .hero h2 {
    margin: 7px 0 12px;
    font-size: clamp(1.8rem, 9vw, 2.65rem);
    line-height: 1.03;
  }

  .eyebrow {
    font-size: 0.68rem;
    line-height: 1.4;
    letter-spacing: 0.12em;
  }

  .lead {
    font-size: 0.96rem;
    line-height: 1.58;
  }

  .hero-card,
  .notice,
  .summary-card,
  .finding-card,
  .technical-card,
  .player-download-panel,
  .rules-source-card {
    border-radius: 13px;
  }

  .hero-card,
  .finding-card,
  .player-download-panel,
  .rules-source-card {
    padding: 15px;
  }

  .section-head {
    align-items: flex-start;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 14px;
  }

  .section-head h2,
  .section-head h3 {
    font-size: 1.18rem;
    line-height: 1.3;
  }

  .actions {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  .button,
  .tab,
  .rules-source-link,
  .advanced-downloads summary {
    min-height: 44px;
  }

  .button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 9px 10px;
    line-height: 1.25;
    text-align: center;
  }

  .drop-zone {
    min-height: 180px;
    padding: 18px 12px;
    border-radius: 14px;
  }

  .drop-icon {
    font-size: 32px;
  }

  .status {
    padding: 12px;
    overflow-wrap: anywhere;
  }

  .result-section {
    margin-top: 20px;
  }

  .summary-grid,
  .counts {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  .summary-card,
  .count {
    padding: 12px;
  }

  .summary-card .value {
    font-size: 16px;
  }

  .count strong {
    font-size: 21px;
  }

  .tabs {
    flex-wrap: nowrap;
    gap: 7px;
    overflow-x: auto;
    overscroll-behavior-inline: contain;
    scroll-snap-type: x proximity;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
    margin: 14px 0;
    padding-bottom: 2px;
  }

  .tabs::-webkit-scrollbar {
    display: none;
  }

  .tab {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    scroll-snap-align: start;
    padding: 8px 12px;
    white-space: nowrap;
  }

  .finding-card {
    border-left-width: 4px;
  }

  .finding-top {
    gap: 8px;
  }

  .finding-card h4 {
    font-size: 1rem;
    line-height: 1.35;
  }

  .finding-card p,
  .fix-section p,
  .fix-section li,
  .notice,
  .rules-source-card p,
  .rules-source-note {
    font-size: 0.9rem;
    line-height: 1.55;
  }

  .severity {
    font-size: 0.62rem;
  }

  .fix {
    padding: 13px;
    border-radius: 11px;
  }

  pre {
    max-width: 100%;
    max-height: 300px;
    font-size: 10px;
    -webkit-overflow-scrolling: touch;
  }

  /* Downloads become thumb-friendly, full-width choices. */
  .primary-download-actions {
    grid-template-columns: 1fr;
    gap: 9px;
  }

  .action-choice {
    min-height: 102px;
    padding: 14px;
    border-radius: 13px;
  }

  .action-choice-title {
    font-size: 17px;
  }

  .action-choice-subtitle {
    font-size: 12px;
  }

  .advanced-downloads {
    margin-top: 10px;
    padding-top: 9px;
  }

  .advanced-downloads summary {
    display: flex;
    align-items: center;
    padding: 4px 0;
  }

  /* Rules/source transparency cards */
  .rules-source-grid {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .rules-source-card {
    min-height: 0;
  }

  .rules-source-link {
    width: 100%;
    justify-content: center;
    text-align: center;
  }

  .rules-source-note {
    padding: 13px;
  }

  details.tech summary {
    min-height: 44px;
    display: flex;
    align-items: center;
  }

  footer {
    padding:
      16px
      max(12px, env(safe-area-inset-right))
      calc(18px + env(safe-area-inset-bottom))
      max(12px, env(safe-area-inset-left));
    font-size: 0.76rem;
    line-height: 1.55;
  }

  .footer-disclaimer {
    font-size: 0.72rem;
    line-height: 1.5;
  }

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

  .panel,
  .rules-sources-panel,
  .result-section {
    scroll-margin-top: calc(76px + env(safe-area-inset-top));
  }
}

@media (max-width: 390px) {
  .site-header {
    padding-left: max(8px, env(safe-area-inset-left));
    padding-right: max(8px, env(safe-area-inset-right));
  }

  .brand-mark {
    width: 38px;
    height: 38px;
    flex-basis: 38px;
  }

  .brand h1 {
    font-size: 14px;
  }

  .header-referral {
    min-height: 42px;
    max-width: 112px;
    padding: 6px 7px;
    font-size: 0.62rem;
  }

  main {
    padding-left: max(8px, env(safe-area-inset-left));
    padding-right: max(8px, env(safe-area-inset-right));
  }

  .cad-top-hub-inner {
    padding: 0.68rem 0.65rem 0.72rem;
  }

  .cad-link-row {
    gap: 0.45rem;
  }

  .cad-button {
    flex-basis: 138px;
    min-height: 46px;
    font-size: 0.64rem;
    letter-spacing: 0.045em;
  }

  .panel {
    padding: 15px 11px;
  }

  .hero h2 {
    font-size: clamp(1.65rem, 9vw, 2.25rem);
  }

  .actions {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 330px) {
  .summary-grid,
  .counts {
    grid-template-columns: 1fr;
  }

  .cad-button {
    flex-basis: 132px;
  }

  .brand h1 {
    max-width: 116px;
  }

  .header-referral {
    max-width: 98px;
    font-size: 0.58rem;
  }
}

@media (hover: none) and (pointer: coarse) {
  .cad-site-preview {
    display: none !important;
  }

  .cad-button:hover,
  .button:hover,
  .action-choice:hover,
  .rules-source-link:hover,
  nav a:hover,
  .header-referral:hover {
    transform: none;
  }

  /* Preserve the same sequential aura/moonlight lighting used by the One Piece builder. */
  .header-referral,
  .spinner {
    animation-duration: 0s;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
  }
}
