/* Dark come tema di base; il tema chiaro è un override su [data-theme="light"].
   I colori chiari non sono l'inverso di quelli scuri: ogni tema ha i suoi valori,
   scelti per restare sopra 4.5:1 sul proprio fondo. */

:root {
  --bg: #10131b;
  --surface: #191e29;
  --surface-2: #232a38;
  --text: #edf1f8;
  --text-muted: #9fabc0;
  --border: #333c4e;
  --accent: #7c8dff;
  --on-accent: #0b0e18;
  --gold: #ffd447;
  --danger: #ff7a7a;
  --ok: #4ade80;
  --scrim: rgba(0, 0, 0, 0.64);

  --pc-default: #edf1f8;
  --pc-red: #ff4d6d;
  --pc-orange: #ff9124;
  --pc-yellow: #ffd21f;
  --pc-green: #2ee87f;
  --pc-teal: #16dcc4;
  --pc-blue: #4d94ff;
  --pc-purple: #b96bff;
  --pc-pink: #ff5fb2;

  --tint: 20%;
  --radius: 16px;
  --tabbar-h: 64px;
  --shadow-bar: 0 10px 30px rgba(0, 0, 0, 0.45);
  /* Quanto resta pieno il fondo della barra flottante sopra la sfocatura:
     abbastanza da tenere le etichette leggibili anche quando sotto passa
     una card di colore acceso. */
  --bar-opacity: 78%;
}

[data-theme="light"] {
  --bg: #f5f7fc;
  --surface: #ffffff;
  --surface-2: #eceff7;
  --text: #161b26;
  --text-muted: #5a6377;
  --border: #dde2ee;
  --accent: #4f46e5;
  --on-accent: #ffffff;
  --gold: #b4820a;
  --danger: #d92d2d;
  --ok: #16a34a;
  --scrim: rgba(15, 20, 30, 0.42);

  --pc-default: #161b26;
  --pc-red: #e11d48;
  --pc-orange: #ea580c;
  --pc-yellow: #b45309;
  --pc-green: #059669;
  --pc-teal: #0d9488;
  --pc-blue: #2563eb;
  --pc-purple: #7c3aed;
  --pc-pink: #db2777;

  --tint: 14%;
  --shadow-bar: 0 8px 24px rgba(30, 40, 70, 0.14);
  --bar-opacity: 80%;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.5;
}

.screen { min-height: 100dvh; display: flex; flex-direction: column; }
[hidden] { display: none !important; }

.ic {
  width: 22px;
  height: 22px;
  flex-shrink: 0;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ---------- login ---------- */

#login, #register { align-items: center; justify-content: center; padding: 24px; }

.login-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px 26px;
  width: 100%;
  max-width: 340px;
  text-align: center;
}

.login-mark { width: 76px; height: 76px; display: block; margin: 0 auto 4px; border-radius: 18px; }
.login-box h1 { margin: 12px 0 6px; font-size: 1.5rem; }
.muted { color: var(--text-muted); font-size: 0.9rem; margin: 0 0 20px; }

/* ---------- struttura ---------- */

.topbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: max(12px, env(safe-area-inset-top)) 16px 12px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}

.topbar h1 {
  font-size: 1.15rem;
  margin: 0;
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.badge {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ok);
  border: 1px solid var(--ok);
  border-radius: 999px;
  padding: 3px 9px;
  flex-shrink: 0;
}

/* Spazio in fondo perché il contenuto non finisca sotto la barra flottante. */
.content {
  flex: 1;
  padding: 16px 14px calc(var(--tabbar-h) + 46px + env(safe-area-inset-bottom));
  max-width: 720px;
  width: 100%;
  margin: 0 auto;
}

.tab { display: flex; flex-direction: column; gap: 14px; }

/* ---------- controlli ---------- */

button {
  font: inherit;
  cursor: pointer;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  padding: 10px 14px;
  transition: background-color 0.13s ease, opacity 0.13s ease;
}

button:active { background: var(--border); }
button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

button.primary {
  background: var(--accent);
  color: var(--on-accent);
  border-color: transparent;
  font-weight: 600;
}

button.primary:active { opacity: 0.78; background: var(--accent); }

button.big {
  padding: 15px;
  font-size: 1.02rem;
  width: 100%;
  border-radius: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
}

/* Salvataggio: azione secondaria, in fondo alla pagina e più contenuta. */
button.save-small {
  align-self: center;
  width: auto;
  min-width: 210px;
  padding: 11px 22px;
  margin-top: 4px;
  font-size: 0.92rem;
  border-radius: 999px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

button.save-small .ic { width: 18px; height: 18px; }

button.ghost { background: transparent; }
button.ghost:active { background: var(--surface-2); }
button.danger { color: var(--danger); }

.icon-btn {
  background: transparent;
  border: none;
  font-size: 1.4rem;
  line-height: 1;
  min-width: 44px;
  min-height: 44px;
  color: var(--text-muted);
}

input, select {
  font: inherit;
  width: 100%;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  margin-bottom: 12px;
}

input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: -1px; }

.error { color: var(--danger); font-size: 0.88rem; margin: 0 0 12px; }
label.field { display: block; font-size: 0.88rem; color: var(--text-muted); margin-bottom: 5px; }

/* Interruttori: restano <input type="checkbox"> per semantica e tastiera,
   ma vengono disegnati come toggle. */
label.check {
  display: flex;
  align-items: center;
  gap: 14px;
  justify-content: space-between;
  min-height: 48px;
  font-size: 0.95rem;
  cursor: pointer;
}

label.check span { order: -1; }

label.check input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  position: relative;
  width: 50px;
  height: 30px;
  margin: 0;
  padding: 0;
  flex-shrink: 0;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: background-color 0.18s ease, border-color 0.18s ease;
}

label.check input[type="checkbox"]::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--text-muted);
  transition: transform 0.18s ease, background-color 0.18s ease;
}

label.check input[type="checkbox"]:checked {
  background: var(--accent);
  border-color: transparent;
}

label.check input[type="checkbox"]:checked::after {
  transform: translateX(20px);
  background: var(--on-accent);
}

label.check input[type="checkbox"]:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

/* ---------- barra inferiore ---------- */

/* Barra flottante a pillola, staccata dai bordi. */
#tabbar {
  position: fixed;
  left: 0; right: 0;
  bottom: calc(12px + env(safe-area-inset-bottom));
  margin: 0 auto;
  max-width: min(460px, calc(100% - 24px));
  z-index: 20;
  display: flex;
  gap: 4px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 26px;
  padding: 6px;
  box-shadow: var(--shadow-bar);
}

/* Vetro smerigliato: il contenuto che scorre sotto la barra si intravede
   sfocato invece di sparire dietro un pannello pieno.
   Il fondo diventa semitrasparente SOLO dove il browser sa sfocare davvero:
   senza `backdrop-filter` una barra translucida lascerebbe passare il testo
   nitido di sotto, illeggibile. Per questo sta tutto in un @supports e il
   fondo pieno resta come ripiego. */
@supports (backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px)) {
  #tabbar {
    background: color-mix(in srgb, var(--surface) var(--bar-opacity), transparent);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    backdrop-filter: blur(20px) saturate(180%);
  }
}

/* Chi ha chiesto meno trasparenza al sistema si riprende la barra piena. */
@media (prefers-reduced-transparency: reduce) {
  #tabbar {
    background: var(--surface);
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
  }
}

.tabbtn {
  flex: 1;
  border: none;
  border-radius: 20px;
  background: transparent;
  color: var(--text-muted);
  height: 52px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  font-size: 0.72rem;
  font-weight: 500;
  padding: 0;
}

.tabbtn[aria-current="page"] {
  color: var(--accent);
  font-weight: 600;
  background: color-mix(in srgb, var(--accent) 16%, transparent);
}

.tabbtn:active { background: color-mix(in srgb, var(--accent) 26%, transparent); }

/* ---------- lista partite ---------- */

#games { display: flex; flex-direction: column; gap: 10px; }

.game-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 8px 14px 16px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.game-card .info { flex: 1; min-width: 0; cursor: pointer; padding: 2px 0; }
.game-card .name { font-weight: 600; margin-bottom: 2px; }
.game-card .meta { font-size: 0.84rem; color: var(--text-muted); }
.game-card.current { border-color: var(--accent); }

.empty { text-align: center; color: var(--text-muted); padding: 28px 12px; margin: 0; }

/* ---------- riepilogo squadre ---------- */

.teamstrip { display: flex; gap: 10px; }

.tchip {
  flex: 1;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 10px 14px;
}

.tchip.lead { border-color: var(--gold); }
.tchip .tn { font-size: 0.85rem; color: var(--text-muted); }
.tchip .tp { font-size: 1.25rem; font-weight: 700; font-variant-numeric: tabular-nums; }

/* ---------- card giocatore ---------- */

#standings { display: flex; flex-direction: column; gap: 12px; }

.pcard {
  --pc: var(--pc-default);
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface);
  background: color-mix(in srgb, var(--pc) var(--tint), var(--surface));
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 12px;
}

.pcard[data-color="red"]    { --pc: var(--pc-red); }
.pcard[data-color="orange"] { --pc: var(--pc-orange); }
.pcard[data-color="yellow"] { --pc: var(--pc-yellow); }
.pcard[data-color="green"]  { --pc: var(--pc-green); }
.pcard[data-color="teal"]   { --pc: var(--pc-teal); }
.pcard[data-color="blue"]   { --pc: var(--pc-blue); }
.pcard[data-color="purple"] { --pc: var(--pc-purple); }
.pcard[data-color="pink"]   { --pc: var(--pc-pink); }

.pcard.leader { border-color: var(--gold); border-width: 2px; padding: 11px; }
.pcard.out { opacity: 0.6; }

.pcard .step {
  width: 58px;
  height: 58px;
  flex-shrink: 0;
  border-radius: 50%;
  font-size: 1.7rem;
  font-weight: 600;
  line-height: 1;
  background: var(--surface);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.pcard .mid {
  flex: 1;
  min-width: 0;
  text-align: center;
  cursor: pointer;
  padding: 6px 2px;
  border-radius: 10px;
}

.pcard .mid:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

.pcard .nm {
  font-weight: 600;
  font-size: 0.98rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pcard .sc {
  font-size: 2rem;
  font-weight: 700;
  line-height: 1.15;
  font-variant-numeric: tabular-nums;
  color: var(--pc);
}

.pcard .tm { font-size: 0.78rem; color: var(--text-muted); }

/* ---------- barra strumenti punteggio ---------- */

#score-tools { display: flex; flex-direction: column; gap: 8px; }

.tools { display: flex; gap: 8px; }

.hint {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin: 0;
  text-align: center;
  line-height: 1.35;
}

.chip {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 11px 12px;
  border-radius: 999px;
  font-size: 0.86rem;
  font-weight: 500;
  min-height: 44px;
}

.chip .ic { width: 17px; height: 17px; }
.chip.icon-only { flex: 0 0 auto; padding: 11px 15px; }

/* ---------- trascinamento ---------- */

/* pan-y lascia scorrere la pagina; durante il trascinamento passa a none. */
.pcard { touch-action: pan-y; -webkit-user-select: none; user-select: none; }

.pcard.dragging {
  position: relative;
  z-index: 5;
  touch-action: none;
  cursor: grabbing;
  box-shadow: 0 14px 32px rgba(0, 0, 0, 0.42);
  border-color: var(--accent);
}

/* ---------- modale ---------- */

.modal {
  position: fixed;
  inset: 0;
  background: var(--scrim);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 100;
}

@media (min-width: 560px) { .modal { align-items: center; padding: 20px; } }

.modal-box {
  background: var(--surface);
  border-radius: 24px 24px 0 0;
  padding: 22px 20px calc(20px + env(safe-area-inset-bottom));
  width: 100%;
  max-width: 440px;
  max-height: 88dvh;
  overflow-y: auto;
}

@media (min-width: 560px) { .modal-box { border-radius: 24px; } }

.modal-box h2 { margin: 0 0 16px; font-size: 1.15rem; }
.modal-actions { display: flex; gap: 10px; margin-top: 18px; }
.modal-actions button { flex: 1; padding: 13px; }

.player-edit { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.player-edit input { margin: 0; }
.player-edit select { margin: 0; width: auto; flex-shrink: 0; }

.menu-item {
  display: block;
  width: 100%;
  text-align: left;
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--border);
  border-radius: 0;
  padding: 15px 4px;
  min-height: 48px;
}

.menu-item:last-child { border-bottom: none; }

.sec-title {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-muted);
  margin: 22px 0 10px;
  font-weight: 600;
}

.sec-title:first-child { margin-top: 0; }

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}

/* ---------- scheda giocatore ---------- */

.swatches { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 16px; }

.sw {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  padding: 0;
  border: 1px solid var(--border);
}

.sw.on { outline: 3px solid var(--text); outline-offset: 2px; }
.sw[data-color="default"] { background: var(--pc-default); }
.sw[data-color="red"]     { background: var(--pc-red); }
.sw[data-color="orange"]  { background: var(--pc-orange); }
.sw[data-color="yellow"]  { background: var(--pc-yellow); }
.sw[data-color="green"]   { background: var(--pc-green); }
.sw[data-color="teal"]    { background: var(--pc-teal); }
.sw[data-color="blue"]    { background: var(--pc-blue); }
.sw[data-color="purple"]  { background: var(--pc-purple); }
.sw[data-color="pink"]    { background: var(--pc-pink); }

.preview {
  font-size: 2.4rem;
  font-weight: 700;
  text-align: center;
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
}

.delta {
  text-align: center;
  font-size: 0.85rem;
  color: var(--text-muted);
  min-height: 1.3em;
  margin-bottom: 12px;
}

.ops { display: flex; gap: 8px; }
.ops button { flex: 1; padding: 13px 4px; }

/* Operazione scelta ma non ancora confermata. */
.ops button.on {
  background: var(--accent);
  color: var(--on-accent);
  border-color: transparent;
  font-weight: 600;
}

.ops button.on:active { opacity: 0.8; background: var(--accent); }

/* ---------- cronologia ---------- */

.history { display: flex; flex-direction: column; gap: 12px; }

.hgroup {
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 10px 12px;
  background: var(--bg);
}

.hgroup.single { background: transparent; }

.hhead {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 6px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
}

.hlabel { font-weight: 600; font-size: 0.92rem; }

.hrow {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 9px 4px;
  border-radius: 8px;
  cursor: pointer;
  min-height: 44px;
}

.hrow:active { background: var(--surface-2); }
.hrow:focus-visible { outline: 2px solid var(--accent); }
.hrow .hn { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hrow .hd { font-weight: 700; font-variant-numeric: tabular-nums; }
.hrow .hd.pos { color: var(--ok); }
.hrow .hd.neg { color: var(--danger); }
.ht { font-size: 0.8rem; color: var(--text-muted); font-variant-numeric: tabular-nums; }

.legend { margin: 14px 0 0; font-size: 0.8rem; line-height: 1.45; }

/* ---------- separatore e modalità ospite ---------- */

.or-sep {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 18px 0 14px;
  color: var(--text-muted);
  font-size: 0.8rem;
}

.or-sep::before,
.or-sep::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border);
}

.limits {
  margin: 0 0 14px;
  padding-left: 20px;
  color: var(--text-muted);
  font-size: 0.88rem;
  line-height: 1.5;
}

.limits li { margin-bottom: 6px; }

.google-btn { background: var(--surface); }
.google-btn:active { background: var(--surface-2); }
.g-mark { width: 19px; height: 19px; flex-shrink: 0; }

/* Stacca l'accesso come ospite da quello con Google: sono due scelte diverse,
   non due varianti della stessa. Doppio id per superare la regola su
   "#register-form button.ghost". */
#login #guest-login,
#register-form #guest-register { margin-top: 18px; }

/* ---------- notifiche amicizia ---------- */

.icon-btn.notif { position: relative; flex-shrink: 0; margin-left: -6px; }
.icon-btn.notif .ic { width: 23px; height: 23px; }

.notif-dot {
  position: absolute;
  top: 4px;
  right: 4px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--danger);
  color: var(--bg);
  font-size: 0.68rem;
  font-weight: 700;
  line-height: 18px;
  text-align: center;
}

.mini { padding: 7px 12px; font-size: 0.82rem; border-radius: 999px; flex-shrink: 0; }
.mini.primary { background: var(--accent); color: var(--on-accent); border-color: transparent; }

/* I suggerimenti sono una tendina che galleggia sopra il contenuto: se
   stessero nel flusso, comparendo e sparendo mentre si scrive farebbero
   crescere la finestra e sposterebbero il campo del nome. */
.addbar { position: relative; z-index: 2; }

.suggest {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 232px;
  overflow-y: auto;
  overscroll-behavior: contain;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 6px;
  box-shadow: var(--shadow-bar);
}

/* Senza risultati non deve restare il riquadro vuoto. */
.suggest:empty { display: none; }

.sugg {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: 999px;
  background: var(--surface-2);
  font-size: 0.9rem;
  text-align: left;
}

/* ---------- profilo e foto ---------- */

.avatar {
  border-radius: 50%;
  flex-shrink: 0;
  object-fit: cover;
  background: var(--surface-2);
  border: 1px solid var(--border);
  display: block;
}

.avatar.initials {
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  color: var(--text-muted);
  line-height: 1;
}

.profile {
  display: flex;
  align-items: center;
  gap: 16px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 4px;
}

.profile-info { flex: 1; min-width: 0; }
.profile-info .pname { font-weight: 600; font-size: 1.05rem; }
.profile-info .prole { font-size: 0.84rem; color: var(--text-muted); margin-bottom: 8px; }
.profile-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.profile-actions button { padding: 8px 14px; font-size: 0.85rem; }

.tag.linked { color: var(--accent); border-color: var(--accent); }
.badge.readonly { color: var(--text-muted); border-color: var(--border); }

.game-card .name { display: flex; align-items: center; gap: 8px; }
.game-card .name > span:first-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pcard .step:disabled { opacity: 0.35; cursor: default; }

/* ---------- account e utenti ---------- */

#mfa-form button.ghost { width: 100%; margin-top: 8px; }
#mfa-code { text-align: center; letter-spacing: 0.35em; font-size: 1.3rem; }

.muted.small { font-size: 0.82rem; margin: 8px 0 4px; }

.accrow {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  padding: 9px 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.94rem;
}

.accrow span { color: var(--text-muted); }

.secretbox {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 1.05rem;
  letter-spacing: 0.08em;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px;
  text-align: center;
  word-break: break-all;
  margin-bottom: 10px;
}

.inline-actions { display: flex; gap: 8px; margin-bottom: 4px; }
.inline-actions button { flex: 1; }

.userlist { display: flex; flex-direction: column; }

.userrow {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 4px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  min-height: 48px;
}

.userrow:last-child { border-bottom: none; }
.userrow:active { background: var(--surface-2); }
.userrow:focus-visible { outline: 2px solid var(--accent); }
.userrow .un { flex: 1; min-width: 0; font-weight: 500; overflow: hidden; text-overflow: ellipsis; }

.tag {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 3px 9px;
  flex-shrink: 0;
}

.tag.admin { color: var(--accent); border-color: var(--accent); }
.tag.mfa { color: var(--ok); border-color: var(--ok); }
.tag.ok { color: var(--ok); border-color: var(--ok); }
.tag.off { color: var(--text-muted); }

.userrow.static { cursor: default; }
.userrow.static:active { background: transparent; }

#register-form button.ghost { width: 100%; margin-top: 8px; }

/* ---------- link di invito ---------- */

.invitelist { display: flex; flex-direction: column; margin-top: 8px; }

.inviterow {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 13px 4px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  min-height: 52px;
}

.inviterow:last-child { border-bottom: none; }
.inviterow:active { background: var(--surface-2); }
.inviterow:focus-visible { outline: 2px solid var(--accent); }
.inviterow .ileft { flex: 1; min-width: 0; }
.inviterow .iname { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.inviterow .imeta { font-size: 0.82rem; color: var(--text-muted); }

.linkbox {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.82rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px;
  word-break: break-all;
  margin-bottom: 10px;
  line-height: 1.5;
}

/* ---------- aggiunta giocatori ---------- */

.addform { display: flex; gap: 8px; align-items: stretch; }
.addform input { margin: 0; }
.addform button { flex-shrink: 0; padding: 12px 18px; }

/* Altezza fissa, non "massima": la finestra deve avere la stessa dimensione
   con zero giocatori e con dieci, altrimenti ogni aggiunta la fa crescere e
   — essendo il foglio ancorato in basso — spinge in alto il campo del nome.
   A crescere è solo il contenuto, che scorre qui dentro. */
.addedlist {
  margin-top: 16px;
  display: flex;
  flex-direction: column;
  height: clamp(132px, 34dvh, 300px);
  overflow-y: auto;
  overscroll-behavior: contain;
}

.addedlist .empty { margin: 0; }

.addedrow {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
  /* In un contenitore flex ad altezza fissa le righe si schiaccerebbero
     invece di far scorrere la lista. */
  flex-shrink: 0;
}

.addedrow:last-child { border-bottom: none; }
.addedrow .an { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.addedrow .dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
  background: var(--pc-default);
}

.addedrow .dot[data-color="red"]    { background: var(--pc-red); }
.addedrow .dot[data-color="orange"] { background: var(--pc-orange); }
.addedrow .dot[data-color="yellow"] { background: var(--pc-yellow); }
.addedrow .dot[data-color="green"]  { background: var(--pc-green); }
.addedrow .dot[data-color="teal"]   { background: var(--pc-teal); }
.addedrow .dot[data-color="blue"]   { background: var(--pc-blue); }
.addedrow .dot[data-color="purple"] { background: var(--pc-purple); }
.addedrow .dot[data-color="pink"]   { background: var(--pc-pink); }

/* ---------- toast ---------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--tabbar-h) + 38px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  background: var(--text);
  color: var(--bg);
  padding: 11px 18px;
  border-radius: 999px;
  font-size: 0.9rem;
  z-index: 200;
  max-width: 90vw;
  text-align: center;
}

/* ---------- animazioni ---------- */

/* Cambio scheda: entra dal lato da cui si è arrivati. */
@keyframes enter-from-right {
  from { opacity: 0; transform: translateX(26px); }
  to { opacity: 1; transform: none; }
}

@keyframes enter-from-left {
  from { opacity: 0; transform: translateX(-26px); }
  to { opacity: 1; transform: none; }
}

.tab.enter-right { animation: enter-from-right 0.24s cubic-bezier(0.22, 0.8, 0.3, 1); }
.tab.enter-left { animation: enter-from-left 0.24s cubic-bezier(0.22, 0.8, 0.3, 1); }

/* Finestre: sul telefono salgono dal basso come un foglio, su schermi larghi
   compaiono al centro con una scala appena percettibile. */
@keyframes scrim-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes scrim-out { from { opacity: 1; } to { opacity: 0; } }

@keyframes sheet-up {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

@keyframes sheet-down {
  from { transform: translateY(0); }
  to { transform: translateY(100%); }
}

@keyframes pop-in {
  from { opacity: 0; transform: scale(0.96); }
  to { opacity: 1; transform: none; }
}

@keyframes pop-out {
  from { opacity: 1; transform: none; }
  to { opacity: 0; transform: scale(0.97); }
}

.modal { animation: scrim-in 0.18s ease-out; }
.modal .modal-box { animation: sheet-up 0.28s cubic-bezier(0.22, 0.8, 0.28, 1); }

.modal.closing { animation: scrim-out 0.17s ease-in forwards; }
.modal.closing .modal-box { animation: sheet-down 0.17s ease-in forwards; }

@media (min-width: 560px) {
  .modal .modal-box { animation: pop-in 0.2s cubic-bezier(0.22, 0.8, 0.3, 1); }
  .modal.closing .modal-box { animation: pop-out 0.15s ease-in forwards; }
}

/* Il toast entra dal basso senza rubare l'attenzione. */
@keyframes toast-in {
  from { opacity: 0; transform: translate(-50%, 12px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

.toast { animation: toast-in 0.22s cubic-bezier(0.22, 0.8, 0.3, 1); }

@media (prefers-reduced-motion: reduce) {
  * { transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; }
}
