/* ==========================================================================
   Tournaments Public — Mobile-First Responsive CSS
   WebView-optimized | iOS safe areas | Touch targets 44px
   ========================================================================== */

/* --- 1. Design System Variables --- */
:root {
  --tp-primary: #1B2A4A;
  --tp-primary-light: #2D4373;
  --tp-accent: #FF6B35;
  --tp-success: #22C55E;
  --tp-danger: #EF4444;
  --tp-info: #3B82F6;
  --tp-bg: #F8FAFC;
  --tp-card: #FFFFFF;
  --tp-text: #0F172A;
  --tp-text-secondary: #64748B;
  --tp-text-muted: #94A3B8;
  --tp-border: #E2E8F0;
  --tp-safe-top: env(safe-area-inset-top, 0px);
  --tp-safe-bottom: env(safe-area-inset-bottom, 0px);
  --tp-touch-min: 44px;
  --tp-radius: 12px;
  --tp-radius-sm: 8px;
  --tp-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
  --tp-shadow-lg: 0 4px 16px rgba(0, 0, 0, 0.12);
}

/* --- 2. Reset & Base --- */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  -webkit-text-size-adjust: 100%;
  -ms-text-size-adjust: 100%;
  font-size: 16px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Segoe UI',
    Roboto, Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji';
  background-color: var(--tp-bg);
  color: var(--tp-text);
  line-height: 1.5;
  max-width: 100vw;
  /* `clip` evita lo scroll orizzontale SENZA trasformare il body in un
     contenitore di scroll: `overflow-x: hidden` lo faceva, rompendo
     `position: sticky` di header e tab (che così sparivano allo scroll). */
  overflow-x: clip;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  -ms-overflow-style: none;
  scrollbar-width: none;
}

body::-webkit-scrollbar {
  display: none;
}

a {
  color: inherit;
  text-decoration: none;
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
  color: inherit;
}

img {
  max-width: 100%;
  display: block;
}

table {
  border-spacing: 0;
  border-collapse: collapse;
}

/* --- 3. Header --- */
/* Barra superiore persistente: header (logo/titolo) + tab (Calendario/Gironi)
   restano fissi in cima durante lo scroll, così le tab sono sempre usabili.
   Header e tab sono resi statici dentro al wrapper per evitare doppio sticky. */
.tp-topbar {
  position: -webkit-sticky;
  position: sticky;
  top: 0;
  z-index: 100;
}

.tp-topbar .tp-header,
.tp-topbar .tp-tabs {
  position: static;
}

/* Barra secondaria persistente (day-nav del calendario, switch Classifica/
   Partite, switch Lista/Albero): resta agganciata subito SOTTO la topbar.
   `--tp-topbar-h` è l'altezza reale della topbar, misurata in JS (fallback
   104px). Sfondo pieno a tutta larghezza così le card scorrono sotto senza
   trasparire ai lati dei controlli (che hanno margini laterali). */
.tp-substicky {
  position: -webkit-sticky;
  position: sticky;
  top: calc(var(--tp-topbar-h, 104px) - 1px);
  z-index: 90;
  background-color: var(--tp-bg);
  /* Contiene i margini dei controlli interni (day-nav/switch) così lo sfondo
     del wrapper copre tutta la spaziatura e nessuna card resta scoperta. */
  display: flow-root;
}

.tp-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: linear-gradient(135deg, var(--tp-primary) 0%, var(--tp-primary-light) 100%);
  color: #FFFFFF;
  padding: calc(var(--tp-safe-top) + 12px) 16px 12px;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.tp-header-back {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  width: var(--tp-touch-min);
  height: var(--tp-touch-min);
  margin-left: -8px;
  margin-right: -4px;
  border-radius: var(--tp-radius-sm);
  color: #FFFFFF;
  font-size: 18px;
  text-decoration: none;
}

.tp-header-back:hover,
.tp-header-back:focus,
.tp-header-back:active {
  background: rgba(255, 255, 255, 0.15);
  color: #FFFFFF;
  text-decoration: none;
}

.tp-header-back-label {
  display: none;
}

.tp-header-logo {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  background-color: rgba(255, 255, 255, 0.15);
}

.tp-header-info {
  flex: 1;
  min-width: 0;
}

.tp-header-info h1 {
  font-size: 17px;
  font-weight: 700;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tp-header-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.tp-header-meta .tp-live-badge {
  flex: 0 0 auto;
  gap: 5px;
  padding: 2px 8px;
  border: 1px solid rgba(34, 197, 94, 0.55);
  border-radius: 999px;
  background: rgba(34, 197, 94, 0.2);
  color: #FFFFFF;
  font-size: 11px;
  font-weight: 700;
  line-height: 1.3;
  letter-spacing: 0.4px;
}

.tp-header-meta .tp-live-badge.tp-live-stale {
  border-color: rgba(255, 255, 255, 0.3);
  background: rgba(255, 255, 255, 0.12);
}

.tp-header-meta .tp-live-dot {
  width: 7px;
  height: 7px;
}

.tp-header-meta .tp-header-subtitle {
  min-width: 0;
}

.tp-header-subtitle {
  font-size: 12px;
  opacity: 0.8;
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tp-header-live {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
  padding: 4px 10px;
  background: rgba(255, 255, 255, 0.15);
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

.tp-header-live-dot {
  width: 8px;
  height: 8px;
  background-color: var(--tp-danger);
  border-radius: 50%;
  animation: tp-pulse 1.5s ease-in-out infinite;
}

/* --- 4. Tab Navigation --- */
.tp-tabs {
  position: sticky;
  top: 0;
  z-index: 99;
  display: flex;
  background-color: var(--tp-card);
  border-bottom: 1px solid var(--tp-border);
  box-shadow: var(--tp-shadow);
}

.tp-tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-height: var(--tp-touch-min);
  padding: 6px 4px;
  font-size: 13px;
  font-weight: 500;
  color: var(--tp-text-muted);
  border-bottom: 3px solid transparent;
  transition: color 0.2s, border-color 0.2s;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

.tp-tab-icon {
  font-size: 18px;
  line-height: 1;
}

.tp-tab-label {
  font-size: 10px;
  line-height: 1;
  white-space: nowrap;
}

.tp-tab.active {
  color: var(--tp-primary);
  border-bottom-color: var(--tp-primary);
  font-weight: 600;
}

.tp-tab:active {
  background-color: rgba(0, 0, 0, 0.04);
}

/* --- 5. Content Area --- */
.tp-content {
  padding: 0 0 calc(56px + var(--tp-safe-bottom));
}

.tp-tab-panel,
.tp-panel {
  display: none;
}

.tp-tab-panel.active,
.tp-panel.active {
  display: block;
}

/* --- 6. Section Headers --- */
.tp-section-header {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--tp-text-muted);
  padding: 16px 16px 8px;
}

/* --- 7. Match Cards --- */
/* Navigatore giorno del calendario (stile diretta.it). */
.tp-daynav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 10px;
  margin-bottom: 10px;
  background-color: var(--tp-card);
  border: 1px solid var(--tp-border);
  border-radius: var(--tp-radius-sm);
}

.tp-daynav-btn {
  flex: 0 0 auto;
  width: 42px;
  height: 36px;
  border: none;
  background-color: var(--tp-bg);
  color: var(--tp-primary);
  font-size: 22px;
  line-height: 1;
  border-radius: var(--tp-radius-sm);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.tp-daynav-btn:active {
  background-color: #E2E8F0;
}

/* Contenitore dell'etichetta data: ospita il date picker nativo sovrapposto. */
.tp-daynav-datewrap {
  flex: 1 1 auto;
  position: relative;
}

.tp-daynav-label {
  text-align: center;
  font-size: 14px;
  font-weight: 700;
  color: var(--tp-text);
  cursor: pointer;
}

/* Piccolo indicatore che l'etichetta apre il calendario. */
.tp-daynav-label::after {
  content: " \25BE";
  font-size: 11px;
  color: var(--tp-primary);
}

/* Input date nativo: trasparente e sovrapposto all'etichetta, cosi un tap
   apre il selettore data del dispositivo (mobile) o del browser (desktop).
   Larghezza ~ a quella del calendario nativo e centrato: il popup nativo si
   ancora al bordo sinistro dell'input, quindi con questa larghezza si apre
   centrato sotto la data invece che a sinistra della barra. */
.tp-day-picker {
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 210px;
  max-width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: transparent;
  opacity: 0;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
}

.tp-match-card {
  background-color: var(--tp-card);
  border-left: 3px solid var(--tp-border);
  padding: 12px 16px;
  min-height: var(--tp-touch-min);
  border-bottom: 1px solid var(--tp-border);
  cursor: pointer;
  transition: background-color 0.15s;
  -webkit-tap-highlight-color: transparent;
}

.tp-match-card:active {
  background-color: #F1F5F9;
}

.tp-match-card.tp-match-finished {
  border-left-color: var(--tp-success);
}

.tp-match-card.tp-match-live {
  border-left-color: var(--tp-danger);
}

.tp-match-card.tp-match-scheduled {
  border-left-color: var(--tp-text-muted);
}

.tp-match-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.tp-match-info {
  font-size: 11px;
  color: var(--tp-text-muted);
  font-weight: 500;
}

/* Griglia punteggio in stile diretta.it: nome squadra a sinistra, poi il
   RISULTATO (set vinti) in grande/grassetto e i PARZIALI dei set in colonne
   piccole e chiare a destra. Niente bordi pesanti: solo un divisore tra
   risultato e parziali. */
.tp-score-grid {
  width: 100%;
  border-collapse: collapse;
  table-layout: auto;
}

.tp-sg-name {
  font-size: 14px;
  color: var(--tp-text);
  width: 100%;
  max-width: 0;
  padding: 4px 10px 4px 0;
  vertical-align: middle;
  line-height: 1.3;
}

/* Ogni giocatore della coppia su una riga, con ellissi se troppo lungo. */
.tp-sg-player {
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Risultato finale del match (set vinti): grande, in grassetto, prominente. */
.tp-sg-result {
  font-family: 'SF Mono', 'Menlo', 'Monaco', 'Courier New', monospace;
  font-size: 17px;
  font-weight: 700;
  color: var(--tp-text);
  width: 1%;
  white-space: nowrap;
  text-align: center;
  vertical-align: middle;
  padding: 3px 12px;
  border-right: 1px solid var(--tp-border);
}

/* Primo parziale dopo il divisore: un po' di respiro. */
.tp-sg-result + .tp-sg-set {
  padding-left: 10px;
}

/* Parziali dei set: colonne piccole, grigie; il set vinto risalta in scuro. */
.tp-sg-set {
  font-family: 'SF Mono', 'Menlo', 'Monaco', 'Courier New', monospace;
  font-size: 12px;
  font-weight: 500;
  color: var(--tp-text-muted);
  width: 1%;
  white-space: nowrap;
  text-align: center;
  vertical-align: middle;
  padding: 3px 6px;
}

.tp-sg-set.won {
  color: var(--tp-text);
  font-weight: 700;
}

/* Squadra vincente: nome e risultato evidenziati. */
.tp-score-grid tr.winner .tp-sg-name {
  font-weight: 700;
}

.tp-score-grid tr.winner .tp-sg-result {
  color: var(--tp-success);
}

/* Tie-break ad apice accanto al parziale del set (es. 6⁵ / 7). */
.tp-tb {
  font-size: 9px;
  font-weight: 600;
  vertical-align: super;
  margin-left: 1px;
  color: var(--tp-text-muted);
}

/* Variante della griglia nel modale di dettaglio: più grande e ariosa. */
.tp-score-grid--modal {
  width: 100%;
  margin: 6px 0 18px;
}

.tp-score-grid--modal tr + tr .tp-sg-name,
.tp-score-grid--modal tr + tr .tp-sg-result,
.tp-score-grid--modal tr + tr .tp-sg-set {
  border-top: 1px solid var(--tp-border);
}

.tp-score-grid--modal .tp-sg-name {
  font-size: 15px;
  padding: 12px 12px 12px 0;
  line-height: 1.35;
}

.tp-score-grid--modal .tp-sg-result {
  font-size: 20px;
  padding: 12px 16px;
}

.tp-score-grid--modal .tp-sg-set {
  font-size: 15px;
  min-width: 26px;
  padding: 12px 8px;
}

.tp-score-grid--modal .tp-tb {
  font-size: 11px;
}

.tp-match-footer {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  font-size: 11px;
  color: var(--tp-text-muted);
}

.tp-match-footer-separator {
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background-color: var(--tp-text-muted);
  flex-shrink: 0;
}

/* --- 8. Status Badges --- */
.tp-badge {
  display: inline-block;
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 2px 8px;
  border-radius: 10px;
  line-height: 1.4;
  white-space: nowrap;
}

.tp-badge-finished {
  background-color: rgba(34, 197, 94, 0.12);
  color: #16A34A;
}

.tp-badge-live {
  background-color: rgba(239, 68, 68, 0.12);
  color: var(--tp-danger);
  animation: tp-blink 1.2s ease-in-out infinite;
}

.tp-badge-scheduled {
  background-color: rgba(59, 130, 246, 0.12);
  color: var(--tp-info);
}

.tp-badge-bye {
  background-color: rgba(148, 163, 184, 0.12);
  color: var(--tp-text-muted);
}

/* --- 9. Standings Tables --- */
.tp-standings {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.tp-standings thead th {
  background-color: var(--tp-primary);
  color: #FFFFFF;
  padding: 8px;
  font-weight: 600;
  text-align: center;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  white-space: nowrap;
}

.tp-standings thead th:first-child {
  text-align: left;
}

.tp-standings tbody td {
  padding: 8px;
  text-align: center;
  border-bottom: 1px solid var(--tp-border);
  color: var(--tp-text);
}

.tp-standings tbody td:first-child {
  text-align: left;
  font-weight: 500;
}

.tp-standings tbody tr:hover {
  background-color: rgba(59, 130, 246, 0.06);
}

.tp-standings tbody tr.tp-qualify {
  background-color: rgba(34, 197, 94, 0.08);
  border-left: 3px solid var(--tp-success);
}

.tp-standings tbody tr.tp-qualify:hover {
  background-color: rgba(34, 197, 94, 0.14);
}

/* Nota classifica ripescaggi (dentro l'accordion) */
.tp-runnerups-note {
  font-size: 11px;
  color: var(--tp-text-muted);
  padding: 6px 16px 12px;
  line-height: 1.4;
}

/* --- 10. Group Accordion --- */
.tp-group {
  background-color: var(--tp-card);
  border-radius: var(--tp-radius);
  margin: 0 12px 12px;
  box-shadow: var(--tp-shadow);
  overflow: hidden;
}

.tp-group-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  min-height: var(--tp-touch-min);
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 700;
  color: var(--tp-text);
  background: none;
  border: none;
  border-bottom: 1px solid var(--tp-border);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background-color 0.15s;
}

.tp-group-toggle:active {
  background-color: #F1F5F9;
}

.tp-group-toggle-left {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 0;
}

.tp-group-toggle-arrow {
  font-size: 12px;
  color: var(--tp-text-muted);
  transition: transform 0.25s ease;
  flex-shrink: 0;
}

.tp-group.open .tp-group-toggle-arrow {
  transform: rotate(180deg);
}

.tp-group-progress {
  height: 4px;
  background-color: var(--tp-border);
  border-radius: 2px;
  overflow: hidden;
  width: 60px;
  margin-right: 10px;
  flex-shrink: 0;
}

.tp-group-progress-bar {
  height: 100%;
  background-color: var(--tp-success);
  border-radius: 2px;
  transition: width 0.3s ease;
}

.tp-group-content {
  display: none;
  overflow: hidden;
}

.tp-group.open .tp-group-content {
  display: block;
}

/* --- 11. Modal (Bottom Sheet) --- */
.tp-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 1000;
  display: flex;
  align-items: flex-end;
  justify-content: flex-end;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.25s, visibility 0.25s;
}

.tp-modal-overlay.active {
  opacity: 1;
  visibility: visible;
}

.tp-modal-sheet {
  background-color: var(--tp-card);
  border-radius: 16px 16px 0 0;
  width: 100%;
  max-height: 85vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  animation: tp-slideUp 0.3s ease-out;
  padding-bottom: var(--tp-safe-bottom);
}

.tp-modal-handle {
  display: flex;
  justify-content: center;
  padding: 10px 0 6px;
}

.tp-modal-handle::after {
  content: '';
  width: 36px;
  height: 4px;
  background-color: var(--tp-border);
  border-radius: 2px;
}

.tp-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px 12px;
  border-bottom: 1px solid var(--tp-border);
}

.tp-modal-title {
  font-size: 16px;
  font-weight: 700;
}

.tp-modal-close {
  width: var(--tp-touch-min);
  height: var(--tp-touch-min);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  color: var(--tp-text-muted);
  border-radius: 50%;
  transition: background-color 0.15s;
}

.tp-modal-close:active {
  background-color: #F1F5F9;
}

.tp-modal-body {
  padding: 16px;
}

.tp-modal-matchup {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 20px 0;
}

.tp-modal-team {
  flex: 1;
  text-align: center;
  font-size: 15px;
  font-weight: 600;
  min-width: 0;
  word-break: break-word;
}

.tp-modal-vs {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background-color: var(--tp-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  color: var(--tp-text-muted);
  flex-shrink: 0;
}

.tp-modal-scores {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 8px;
  padding: 16px 0;
  border-top: 1px solid var(--tp-border);
  border-bottom: 1px solid var(--tp-border);
}

.tp-modal-score-set {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  font-family: 'SF Mono', 'Menlo', monospace;
  font-size: 18px;
  font-weight: 700;
}

.tp-modal-score-divider {
  color: var(--tp-text-muted);
  font-size: 14px;
}

.tp-modal-details {
  padding: 16px 0 0;
}

.tp-modal-detail-row {
  display: flex;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid var(--tp-border);
  font-size: 13px;
}

.tp-modal-detail-label {
  color: var(--tp-text-muted);
}

.tp-modal-detail-value {
  font-weight: 600;
  color: var(--tp-text);
}

/* --- 12. Tournament List --- */
.tp-tournament-card {
  display: flex;
  align-items: center;
  gap: 12px;
  background-color: var(--tp-card);
  padding: 12px 16px;
  min-height: var(--tp-touch-min);
  border-bottom: 1px solid var(--tp-border);
  cursor: pointer;
  transition: background-color 0.15s;
  -webkit-tap-highlight-color: transparent;
}

.tp-tournament-card:active {
  background-color: #F1F5F9;
}

.tp-tournament-icon {
  width: 44px;
  height: 44px;
  background: linear-gradient(135deg, var(--tp-primary) 0%, var(--tp-primary-light) 100%);
  border-radius: var(--tp-radius);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
  color: #FFFFFF;
}

.tp-tournament-info {
  flex: 1;
  min-width: 0;
}

.tp-tournament-name {
  font-size: 16px;
  font-weight: 700;
  color: var(--tp-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tp-tournament-detail {
  font-size: 12px;
  color: var(--tp-text-muted);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tp-tournament-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.tp-tournament-chevron {
  font-size: 16px;
  color: var(--tp-text-muted);
}

/* --- 13. Archive --- */
.tp-archive-card {
  display: flex;
  align-items: center;
  gap: 12px;
  background-color: var(--tp-card);
  padding: 12px 16px;
  min-height: var(--tp-touch-min);
  border-bottom: 1px solid var(--tp-border);
  cursor: pointer;
  transition: background-color 0.15s;
  -webkit-tap-highlight-color: transparent;
}

.tp-archive-card:active {
  background-color: #F1F5F9;
}

.tp-archive-icon {
  width: 44px;
  height: 44px;
  background: linear-gradient(135deg, var(--tp-text-muted) 0%, var(--tp-text-secondary) 100%);
  border-radius: var(--tp-radius);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
  color: #FFFFFF;
}

.tp-archive-info {
  flex: 1;
  min-width: 0;
}

.tp-archive-name {
  font-size: 16px;
  font-weight: 700;
  color: var(--tp-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tp-archive-detail {
  font-size: 12px;
  color: var(--tp-text-muted);
  margin-top: 2px;
}

.tp-archive-winner {
  font-size: 12px;
  color: var(--tp-success);
  font-weight: 600;
  margin-top: 2px;
}

.tp-archive-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.tp-archive-chevron {
  font-size: 16px;
  color: var(--tp-text-muted);
}

/* --- 14. Empty State --- */
.tp-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 24px;
  text-align: center;
}

.tp-empty-icon {
  font-size: 64px;
  line-height: 1;
  margin-bottom: 16px;
  opacity: 0.5;
}

.tp-empty-message {
  font-size: 16px;
  font-weight: 600;
  color: var(--tp-text);
  margin-bottom: 6px;
}

.tp-empty-submessage {
  font-size: 13px;
  color: var(--tp-text-muted);
  line-height: 1.4;
  max-width: 260px;
}

/* --- 15. Footer Bar --- */
.tp-footer {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 98;
  background-color: var(--tp-card);
  border-top: 1px solid var(--tp-border);
  padding: 8px 16px calc(8px + var(--tp-safe-bottom));
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.tp-footer-text {
  font-size: 11px;
  color: var(--tp-text-muted);
}

.tp-footer-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background-color: var(--tp-success);
  animation: tp-pulse 2s ease-in-out infinite;
  flex-shrink: 0;
}

/* --- 16. Animations --- */
@keyframes tp-pulse {
  0%, 100% {
    opacity: 1;
    transform: scale(1);
  }
  50% {
    opacity: 0.4;
    transform: scale(0.85);
  }
}

@keyframes tp-blink {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.5;
  }
}

@keyframes tp-flash {
  0% {
    background-color: rgba(251, 191, 36, 0.35);
  }
  100% {
    background-color: transparent;
  }
}

@keyframes tp-slideUp {
  0% {
    transform: translateY(100%);
    opacity: 0;
  }
  100% {
    transform: translateY(0);
    opacity: 1;
  }
}

@keyframes tp-spin {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}

/* --- 17. Skeleton Loader --- */
.tp-skeleton {
  position: relative;
  overflow: hidden;
  background-color: #E2E8F0;
  border-radius: var(--tp-radius-sm);
}

.tp-skeleton::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(255, 255, 255, 0.5) 50%,
    transparent 100%
  );
  animation: tp-shimmer 1.5s ease-in-out infinite;
}

@keyframes tp-shimmer {
  0% {
    transform: translateX(-100%);
  }
  100% {
    transform: translateX(100%);
  }
}

.tp-skeleton-line {
  height: 14px;
  margin-bottom: 8px;
  border-radius: 4px;
}

.tp-skeleton-line:last-child {
  margin-bottom: 0;
}

.tp-skeleton-line-short {
  width: 60%;
}

.tp-skeleton-line-medium {
  width: 80%;
}

.tp-skeleton-circle {
  width: 36px;
  height: 36px;
  border-radius: 50%;
}

.tp-skeleton-card {
  background-color: var(--tp-card);
  padding: 12px 16px;
  border-bottom: 1px solid var(--tp-border);
}

/* --- 18. Utility Helpers --- */
.tp-flash-highlight {
  animation: tp-flash 1.5s ease-out;
}

/* Tab nascosta finché il relativo contenuto non esiste (es. Tabellone prima
   della promozione): il polling la mostra automaticamente quando compare. */
.tp-tab-hidden {
  display: none;
}

/* Badge "LIVE": pallino verde pulsante quando l'aggiornamento automatico
   (polling) funziona; diventa grigio e smette di pulsare se il polling fallisce. */
.tp-live-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.tp-live-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: #22c55e;
  animation: tp-blink 1.4s ease-in-out infinite;
}

.tp-live-badge.tp-live-stale {
  opacity: 0.75;
}

.tp-live-badge.tp-live-stale .tp-live-dot {
  background-color: #9ca3af;
  animation: none;
}

.tp-loading-spinner {
  width: 24px;
  height: 24px;
  border: 3px solid var(--tp-border);
  border-top-color: var(--tp-primary);
  border-radius: 50%;
  animation: tp-spin 0.7s linear infinite;
  margin: 24px auto;
}

.tp-sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* --- 19. Desktop Breakpoint (769px+) --- */
@media (min-width: 769px) {
  .tp-content {
    max-width: 1024px;
    margin: 0 auto;
  }

  .tp-header {
    position: sticky;
    /* Il contenuto dell'intestazione segue la colonna di schede e contenuti. */
    padding-left: max(16px, calc(50% - 512px));
    padding-right: max(16px, calc(50% - 512px));
    gap: 16px;
  }

  .tp-header-back {
    gap: 8px;
    width: auto;
    padding: 0 14px;
    margin: 0;
    border: 1px solid rgba(255, 255, 255, 0.3);
    font-size: 14px;
    font-weight: 600;
  }

  .tp-header-back-label {
    display: inline;
  }

  .tp-header-logo {
    width: 44px;
    height: 44px;
  }

  .tp-header-info h1 {
    font-size: 21px;
  }

  .tp-header-subtitle {
    font-size: 13px;
  }

  /* Pill a destra: titolo e dettagli a sinistra su due righe. */
  .tp-header-info {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    column-gap: 16px;
    align-items: center;
  }

  .tp-header-meta {
    display: contents;
  }

  .tp-header-info h1 {
    grid-column: 1;
    grid-row: 1;
  }

  .tp-header-meta .tp-header-subtitle {
    grid-column: 1;
    grid-row: 2;
  }

  .tp-header-meta .tp-live-badge {
    grid-column: 2;
    grid-row: 1 / span 2;
    padding: 5px 12px;
    font-size: 13px;
  }

  .tp-tabs {
    max-width: 1024px;
    margin: 0 auto;
    border-radius: 0;
  }

  /* Match cards in 2-column grid */
  .tp-match-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0;
  }

  .tp-match-grid .tp-match-card {
    border-right: 1px solid var(--tp-border);
  }

  .tp-match-grid .tp-match-card:nth-child(2n) {
    border-right: none;
  }

  .tp-match-card:hover {
    background-color: #F8FAFC;
  }

  /* Standings side by side */
  .tp-standings-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    padding: 0 16px;
  }

  .tp-standings-grid .tp-group {
    margin: 0 0 16px;
  }

  /* Modal centered on desktop */
  .tp-modal-overlay {
    align-items: center;
    justify-content: center;
  }

  .tp-modal-sheet {
    border-radius: 16px;
    max-width: 460px;
    max-height: 80vh;
    box-shadow: var(--tp-shadow-lg);
  }

  .tp-modal-handle {
    display: none;
  }

  /* Tournament & archive cards hover */
  .tp-tournament-card:hover,
  .tp-archive-card:hover {
    background-color: #F8FAFC;
  }
}
