/* Due Maglie — mobile polish, loaded after app.css (kept apart so parallel work on app.css does not clash).
   Safe areas (notch, home bar, landscape), dialogs that fit the visible viewport, small overflow fixes,
   bigger tap targets, long-list rendering, and the "install the app" hint of assets/js/pwa.js. */

/* ---------- safe areas ----------
   iPhone home-screen app uses status-bar-style black-translucent: the sticky header grows under the status bar.
   In the browser every inset is 0 in portrait, so nothing moves there. */
.top { padding-top: env(safe-area-inset-top, 0px); }
.top-in,
.main,
.foot {
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}
.tabs {
  padding-left: env(safe-area-inset-left, 0px);
  padding-right: env(safe-area-inset-right, 0px);
}
/* the grid's sticky clock sits under the header, which is taller in the home-screen app */
.playbar { top: calc(var(--head-h) + 6px + env(safe-area-inset-top, 0px)); }

/* ---------- dialogs: fit the visible viewport (mobile browser bars), never under notch or home bar ---------- */
@supports (height: 100dvh) {
  .dlg {
    max-height: calc(100dvh - 24px - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px));
    overscroll-behavior: contain;
  }
}
.dlg-search .hint { margin: 8px 2px 0; }

/* ---------- tap targets ---------- */
.lang-btn { height: 40px; }
/* how-to step dots: the dot stays small, the button around it is taller and as wide as there is room for */
@media (max-width: 600px) {
  .hw-dots { gap: 2px; }
  .hw-dot-btn { flex: 0 1 32px; min-width: 22px; height: 40px; }
}
.cup-round summary { min-height: 44px; }
.chip { min-width: 40px; }
/* close buttons next to a long title: never squeezed below 44 px */
.dlg-head .icon-btn, .uni-dlg-head .icon-btn { flex: none; }

/* ---------- overflow ---------- */
/* Classifiche > Amici: the code / name forms pushed the page 6-20 px wider at 360 px (input intrinsic width) */
.fr-form { grid-template-columns: minmax(0, 1fr); }
.fr-row { min-width: 0; }
.fr-row .club-btn-main { flex: none; }
/* cup bracket: long nicknames end with "…" instead of breaking letter by letter */
.cup-nm small { display: block; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; overflow-wrap: normal; }

/* ---------- long lists: skip layout/paint of the cards off screen ---------- */
.uni-item { content-visibility: auto; contain-intrinsic-size: auto 430px; }
/* the album only when it is big (a few hundred cards after some months); the clip margin keeps the card glow */
.album-grid:has(> .album-item:nth-child(24)) > .album-item {
  content-visibility: auto; contain-intrinsic-size: auto 260px; overflow-clip-margin: 18px;
}

/* ---------- "install the app" hint (assets/js/pwa.js) ---------- */
.pwa-hint {
  position: fixed; z-index: 150; left: 50%; transform: translateX(-50%);
  bottom: calc(var(--tabbar-h) + 10px + env(safe-area-inset-bottom, 0px));
  width: min(460px, calc(100vw - 24px));
  display: grid; grid-template-columns: auto 1fr; gap: 10px 12px; align-items: start;
  padding: 12px 14px; border-radius: 14px;
  background: linear-gradient(170deg, #13301f, #0b1d13); border: 1px solid rgba(224, 180, 58, .5);
  box-shadow: 0 16px 40px rgba(0, 0, 0, .55);
  animation: nudge-in .35s ease-out both;
}
.pwa-hint-ico { width: 48px; height: 48px; border-radius: 11px; box-shadow: 0 0 0 1px rgba(224, 180, 58, .35); }
.pwa-hint-body { min-width: 0; }
.pwa-hint-h { margin: 0 0 2px; font: 800 19px/1.1 var(--display); text-transform: uppercase; letter-spacing: .02em; color: var(--oro-1); }
.pwa-hint-text { margin: 0; font-size: 14.5px; line-height: 1.35; color: var(--chalk); }
.pwa-share { width: 18px; height: 18px; vertical-align: -3px; color: #6cb4ff; }
.pwa-hint-actions { grid-column: 1 / -1; display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }
@media (min-width: 880px) {
  .pwa-hint { bottom: 20px; left: auto; right: 24px; transform: none; animation-name: nudge-in-d; }
}
@media (prefers-reduced-motion: reduce) { .pwa-hint { animation: none; } }
