/* —— Phone / narrow: compact header, dense cabinets, short lists —— */
@media (max-width: 720px) {
  .topbar {
    padding: 0.4rem 0.65rem;
    gap: 0.4rem;
  }

  .music-dock-tab {
    padding: 0.8rem 0.4rem;
  }

  .music-dock {
    --music-panel-w: min(20rem, calc(100vw - 2.25rem));
  }

  .music-dock-panel {
    top: 3.5rem;
    bottom: 0.65rem;
    width: var(--music-panel-w);
    max-height: calc(100vh - 4.15rem);
    padding: 0.8rem 0.85rem 0.95rem;
  }

  .brand-mark {
    width: 28px;
    height: 28px;
    border-radius: 8px;
    font-size: 0.65rem;
  }

  .brand strong {
    font-size: 0.82rem;
  }

  .brand small {
    display: none;
  }

  .top-nav {
    gap: 0.4rem 0.55rem;
    font-size: 0.74rem;
    justify-content: flex-end;
  }

  /* Keep primary actions on one short row; hide external links on phone */
  .top-nav .nav-extra {
    display: none;
  }

  .top-nav .mute-btn {
    width: 1.75rem;
    height: 1.75rem;
    font-size: 0.85rem;
  }

  .nav-text-btn {
    font-size: inherit;
  }

  main {
    padding: 0.85rem 0.7rem 2rem;
  }

  #play-view:not(.is-app-fullscreen) {
    padding-bottom: calc(4rem + env(safe-area-inset-bottom));
  }

  #play-view:not(.is-app-fullscreen) .play-layout.is-document-flow {
    overflow: visible;
  }

  #play-view:not(.is-app-fullscreen) .game-mount.is-document-flow {
    min-height: 0;
    overflow: visible;
    padding: 0.8rem 0.55rem calc(2.75rem + env(safe-area-inset-bottom));
    border-radius: 12px;
    backdrop-filter: none;
    box-shadow: none;
  }

  .player-stats {
    grid-template-columns: repeat(2, 1fr);
  }

  .player-bar {
    padding: 0.75rem 0.8rem;
    margin-bottom: 0.9rem;
    gap: 0.55rem;
  }

  .cabinet-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.4rem;
  }

  .cabinet {
    grid-template-columns: auto 1fr;
    padding: 0.5rem 0.55rem;
    gap: 0.4rem;
    border-radius: 10px;
  }

  .cab-go {
    display: none;
  }

  .cab-icon {
    width: 30px;
    height: 30px;
    font-size: 1.05rem;
    border-radius: 8px;
  }

  .cab-body strong {
    font-size: 0.82rem;
  }

  .cab-desc {
    display: none;
  }

  .cab-best {
    font-size: 0.58rem;
    margin-top: 0.1rem;
  }

  .section-title {
    font-size: 1.05rem;
    margin-bottom: 0.55rem;
  }

  .scores-grid {
    grid-template-columns: 1fr;
    gap: 0.85rem;
  }

  /* ~3 rows on phone for achievements / boards */
  .list-scroll-ach {
    max-height: 8.25rem;
    grid-template-columns: 1fr;
  }

  .list-scroll-hof,
  .list-scroll-pb {
    max-height: 9.25rem; /* ~5 hall / pb rows compact */
  }

  .list-scroll-global {
    max-height: 9.25rem; /* same density as hall of fame on phone */
  }

  .list-scroll-history {
    max-height: 8.5rem;
  }

  .scores {
    padding: 0.85rem 0.8rem;
    margin-bottom: 1rem;
  }

  .scores-head {
    flex-wrap: wrap;
    gap: 0.45rem;
  }

  .score-tools {
    gap: 0.3rem;
  }

  .score-tools .btn.small {
    padding: 0.3rem 0.5rem;
    font-size: 0.72rem;
  }

  .achievements {
    padding: 0.7rem 0.75rem 0.8rem;
  }

  .ach-item {
    padding: 0.4rem 0.45rem;
  }

  .ach-body strong {
    font-size: 0.78rem;
  }

  .ach-body small {
    font-size: 0.68rem;
  }

  .daily-row {
    padding: 0.7rem 0.8rem;
    margin-bottom: 0.75rem;
  }

  .history-list li {
    grid-template-columns: 1fr auto;
  }

  .history-list .when {
    grid-column: 1 / -1;
  }

  .hs-list li,
  .hall-list li,
  .history-list li {
    padding: 0.38rem 0.5rem;
    font-size: 0.8rem;
  }

  /* Tighten intro / lore so cabinets rise on the page */
  .lobby-top {
    margin-bottom: 0.75rem;
    gap: 0.55rem;
  }

  .intro-hero {
    padding: 0.75rem 0.85rem;
  }

  .aa-logo {
    font-size: 0.42rem;
    line-height: 1.15;
    margin: 0;
  }

  .intro-title {
    font-size: 1.35rem !important;
  }

  .intro-thanks {
    font-size: 0.82rem;
    margin-top: 0.4rem;
  }

  .intro-tip {
    display: none;
  }

  .fun-facts-side {
    padding: 0.7rem 0.75rem;
  }

  .fun-facts-side .fun-fact-actions .btn.small {
    padding: 0.28rem 0.45rem;
    font-size: 0.72rem;
  }

  .bg-music-btn {
    padding: 0.5rem 0.65rem;
  }

  .bg-music-btn small {
    display: none;
  }
}

/* Mid widths: 2-col cabinets, 3-col scores when space allows */
@media (min-width: 721px) and (max-width: 899px) {
  .cabinet-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

  .scores-col-global {
    grid-column: 1 / -1;
  }

  .list-scroll-global {
    max-height: 16rem;
  }
}

@media (min-width: 900px) {
  .scores-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .scores-col-global {
    grid-column: auto;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }

  .topbar,
  .topbar.is-scroll-hidden {
    transition: none;
    transform: none;
    opacity: 1;
    pointer-events: auto;
  }
}

/* Desktop: never auto-hide the top section header */
@media (min-width: 721px) {
  .topbar.is-scroll-hidden {
    transform: none;
    opacity: 1;
    pointer-events: auto;
  }
}
