/* Lobby Games: colori, misure e componenti comuni a tutte le pagine web.
   Ogni pagina carica questo file per primo e aggiunge solo la propria impaginazione.
   Regole (vedi anche branding/README.md, «Pagine web»):
   - una larghezza di contenuto per pagina (--page-w) e un solo bordo sinistro: tutto parte da .lg-page;
   - spazi solo dalla scala --sp-*, testi solo dalla scala --fs-* (in rem: la classifica scala con lo schermo);
   - etichetta di sezione + azione sulla stessa riga, alta quanto un controllo (.lg-head);
   - celle di tabella con la stessa spaziatura anche per lo stato vuoto (td.cell-empty);
   - numeri allineati a destra con cifre tabulari (.n), etichette che aprono una riga a larghezza fissa (.tag);
   - riquadri numerici della stessa altezza qualunque sia l'etichetta (.tiles). */
:root {
  /* Palette */
  --lg-navy: #000433;
  --lg-deep: #011152;
  --lg-royal: #1B2F86;
  --lg-turquoise: #33E5C2;
  --lg-white: #FFFFFF;
  --lg-soft: #B7C6F2;
  --lg-sky: #7AB7ED;
  --lg-coral: #FF6B57;
  --lg-gradient: linear-gradient(180deg, #012576 0%, #000433 45%, #00011B 100%);

  /* Ruoli */
  --bg: var(--lg-navy);
  --card: var(--lg-deep);
  --sunk: var(--lg-navy);          /* campi, riquadri numerici: un gradino sotto la scheda */
  --line: var(--lg-royal);
  --text: var(--lg-white);
  --muted: var(--lg-soft);
  --accent: var(--lg-turquoise);
  --info: var(--lg-sky);
  --danger: var(--lg-coral);

  /* Caratteri */
  --font-sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  /* Scala degli spazi (base 4 px a 16 px di corpo) */
  --sp-1: 0.25rem;
  --sp-2: 0.5rem;
  --sp-3: 0.75rem;
  --sp-4: 1rem;
  --sp-5: 1.5rem;
  --sp-6: 2rem;
  --sp-7: 3rem;

  /* Scala dei testi */
  --fs-xs: 0.8125rem;   /* 13: etichette, intestazioni di tabella, note */
  --fs-sm: 0.9375rem;   /* 15: controlli, testo secondario */
  --fs-md: 1rem;        /* 16: testo */
  --fs-lg: 1.25rem;     /* 20: titoli di scheda, righe della classifica */
  --fs-xl: 1.75rem;     /* 28: numeri, nome dell'evento */
  --fs-2xl: 2.5rem;     /* 40: titolo di pagina */
  --lh: 1.5;
  --lh-tight: 1.2;

  /* Forme e misure */
  --radius-s: 10px;
  --radius: 16px;
  --control-h: 2.5rem;  /* pulsanti, pillole, campi: stessa altezza */
  --cell-y: 0.75rem;
  --cell-x: 1rem;
  --gutter: 1rem;       /* margine laterale minimo */
  --page-w: 61.25rem;   /* 980 px; ogni pagina può cambiarla */
}
@media (max-width: 560px) {
  :root { --cell-x: 0.375rem; --cell-y: 0.625rem; }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--lg-gradient) fixed;
  background-color: var(--bg);
  color: var(--text);
  font: var(--fs-md) / var(--lh) var(--font-sans);
}
a { color: var(--accent); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
[hidden] { display: none !important; }

/* Pagina: una colonna centrata, un bordo sinistro per tutto il contenuto */
.lg-page {
  width: min(100% - 2 * var(--gutter), var(--page-w));
  margin-inline: auto;
  padding-block: var(--sp-5) var(--sp-7);
}

/* Barra in alto: logo a sinistra, il resto a destra, centrati sulla stessa linea */
.lg-topbar {
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: max(var(--sp-3), calc(var(--brand-h, 32px) * 0.5)) var(--sp-5);
  min-height: max(var(--brand-h, 32px), var(--control-h));
}

/* Logo: altezza decisa dalla pagina con --brand-h. Spazio libero attorno: metà dell'altezza del logo
   (≈ diametro di un punto del marchio). */
.brand { display: inline-flex; align-items: center; line-height: 0; text-decoration: none; flex: none; }
.brand img { display: block; height: var(--brand-h, 32px); width: auto; }
.brand:focus-visible { outline-offset: 6px; border-radius: 6px; }
/* Versione per fondi chiari, usata in stampa (le pagine che la includono hanno due <img>). */
.brand .on-light { display: none; }
@media print {
  .brand .on-dark { display: none; }
  .brand .on-light { display: block; }
}

/* Etichetta di sezione e riga «etichetta + azione» */
.lg-label {
  margin: 0;
  font-size: var(--fs-label, var(--fs-xs)); line-height: var(--lh-tight);
  font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--muted);
}
.lg-head {
  display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3);
  min-height: var(--control-h);
  margin: var(--sp-6) 0 var(--sp-3);
}
.lg-head > * { margin: 0; }

/* Superfici */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: var(--sp-4); }
.muted { color: var(--muted); }
.empty { color: var(--muted); margin: 0; }
.mono { font-family: var(--font-mono); font-size: 0.92em; }

/* Pillole (filtri) e pulsanti: stessa altezza */
.pills { display: flex; flex-wrap: wrap; gap: var(--sp-2); margin: 0 0 var(--sp-3); }
.pill {
  display: inline-flex; align-items: center; gap: 0.4em;
  min-height: var(--control-h); padding: 0 var(--sp-4);
  border-radius: 999px; border: 1px solid var(--line); background: var(--card);
  color: var(--muted); font: inherit; font-size: var(--fs-sm); line-height: 1; cursor: pointer;
}
.pill:hover { color: var(--text); border-color: var(--muted); }
.pill.on { border-color: var(--accent); color: var(--accent); font-weight: 600; }
/* Nomi lunghi (Sasso Carta Forbice Lizard Spock) sul telefono: la pillola non supera la riga, il nome si tronca
   e resta intero nel title */
.pill { max-width: 100%; }
.pill .pill-label { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; line-height: 1.2; }

/* Icone dei giochi (assets/games.js): emoji, il gesto di Spock di Font Awesome, l'immagine del Tris 4×4.
   Font Awesome Free 6.7.2 Regular: icone CC BY 4.0, font SIL OFL 1.1 (https://fontawesome.com/license/free). */
@font-face {
  font-family: "LG Hands";
  src: url("fonts/fa-regular-400.woff2") format("woff2");
  font-weight: 400; font-style: normal; font-display: swap;
}
.game-icon { display: inline-block; flex: none; line-height: 1; vertical-align: -0.15em; }
.game-icon .fa-hand { font-family: "LG Hands"; font-weight: 400; font-style: normal; font-size: 1.1em; }
img.game-icon { width: 1.2em; height: 1.2em; vertical-align: -0.25em; }
.tile .game-icon, .tile .fa-hand { min-height: 0; }

/* Tabelle: stessa spaziatura per intestazioni, righe e stato vuoto */
.table { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow-x: auto; }
.table table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: var(--cell-y) var(--cell-x); text-align: left; vertical-align: middle; }
.table th {
  font-size: var(--fs-xs); font-weight: 600; line-height: var(--lh-tight); color: var(--muted);
  white-space: nowrap; border-bottom: 1px solid var(--line);
}
.table td { border-bottom: 1px solid var(--line); }
.table tr:last-child td { border-bottom: 0; }
.table .rank, .table .n { width: 1%; text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.table td.rank { color: var(--muted); }
.table .name { width: 100%; overflow-wrap: break-word; }
@media (max-width: 560px) {
  /* sul telefono la tabella deve stare nello schermo: intestazioni più piccole, nomi lunghi spezzati */
  .table th { font-size: 0.75rem; }
  .table .name { overflow-wrap: anywhere; }
}
.table td.cell-empty { color: var(--muted); }
.table tr.first td.rank, .table tr.first td.name { color: var(--accent); font-weight: 700; }
.w { color: var(--accent); }
.l { color: var(--danger); }
.d { color: var(--muted); }

/* Etichetta corta che apre una riga (lingua, stato): larghezza fissa, così il testo dopo parte allo stesso x */
.tag {
  display: inline-block; flex: none; min-width: 2.25rem; text-align: left;
  font-size: var(--fs-xs); font-weight: 700; letter-spacing: 0.04em; color: var(--text);
}

/* Riquadri numerici: righe di pari altezza, numero in alto, etichetta su due righe al massimo */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(8.5rem, 1fr)); grid-auto-rows: 1fr; gap: var(--sp-3); }
.tile {
  display: flex; flex-direction: column; gap: var(--sp-1);
  background: var(--sunk); border: 1px solid var(--line); border-radius: var(--radius-s);
  padding: var(--sp-3) var(--sp-4);
}
.tile b { font-size: var(--fs-xl); line-height: var(--lh-tight); font-variant-numeric: tabular-nums; color: var(--accent); }
.tile span { font-size: var(--fs-xs); line-height: 1.35; color: var(--muted); min-height: 2.7em; }
