:root {
  --bg-1: #0b0f2b;
  --bg-2: #1a1044;
  --accent: #ffcb47;
  --accent-2: #ff4d6d;
  --neon-cyan: #00f0ff;
  --neon-magenta: #ff2fd0;
  --text: #f5f5ff;
  --text-dim: #a8a8c8;
  --card-bg: rgba(255, 255, 255, 0.06);
  --card-bg-hover: rgba(255, 255, 255, 0.1);
  --card-border: rgba(255, 255, 255, 0.14);
  --radius-lg: 20px;
  --radius-md: 14px;
  --radius-sm: 8px;
  --font-display: 'Bebas Neue', sans-serif;
  --font-pixel: 'Press Start 2P', 'Bebas Neue', cursive;
  --font-body: 'Poppins', sans-serif;
  /* Tubo Catodico x PS1: nuovi ruoli tipografici accanto a quelli esistenti,
     nessuno sostituito - vedi Palle 4.0 (artifact di riferimento approvato). */
  --font-tech: 'Rajdhani', sans-serif;
  --font-mono: 'Share Tech Mono', monospace;
  --neon-term: #5dffb0;
}

/* Bordo "plastica premibile" in stile menu PS1: luce in alto a sinistra,
   ombra in basso a destra, nessuna sfumatura morbida. Riusato da bottoni,
   card e pannelli - un'unica dichiarazione, effetto coerente ovunque. */
.ps1-bevel {
  box-shadow:
    inset 2px 2px 0 rgba(255, 255, 255, 0.10),
    inset -2px -2px 0 rgba(0, 0, 0, 0.35);
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  font-family: var(--font-body);
  color: var(--text);
  background:
    radial-gradient(circle at 15% 10%, rgba(255, 203, 71, 0.12), transparent 40%),
    radial-gradient(circle at 85% 15%, rgba(0, 240, 255, 0.1), transparent 40%),
    radial-gradient(circle at 85% 90%, rgba(255, 47, 208, 0.14), transparent 45%),
    repeating-linear-gradient(0deg, rgba(255, 255, 255, 0.03) 0px, rgba(255, 255, 255, 0.03) 1px, transparent 1px, transparent 3px),
    linear-gradient(160deg, var(--bg-1), var(--bg-2));
  min-height: 100vh;
  overflow-x: hidden;
  position: relative;
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background-image:
    linear-gradient(rgba(0, 240, 255, 0.06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0, 240, 255, 0.06) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: radial-gradient(ellipse 80% 60% at 50% 100%, black 40%, transparent 90%);
  -webkit-mask-image: radial-gradient(ellipse 80% 60% at 50% 100%, black 40%, transparent 90%);
}

.app-shell {
  position: relative;
  z-index: 1;
}

/* Vignettatura da tubo catodico: ai bordi dello schermo, ovunque nel sito */
/* Effetto tubo catodico vero: scanline che scorrono lentissime, un bagliore
   diagonale da vetro dello schermo, vignettatura ai bordi, e un flicker
   appena percettibile - tre livelli in un solo elemento, il secondo (le
   scanline) è l'unico che si muove. */
body::after {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 5;
  background-image:
    linear-gradient(115deg, rgba(255, 255, 255, 0.1) 0%, transparent 20%, transparent 80%, rgba(255, 255, 255, 0.06) 100%),
    repeating-linear-gradient(rgba(0, 0, 0, 0) 0px, rgba(0, 0, 0, 0) 2px, rgba(0, 0, 0, 0.1) 2px, rgba(0, 0, 0, 0.1) 4px),
    radial-gradient(ellipse at 50% 45%, transparent 62%, rgba(0, 0, 0, 0.22) 100%);
  background-position: 0 0, 0 0, 0 0;
  animation: crt-scan-drift 4s linear infinite, crt-flicker 3.2s ease-in-out infinite;
}

@keyframes crt-scan-drift {
  from { background-position: 0 0, 0 0, 0 0; }
  to { background-position: 0 0, 0 40px, 0 0; }
}

@keyframes crt-flicker {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.88; }
  52% { opacity: 1; }
  74% { opacity: 0.92; }
  76% { opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  body::after { animation: none; }
}

button {
  font-family: var(--font-body);
  cursor: pointer;
}

.app-shell {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ---------- Scoreboard bar ---------- */

.scoreboard-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  padding: 14px 24px;
  background: rgba(0, 0, 0, 0.25);
  border-bottom: 1px solid var(--card-border);
  align-items: center;
}

.scoreboard-title {
  font-family: var(--font-display);
  font-size: 22px;
  letter-spacing: 1px;
  color: var(--accent);
  text-shadow: 1px 0 rgba(255, 47, 208, 0.4), -1px 0 rgba(0, 240, 255, 0.4);
  margin-right: 8px;
  white-space: nowrap;
}

.team-pill {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #171a35;
  border: 1px solid rgba(0, 240, 255, 0.3);
  border-radius: 999px;
  box-shadow: inset 2px 2px 0 rgba(255, 255, 255, 0.10), inset -2px -2px 0 rgba(0, 0, 0, 0.45);
  padding: 6px 8px 6px 14px;
}

.team-pill .swatch {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
}

.team-pill .name {
  font-weight: 600;
  font-size: 15px;
  white-space: nowrap;
}

.team-pill .score {
  font-family: var(--font-mono);
  color: var(--neon-term);
  font-size: 19px;
  min-width: 34px;
  text-align: center;
}

.team-pill .score-btn {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 1px solid var(--card-border);
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
  font-size: 16px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

.team-pill .score-btn:hover {
  background: rgba(255, 255, 255, 0.18);
}

/* ---------- Buttons ---------- */

.btn {
  border: 1px solid rgba(0, 240, 255, 0.45);
  background: #171a35;
  color: var(--text);
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-weight: 600;
  transition: background 0.15s ease, transform 0.1s ease, box-shadow 0.15s ease;
  box-shadow: inset 3px 3px 0 rgba(255, 255, 255, 0.22), inset -3px -3px 0 rgba(0, 0, 0, 0.6);
}

.btn:hover {
  background: var(--card-bg-hover);
  box-shadow: inset 1px 1px 0 rgba(255, 255, 255, 0.10), inset -1px -1px 0 rgba(0, 0, 0, 0.3), 0 0 0 1px var(--neon-cyan), 0 0 12px rgba(0, 240, 255, 0.35);
}

.btn:active {
  transform: scale(0.97);
}

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #2a1b00;
  box-shadow: inset 2px 2px 0 rgba(255, 255, 255, 0.65), inset -2px -2px 0 rgba(0, 0, 0, 0.35);
}

.btn-primary:hover {
  background: #ffd873;
  box-shadow: inset 1px 1px 0 rgba(255, 255, 255, 0.55), inset -1px -1px 0 rgba(0, 0, 0, 0.2), 0 0 14px rgba(255, 203, 71, 0.5);
}

.btn-danger {
  border-color: var(--accent-2);
  color: var(--accent-2);
}

.btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

/* Etichetta "In arrivo" per azioni non ancora cliccabili accanto ad altre
   già attive (es. lo Shop in home, vicino a Classifiche) - stessa palette
   accento delle card "status-demo", ma inline dentro un .btn normale. */
.badge-soon {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 2px 7px;
  border-radius: 999px;
  background: rgba(255, 203, 71, 0.25);
  color: var(--accent);
  margin-left: 6px;
  vertical-align: middle;
}

/* ---------- Stage (main content) ---------- */

.stage {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 24px;
  text-align: center;
}

.stage-inner {
  width: 100%;
  max-width: 980px;
  animation: fade-up 0.35s ease;
}

@keyframes fade-up {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ---------- Home / menu ---------- */

.home-title {
  font-family: var(--font-pixel);
  font-size: clamp(22px, 5vw, 44px);
  line-height: 1.5;
  letter-spacing: 1px;
  color: var(--accent);
  margin: 0 0 16px;
  text-shadow:
    0 0 14px rgba(255, 203, 71, 0.55),
    2px 0 rgba(255, 47, 208, 0.7),
    -2px 0 rgba(0, 240, 255, 0.7);
}

.brand-title {
  position: relative;
  display: inline-block;
}

.brand-title-sub {
  position: absolute;
  right: -4px;
  bottom: -2px;
  transform: rotate(-8deg);
  font-family: var(--font-body);
  font-style: italic;
  font-weight: 600;
  font-size: 0.22em;
  letter-spacing: 1px;
  color: var(--neon-cyan);
  text-shadow: none;
  white-space: nowrap;
}

.home-subtitle {
  color: var(--text-dim);
  margin: 0 0 36px;
  font-size: 18px;
}

.playing-as-line {
  color: var(--text-dim);
  font-family: var(--font-tech);
  font-size: 15px;
  letter-spacing: .3px;
  margin: 0 0 36px;
}
.playing-as-line strong {
  color: var(--accent);
  font-weight: 700;
}

.home-wrap {
  position: relative;
}

/* ---------- Accesso (login social / guest) ---------- */

.account-gate-grid {
  display: flex;
  flex-direction: column;
  gap: 16px;
  max-width: 340px;
  margin: 32px auto 0;
}

.account-gate-note {
  max-width: 340px;
  margin: 20px auto 0;
  color: var(--text-dim);
  font-size: 13px;
  line-height: 1.5;
}

.account-gate-grid-compact {
  flex-direction: row;
  flex-wrap: wrap;
  justify-content: center;
  max-width: 480px;
}

/* Pulsanti di login ufficiali Google/Discord - loghi/colori a norma, non uno
   stile inventato per il gioco. */
.btn-social {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  flex: 1 1 200px;
  padding: 11px 18px;
  border-radius: 6px;
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 14px;
  text-decoration: none;
  border: none;
  transition: filter 0.15s ease;
}

.btn-social:hover {
  filter: brightness(0.96);
}

.btn-social svg {
  flex-shrink: 0;
}

.btn-social-google {
  background: #ffffff;
  color: #3c4043;
  border: 1px solid #dadce0;
}

.btn-social-discord {
  background: #5865f2;
  color: #ffffff;
}

.user-badge {
  position: fixed;
  top: calc(18px + env(safe-area-inset-top, 0px));
  right: calc(18px + env(safe-area-inset-right, 0px));
  width: 48px;
  height: 48px;
  z-index: 60;
  cursor: default;
  padding: 0;
}

/* Non loggato: resta il vecchio pallino generico col "?" (nessuna cornice di
   livello da mostrare). Loggato: l'avatar-frame-wrap dentro (vedi
   renderUserBadge) porta già bordo/sfondo/anello suoi - niente doppia
   cornice qui sopra. */
.user-badge:not(.is-logged-in) {
  border-radius: 50%;
  border: 2px solid rgba(0, 240, 255, 0.28);
  background: #171a35;
  box-shadow: inset 2px 2px 0 rgba(255, 255, 255, 0.10), inset -2px -2px 0 rgba(0, 0, 0, 0.4);
  color: var(--text-dim);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-size: 20px;
  overflow: hidden;
}

.user-badge.is-logged-in {
  border: none;
  background: none;
  cursor: pointer;
}

@media (max-width: 640px) {
  .user-badge, .avatar-frame-wrap.corner { width: 40px; height: 40px; }
  .user-badge {
    top: calc(12px + env(safe-area-inset-top, 0px));
    right: calc(12px + env(safe-area-inset-right, 0px));
    font-size: 16px;
  }
}

.profile-name {
  font-family: var(--font-display);
  font-size: 22px;
  letter-spacing: 0.5px;
  text-shadow: 1px 0 rgba(255, 47, 208, 0.4), -1px 0 rgba(0, 240, 255, 0.4);
}

.profile-provider {
  color: var(--text-dim);
  font-size: 12px;
  margin-top: -6px;
}

/* ---------- Badge ---------- */

.badge-gallery-title {
  text-align: center;
  font-family: var(--font-display);
  font-size: 20px;
  color: var(--accent);
  margin-top: 30px;
  letter-spacing: 0.5px;
}

/* Album di figurine: medaglie ravvicinate, niente più rettangolo attorno a
   ciascuna (è una vetrina di sola lettura, non un'area di selezione - vedi
   renderBadgeGallery). Descrizione sempre visibile sotto al nome - dice come
   sbloccare il badge, troppo utile per nasconderla solo dietro un tooltip. */
.badge-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  gap: 14px 8px;
  margin-top: 14px;
}

.badge-gallery-item {
  text-align: center;
  padding: 2px;
  display: flex;
  flex-direction: column;
  align-items: center;
  cursor: pointer; /* tap sulla medaglia = espandi/richiudi la descrizione */
}

/* I non ottenuti devono saltare all'occhio come "da conquistare": medaglia
   spenta E lucchetto ben visibile in sovraimpressione, non solo un filtro
   leggero - nome e descrizione restano comunque sempre leggibili. */
.badge-gallery-item.is-locked .badge-name { color: var(--text-dim); }

/* Medaglie esagonali (non più cerchi dorati piatti): stesso trattamento
   riusato per lo slot Vetrina, la galleria "Tutti i badge" e il picker per
   scegliere cosa mettere in vetrina (vedi .showcase-icon/.badge-icon-lg/
   .badge-picker-icon sotto), colorate per rarità (badgeTier() in main.js) -
   stessa identica scala cromatica dell'anello avatar per livello. L'icona
   dentro è un vero disegno SVG (badgeIconHtml()), non più un'emoji. */
.badge-icon-lg, .showcase-icon, .badge-picker-icon {
  clip-path: polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%);
  border: none;
  border-radius: 0;
  display: flex; align-items: center; justify-content: center;
  box-shadow: inset 3px 4px 0 rgba(255, 255, 255, 0.32), inset -3px -4px 0 rgba(0, 0, 0, 0.4);
  position: relative;
  flex-shrink: 0;
}
/* Persa nel refactor per la forma esagonale: senza una misura fissa
   l'elemento (dentro una griglia flessibile) si allargava a riempire tutta
   la cella invece di restare una medaglia compatta. */
.badge-icon-lg {
  width: 50px; height: 50px;
  margin: 0 auto;
}
.badge-icon-lg.tier-bronze, .showcase-icon.tier-bronze, .badge-picker-icon.tier-bronze {
  background: conic-gradient(#c9860a, #7a5406, #c9860a, #e0a05c, #c9860a);
  filter: drop-shadow(0 0 6px rgba(201, 134, 10, 0.4));
}
.badge-icon-lg.tier-silver, .showcase-icon.tier-silver, .badge-picker-icon.tier-silver {
  background: conic-gradient(#d7d7e0, #8c8c9c, #d7d7e0, #f0f0f5, #d7d7e0);
  filter: drop-shadow(0 0 7px rgba(215, 215, 224, 0.4));
}
.badge-icon-lg.tier-gold, .showcase-icon.tier-gold, .badge-picker-icon.tier-gold {
  background: conic-gradient(#ffd873, #a3720a, #ffd873, #fff2c4, #ffd873);
  filter: drop-shadow(0 0 9px rgba(255, 216, 115, 0.5));
}
.badge-icon-lg.tier-red, .showcase-icon.tier-red, .badge-picker-icon.tier-red {
  background: conic-gradient(#ff3b3b, #8b0000, #ff3b3b, #ff8a00, #ff3b3b);
  filter: drop-shadow(0 0 10px rgba(255, 59, 59, 0.6));
  animation: badge-medal-flame-pulse 1.8s ease-in-out infinite;
}
@keyframes badge-medal-flame-pulse {
  0%, 100% { filter: drop-shadow(0 0 10px rgba(255, 59, 59, 0.6)); }
  50% { filter: drop-shadow(0 0 16px rgba(255, 59, 59, 0.9)); }
}
.badge-svg-icon {
  width: 60%; height: 60%;
  fill: #241a04;
  filter: drop-shadow(0 1px 0 rgba(255, 255, 255, 0.4));
}
/* "Metallo spento": stessa tinta del tier ma desaturata/scurita invece di un
   grigio uniforme - si riconosce ancora se vale bronzo/argento/oro/rosso
   anche prima di averlo ottenuto, non solo dopo. */
.badge-gallery-item.is-locked .badge-icon-lg {
  filter: none;
  animation: none;
}
.badge-gallery-item.is-locked .badge-icon-lg.tier-bronze {
  background: conic-gradient(#6b5a44, #423728, #6b5a44, #7d6b52, #6b5a44);
}
.badge-gallery-item.is-locked .badge-icon-lg.tier-silver {
  background: conic-gradient(#5c5c64, #3c3c42, #5c5c64, #6a6a72, #5c5c64);
}
.badge-gallery-item.is-locked .badge-icon-lg.tier-gold {
  background: conic-gradient(#6e6448, #463f2c, #6e6448, #7c7254, #6e6448);
}
.badge-gallery-item.is-locked .badge-icon-lg.tier-red {
  background: conic-gradient(#5c3f3f, #3a2626, #5c3f3f, #664c4c, #5c3f3f);
}
.badge-gallery-item.is-locked .badge-svg-icon { opacity: 0.55; filter: none; }
.badge-gallery-item.is-locked .badge-icon-lg::after {
  content: "🔒";
  position: absolute;
  bottom: -3px; right: -4px;
  width: 17px; height: 17px;
  border-radius: 50%;
  background: rgba(4, 5, 22, 0.9);
  border: 1px solid var(--card-border);
  font-size: 9px;
  display: flex; align-items: center; justify-content: center;
}

.badge-gallery-item .badge-name {
  font-weight: 700;
  font-size: 10.5px;
  margin-top: 6px;
  line-height: 1.2;
}

/* Altezza fissa a 2 righe (troncata oltre, testo pieno nel title) - così ogni
   medaglia occupa la STESSA altezza a prescindere da quanto è lunga la sua
   descrizione, non solo quelle sulla stessa riga della griglia. */
.badge-gallery-item .badge-desc {
  font-size: 9.5px;
  color: var(--text-dim);
  margin-top: 2px;
  line-height: 1.25;
  min-height: 24px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
/* Tap sulla medaglia per leggerla per intero (utile su mobile, dove il
   title/tooltip non è raggiungibile) - la cella si allunga, non sposta le
   altre righe della griglia in modo strano perché ognuna ha la sua altezza. */
.badge-gallery-item.is-expanded .badge-desc {
  -webkit-line-clamp: unset;
  min-height: 0;
}

/* margin-top:auto per allinearla sempre in fondo alla cella (che la griglia
   stira già all'altezza della riga), a prescindere da quanto testo ha la
   descrizione sopra - stessa quota per tutti i badge della stessa riga. */
.badge-pin-tag { font-size: 9.5px; font-weight: 700; color: var(--neon-term); margin-top: auto; padding-top: 3px; }

/* ---------- Profilo: cornice avatar per livello ---------- */
/* Riusata sia in profilo (grande, .lg) sia in classifica (piccola, .sm) -
   stessa forma dappertutto, si riconosce a colpo d'occhio. */

.avatar-frame-wrap { position: relative; flex-shrink: 0; }
.avatar-frame-wrap.lg { width: 128px; height: 128px; }
.avatar-frame-wrap.sm { width: 32px; height: 32px; }
/* Angolo in alto a destra (vedi renderUserBadge) - stessa cornice di
   profilo/classifica, misura intermedia tra .sm e .lg. */
.avatar-frame-wrap.corner { width: 48px; height: 48px; }
.avatar-ring { position: absolute; inset: 0; border-radius: 50%; }
.avatar-frame-wrap.lg .avatar-ring { padding: 5px; }
.avatar-frame-wrap.sm .avatar-ring { padding: 2px; }
.avatar-frame-wrap.corner .avatar-ring { padding: 3px; }
/* Soglie: 1-20=bronzo, 21-100=argento, 101-500=oro, 501+=rosso fiammante
   (vedi avatarTier() in main.js). */
.avatar-ring.tier-bronze {
  background: conic-gradient(#c9860a, #7a5406, #c9860a, #e0a05c, #c9860a);
  box-shadow: 0 0 10px rgba(201, 134, 10, 0.4);
}
.avatar-ring.tier-silver {
  background: conic-gradient(#d7d7e0, #8c8c9c, #d7d7e0, #f0f0f5, #d7d7e0);
  box-shadow: 0 0 12px rgba(215, 215, 224, 0.4);
}
.avatar-ring.tier-gold {
  background: conic-gradient(#ffd873, #a3720a, #ffd873, #fff2c4, #ffd873);
  box-shadow: 0 0 18px rgba(255, 216, 115, 0.55), 0 0 0 1px rgba(255, 216, 115, 0.35);
}
.avatar-ring.tier-red {
  background: conic-gradient(#ff3b3b, #8b0000, #ff3b3b, #ff8a00, #ff3b3b);
  box-shadow: 0 0 20px rgba(255, 59, 59, 0.6), 0 0 0 1px rgba(255, 138, 0, 0.45);
  animation: avatar-ring-flame-pulse 1.8s ease-in-out infinite;
}
@keyframes avatar-ring-flame-pulse {
  0%, 100% { box-shadow: 0 0 20px rgba(255, 59, 59, 0.6), 0 0 0 1px rgba(255, 138, 0, 0.45); }
  50% { box-shadow: 0 0 30px rgba(255, 59, 59, 0.88), 0 0 0 2px rgba(255, 138, 0, 0.65); }
}
.avatar-face {
  position: absolute;
  border-radius: 50%;
  background: linear-gradient(145deg, #2a2060, #171a35);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  border: 2px solid var(--bg-1, #0b0f2b);
  color: var(--text-dim);
  font-family: var(--font-display);
}
.avatar-frame-wrap.lg .avatar-face { inset: 5px; font-size: 44px; }
.avatar-frame-wrap.sm .avatar-face { inset: 2px; font-size: 12px; border-width: 1px; }
.avatar-frame-wrap.corner .avatar-face { inset: 3px; font-size: 18px; }
.avatar-face img { width: 100%; height: 100%; object-fit: cover; }

/* ---------- Profilo: layout a due colonne ---------- */

.profile-grid {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 20px;
  align-items: start;
  margin-top: 18px;
}

.profile-sidebar {
  background: #171a35;
  border: 1px solid var(--card-border);
  border-radius: var(--radius-lg);
  padding: 26px 20px 22px;
  text-align: center;
  position: sticky;
  top: 16px;
}
.profile-frame-wrap { position: relative; width: 128px; margin: 0 auto 14px; }
.profile-tier-chip {
  position: absolute;
  bottom: -6px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-1);
  border: 1px solid var(--accent);
  color: var(--accent);
  font-family: var(--font-tech);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.03em;
  padding: 3px 10px;
  border-radius: 999px;
  white-space: nowrap;
}
.profile-xp-block { margin-top: 20px; }
.profile-sidebar-divider { height: 1px; background: var(--card-border); margin: 18px 0; }
.profile-sidebar-stats { display: flex; flex-direction: column; gap: 9px; text-align: left; }
/* La sidebar è text-align:center di base (foto, livello...): il modulo Amici
   e la lista amici vera e propria vivono qui (vedi renderProfileCard) e vanno
   riportati a sinistra come nel resto del sito. */
.profile-sidebar .module,
.profile-sidebar .friend-subtitle,
.profile-sidebar .friend-list-sidebar,
.profile-sidebar .account-gate-note { text-align: left; }
.sidebar-stat-row {
  display: flex;
  justify-content: space-between;
  font-family: var(--font-tech);
  font-size: 12.5px;
  color: var(--text-dim);
}
.sidebar-stat-row span:last-child { font-family: var(--font-mono); color: var(--text); }
.profile-signout-btn { margin-top: 18px; width: 100%; }

.profile-main-col { display: flex; flex-direction: column; gap: 18px; }

.module {
  background: #171a35;
  border: 1px solid var(--card-border);
  border-radius: var(--radius-lg);
  padding: 18px 20px 20px;
}
.module-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.module-title { font-family: var(--font-tech); font-size: 14.5px; font-weight: 700; letter-spacing: 0.03em; }
.module-sub { font-size: 11px; color: var(--text-dim); font-family: var(--font-tech); }

/* Vetrina - niente più rettangolo attorno: l'area di selezione è la
   medaglia stessa (.showcase-icon), lo slot è solo un contenitore invisibile
   che centra medaglia+nome. Stato/hover si vedono sulla medaglia (bordo,
   glow, scale), mai su un box quadrato attorno. */
.showcase-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.showcase-slot { padding: 6px 4px; text-align: center; }
.showcase-slot.is-clickable { cursor: pointer; }
.showcase-slot.is-clickable:hover .showcase-icon, .showcase-slot.is-clickable:active .showcase-icon { transform: scale(1.08); }
.showcase-slot.empty.is-clickable:hover .showcase-icon, .showcase-slot.empty.is-clickable:active .showcase-icon { border-color: var(--neon-cyan); }
/* Stessa medaglia esagonale di .badge-icon-lg (vedi sopra), solo leggermente
   più grande perché qui è la protagonista dello slot. */
.showcase-icon {
  width: 64px; height: 64px;
  margin: 0 auto 8px;
  transition: transform 0.15s ease;
}
.showcase-name { font-family: var(--font-tech); font-size: 11px; font-weight: 700; }
.showcase-slot.empty { color: var(--text-dim); }
/* Slot vuoto: cerchio tratteggiato, non una medaglia "finta" - niente forma
   esagonale né colore di rarità qui, non è un badge vero. */
.showcase-slot.empty .showcase-icon {
  clip-path: none;
  border-radius: 50%;
  background: transparent;
  border: 2px dashed var(--card-border);
  box-shadow: none;
  filter: none;
  color: var(--text-dim);
  font-size: 22px;
}
.showcase-slot.empty .showcase-name { font-weight: 400; }

/* Punteggi per manche */
.profile-manche-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.manche-tile {
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-sm);
  padding: 10px;
  text-align: center;
}
.manche-tile .name { font-family: var(--font-tech); font-size: 11px; color: var(--text-dim); }
.manche-tile .score { font-family: var(--font-mono); font-size: 16px; color: var(--neon-cyan); margin-top: 2px; }

/* Skin di Palla */
.skin-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 12px; }
.skin-item {
  background: linear-gradient(160deg, rgba(255, 203, 71, 0.12), rgba(255, 47, 208, 0.08));
  border: 1px solid rgba(255, 203, 71, 0.35);
  border-radius: var(--radius-md);
  padding: 14px 8px 10px;
  text-align: center;
  position: relative;
}
/* Bloccate: attenuate ma ben leggibili, si deve vedere bene la skin vera
   (niente più grayscale/opacità troppo bassa) - un lucchetto in
   sovraimpressione basta a comunicare "non ancora tua". */
.skin-item.is-locked { opacity: 0.75; background: rgba(0, 0, 0, 0.2); border-color: var(--card-border); }
.skin-item.is-unlocked[data-action] { cursor: pointer; transition: transform 0.15s ease, border-color 0.15s ease; }
.skin-item.is-unlocked[data-action]:hover, .skin-item.is-unlocked[data-action]:active { border-color: var(--neon-cyan); transform: translateY(-2px); }
.skin-item.is-equipped { border-color: var(--neon-term); box-shadow: 0 0 0 1px var(--neon-term) inset; }
.skin-name { font-family: var(--font-tech); font-size: 11px; font-weight: 700; line-height: 1.25; }
.skin-level { font-family: var(--font-mono); font-size: 10px; color: var(--text-dim); margin-top: 2px; }
.skin-equipped-tag { font-family: var(--font-tech); font-size: 9.5px; font-weight: 700; color: var(--neon-term); margin-top: 4px; }

/* Anteprima mascotte vera in ogni riquadro skin (locked incluse) - vedi
   renderPallaMiniMascot: stesso markup del vero #palla-wrap, solo
   rimpicciolito con scale() così le misure in px restano proporzionate. */
.skin-preview-frame { position: relative; width: 62px; height: 62px; margin: 0 auto 6px; }
/* Anello di rarità (stesse classi tier-* dell'anello avatar per livello,
   vedi renderPallaSkinsModule in main.js): il colore di Palla stesso non
   cambia mai, è solo la cornice a raccontare quanto è rara la skin. */
.skin-preview-frame .avatar-ring { padding: 3px; z-index: 0; }
.skin-preview-frame .skin-preview-mascot { z-index: 1; }
.skin-preview-mascot.palla-wrap {
  position: absolute; top: 50%; left: 50%;
  width: 92px; height: 92px;
  transform: translate(-50%, -50%) scale(0.6);
  animation: none;
  cursor: inherit;
}
.skin-lock-badge {
  position: absolute; top: -2px; right: -2px;
  width: 20px; height: 20px;
  border-radius: 50%;
  background: rgba(4, 5, 22, 0.8);
  border: 1px solid var(--card-border);
  font-size: 11px;
  display: flex; align-items: center; justify-content: center;
  z-index: 5;
}

/* ---------- Foto profilo personalizzata ---------- */

.avatar-upload-btn {
  position: absolute;
  right: -2px;
  bottom: 2px;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--bg-1);
  border: 2px solid var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  cursor: pointer;
  transition: transform 0.1s ease;
}
.avatar-upload-btn:hover, .avatar-upload-btn:active { transform: scale(1.08); }

/* ---------- Amici ---------- */

.friend-code-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  margin-bottom: 14px;
}
.friend-code-label { font-family: var(--font-tech); font-size: 12px; color: var(--text-dim); }
.friend-code-value {
  font-family: var(--font-mono);
  font-size: 17px;
  letter-spacing: 0.1em;
  color: var(--accent);
  margin-right: auto;
}
.friend-search-row { display: flex; gap: 8px; margin-bottom: 6px; }
.friend-search-row .btn { flex-shrink: 0; }
.friend-search-input {
  flex: 1;
  min-width: 0; /* di default un input flex non si restringe sotto la sua larghezza "naturale" (~size=20), spingendo il pulsante Cerca fuori dal bordo su una colonna stretta */
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--card-border);
  background: rgba(0, 0, 0, 0.3);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 16px; /* sotto i 16px Safari iOS zooma tutta la pagina al focus */
  letter-spacing: 0.1em;
  text-transform: uppercase;
}
.friend-search-input:focus { outline: none; border-color: var(--neon-cyan); }
.friend-search-error { color: #ff6b6b; font-size: 12px; margin: 6px 0 0; }

.friend-subtitle {
  font-family: var(--font-tech);
  font-size: 12px;
  font-weight: 700;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  margin: 16px 0 8px;
}
.friend-list, .friend-row.friend-search-result { margin-bottom: 4px; }
.friend-row {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  margin-bottom: 8px;
}
.friend-row-name { flex: 1; font-weight: 700; font-size: 13.5px; }
.friend-row-actions { display: flex; gap: 6px; }
.friend-status-chip {
  font-size: 11px;
  font-weight: 700;
  color: var(--neon-term);
  background: rgba(93, 255, 176, 0.12);
  border-radius: 999px;
  padding: 4px 10px;
  display: inline-block;
}

.friend-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: 10px;
}
.friend-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  cursor: pointer;
  transition: border-color 0.15s ease;
}
.friend-chip:hover, .friend-chip:active { border-color: var(--neon-cyan); }
.friend-chip-name { font-size: 12.5px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.friend-list-sidebar { display: flex; flex-direction: column; }
.friend-row.is-clickable { cursor: pointer; transition: border-color 0.15s ease; }
.friend-row.is-clickable:hover, .friend-row.is-clickable:active { border-color: var(--neon-cyan); }

@media (max-width: 760px) {
  .profile-grid { grid-template-columns: 1fr; }
  .profile-sidebar { position: static; }
  .showcase-row, .profile-manche-grid { grid-template-columns: repeat(2, 1fr); }
}

/* ---------- Scelta modalità (single/multi player) ---------- */

.mode-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 22px;
  max-width: 760px;
  margin: 32px auto 0;
  text-align: left;
}

.mode-grid .manche-card .title {
  font-family: var(--font-display);
  font-size: 26px;
  letter-spacing: 0.5px;
}

.mode-grid .manche-card .subtitle {
  font-size: 15px;
  line-height: 1.5;
  margin-top: 8px;
}

/* Pulsante "Continua"/"Continua partita": compare SOLO quando c'è davvero
   qualcosa da riprendere (mai come pulsante grigio/disabilitato sempre
   presente), quindi basta uno spazio fisso sopra per staccarlo dal testo. */
.btn-resume {
  display: block;
  width: 100%;
  margin-top: 20px;
  background: var(--accent);
  border-color: var(--accent);
  color: #2a1b00;
  text-align: center;
}

.btn-resume:hover {
  background: #ffd873;
}

/* ---------- Single player: bivio avventura / allenamento ---------- */

.sp-mode-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 24px;
  max-width: 820px;
  margin: 36px auto 0;
  text-align: left;
}

.sp-mode-card {
  display: flex;
  flex-direction: column;
  padding: 28px 24px;
}

.sp-mode-card .title {
  font-family: var(--font-display);
  font-size: 30px;
  letter-spacing: 0.5px;
  color: var(--accent);
}

.sp-mode-card .subtitle {
  font-size: 15px;
  line-height: 1.55;
  margin-top: 10px;
}

.sp-mode-leaderboard-link {
  display: block;
  width: 100%;
  margin-top: 16px;
  text-align: center;
}

/* ---------- Single player: riepilogo, profilo, classifiche ---------- */

.sp-summary-stats {
  display: flex;
  justify-content: center;
  gap: 28px;
  margin: 28px 0;
  flex-wrap: wrap;
}

.sp-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 90px;
}

.sp-stat-value {
  font-family: var(--font-mono);
  font-size: 28px;
  color: var(--accent);
}

.sp-stat-label {
  font-size: 12px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.xp-bar-wrap {
  max-width: 420px;
  margin: 12px auto 0;
  height: 14px;
  border-radius: 7px;
  background: #171a35;
  border: 1px solid var(--card-border);
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.5);
  overflow: hidden;
}

.xp-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--neon-cyan), var(--accent));
  transition: width 0.3s ease;
}

.xp-bar-label {
  text-align: center;
  color: var(--text-dim);
  font-family: var(--font-mono);
  font-size: 12px;
  margin-top: 8px;
}

.topic-skills-locked { text-align: center; }
.topic-skills-lock-icon { font-size: 28px; margin-bottom: 8px; opacity: 0.7; }
.topic-skills-lock-text {
  color: var(--text-dim);
  font-size: 13px;
  line-height: 1.4;
  margin: 0 0 14px;
}
.topic-skills-lock-progress { text-align: center; margin-top: 6px; }
.topic-skill-row { margin-bottom: 12px; }
.topic-skill-row:last-child { margin-bottom: 0; }
.topic-skill-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 4px;
}
.topic-skill-name {
  font-family: var(--font-tech);
  font-size: 13px;
  color: var(--text-dim);
}
.topic-skill-badge {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.02em;
  padding: 2px 9px;
  border-radius: 999px;
  white-space: nowrap;
}
.topic-skill-badge.is-favorite { background: rgba(107, 255, 143, 0.15); color: #6bff8f; }
.topic-skill-badge.is-weak { background: rgba(255, 107, 107, 0.15); color: #ff6b6b; }
.topic-skill-bar {
  height: 8px;
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--card-border);
  overflow: hidden;
}
.topic-skill-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--neon-cyan), var(--accent));
  transition: width 0.3s ease;
}
.topic-skill-meta {
  margin-top: 4px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-dim);
  text-align: right;
}

.btn.small {
  padding: 6px 14px;
  font-size: 13px;
}

.btn.secondary {
  background: transparent;
  color: var(--text-dim);
}

.btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #2a1b00;
}

.topic-filter-disabled {
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: 420px;
  margin: 0 0 20px;
  padding: 10px 14px;
  background: #171a35;
  border: 1px dashed var(--card-border);
  border-radius: var(--radius-md);
  opacity: 0.7;
}
.topic-filter-label {
  font-family: var(--font-tech);
  font-size: 12px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.topic-filter-select {
  flex: 1;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--card-border);
  background: rgba(0, 0, 0, 0.3);
  color: var(--text-dim);
  font-family: var(--font-body);
  font-size: 13px;
  cursor: not-allowed;
}
.topic-filter-hint {
  font-size: 11px;
  color: var(--text-dim);
  white-space: nowrap;
}

.home-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 20px;
  margin-bottom: 32px;
  padding-right: 320px;
}

.home-ranking {
  position: absolute;
  top: -10px;
  right: 0;
  width: 300px;
  background: rgba(10, 8, 20, 0.82);
  border: 2px solid var(--accent);
  border-radius: var(--radius-md);
  padding: 20px 22px;
  backdrop-filter: blur(8px);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45), 0 0 24px rgba(255, 203, 71, 0.15);
  z-index: 2;
  text-align: left;
}

.home-ranking-title {
  font-family: var(--font-display);
  font-size: 22px;
  color: var(--accent);
  margin-bottom: 14px;
  letter-spacing: 0.5px;
}

.home-ranking-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 0;
  font-size: 17px;
}

.home-ranking-row .pos {
  font-family: var(--font-display);
  font-size: 20px;
  width: 30px;
  flex-shrink: 0;
  color: var(--text-dim);
}

.home-ranking-row .swatch {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  flex-shrink: 0;
}

.home-ranking-row .name {
  flex: 1;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.home-ranking-row .score {
  font-family: var(--font-display);
  font-size: 20px;
  color: var(--accent);
}

.home-footer-actions {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}

.rosik-btn {
  font-size: 12px;
  color: var(--text-dim);
  background: transparent;
  border-color: transparent;
  opacity: 0.6;
}

.rosik-btn:hover {
  opacity: 1;
  color: var(--accent-2);
  border-color: var(--accent-2);
  background: rgba(255, 77, 109, 0.08);
}

.buzzer-btn {
  font-size: 12px;
  color: var(--text-dim);
  background: transparent;
  border-color: transparent;
  opacity: 0.6;
}

.buzzer-btn:hover {
  opacity: 1;
  color: var(--neon-cyan);
  border-color: var(--neon-cyan);
  background: rgba(0, 240, 255, 0.08);
}

.buzzer-intro {
  color: var(--text-dim);
  font-size: 15px;
  line-height: 1.5;
  margin-bottom: 18px;
}

.buzzer-qr {
  display: block;
  margin: 0 auto 20px;
  width: 200px;
  height: 200px;
  background: #fff;
  padding: 10px;
  border-radius: var(--radius-md);
}

.buzzer-steps {
  text-align: left;
  max-width: 420px;
  margin: 0 auto;
  padding-left: 22px;
  color: var(--text);
  font-size: 15px;
  line-height: 1.7;
}

.rosik-letter {
  text-align: left;
  font-size: 15px;
  line-height: 1.6;
  color: var(--text);
}

.manche-card {
  background: #171a35;
  border: 1px solid rgba(0, 240, 255, 0.4);
  border-radius: var(--radius-lg);
  padding: 28px 20px;
  text-align: left;
  color: var(--text);
  position: relative;
  transition: background 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
  box-shadow: inset 3px 3px 0 rgba(255, 255, 255, 0.14), inset -3px -3px 0 rgba(0, 0, 0, 0.55);
}

.manche-card:hover:not(.is-locked) {
  background: var(--card-bg-hover);
  transform: translateY(-4px);
  border-color: var(--neon-cyan);
  box-shadow: inset 2px 2px 0 rgba(255, 255, 255, 0.10), inset -2px -2px 0 rgba(0, 0, 0, 0.4), 0 0 28px rgba(0, 240, 255, 0.35);
}

.manche-card .num {
  font-family: var(--font-display);
  font-size: 40px;
  color: var(--accent);
  line-height: 1;
}

.manche-card .title {
  font-size: 20px;
  font-weight: 700;
  margin: 6px 0 2px;
}

.manche-card .subtitle {
  color: var(--text-dim);
  font-size: 14px;
}

.manche-card .badge {
  position: absolute;
  top: 16px;
  right: 16px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 3px 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
}

.manche-card.status-demo .badge {
  background: rgba(255, 203, 71, 0.25);
  color: var(--accent);
}

.manche-card.status-ready .badge {
  background: rgba(107, 255, 143, 0.25);
  color: #6bff8f;
}

.manche-card.status-beta .badge {
  background: rgba(255, 47, 208, 0.22);
  color: var(--neon-magenta);
}

.manche-card.is-locked {
  opacity: 0.4;
  cursor: not-allowed;
}

/* ---------- Manche slides ---------- */

.slide-eyebrow {
  color: var(--text-dim);
  font-size: 14px;
  letter-spacing: 1px;
  text-transform: uppercase;
  margin-bottom: 10px;
}

.slide-title {
  font-family: var(--font-display);
  font-size: clamp(40px, 6vw, 72px);
  color: var(--text);
  margin: 0 0 12px;
  letter-spacing: 1px;
  text-shadow: 1px 0 rgba(255, 47, 208, 0.4), -1px 0 rgba(0, 240, 255, 0.4);
}

.slide-subheading {
  font-family: var(--font-display);
  font-size: clamp(24px, 3.6vw, 40px);
  color: var(--accent);
  margin: 0 0 20px;
  letter-spacing: 1px;
}

.slide-subtitle {
  color: var(--text-dim);
  font-size: 20px;
  max-width: 760px;
  margin: 0 auto;
  line-height: 1.5;
  white-space: pre-line;
}

/* ---------- Scossa grid ---------- */

.grid-title {
  margin-bottom: 6px;
}

.grid-reading-note {
  max-width: 520px;
  margin: 22px auto 0;
  padding: 16px 20px;
  background: #171a35;
  border: 1px solid rgba(0, 240, 255, 0.35);
  border-radius: 12px;
  box-shadow: inset 2px 2px 0 rgba(255, 255, 255, 0.06), inset -2px -2px 0 rgba(0, 0, 0, 0.4);
  color: var(--text);
  font-family: var(--font-tech);
  font-size: 16px;
  letter-spacing: 0.02em;
  text-align: center;
  animation: grid-reading-pulse 1.6s ease-in-out infinite;
}

@keyframes grid-reading-pulse {
  0%, 100% { opacity: 0.75; }
  50% { opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  .grid-reading-note { animation: none; }
}

.scossa-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 20px 14px;
  margin: 24px 0;
}

.scossa-item {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.cell-caption {
  color: #ffffff;
  font-size: 13px;
  font-weight: 700;
  text-align: center;
  line-height: 1.3;
}

.scossa-cell {
  position: relative;
  aspect-ratio: 3 / 4;
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 2px solid var(--card-border);
  background: #171a35;
  box-shadow: inset 2px 2px 0 rgba(255, 255, 255, 0.08), inset -2px -2px 0 rgba(0, 0, 0, 0.4);
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.1s ease, box-shadow 0.15s ease;
}

.scossa-cell:hover {
  background: var(--card-bg-hover);
  border-color: var(--neon-cyan);
  transform: translateY(-2px);
}

.scossa-cell.is-hidden-card {
  cursor: default;
  opacity: 0.55;
}
.scossa-cell.is-hidden-card:hover {
  background: #171a35;
  border-color: var(--card-border);
  transform: none;
}
.scossa-hidden-icon {
  font-size: 34px;
  animation: grid-reading-pulse 1.6s ease-in-out infinite;
}

.scossa-cell img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.scossa-cell .cell-result-badge {
  position: absolute;
  top: 6px;
  left: 6px;
  right: 6px;
  text-align: center;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 4px 2px;
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.65);
  z-index: 1;
}

.scossa-cell.is-esatta {
  border-color: #6bff8f;
  box-shadow: 0 0 16px rgba(107, 255, 143, 0.35);
}
.scossa-cell.is-esatta .cell-result-badge { color: #6bff8f; }

.scossa-cell.is-limite {
  border-color: #c77dff;
  box-shadow: 0 0 16px rgba(199, 125, 255, 0.35);
}
.scossa-cell.is-limite .cell-result-badge { color: #c77dff; }

.scossa-cell.is-bomba {
  border-color: #ff3b3b;
  background: #0a0a0a;
  box-shadow: 0 0 16px rgba(255, 59, 59, 0.4);
}
.scossa-cell.is-bomba .cell-result-badge { color: #ff6b6b; }
.scossa-cell.is-bomba img { filter: brightness(0.35) grayscale(0.5); }

/* Messaggio di fine round (Manche 2 single player): grande, al centro, resta
   a schermo finché non si preme il pulsante - niente più avanzamento
   automatico dopo pochi secondi. */
.round-over-banner {
  max-width: 480px;
  margin: 28px auto 0;
  padding: 32px 28px;
  border-radius: var(--radius-lg);
  background: linear-gradient(160deg, var(--bg-2), var(--bg-1));
  border: 2px solid var(--accent);
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.5), 0 0 26px rgba(255, 203, 71, 0.25);
  text-align: center;
  animation: fade-up 0.4s ease;
}

.round-over-icon {
  font-size: 46px;
  margin-bottom: 12px;
}

.round-over-text {
  font-size: 19px;
  font-weight: 700;
  line-height: 1.5;
  margin-bottom: 20px;
}

.last-pick-panel {
  margin-top: 8px;
  padding: 20px 24px;
  border-radius: var(--radius-md);
  background: #171a35;
  border: 1px solid var(--card-border);
}

.last-pick-panel.is-esatta { border-color: #6bff8f; background: rgba(107, 255, 143, 0.1); }
.last-pick-panel.is-limite { border-color: #c77dff; background: rgba(199, 125, 255, 0.1); }
.last-pick-panel.is-bomba { border-color: #ff3b3b; background: rgba(255, 59, 59, 0.1); }

.last-pick-name {
  font-family: var(--font-display);
  font-size: 28px;
  margin-bottom: 4px;
}

.last-pick-badge {
  font-size: 14px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-dim);
  margin-bottom: 10px;
}

.last-pick-panel.is-esatta .last-pick-badge { color: #6bff8f; }
.last-pick-panel.is-limite .last-pick-badge { color: #c77dff; }
.last-pick-panel.is-bomba .last-pick-badge { color: #ff6b6b; }

.last-pick-detail {
  color: var(--text-dim);
  font-size: 15px;
}

/* ---------- Board (Manche 3) ---------- */

.board-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 32px;
}

/* Il tabellone (5x5, celle min 140/120px = ~756px minimo) è più largo di
   qualunque telefono - .board-scroll lo lascia scorrere in orizzontale
   invece di farlo tagliare via da overflow-x:hidden sul body (altrimenti
   mezzo tabellone è semplicemente irraggiungibile). .board-grid-wrap resta
   "inline-block" così ha sempre la sua larghezza naturale, mai schiacciata
   dal contenitore che scorre - altrimenti anche l'SVG dei collegamenti
   (dimensionato al 100% del suo genitore) si disallineerebbe dalle celle. */
.board-scroll {
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 4px; /* spazio per non far toccare l'eventuale scrollbar alle celle */
}
.board-scroll-hint {
  text-align: center;
  font-family: var(--font-tech);
  font-size: 12px;
  color: var(--text-dim);
  letter-spacing: 0.03em;
  margin-bottom: 8px;
}

.board-grid-wrap {
  position: relative;
  display: inline-block;
}

.board-grid {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: repeat(5, minmax(140px, 200px));
  grid-template-rows: repeat(5, minmax(120px, 170px));
  gap: 14px;
}

@media (max-width: 640px) {
  /* Meno larghezza minima = meno strada da scorrere per arrivare in fondo. */
  .board-grid {
    grid-template-columns: repeat(5, minmax(96px, 130px));
    grid-template-rows: repeat(5, minmax(84px, 110px));
    gap: 10px;
  }
}

.board-links {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 0;
}

.board-links-path {
  fill: none;
  stroke: var(--neon-magenta);
  stroke-width: 0.6;
  stroke-dasharray: 4 3;
  opacity: 0.75;
  filter: drop-shadow(0 0 3px var(--neon-magenta));
  animation: board-links-flow 1.2s linear infinite;
}

@keyframes board-links-flow {
  to { stroke-dashoffset: -14; }
}

.board-zone {
  border: 2px solid var(--card-border);
  border-radius: var(--radius-md);
  background: #171a35;
  box-shadow: inset 2px 2px 0 rgba(255, 255, 255, 0.08), inset -2px -2px 0 rgba(0, 0, 0, 0.4);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 8px;
  gap: 4px;
  overflow: hidden;
  position: relative;
}

.board-zone-center {
  border-color: var(--accent);
  background: rgba(255, 203, 71, 0.08);
  box-shadow: inset 2px 2px 0 rgba(255, 255, 255, 0.12), inset -2px -2px 0 rgba(0, 0, 0, 0.4);
}

.board-zone-boss {
  border-color: var(--neon-magenta);
  box-shadow: inset 2px 2px 0 rgba(255, 255, 255, 0.08), inset -2px -2px 0 rgba(0, 0, 0, 0.4), 0 0 16px rgba(255, 47, 208, 0.25);
}

.boss-image-wrap {
  width: 110px;
  height: 110px;
  border-radius: 50%;
  overflow: hidden;
  border: 3px solid var(--neon-magenta);
  box-shadow: inset 0 0 0 2px rgba(0, 0, 0, 0.4), 0 0 16px rgba(255, 47, 208, 0.45);
  flex-shrink: 0;
  background: #1a1044;
}

.boss-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  filter: brightness(1.15) contrast(1.05) saturate(1.05);
}

.zone-label {
  font-family: var(--font-display);
  font-size: 16px;
  color: #ffffff;
  text-align: center;
}

.zone-theme {
  font-size: 10px;
  color: var(--text-dim);
  text-align: center;
  line-height: 1.2;
}

.zone-tokens {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  justify-content: center;
  min-height: 14px;
}

.board-token {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.5);
}

.board-toolbar {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
}

.question-counter {
  color: var(--text-dim);
  font-size: 13px;
  margin-bottom: 10px;
}

.question-prompt {
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 10px;
}

.question-explanation {
  margin-top: 10px;
  font-size: 14px;
  color: var(--text-dim);
  line-height: 1.5;
  text-align: left;
}

.rebus-display {
  font-size: 72px;
  line-height: 1.2;
  margin: 10px 0 16px;
}

.detail-crop {
  width: 100%;
  max-width: 300px;
  aspect-ratio: 1 / 1;
  overflow: hidden;
  border-radius: var(--radius-md);
  border: 2px solid var(--card-border);
  margin: 0 auto 16px;
}

.detail-crop img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scale(2.4);
  transform-origin: center;
}

.detail-full {
  margin: 0 auto 16px;
  text-align: center;
}

.detail-full img {
  max-width: 100%;
  max-height: 340px;
  border-radius: var(--radius-md);
  border: 2px solid var(--card-border);
}

.dice-result {
  display: flex;
  align-items: center;
  gap: 14px;
}

.dice-value {
  font-family: var(--font-pixel);
  font-size: 32px;
  color: var(--accent);
}

.dice-effect {
  font-size: 15px;
  color: var(--text);
  max-width: 360px;
  text-align: left;
}

.dice-table {
  text-align: left;
  font-size: 13px;
  color: var(--text-dim);
  padding-left: 20px;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.dice-table li.is-active {
  color: var(--accent);
  font-weight: 700;
}

.board-players {
  display: flex;
  flex-direction: column;
  gap: 14px;
  width: 100%;
  max-width: 760px;
}

.board-player-row {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  background: #171a35;
  border: 1px solid var(--card-border);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  text-align: left;
}

.board-player-name {
  font-weight: 700;
  min-width: 110px;
}

.board-move-buttons {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  align-items: center;
}

.board-move-group {
  display: flex;
  gap: 2px;
  background: rgba(255, 255, 255, 0.03);
  padding: 2px;
  border-radius: 999px;
}

.board-move-btn {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--card-border);
  color: var(--text-dim);
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 12px;
}

.board-move-btn.is-active {
  background: var(--accent);
  border-color: var(--accent);
  color: #2a1b00;
  font-weight: 700;
}

.board-fragments {
  display: flex;
  gap: 6px;
}

.fragment-dot {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid rgba(0, 240, 255, 0.3);
  background: #171a35;
  box-shadow: inset 2px 2px 0 rgba(255, 255, 255, 0.08), inset -2px -2px 0 rgba(0, 0, 0, 0.4);
  color: var(--text-dim);
  font-weight: 700;
  font-size: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.fragment-dot.is-collected {
  background: rgba(107, 255, 143, 0.2);
  border-color: #6bff8f;
  color: #6bff8f;
}

.board-claim-buttons {
  display: flex;
  gap: 8px;
  margin-left: auto;
}

/* Manche 4 single player: frecce di direzione (Via -> Isola, o Boss dopo il dado) */
.board-direction-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 14px;
  max-width: 640px;
  margin: 22px auto 0;
}

.board-direction-btn {
  padding: 18px 14px;
  font-size: 16px;
  line-height: 1.4;
}

.board-direction-theme {
  display: block;
  font-size: 12px;
  font-weight: 400;
  opacity: 0.85;
  margin-top: 4px;
}

.victory-badge {
  font-size: 96px;
  line-height: 1;
  margin-bottom: 12px;
  filter: drop-shadow(0 0 24px rgba(255, 203, 71, 0.5));
}

.outro-actions {
  display: flex;
  gap: 16px;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 12px;
}

.song-number {
  font-family: var(--font-pixel);
  font-size: clamp(18px, 3vw, 28px);
  color: var(--accent);
  margin-bottom: 28px;
  text-shadow: 0 0 16px rgba(255, 203, 71, 0.35);
}

/* Rete di sicurezza per l'autoplay bloccato (vedi initSongAutoplayIfNeeded):
   se il browser rifiuta di far ripartire la canzone da sola, questo pulsante
   ben visibile è l'unico modo per farla ripartire con un tocco vero -
   altrimenti in single player (niente controlli sul player) il timer
   resterebbe bloccato in silenzio per sempre. */
.sp-song-play-fallback {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 90;
  background: var(--accent);
  color: #2a1b00;
  border: none;
  border-radius: 999px;
  padding: 14px 26px;
  font-family: var(--font-tech);
  font-weight: 700;
  font-size: 15px;
  box-shadow: 0 0 0 4px rgba(255, 203, 71, 0.25), 0 10px 30px rgba(0, 0, 0, 0.5);
  cursor: pointer;
  animation: sp-song-fallback-pulse 1.4s ease-in-out infinite;
}
@keyframes sp-song-fallback-pulse {
  0%, 100% { box-shadow: 0 0 0 4px rgba(255, 203, 71, 0.25), 0 10px 30px rgba(0, 0, 0, 0.5); }
  50% { box-shadow: 0 0 0 9px rgba(255, 203, 71, 0.12), 0 10px 30px rgba(0, 0, 0, 0.5); }
}

.song-player {
  width: 100%;
  max-width: 480px;
  height: 54px;
  margin: 0 auto 8px;
  display: block;
  filter: invert(0.88) hue-rotate(180deg);
  border-radius: 999px;
}

/* Player audio della Manche 1 single player: widget persistente fuori da
   #app, senza controlli visibili in single player (vedi initSongAudioWidget). */
#sp-song-audio { display: none; }

.song-hint {
  color: var(--text-dim);
  font-size: 13px;
  margin-bottom: 24px;
}

.answer-reveal-song {
  display: flex;
  flex-direction: column;
  gap: 16px;
  text-align: left;
}

.slide-question-text {
  font-size: clamp(26px, 3.4vw, 40px);
  font-weight: 700;
  line-height: 1.35;
  margin-bottom: 28px;
}

.points-badge {
  display: inline-block;
  background: var(--accent);
  color: #2a1b00;
  font-family: var(--font-pixel);
  font-size: 12px;
  padding: 8px 16px;
  border-radius: 999px;
  margin-bottom: 20px;
  box-shadow: 0 0 16px rgba(255, 203, 71, 0.4);
}

.options-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
  margin-top: 10px;
}

.option-card {
  background: #171a35;
  border: 1px solid var(--card-border);
  border-radius: var(--radius-md);
  padding: 18px;
  font-size: 19px;
  font-weight: 600;
  text-align: left;
}

.option-card.is-correct {
  background: rgba(107, 255, 143, 0.18);
  border-color: #6bff8f;
  color: #6bff8f;
}

.answer-reveal {
  margin-top: 28px;
  padding: 20px 24px;
  background: rgba(107, 255, 143, 0.12);
  border: 1px solid #6bff8f;
  border-radius: var(--radius-md);
  box-shadow: inset 2px 2px 0 rgba(255, 255, 255, 0.08), inset -2px -2px 0 rgba(0, 0, 0, 0.25);
  font-size: 22px;
  font-weight: 700;
  color: #6bff8f;
  animation: fade-up 0.3s ease;
}

.answer-reveal .label {
  display: block;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-dim);
  font-weight: 600;
  margin-bottom: 6px;
}

/* Risposta rivelata a tempo scaduto perché non indovinata: rosso invece del
   verde standard, per marcare bene la differenza da un colpo d'occhio. */
.answer-reveal.is-wrong {
  background: rgba(255, 107, 107, 0.12);
  border-color: #ff6b6b;
  color: #ff6b6b;
}

/* ---------- Manche 4 (beta): flash words ---------- */

.flash-meta {
  color: var(--text-dim);
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 12px;
}

.flash-stage {
  position: relative;
  left: 50%;
  transform: translateX(-50%);
  width: 92vw;
  max-width: 1400px;
  height: 540px;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.flash-word {
  position: absolute;
  font-family: var(--font-display);
  font-weight: 700;
  color: var(--neon-cyan);
  text-shadow: 0 0 10px rgba(0, 240, 255, 0.6), 0 0 20px rgba(255, 47, 208, 0.35);
  white-space: nowrap;
  opacity: 0;
  transition: opacity 0.22s ease, transform 0.22s ease;
  pointer-events: none;
}

.flash-word.is-visible {
  opacity: 1;
}

.flash-stage-paused {
  display: flex;
  align-items: center;
  justify-content: center;
  border-color: var(--accent-2);
  background: rgba(255, 77, 109, 0.08);
}

.flash-paused-msg {
  font-family: var(--font-display);
  font-size: 40px;
  letter-spacing: 1px;
  color: var(--accent-2);
  text-shadow: 0 0 18px rgba(255, 77, 109, 0.5);
  animation: fade-up 0.25s ease;
}

.flash-hint {
  margin-top: 14px;
  color: var(--text-dim);
  font-size: 13px;
}

.flash-guess-row {
  display: flex;
  gap: 10px;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
  margin-top: 22px;
}

.flash-guess-input {
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(0, 240, 255, 0.25);
  border-radius: var(--radius-sm);
  box-shadow: inset 2px 2px 0 rgba(0, 0, 0, 0.4), inset -1px -1px 0 rgba(255, 255, 255, 0.05);
  padding: 12px 16px;
  color: var(--text);
  font-size: 16px;
  font-family: var(--font-body);
  width: 320px;
  max-width: 60vw;
}

.flash-guess-input:focus {
  outline: none;
  border-color: var(--neon-cyan);
  box-shadow: inset 2px 2px 0 rgba(0, 0, 0, 0.4), inset -1px -1px 0 rgba(255, 255, 255, 0.05), 0 0 0 1px var(--neon-cyan), 0 0 14px rgba(0, 240, 255, 0.3);
}

.flash-wrong-msg {
  font-family: var(--font-display);
  font-size: 24px;
  letter-spacing: 0.5px;
  color: var(--accent-2);
  margin-top: 18px;
}

.assign-points {
  margin-top: 24px;
}

.assign-points .label {
  font-size: 13px;
  color: var(--text-dim);
  margin-bottom: 10px;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.assign-points-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
}

.assign-btn {
  border-radius: 999px;
  padding: 10px 18px;
  border: 1px solid var(--card-border);
  font-weight: 700;
  color: #14101f;
  display: flex;
  align-items: center;
  gap: 8px;
}

.assign-btn .swatch {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.slide-text-body {
  font-size: 22px;
  line-height: 1.6;
  color: var(--text);
  white-space: pre-line;
}

.slide-image img {
  max-width: 100%;
  max-height: 55vh;
  border-radius: var(--radius-md);
  border: 1px solid var(--card-border);
}

.slide-image .caption {
  margin-top: 14px;
  color: var(--text-dim);
}

/* ---------- Control bar ---------- */

.control-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 18px 24px;
  background: rgba(0, 0, 0, 0.25);
  border-top: 1px solid var(--card-border);
  flex-wrap: wrap;
}

/* ---------- Setup screen ---------- */

.setup-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin: 24px 0;
  max-width: 520px;
  margin-left: auto;
  margin-right: auto;
}

.setup-team-row {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #171a35;
  border: 1px solid var(--card-border);
  border-radius: var(--radius-md);
  padding: 10px 12px;
}

.setup-team-row .swatch-btn {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.4);
  flex-shrink: 0;
}

.setup-team-row input[type="text"] {
  flex: 1;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  color: var(--text);
  font-size: 16px;
  font-family: var(--font-body);
}

.setup-team-row input[type="text"]::placeholder {
  color: var(--text-dim);
}

.setup-team-row .remove-btn {
  background: transparent;
  border: none;
  color: var(--text-dim);
  font-size: 20px;
  padding: 4px 8px;
}

.setup-team-row .remove-btn:hover {
  color: var(--accent-2);
}

.count-picker {
  display: flex;
  gap: 16px;
  justify-content: center;
  flex-wrap: wrap;
  margin: 32px 0;
}

.count-btn {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  border: 2px solid var(--card-border);
  background: #171a35;
  color: var(--text);
  font-family: var(--font-display);
  font-size: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease, transform 0.15s ease;
}

.count-btn:hover {
  background: var(--card-bg-hover);
  transform: translateY(-3px);
}

.count-btn.is-selected {
  background: var(--accent);
  border-color: var(--accent);
  color: #2a1b00;
}

/* Stesso trattamento di .btn.small.secondary (già usato altrove, es.
   "Copia"/"Esci" nel profilo): un vero pulsante bordato, non un link di
   testo sottolineato - si deve vedere subito che è cliccabile. */
.setup-back-link {
  display: block;
  width: fit-content;
  border: 1px solid rgba(0, 240, 255, 0.45);
  background: transparent;
  color: var(--text-dim);
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 600;
  margin: 0 auto 14px; /* .stage è text-align:center, ma un box va centrato con auto, non da text-align */
  box-shadow: inset 3px 3px 0 rgba(255, 255, 255, 0.10), inset -3px -3px 0 rgba(0, 0, 0, 0.4);
  transition: background 0.15s ease, box-shadow 0.15s ease, color 0.15s ease;
}

/* Pulsante "Indietro" fisso, stessa posizione su ogni schermata (non più
   incollato al logo, che cambia lunghezza da schermata a schermata) - vedi
   data-action nelle varie render*() al posto di .setup-back-link. */
.back-fab {
  position: fixed;
  top: calc(18px + env(safe-area-inset-top, 0px));
  left: calc(18px + env(safe-area-inset-left, 0px));
  z-index: 55;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: rgba(10, 12, 34, 0.85);
  border: 1px solid var(--neon-cyan);
  color: var(--neon-cyan);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  box-shadow: 0 0 10px rgba(0, 240, 255, 0.25);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.back-fab:hover, .back-fab:active {
  transform: scale(1.08);
  box-shadow: 0 0 14px rgba(0, 240, 255, 0.4);
}
@media (max-width: 640px) {
  /* Sotto i 640px .bg-player si sposta proprio in alto a sinistra (vedi
     sotto): il back-fab scende sotto di lui invece di sovrapporglisi. */
  .back-fab {
    top: calc(64px + env(safe-area-inset-top, 0px));
    left: calc(12px + env(safe-area-inset-left, 0px));
    width: 34px;
    height: 34px;
    font-size: 16px;
  }
}

.setup-back-link:hover, .setup-back-link:active {
  color: var(--text);
  box-shadow: inset 1px 1px 0 rgba(255, 255, 255, 0.08), inset -1px -1px 0 rgba(0, 0, 0, 0.25), 0 0 0 1px var(--neon-cyan), 0 0 10px rgba(0, 240, 255, 0.3);
}

.setup-hint {
  color: var(--text-dim);
  font-size: 14px;
  margin-top: 6px;
}

/* ---------- Fullscreen scoreboard ---------- */

.rank-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
  max-width: 640px;
  margin: 0 auto;
}

.rank-row {
  display: flex;
  align-items: center;
  gap: 18px;
  background: #171a35;
  border: 1px solid var(--card-border);
  border-radius: var(--radius-md);
  box-shadow: inset 2px 2px 0 rgba(255, 255, 255, 0.06), inset -2px -2px 0 rgba(0, 0, 0, 0.3);
  padding: 16px 22px;
  animation: fade-up 0.4s ease;
}

.rank-row .pos {
  font-family: var(--font-mono);
  font-size: 24px;
  width: 40px;
  color: var(--text-dim);
}

.rank-row.pos-1 .pos { color: #ffd873; }
.rank-row.pos-2 .pos { color: #d7d7e0; }
.rank-row.pos-3 .pos { color: #e0a05c; }

.rank-row-clickable {
  cursor: pointer;
  transition: background 0.15s ease, transform 0.1s ease;
}

.rank-row-clickable:hover {
  background: var(--card-bg-hover);
}

.rank-row-clickable:active {
  transform: scale(0.99);
}

.rank-row .swatch {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  flex-shrink: 0;
}

.rank-row .name {
  flex: 1;
  font-size: 20px;
  font-weight: 700;
  text-align: left;
}

.rank-row .score {
  font-family: var(--font-mono);
  font-size: 23px;
  color: var(--accent);
}

/* ---------- Classifiche: livello 1, Avventura in evidenza ---------- */

.leaderboard-featured {
  max-width: 640px;
  margin: 0 auto 32px;
  padding: 26px 26px 22px;
  border-radius: var(--radius-lg);
  background: linear-gradient(160deg, #241a44, #171a35);
  border: 1px solid var(--accent);
  box-shadow: 0 0 0 1px rgba(255, 203, 71, 0.15), 0 16px 40px rgba(0, 0, 0, 0.45), inset 2px 2px 0 rgba(255, 255, 255, 0.06);
}
.leaderboard-featured-title {
  font-family: var(--font-pixel);
  font-size: 15px;
  color: var(--accent);
  text-align: center;
  text-shadow: 0 0 14px rgba(255, 203, 71, 0.4);
  margin-bottom: 6px;
}
.leaderboard-featured-sub {
  text-align: center;
  color: var(--text-dim);
  font-size: 13px;
  margin-bottom: 20px;
}
.rank-list-featured .rank-row { padding: 18px 24px; }
.rank-row-featured { border-color: rgba(255, 203, 71, 0.35); }
.rank-row-featured.pos-1 { border-color: #ffd873; box-shadow: 0 0 22px rgba(255, 216, 115, 0.25), inset 2px 2px 0 rgba(255, 255, 255, 0.08); }

/* ---------- Classifiche: livello 2, le 4 manche più piccole ---------- */

.leaderboard-manche-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 16px;
  max-width: 900px;
  margin: 0 auto 24px;
}
.leaderboard-manche-card {
  background: #171a35;
  border: 1px solid var(--card-border);
  border-radius: var(--radius-md);
  padding: 14px 16px 16px;
  box-shadow: inset 2px 2px 0 rgba(255, 255, 255, 0.05), inset -2px -2px 0 rgba(0, 0, 0, 0.3);
}
.leaderboard-manche-head {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  margin-bottom: 10px;
}
.leaderboard-manche-title {
  font-family: var(--font-tech);
  font-size: 14px;
  color: var(--text);
}
.leaderboard-manche-tag {
  font-size: 10px;
  color: var(--text-dim);
  background: rgba(0, 0, 0, 0.3);
  border-radius: 999px;
  padding: 2px 8px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.leaderboard-manche-toggle {
  margin-left: auto;
  color: var(--text-dim);
  font-size: 11px;
}
.rank-list-compact { gap: 8px; }
.rank-list-compact .rank-row { padding: 8px 12px; gap: 10px; border-radius: var(--radius-sm); }
.rank-list-compact .rank-row .pos { font-size: 15px; width: 24px; }
.rank-list-compact .rank-row .name { font-size: 14px; }
.rank-list-compact .rank-row .score { font-size: 15px; }
.rank-list-compact .avatar-frame-wrap.sm { width: 22px; height: 22px; }
.leaderboard-expand-btn { display: block; margin: 10px auto 0; }

/* ---------- Classifiche: livello 3, per argomento (bloccato) ---------- */

.leaderboard-topic-accordion {
  max-width: 900px;
  margin: 0 auto;
}
.leaderboard-topic-toggle {
  width: 100%;
  text-align: left;
  background: none;
  border: 1px dashed var(--card-border);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  color: var(--text-dim);
  font-family: var(--font-tech);
  font-size: 13px;
  cursor: pointer;
}
.leaderboard-topic-toggle:hover { color: var(--text); }
.leaderboard-topic-body { padding: 12px 4px 0; text-align: center; }

/* ---------- Restart floating button ---------- */

.restart-fab {
  position: fixed;
  bottom: calc(20px + env(safe-area-inset-bottom, 0px));
  right: calc(20px + env(safe-area-inset-right, 0px));
  z-index: 40;
  background: rgba(255, 77, 109, 0.15);
  border: 1px solid var(--accent-2);
  color: var(--accent-2);
  padding: 10px 18px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 13px;
  white-space: nowrap;
  backdrop-filter: blur(4px);
}

.restart-fab:hover {
  background: rgba(255, 77, 109, 0.3);
  box-shadow: 0 0 18px rgba(255, 77, 109, 0.35);
}

/* ---------- Background ambient player ---------- */

/* Solo un interruttore play/pausa: niente più pannello/scelta brano lato
   giocatore (la playlist si gestisce da wp-admin, vedi initBackgroundPlayer
   in main.js). Icona piena/spenta comunica lo stato senza bisogno di testo. */
.bg-player {
  position: fixed;
  /* env(..., 0px) col fallback: sugli iPhone con home indicator lo scosta
     dalla zona dei gesti di sistema, altrove (o browser senza supporto)
     resta semplicemente 20px come prima. */
  bottom: calc(20px + env(safe-area-inset-bottom, 0px));
  left: calc(20px + env(safe-area-inset-left, 0px));
  z-index: 45;
  display: flex;
  align-items: center;
  gap: 10px;
}

.bg-player-toggle {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid var(--card-border);
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  color: var(--text-dim);
  font-size: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

.bg-player-toggle:hover {
  background: rgba(255, 255, 255, 0.15);
  border-color: var(--neon-cyan);
}

.bg-player-toggle.is-playing {
  color: var(--neon-cyan);
  border-color: var(--neon-cyan);
  box-shadow: 0 0 12px rgba(0, 240, 255, 0.4);
}

.bg-player-icon { pointer-events: none; }

/* Piccolo slider volume, discreto accanto al play/pausa - stessa palette
   ciano usata per lo stato "in riproduzione" del pulsante. */
.bg-player-volume {
  width: 64px;
  height: 4px;
  -webkit-appearance: none;
  appearance: none;
  background: rgba(255, 255, 255, 0.25);
  border-radius: 999px;
  outline: none;
  cursor: pointer;
}
.bg-player-volume::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: var(--neon-cyan);
  box-shadow: 0 0 6px rgba(0, 240, 255, 0.6);
  cursor: pointer;
}
.bg-player-volume::-moz-range-thumb {
  width: 13px;
  height: 13px;
  border-radius: 50%;
  border: none;
  background: var(--neon-cyan);
  box-shadow: 0 0 6px rgba(0, 240, 255, 0.6);
  cursor: pointer;
}
.bg-player-volume::-moz-range-track {
  background: rgba(255, 255, 255, 0.25);
  height: 4px;
  border-radius: 999px;
}

/* ---------- Modals ---------- */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(5, 5, 20, 0.78);
  backdrop-filter: blur(3px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 20px;
}

.modal-panel {
  background: linear-gradient(160deg, var(--bg-2), var(--bg-1));
  border: 1px solid rgba(0, 240, 255, 0.35);
  border-radius: var(--radius-lg);
  padding: 32px;
  max-width: 520px;
  width: 100%;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: inset 3px 3px 0 rgba(255, 255, 255, 0.1), inset -3px -3px 0 rgba(0, 0, 0, 0.5), 0 0 60px rgba(0, 0, 0, 0.5), 0 0 40px rgba(0, 240, 255, 0.15);
}

.modal-title {
  font-family: var(--font-display);
  font-size: 30px;
  color: var(--accent);
  text-shadow: 1px 0 rgba(255, 47, 208, 0.4), -1px 0 rgba(0, 240, 255, 0.4);
  margin: 0 0 20px;
}

.modal-actions {
  margin-top: 24px;
  display: flex;
  justify-content: flex-end;
}

/* Niente più rettangolo/bottone attorno alla riga: l'area di selezione è la
   medaglia stessa (.badge-picker-icon), che reagisce all'hover/focus - la
   riga resta solo un contenitore trasparente per allineare medaglia+testo. */
.badge-picker-list { display: flex; flex-direction: column; gap: 14px; }
.badge-picker-item {
  display: flex;
  align-items: center;
  gap: 14px;
  text-align: left;
  width: 100%;
  background: none;
  border: none;
  padding: 0;
  color: var(--text);
  cursor: pointer;
  font-family: var(--font-body);
}
.badge-picker-item:hover .badge-picker-icon,
.badge-picker-item:active .badge-picker-icon,
.badge-picker-item:focus-visible .badge-picker-icon { transform: scale(1.08); }
/* Sempre badge già sbloccati qui (il picker propone solo quelli guadagnati),
   quindi sempre la medaglia colorata piena, mai la versione spenta. Forma e
   colore per rarità vengono dal blocco condiviso .badge-icon-lg/.showcase-
   icon/.badge-picker-icon più in alto - qui solo la misura. */
.badge-picker-icon {
  width: 50px; height: 50px;
  flex-shrink: 0;
  transition: transform 0.15s ease;
}
.badge-picker-text { display: flex; flex-direction: column; gap: 2px; }
.badge-picker-name { font-weight: 700; font-size: 14px; }
.badge-picker-desc { font-size: 12px; color: var(--text-dim); }

.settings-row {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 16px;
}

.settings-label {
  font-size: 14px;
  color: var(--text-dim);
}

.settings-input {
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(0, 240, 255, 0.25);
  border-radius: var(--radius-sm);
  box-shadow: inset 2px 2px 0 rgba(0, 0, 0, 0.4), inset -1px -1px 0 rgba(255, 255, 255, 0.05);
  padding: 10px 12px;
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 16px;
  width: 140px;
}

.settings-input:focus {
  outline: none;
  border-color: var(--neon-cyan);
  box-shadow: inset 2px 2px 0 rgba(0, 0, 0, 0.4), inset -1px -1px 0 rgba(255, 255, 255, 0.05), 0 0 0 1px var(--neon-cyan), 0 0 14px rgba(0, 240, 255, 0.3);
}

/* Stessa palette ciano dello slider volume del player musicale, ma a piena
   larghezza per le righe del pannello Impostazioni. */
.settings-slider {
  width: 100%;
  height: 5px;
  -webkit-appearance: none;
  appearance: none;
  background: rgba(255, 255, 255, 0.18);
  border-radius: 999px;
  outline: none;
  cursor: pointer;
}
.settings-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--neon-cyan);
  box-shadow: 0 0 8px rgba(0, 240, 255, 0.6);
  cursor: pointer;
}
.settings-slider::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: none;
  background: var(--neon-cyan);
  box-shadow: 0 0 8px rgba(0, 240, 255, 0.6);
  cursor: pointer;
}
.settings-slider::-moz-range-track {
  background: rgba(255, 255, 255, 0.18);
  height: 5px;
  border-radius: 999px;
}

/* ---------- Timer automatico single player (Manche 1/2/3/4) ---------- */
/* Riusa la stessa formula visiva della barra XP (schermata Profilo) per il
   "si svuota col tempo": qui però guida anche il countdown, non solo un
   indicatore di progresso. */

.sp-timer {
  position: fixed;
  top: 88px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 46;
  display: flex;
  align-items: center;
  gap: 12px;
  background: linear-gradient(160deg, var(--bg-2), var(--bg-1));
  border: 1px solid var(--card-border);
  border-radius: 999px;
  padding: 8px 18px 8px 10px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  min-width: 220px;
}

.sp-timer[hidden] {
  display: none;
}

.sp-timer-bar {
  flex: 1;
  height: 10px;
  border-radius: 5px;
  background: #171a35;
  border: 1px solid var(--card-border);
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.5);
  overflow: hidden;
}

.sp-timer-fill {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, var(--neon-cyan), var(--accent-2));
  transition: width 0.1s linear;
}

.sp-timer-value {
  font-family: var(--font-mono);
  font-size: 20px;
  color: var(--accent);
  min-width: 30px;
  text-align: center;
}

/* Punti live che scorrono all'indietro insieme al tempo: fa percepire subito
   che aspettare costa punti. */
.sp-timer-points {
  font-family: var(--font-mono);
  font-size: 17px;
  color: var(--neon-term);
  min-width: 56px;
  text-align: center;
  border-left: 1px solid var(--card-border);
  padding-left: 12px;
}

.sp-timer-points[hidden] {
  display: none;
}

/* Manche 2: due esiti possibili invece di uno solo (vedi spTimerRenderDisplay) -
   una riga per ciascuno, stessi colori delle carte vere in griglia. */
.sp-timer-points.is-multi {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  min-width: 84px;
  text-align: left;
}
.sp-timer-points-row {
  font-size: 12px;
  white-space: nowrap;
}
.sp-timer-points-esatta { color: #6bff8f; }
.sp-timer-points-limite { color: #c77dff; }

/* ---------- Notifica sblocco badge ---------- */

/* Vicino al badge utente in alto a destra (non al centro): un angolo dove non
   copre il gioco. Resta finché non si clicca la chiusura - niente più timer
   automatico che rischiava di sparire prima di essere notato. */
.badge-toast-container {
  position: fixed;
  top: 74px;
  right: 18px;
  z-index: 80;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 10px;
  max-width: min(300px, calc(100vw - 36px));
  pointer-events: none;
}

.badge-toast {
  display: flex;
  align-items: center;
  gap: 12px;
  background: linear-gradient(160deg, var(--bg-2), var(--bg-1));
  border: 2px solid var(--accent);
  border-radius: 999px;
  padding: 8px 12px 8px 10px;
  box-shadow: inset 2px 2px 0 rgba(255, 255, 255, 0.10), inset -2px -2px 0 rgba(0, 0, 0, 0.35), 0 10px 30px rgba(0, 0, 0, 0.5), 0 0 20px rgba(255, 203, 71, 0.4);
  opacity: 0;
  transform: translateY(-16px) scale(0.95);
  transition: opacity 0.35s ease, transform 0.35s ease;
  pointer-events: auto;
}

.badge-toast.is-visible {
  opacity: 1;
  transform: translateY(0) scale(1);
}

.badge-toast-icon {
  font-size: 26px;
  width: 40px;
  height: 40px;
  flex-shrink: 0;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at 30% 30%, rgba(255,203,71,.4), var(--card-bg));
}

.badge-toast-text {
  min-width: 0;
}

.badge-toast-title {
  font-family: var(--font-display);
  font-size: 12px;
  color: var(--accent);
  letter-spacing: 0.5px;
}

.badge-toast-name {
  font-weight: 700;
  font-size: 14px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.badge-toast-close {
  flex-shrink: 0;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 1px solid var(--card-border);
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-dim);
  font-size: 15px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.badge-toast-close:hover {
  background: rgba(255, 255, 255, 0.18);
  color: var(--text);
}

@media (max-width: 640px) {
  .badge-toast-container { top: 56px; right: 12px; }
  .badge-toast { padding: 7px 10px 7px 8px; gap: 8px; }
  .badge-toast-icon { width: 34px; height: 34px; font-size: 20px; }
}

@media (max-width: 640px) {
  .sp-timer { top: 60px; min-width: 160px; padding: 6px 14px 6px 8px; }
  .sp-timer-value { font-size: 18px; min-width: 24px; }
  .sp-timer-points { font-size: 15px; min-width: 44px; padding-left: 8px; }
}

@media (max-width: 640px) {
  .scoreboard-bar { padding: 10px 14px; }
  .stage { padding: 24px 14px; }
  .home-grid { padding-right: 0; }
  .home-ranking {
    position: static;
    width: 100%;
    margin-bottom: 20px;
  }

  /* Su schermi stretti la control-bar (Home/Nomi/Impostazioni) può occupare
     tutta la fascia inferiore: i pulsanti flottanti (restart, player musica,
     timer) ci finivano sopra. Li spostiamo tutti in alto, ben separati tra loro. */
  .restart-fab {
    bottom: auto;
    /* Sotto al pallino profilo (40px + 12px di margine), non sopra: qui a
       questa larghezza finivano esattamente nello stesso angolo. */
    top: calc(60px + env(safe-area-inset-top, 0px));
    right: calc(12px + env(safe-area-inset-right, 0px));
    padding: 8px 14px;
    font-size: 11px;
    z-index: 50;
  }
  .bg-player {
    bottom: auto;
    top: calc(12px + env(safe-area-inset-top, 0px));
    left: calc(12px + env(safe-area-inset-left, 0px));
    z-index: 46;
  }
  .bg-player-volume {
    width: 46px;
  }
  .bg-player-toggle {
    width: 38px;
    height: 38px;
    font-size: 17px;
  }
  .control-bar { padding: 12px 14px; gap: 8px; }
  .control-bar .btn { padding: 8px 14px; font-size: 13px; }

  .modal-panel { padding: 20px 16px; }
  .modal-title { font-size: 24px; }

  .flash-guess-input { max-width: 100%; width: 100%; }
}

@media (max-width: 420px) {
  .scoreboard-title { font-size: 18px; }
  .team-pill .name { font-size: 13px; }
  .team-pill .score { font-size: 18px; }
  .restart-fab {
    white-space: normal;
    max-width: 132px;
    text-align: center;
    line-height: 1.25;
    padding: 7px 10px;
    font-size: 10px;
  }
}

/* ---------- Home: riga titolo + ingranaggio Impostazioni ---------- */

.home-top-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}

/* ---------- Manche 1: schermata "come si gioca" (al posto del regolamento testuale) ---------- */

.tut-demo-card {
  max-width: 420px;
  margin: 8px auto 0;
  background: #171a35;
  border: 1px solid var(--card-border);
  border-radius: var(--radius-lg);
  padding: 22px 22px 18px;
  text-align: left;
}

/* Manche 3: le parole hanno bisogno di più spazio per non sembrare
   ammassate (vedi anche .tut-demo-flash-stage più sotto). */
.tut-demo-card-wide { max-width: 520px; }

.tut-demo-timer-track { height: 8px; border-radius: 999px; background: rgba(255, 255, 255, 0.1); overflow: hidden; margin-bottom: 18px; }
.tut-demo-timer-fill { height: 100%; width: 100%; background: linear-gradient(90deg, var(--neon-cyan), var(--accent)); transform-origin: left; }
.tut-demo-timer-fill.run { animation: tut-demo-timer-drain 6s linear infinite; }
@keyframes tut-demo-timer-drain { from { transform: scaleX(1); } to { transform: scaleX(0); } }

/* Doppio contatore live nell'esempio di Manche 2 (vedi tutM2DemoTick) -
   stessi colori/stessa idea del vero sp-timer-points in gioco. */
.tut-demo-m2-points {
  display: flex;
  justify-content: center;
  gap: 18px;
  margin: -8px 0 18px;
  font-family: var(--font-mono);
  font-size: 14px;
}
.tut-demo-m2-points[hidden] { display: none; }
.tut-demo-m2-points-esatta { color: #6bff8f; }
.tut-demo-m2-points-limite { color: #c77dff; }

/* Contatore singolo (Manche 1 e 3, vedi tutSingleDemoTick): un solo esito
   possibile, niente colonne multiple. */
.tut-demo-single-points {
  text-align: center;
  margin: -8px 0 18px;
  font-family: var(--font-mono);
  font-size: 14px;
  color: var(--neon-term);
}
.tut-demo-single-points[hidden] { display: none; }

.tut-demo-field {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 14px;
  border-radius: var(--radius-md);
  border: 1px solid var(--card-border);
  background: rgba(0, 0, 0, 0.18);
  margin-bottom: 10px;
  font-size: 14px;
  color: var(--text-dim);
  transition: 0.25s;
}
.tut-demo-label { font-family: var(--font-pixel); font-size: 8px; color: var(--text-dim); letter-spacing: 0.5px; text-transform: uppercase; }
.tut-demo-field.locked { border-color: #6bff8f; background: rgba(107, 255, 143, 0.12); color: #6bff8f; }
.tut-demo-field.locked .tut-demo-label { color: #6bff8f; }
.tut-demo-check { margin-left: auto; opacity: 0; transition: 0.2s; }
.tut-demo-field.locked .tut-demo-check { opacity: 1; }

/* Manche 2: griglia coperta con consegna */
.tut-demo-brief {
  text-align: center;
  font-size: 13px;
  color: var(--text-dim);
  margin-bottom: 14px;
}
.tut-demo-brief em { color: var(--accent); font-style: normal; font-weight: 600; }
.tut-demo-brief-note {
  text-align: center;
  font-size: 12px;
  color: #6bff8f;
  font-weight: 700;
  min-height: 16px;
  margin-top: 10px;
}
.tut-demo-cards { display: flex; gap: 12px; justify-content: center; }
.tut-demo-card-mini {
  width: 62px; height: 78px;
  border-radius: 8px;
  border: 1px solid var(--card-border);
  background: rgba(0, 0, 0, 0.25);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  transition: 0.3s ease;
}
.tut-demo-card-icon { font-size: 22px; }
.tut-demo-card-points { font-family: var(--font-pixel); font-size: 9px; opacity: 0; }
.tut-demo-card-mini.is-good { border-color: #6bff8f; background: rgba(107, 255, 143, 0.15); }
.tut-demo-card-mini.is-good .tut-demo-card-points { opacity: 1; color: #6bff8f; }
.tut-demo-card-mini.is-mid { border-color: var(--accent); background: rgba(255, 203, 71, 0.15); }
.tut-demo-card-mini.is-mid .tut-demo-card-points { opacity: 1; color: var(--accent); }
.tut-demo-card-mini.is-bad { border-color: #ff6b6b; background: rgba(255, 107, 107, 0.15); }
.tut-demo-card-mini.is-bad .tut-demo-card-points { opacity: 1; color: #ff6b6b; }

/* Manche 3: parole a raffica - stesso .flash-word del gioco vero, palcoscenico piccolo */
.tut-demo-flash-stage {
  position: relative;
  height: 160px;
  border-radius: 8px;
  border: 1px solid var(--card-border);
  background: rgba(0, 0, 0, 0.25);
  overflow: hidden;
  margin-bottom: 14px;
}
.tut-demo-scroll-input {
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--card-border);
  background: rgba(0, 0, 0, 0.18);
  color: var(--text-dim);
  font-size: 13px;
  transition: 0.25s;
}
.tut-demo-scroll-input.locked { border-color: #6bff8f; background: rgba(107, 255, 143, 0.12); color: #6bff8f; }

/* Manche 4: il tabellone vero, rimpicciolito - stesse classi/celle del gioco
   (renderBoardGrid/renderBoardZone), solo con dimensioni molto più piccole e
   senza testi/immagini che a quella scala non si leggerebbero comunque. */
.tut-demo-board-mini { display: flex; justify-content: center; }
.tut-demo-board-mini .board-grid {
  grid-template-columns: repeat(5, 42px);
  grid-template-rows: repeat(5, 38px);
  gap: 5px;
}
.tut-demo-board-mini .board-cell { padding: 2px; border-width: 1px; gap: 1px; }
.tut-demo-board-mini .zone-label { font-size: 7px; letter-spacing: 0; }
.tut-demo-board-mini .zone-theme,
.tut-demo-board-mini .boss-image-wrap { display: none; }
.tut-demo-board-mini .board-token { width: 8px; height: 8px; border-width: 1px; }
.tut-demo-board-mini .zone-tokens { gap: 2px; }
#tut-demo-board-mini[hidden] { display: none; }

/* Evidenziazione mirata (es. i boss raggiungibili col dado dal Nord) */
.tut-demo-board-mini .board-cell.tut-cell-highlight {
  border-color: var(--neon-cyan);
  box-shadow: 0 0 10px rgba(0, 240, 255, 0.6);
  animation: tut-cell-pulse 1.4s ease-in-out infinite;
}
@keyframes tut-cell-pulse {
  0%, 100% { box-shadow: 0 0 8px rgba(0, 240, 255, 0.45); }
  50% { box-shadow: 0 0 16px rgba(0, 240, 255, 0.8); }
}
.tut-demo-board-mini .board-cell.tut-cell-dim { opacity: 0.25; }

/* Zoom su una direzione: percorso Via -> Isola -> Boss -> Frammento */
#tut-demo-flow[hidden] { display: none; }
.tut-demo-flow { display: flex; align-items: center; justify-content: center; gap: 6px; flex-wrap: wrap; }
.tut-demo-flow-step {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  font-size: 26px;
  opacity: 0.35;
  transition: 0.3s ease;
}
.tut-demo-flow-step small { font-family: var(--font-pixel); font-size: 8px; color: var(--text-dim); letter-spacing: 0.5px; }
.tut-demo-flow-step.active { opacity: 1; transform: scale(1.15); }
.tut-demo-flow-step.active small { color: var(--accent); }
.tut-demo-flow-arrow { color: var(--text-dim); font-size: 18px; }

/* ---------- Mascotte Palla: tutorial guidato ---------- */
/* Vive fuori da #app (come badge-toast/sp-timer) per sopravvivere ai
   re-render mentre un messaggio sta "scrivendo" o mentre resta come
   compagno ambientale. Lo spotlight invece si applica a elementi dentro
   #app, quindi va ri-applicato a ogni render (vedi initTutorialIfNeeded). */

.tut-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  display: flex;
  align-items: flex-end;
  justify-content: flex-end;
  padding: 0 64px 22px;
  z-index: 70;
}
.tut-layer[hidden] { display: none; }

.tut-bubble-wrap {
  display: flex;
  align-items: flex-end;
  gap: 14px;
  pointer-events: auto;
  max-width: 100%;
}

/* Solo mentre spiega una manche (vedi tutMoveToSpot/TUT_ROAMING_KEYS in
   main.js): nuvoletta e Palla si staccano dal flusso normale IN COPPIA e si
   spostano di fianco al pezzo di esempio di cui sta parlando. */
.tut-bubble-wrap.is-roaming {
  position: fixed;
  z-index: 80;
  transition: left 0.6s cubic-bezier(.34, 1.56, .64, 1), top 0.6s cubic-bezier(.34, 1.56, .64, 1);
}
/* Quando il bersaglio è alla sua sinistra, si ribalta l'ordine (Palla prima
   della nuvoletta) così è sempre lei il pezzo più vicino a ciò che indica. */
.tut-bubble-wrap.point-reverse { flex-direction: row-reverse; }

.tut-bubble {
  width: 300px;
  max-width: 48vw;
  background: linear-gradient(165deg, rgba(26, 16, 68, 0.96), rgba(11, 15, 43, 0.96));
  border: 1px solid var(--accent);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.5), 0 0 26px rgba(255, 203, 71, 0.22);
  border-radius: 18px;
  padding: 16px 17px 14px;
  position: relative;
  animation: tut-bubble-in 0.28s cubic-bezier(.2, .9, .3, 1.2);
}
.tut-bubble::after {
  content: "";
  position: absolute;
  right: -9px;
  bottom: 30px;
  width: 18px; height: 18px;
  background: inherit;
  border-right: 1px solid var(--accent);
  border-bottom: 1px solid var(--accent);
  transform: rotate(-45deg);
  border-radius: 0 0 4px 0;
}
@keyframes tut-bubble-in { from { opacity: 0; transform: translateY(10px) scale(.94); } to { opacity: 1; transform: translateY(0) scale(1); } }

.tut-bubble-name {
  font-family: var(--font-pixel);
  font-size: 9px;
  letter-spacing: 1px;
  color: var(--accent);
  margin-bottom: 8px;
}
.tut-bubble-text {
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.55;
  color: var(--text);
  min-height: 66px;
}
.tut-bubble-text .tut-caret {
  display: inline-block;
  width: 2px; height: 14px;
  background: var(--neon-cyan);
  margin-left: 2px;
  vertical-align: -2px;
  animation: tut-caret-blink 0.85s step-end infinite;
}
@keyframes tut-caret-blink { 50% { opacity: 0; } }

.tut-bubble-foot { display: flex; align-items: center; justify-content: space-between; margin-top: 12px; gap: 10px; }
.tut-bubble-dots { display: flex; gap: 5px; }
.tut-bubble-dots span { width: 6px; height: 6px; border-radius: 50%; background: rgba(255, 255, 255, 0.18); }
.tut-bubble-dots span.on { background: var(--accent); }
.tut-bubble-skip {
  background: none; border: none;
  color: var(--text-dim);
  font-family: var(--font-body);
  font-size: 12px;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
  padding: 4px;
}
.tut-bubble-skip:hover { color: var(--text); }

.palla-wrap { position: relative; width: 92px; height: 92px; flex-shrink: 0; animation: palla-pop-in 0.6s cubic-bezier(.3, 1.4, .4, 1); cursor: pointer; }
.palla-wrap.idle { animation: palla-idle-bounce 2.6s ease-in-out infinite; }
@keyframes palla-pop-in {
  0% { transform: translateY(90px) scale(.3); opacity: 0; }
  55% { transform: translateY(-12px) scale(1.08); opacity: 1; }
  75% { transform: translateY(4px) scale(.96); }
  100% { transform: translateY(0) scale(1); }
}
@keyframes palla-idle-bounce { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-7px); } }

/* Quirk annidato dentro palla-wrap così il suo transform si compone con il
   bounce invece di sostituirlo (due animazioni sulla stessa proprietà/
   elemento non si sommano, vince solo l'ultima). */
.palla-quirk { position: absolute; inset: 0; }
.palla-quirk.q-spin { animation: palla-q-spin 0.9s cubic-bezier(.4, 0, .2, 1); }
.palla-quirk.q-hop { animation: palla-q-hop 0.7s cubic-bezier(.3, 1.6, .4, 1); }
.palla-quirk.q-wobble { animation: palla-q-wobble 0.8s ease-in-out; }
.palla-quirk.q-squash { animation: palla-q-squash 0.55s ease-in-out; }
@keyframes palla-q-spin { 0% { transform: rotate(0) translateY(0); } 45% { transform: rotate(190deg) translateY(-14px); } 100% { transform: rotate(360deg) translateY(0); } }
@keyframes palla-q-hop { 0%, 100% { transform: translateY(0) scale(1, 1); } 30% { transform: translateY(3px) scale(1.12, .84); } 55% { transform: translateY(-24px) scale(.94, 1.08); } 80% { transform: translateY(0) scale(1.08, .92); } }
@keyframes palla-q-wobble { 0%, 100% { transform: rotate(0); } 25% { transform: rotate(-11deg); } 50% { transform: rotate(0); } 75% { transform: rotate(11deg); } }
@keyframes palla-q-squash { 0%, 100% { transform: scale(1, 1); } 40% { transform: scale(1.22, .78); } 70% { transform: scale(.9, 1.14); } }

.palla-eye.winking { animation: palla-eye-wink 0.5s ease-in-out; }
@keyframes palla-eye-wink { 0%, 100% { transform: scaleY(1); } 50% { transform: scaleY(0.08); } }

.tut-help-pin {
  position: absolute;
  top: -5px;
  left: -5px;
  width: 24px; height: 24px;
  border-radius: 50%;
  background: var(--bg-2);
  border: 2px solid var(--neon-cyan);
  color: var(--neon-cyan);
  font-family: var(--font-body);
  font-weight: 800;
  font-size: 13px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 2;
  box-shadow: 0 0 10px rgba(0, 240, 255, 0.4);
  transition: transform 0.15s ease;
}
.tut-help-pin:hover, .tut-help-pin:active { transform: scale(1.15); }

.tut-reaction-chip {
  position: absolute;
  bottom: 108%;
  left: 50%;
  transform: translateX(-50%) translateY(6px) scale(.85);
  white-space: nowrap;
  background: var(--text);
  color: #1a1044;
  font-family: var(--font-body);
  font-weight: 700;
  font-size: 12.5px;
  padding: 6px 12px;
  border-radius: 999px;
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.35);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease;
}
.tut-reaction-chip::after { content: ""; position: absolute; top: 100%; left: 50%; transform: translateX(-50%); border: 6px solid transparent; border-top-color: var(--text); }
.tut-reaction-chip.show { opacity: 1; transform: translateX(-50%) translateY(0) scale(1); }

.tut-sparkle { position: absolute; top: 50%; left: 50%; width: 6px; height: 6px; border-radius: 50%; background: var(--neon-cyan); pointer-events: none; animation: tut-sparkle-burst 0.6s ease-out forwards; }
@keyframes tut-sparkle-burst { 0% { transform: translate(-50%, -50%) translate(0, 0) scale(1); opacity: 1; } 100% { transform: translate(-50%, -50%) translate(var(--sx), var(--sy)) scale(0); opacity: 0; } }

.palla-body {
  position: absolute; inset: 0;
  border-radius: 50%;
  /* Palla resta com'è per ora - il suo restyling arriva in un giro dedicato */
  background: radial-gradient(circle at 34% 28%, #fff6da 0%, var(--accent) 32%, #c9860a 88%);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45), 0 0 30px rgba(255, 203, 71, 0.35);
}
.palla-shine { position: absolute; top: 14%; left: 20%; width: 26%; height: 16%; border-radius: 50%; background: rgba(255, 255, 255, 0.75); filter: blur(3px); }

.palla-arm { position: absolute; width: 28px; height: 10px; border-radius: 999px; background: #c9860a; top: 46%; }
.palla-arm.left { left: -11px; transform: rotate(18deg); }
.palla-arm.right { right: -11px; transform: rotate(-30deg); transform-origin: right center; animation: palla-wave 1.8s ease-in-out infinite; }
@keyframes palla-wave { 0%, 100% { transform: rotate(-20deg); } 50% { transform: rotate(-45deg); } }

.palla-eye { position: absolute; top: 36%; width: 14px; height: 17px; border-radius: 50%; background: #12102c; animation: palla-blink 4.2s ease-in-out infinite; }
.palla-eye.left { left: 28%; }
.palla-eye.right { right: 28%; }
.palla-eye::after { content: ""; position: absolute; top: 3px; left: 3px; width: 5px; height: 5px; border-radius: 50%; background: #fff; opacity: .85; }
@keyframes palla-blink { 0%, 92%, 100% { transform: scaleY(1); } 96% { transform: scaleY(0.1); } }

.palla-mouth { position: absolute; bottom: 26%; left: 50%; transform: translateX(-50%); width: 24px; height: 11px; border-radius: 0 0 20px 20px; background: #12102c; transition: height 0.09s ease; }
.palla-wrap.talking .palla-mouth { animation: palla-talk 0.28s steps(2) infinite; }
@keyframes palla-talk { 0% { height: 11px; } 50% { height: 4px; } 100% { height: 11px; } }

/* Skin di Palla: accessori cosmetici sbloccati a un dato livello (vedi
   applyPallaSkinClass/renderPallaSkinsModule) - .palla-accessory e il suo
   gemello .palla-accessory-2 (aggiunto per gli occhiali, che da soli non
   bastavano più: lente+lente+ponte esauriva già i 3 livelli disponibili,
   servivano anche le stanghette) - l'aspetto lo decide del tutto la classe
   skin-xxx su .palla-wrap. "classic" non aggiunge nessuna classe, resta
   invariata. */
.palla-accessory, .palla-accessory-2 { display: none; position: absolute; }

/* Occhiali "anime" classici: dischi OPACHI che coprono l'occhio (trope
   "Opaque/Nerd Glasses") invece di una montatura sottile che deve
   incorniciarlo con precisione millimetrica - molto più tollerante, niente
   rischio di tagliare male l'occhio. Stanghette (.palla-accessory-2) dello
   stesso spessore/colore del bordo delle lenti, fino al bordo esterno della
   sfera, alla stessa altezza occhi. */
.palla-wrap.skin-nerd .palla-accessory {
  display: block;
  top: 41.3px; left: 50%; transform: translateX(-50%);
  width: 4.5px; height: 2px;
  background: #1a1a1a;
}
.palla-wrap.skin-nerd .palla-accessory::before {
  content: "";
  position: absolute; top: -11px; left: -22px;
  width: 22px; height: 22px;
  border-radius: 50%;
  border: 2px solid #1a1a1a;
  background: radial-gradient(circle at 32% 28%, #ffffff 0%, #dfe6ee 55%, #b7c2d0 100%);
  box-shadow: inset 0 -2px 3px rgba(0, 0, 0, 0.15);
}
.palla-wrap.skin-nerd .palla-accessory::after {
  content: "";
  position: absolute; top: -11px; right: -22px;
  width: 22px; height: 22px;
  border-radius: 50%;
  border: 2px solid #1a1a1a;
  background: radial-gradient(circle at 32% 28%, #ffffff 0%, #dfe6ee 55%, #b7c2d0 100%);
  box-shadow: inset 0 -2px 3px rgba(0, 0, 0, 0.15);
}
.palla-wrap.skin-nerd .palla-accessory-2 {
  display: block;
  top: 40.37px; left: 0;
  width: 21.76px; height: 2.5px;
  background: #1a1a1a;
}
.palla-wrap.skin-nerd .palla-accessory-2::before {
  content: "";
  position: absolute; top: 0; left: 70.24px;
  width: 21.76px; height: 2.5px;
  background: #1a1a1a;
}

/* Cuffie: arco che collega davvero i due padiglioni passando su tutta la
   sommità della sfera - i padiglioni restano ancorati al bordo esterno,
   altezza occhi (dove starebbero le orecchie su una sfera). */
.palla-wrap.skin-gamer .palla-accessory {
  display: block;
  top: -6%; left: 4%; right: 4%;
  height: 37%;
  border: 5px solid #f2f2f2;
  border-bottom: none;
  border-radius: 40px 40px 0 0;
}
.palla-wrap.skin-gamer .palla-accessory::before,
.palla-wrap.skin-gamer .palla-accessory::after {
  content: "";
  position: absolute; top: 34px;
  width: 18px; height: 26px;
  border-radius: 9px;
  background: linear-gradient(180deg, #a855f7, #6d28d9);
  box-shadow: 0 0 8px rgba(168, 85, 247, 0.6);
}
.palla-wrap.skin-gamer .palla-accessory::before { left: -13px; }
.palla-wrap.skin-gamer .palla-accessory::after { right: -13px; }

.palla-wrap.skin-ninja .palla-accessory {
  display: block;
  left: 2%; right: 2%; top: 15%;
  height: 19%;
  background: #14141c;
  clip-path: polygon(0 25%, 100% 0, 100% 75%, 0 100%);
}
.palla-wrap.skin-ninja .palla-accessory::before,
.palla-wrap.skin-ninja .palla-accessory::after {
  content: "";
  position: absolute; right: -11px;
  width: 13px; height: 6px;
  background: #14141c;
}
.palla-wrap.skin-ninja .palla-accessory::before { top: 15%; transform: rotate(18deg); }
.palla-wrap.skin-ninja .palla-accessory::after { top: 55%; transform: rotate(-14deg); }

.palla-wrap.skin-astro .palla-accessory {
  display: block;
  inset: -9%;
  border-radius: 50%;
  border: 4px solid #cfd8e3;
  background: radial-gradient(circle at 30% 25%, rgba(255, 255, 255, 0.55), rgba(180, 220, 255, 0.12) 60%, rgba(180, 220, 255, 0.05));
  box-shadow: 0 0 14px rgba(180, 220, 255, 0.5), inset 0 0 20px rgba(255, 255, 255, 0.25);
}
.palla-wrap.skin-astro .palla-accessory::before {
  content: "";
  position: absolute; top: -14px; left: 50%; transform: translateX(-50%);
  width: 4px; height: 14px; background: #cfd8e3;
}
.palla-wrap.skin-astro .palla-accessory::after {
  content: "";
  position: absolute; top: -21px; left: 50%; transform: translateX(-50%);
  width: 8px; height: 8px; border-radius: 50%; background: #ff6b6b;
  box-shadow: 0 0 6px #ff6b6b;
}

.palla-wrap.skin-regal .palla-accessory {
  display: block;
  top: -16%; left: 22%; right: 22%;
  height: 28%;
  background: linear-gradient(180deg, #ffd85e, #d4a017);
  clip-path: polygon(0% 100%, 0% 40%, 20% 70%, 35% 15%, 50% 70%, 65% 15%, 80% 70%, 100% 40%, 100% 100%);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.35);
}
.palla-wrap.skin-regal .palla-accessory::before {
  content: "";
  position: absolute; top: 58%; left: 50%; transform: translateX(-50%);
  width: 6px; height: 6px; border-radius: 50%;
  background: #ff2fd0; box-shadow: 0 0 4px #ff2fd0;
}

.palla-wrap.skin-golden .palla-body {
  background: radial-gradient(circle at 34% 28%, #fff8e1 0%, #ffd85e 30%, #b8860b 88%);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45), 0 0 40px rgba(255, 216, 94, 0.7);
}
.palla-wrap.skin-golden .palla-shine { background: rgba(255, 255, 255, 0.95); }
.palla-wrap.skin-golden::before {
  content: "";
  position: absolute; inset: -8px;
  border-radius: 50%;
  background: conic-gradient(from 0deg, transparent, rgba(255, 216, 94, 0.55), transparent 30%);
  animation: palla-golden-halo-spin 3s linear infinite;
  pointer-events: none;
  z-index: -1;
}
@keyframes palla-golden-halo-spin { to { transform: rotate(360deg); } }

/* Anello ciano pulsante + tutto il resto attenuato: stessa tecnica del
   prototipo, applicata direttamente all'elemento reale che Palla indica. */
.tut-spotlight {
  position: relative;
  z-index: 6;
  border-radius: var(--radius-lg);
  box-shadow: 0 0 0 4px var(--neon-cyan), 0 0 34px 6px rgba(0, 240, 255, 0.55), 0 0 0 2000px rgba(4, 5, 22, 0.74);
  animation: tut-spot-pulse 1.6s ease-in-out infinite;
}
@keyframes tut-spot-pulse {
  0%, 100% { box-shadow: 0 0 0 4px var(--neon-cyan), 0 0 34px 6px rgba(0, 240, 255, 0.5), 0 0 0 2000px rgba(4, 5, 22, 0.74); }
  50% { box-shadow: 0 0 0 6px var(--neon-cyan), 0 0 46px 10px rgba(0, 240, 255, 0.75), 0 0 0 2000px rgba(4, 5, 22, 0.74); }
}

@media (max-width: 640px) {
  .tut-layer { padding: 0 12px 14px; }
  .tut-bubble-wrap { flex-direction: column-reverse; align-items: flex-end; }
  .tut-bubble { width: min(270px, 74vw); }
  .tut-bubble::after { display: none; }
  .palla-wrap { width: 74px; height: 74px; }
}
