/* ============================================
   FONT — Inter da Google Fonts
   ============================================ */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

/* ============================================
   SFONDO PARTICELLE
   ============================================ */
.background-particles{
  position:fixed;
  inset:0;
  z-index:0;
  pointer-events:none;
  overflow:hidden;
}

.background-particles .particle{
  position:absolute;
  border-radius:50%;
  filter:blur(60px);
  opacity:0.45;
}

.particle-1{
  width:400px;height:400px;
  background:radial-gradient(circle,#8b5cf6,transparent 70%);
  top:-100px;left:-100px;
  animation:float1 25s ease-in-out infinite;
}
.particle-2{
  width:500px;height:500px;
  background:radial-gradient(circle,#3b82f6,transparent 70%);
  top:30%;right:-150px;
  animation:float2 30s ease-in-out infinite;
}
.particle-3{
  width:350px;height:350px;
  background:radial-gradient(circle,#ec4899,transparent 70%);
  bottom:-100px;left:20%;
  animation:float3 28s ease-in-out infinite;
}
.particle-4{
  width:300px;height:300px;
  background:radial-gradient(circle,#f59e0b,transparent 70%);
  top:60%;left:50%;
  animation:float4 35s ease-in-out infinite;
}
.particle-5{
  width:450px;height:450px;
  background:radial-gradient(circle,#10b981,transparent 70%);
  bottom:10%;right:10%;
  animation:float5 32s ease-in-out infinite;
}

@keyframes float1{
  0%,100%{transform:translate(0,0) scale(1)}
  50%{transform:translate(120px,80px) scale(1.15)}
}
@keyframes float2{
  0%,100%{transform:translate(0,0) scale(1)}
  50%{transform:translate(-100px,60px) scale(1.1)}
}
@keyframes float3{
  0%,100%{transform:translate(0,0) scale(1)}
  50%{transform:translate(80px,-80px) scale(1.2)}
}
@keyframes float4{
  0%,100%{transform:translate(0,0) scale(1)}
  50%{transform:translate(-120px,-100px) scale(1.05)}
}
@keyframes float5{
  0%,100%{transform:translate(0,0) scale(1)}
  50%{transform:translate(-80px,120px) scale(1.15)}
}

header, main, .toast, .modale-backdrop{
  position:relative;
  z-index:1;
}

@media (prefers-reduced-motion: reduce){
  .background-particles .particle{animation:none}
}

@media (max-width:1024px){
  .particle-4, .particle-5{opacity:.25}
}

@media (max-width:600px){
  .background-particles .particle{
    filter:blur(40px);
    opacity:0.3;
  }
  .background-particles .particle-4,
  .background-particles .particle-5{
    display:none;
  }
}

/* ============================================
   SCROLL PROGRESS
   ============================================ */
body::before{
  content:'';
  position:fixed;
  top:0;left:0;
  height:3px;
  width:100%;
  background:linear-gradient(90deg,var(--info),var(--primary),var(--danger));
  transform-origin:left;
  transform:scaleX(var(--scroll-progress,0));
  z-index:1000;
  pointer-events:none;
  transition:transform 100ms linear;
}

/* ============================================
   SKELETON LOADING
   ============================================ */
.skeleton-overlay{
  position:fixed;
  inset:0;
  z-index:50;
  background:linear-gradient(135deg,#585792 0%,#8a3f8f 50%,#c03f75 100%);
  padding:100px 20px 20px;
  overflow:hidden;
  transition:opacity 400ms var(--ease),visibility 400ms var(--ease);
}

.skeleton-overlay.hidden{
  opacity:0;
  visibility:hidden;
  pointer-events:none;
}

.skeleton-grid{
  display:grid;
  grid-template-columns:repeat(auto-fill,minmax(240px,1fr));
  gap:14px;
  max-width:1400px;
  margin:0 auto;
}

.skeleton-card{
  background:rgba(255,255,255,.9);
  border-radius:20px;
  padding:18px;
  box-shadow:0 6px 20px rgba(0,0,0,.15);
  display:flex;
  flex-direction:column;
  gap:10px;
  animation:skeletonPulse 1.6s ease-in-out infinite;
}

.skeleton-line{
  height:12px;
  border-radius:6px;
  background:linear-gradient(90deg,
    rgba(0,0,0,.06) 0%,
    rgba(0,0,0,.12) 50%,
    rgba(0,0,0,.06) 100%);
  background-size:200% 100%;
  animation:shimmer 1.5s ease-in-out infinite;
}

.skeleton-line-sm{width:30%}
.skeleton-line-md{width:70%}
.skeleton-line-lg{width:90%;height:16px}

@keyframes shimmer{
  0%{background-position:200% 0}
  100%{background-position:-200% 0}
}

@keyframes skeletonPulse{
  0%,100%{opacity:1}
  50%{opacity:0.85}
}

/* ============================================
   ANIMAZIONI MICRO-INTERAZIONI
   ============================================ */
.pcard{
  animation:cardStagger 400ms var(--ease-smooth) backwards;
}

.pcard:nth-child(1){animation-delay:0ms}
.pcard:nth-child(2){animation-delay:30ms}
.pcard:nth-child(3){animation-delay:60ms}
.pcard:nth-child(4){animation-delay:90ms}
.pcard:nth-child(5){animation-delay:120ms}
.pcard:nth-child(6){animation-delay:150ms}
.pcard:nth-child(7){animation-delay:180ms}
.pcard:nth-child(8){animation-delay:210ms}
.pcard:nth-child(9){animation-delay:240ms}
.pcard:nth-child(10){animation-delay:270ms}

@keyframes cardStagger{
  from{
    opacity:0;
    transform:translateY(20px) scale(0.95);
  }
  to{
    opacity:1;
    transform:translateY(0) scale(1);
  }
}

.counting-number{
  display:inline-block;
  font-variant-numeric:tabular-nums;
  transition:transform 200ms var(--ease-smooth);
}

.ruolo-chip.attivo{
  animation:chipPulse 400ms var(--ease-smooth);
}

@keyframes chipPulse{
  0%{transform:scale(1)}
  50%{transform:scale(1.08)}
  100%{transform:scale(1)}
}

.toast.show{
  animation:toastBounce 500ms cubic-bezier(.68,-0.55,.27,1.55);
}

@keyframes toastBounce{
  0%{transform:translateX(-50%) translateY(150%) scale(0.9)}
  60%{transform:translateX(-50%) translateY(-10px) scale(1.02)}
  80%{transform:translateX(-50%) translateY(2px) scale(0.98)}
  100%{transform:translateX(-50%) translateY(0) scale(1)}
}

.modale-box{
  animation:modalePop 350ms cubic-bezier(.34,1.56,.64,1);
}

@keyframes modalePop{
  from{
    opacity:0;
    transform:scale(0.85) translateY(-20px);
  }
  to{
    opacity:1;
    transform:scale(1) translateY(0);
  }
}

@media (hover:hover){
  .btn-calcola:not(:active){
    animation:buttonPulse 4s ease-in-out infinite;
  }
}

@keyframes buttonPulse{
  0%,100%{filter:brightness(1)}
  50%{filter:brightness(1.08)}
}

.visualizzazioni:not(.hidden){
  animation:visualizzazioniIn 600ms var(--ease-smooth);
}

@keyframes visualizzazioniIn{
  from{
    opacity:0;
    transform:translateY(30px) scale(0.98);
  }
  to{
    opacity:1;
    transform:translateY(0) scale(1);
  }
}

@media (prefers-reduced-motion: reduce){
  .pcard,
  .ruolo-chip.attivo,
  .btn-calcola:not(:active),
  .visualizzazioni:not(.hidden){
    animation:none !important;
  }
}

/* ============================================
   RESET E VARIABILI
   ============================================ */
:root{
  box-sizing:border-box;

  /* Palette ruolo */
  --p-bg:#fff3d6;--p-bd:#e0a83a;
  --d-bg:#dcf5e2;--d-bd:#34c759;
  --c-bg:#dcecff;--c-bd:#3b82f6;
  --a-bg:#ffe1e6;--a-bd:#ef4444;

  /* Palette brand */
  --primary:#8b5cf6;
  --primary-dark:#7c3aed;
  --primary-light:#a78bfa;
  --success:#22c55e;
  --success-dark:#16a34a;
  --danger:#ef4444;
  --danger-dark:#dc2626;
  --info:#3b82f6;
  --neutral:#64748b;
  --neutral-dark:#475569;

  /* Tokens testo */
  --text-on-dark:#eaf2ff;
  --text-muted-dark:#c9dcf4;
  --text-subtle-dark:#9fc3ee;
  --text-hint:#7b8aa3;
  --text-on-light:#12213a;
  --text-body-light:#3a4a63;
  --text-muted-light:#5b6b85;

  /* Glass */
  --glass-bg:rgba(255,255,255,.08);
  --glass-bg-strong:rgba(255,255,255,.14);
  --glass-border:rgba(255,255,255,.18);
  --glass-border-strong:rgba(255,255,255,.28);

  /* Ombre */
  --shadow-sm:0 2px 8px rgba(0,0,0,.15);
  --shadow-md:0 6px 20px rgba(0,0,0,.25);
  --shadow-lg:0 12px 40px rgba(0,0,0,.35);
  --shadow-xl:0 20px 50px rgba(0,0,0,.45);

  /* Raggi */
  --radius-sm:10px;
  --radius:16px;
  --radius-lg:24px;

  /* Transizioni */
  --ease:cubic-bezier(.4,0,.2,1);
  --ease-smooth:cubic-bezier(.25,.1,.25,1);
  --transition-fast:200ms var(--ease-smooth);
  --transition:350ms var(--ease-smooth);
}

html{
  -webkit-tap-highlight-color:transparent;
}

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

body{
  padding:0 0 2rem;
  font-family:'Inter',-apple-system,system-ui,sans-serif;
  color:var(--text-on-dark);
  background:linear-gradient(135deg,#585792 0%,#8a3f8f 25%,#c03f75 50%,#d9504b 75%,#fbad5a 100%);
  background-attachment:fixed;
  background-size:200% 200%;
  animation:gradientShift 20s ease infinite;
  min-height:100vh;
  font-size:15px;
  line-height:1.55;
  letter-spacing:.005em;
  -webkit-font-smoothing:antialiased;
  -moz-osx-font-smoothing:grayscale;
}

@media (max-width:768px){
  body{background-attachment:scroll}
}

@media (prefers-color-scheme: dark){
  :root{
    --glass-bg:rgba(0,0,0,.15);
    --glass-bg-strong:rgba(0,0,0,.25);
  }
  body{
    background:linear-gradient(135deg,#3d3d66 0%,#5f2c63 50%,#8a2c52 100%);
  }
}

@keyframes gradientShift{
  0%,100%{background-position:0% 50%}
  50%{background-position:100% 50%}
}

h1{letter-spacing:-.03em;font-weight:800}
h2,h3{letter-spacing:-.02em;font-weight:800}
h4{letter-spacing:0;font-weight:800}

.appbar h1,
.visualizzazioni-title,
.card .tot,
.modale-box h3{
  text-wrap:balance;
}

/* ============================================
   ACCESSIBILITÀ + DETTAGLI
   ============================================ */
.sr-only{
  position:absolute;width:1px;height:1px;padding:0;margin:-1px;
  overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0;
}
.hidden{display:none !important}

@media (prefers-reduced-motion: reduce){
  *,*::before,*::after{
    animation-duration:0.01ms !important;
    animation-iteration-count:1 !important;
    transition-duration:0.01ms !important;
  }
  .skeleton-overlay{transition:none}
}

button:focus-visible{
  outline:2px solid currentColor;
  outline-offset:3px;
}
input:focus-visible,
select:focus-visible{
  outline:none;
  box-shadow:0 0 0 3px rgba(139,92,246,.35);
  border-radius:8px;
}

::selection{
  background:var(--primary);
  color:#fff;
}

::-webkit-scrollbar{width:10px;height:10px}
::-webkit-scrollbar-track{background:rgba(255,255,255,.05)}
::-webkit-scrollbar-thumb{
  background:rgba(255,255,255,.2);
  border-radius:5px;
}
::-webkit-scrollbar-thumb:hover{background:rgba(255,255,255,.3)}

::placeholder{
  color:rgba(255,255,255,.4);
  font-style:italic;
}

input[type="file"]{
  font-size:13px;
  color:var(--text-muted-dark);
}

/* ============================================
   HEADER
   ============================================ */
.appbar{
  position:sticky;top:0;z-index:5;
  padding:16px 20px calc(16px + env(safe-area-inset-top,0px));
  background:rgba(8,18,38,.6);
  backdrop-filter:blur(20px) saturate(180%);
  -webkit-backdrop-filter:blur(20px) saturate(180%);
  border-bottom:1px solid rgba(255,255,255,.1);
  display:flex;align-items:center;gap:14px;
  box-shadow:
    0 8px 32px rgba(0,0,0,.25),
    inset 0 1px 0 rgba(255,255,255,.08);
}
.appbar .logo-img{
  width:48px;height:48px;object-fit:contain;
  filter:drop-shadow(0 4px 12px rgba(139,92,246,.5));
  transition:transform var(--transition);
}
.appbar .logo-img:hover{
  transform:scale(1.08) rotate(-3deg);
}
.appbar h1{
  font-size:20px;margin:0;font-weight:800;letter-spacing:-.3px;
  background:linear-gradient(135deg,#fff 0%,#c9dcf4 100%);
  -webkit-background-clip:text;-webkit-text-fill-color:transparent;
  background-clip:text;
}
.appbar .sub{
  font-size:11px;
  color:var(--text-subtle-dark);
  margin:2px 0 0;
  font-weight:500;
}

@media (max-width:768px){
  .appbar{backdrop-filter:blur(14px) saturate(180%);-webkit-backdrop-filter:blur(14px) saturate(180%)}
}

/* ============================================
   CONTENUTO PRINCIPALE
   ============================================ */
.content{
  padding:1.5rem;
  max-width:1400px;
  margin:0 auto;
  padding-bottom:calc(100px + env(safe-area-inset-bottom, 0px));
}
.legend{
  font-size:13px;
  color:var(--text-muted-dark);
  margin-bottom:1.5rem;
  line-height:1.6;
  max-width:70ch;
}

.top{
  background:var(--glass-bg);
  backdrop-filter:blur(20px) saturate(180%);
  -webkit-backdrop-filter:blur(20px) saturate(180%);
  border:1px solid var(--glass-border);
  border-radius:var(--radius-lg);
  padding:20px 24px;
  margin-bottom:1.5rem;
  box-shadow:
    0 8px 32px rgba(0,0,0,.25),
    inset 0 1px 0 rgba(255,255,255,.1);
  transition:background-color var(--transition),
             border-color var(--transition);
  overflow: visible;
  position: relative;
  z-index: 50;
  /* ✅ G1-a — Layout orizzontale rosa + modulo */
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
}

.top:hover{
  background:var(--glass-bg-strong);
  border-color:var(--glass-border-strong);
}
.top label{
  font-size:12px;
  color:var(--text-on-dark);
  margin-right:8px;
  font-weight:700;
  letter-spacing:.02em;
}
.top select{
  font-size:14px;
  padding:10px 36px 10px 14px;
  border-radius:var(--radius-sm);
  border:1px solid #cfd8e3;
  background-color:#fff;
  color:var(--text-on-light);
  font-weight:500;
  transition:border-color var(--transition-fast),
             box-shadow var(--transition-fast);
  cursor:pointer;
  appearance:none;
  -webkit-appearance:none;
  background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%233a4a63' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat:no-repeat;
  background-position:right 12px center;
}
.top select:hover{
  border-color:var(--primary);
  box-shadow:0 0 0 3px rgba(139,92,246,.15);
}

@media (max-width:768px){
  .top{backdrop-filter:blur(12px) saturate(180%);-webkit-backdrop-filter:blur(12px) saturate(180%)}
}

@media (prefers-reduced-transparency: reduce){
  .top, .rosa-selector, .appbar, .modale-box{
    backdrop-filter:none !important;
    -webkit-backdrop-filter:none !important;
    background:rgba(20,20,40,.95) !important;
  }
  .modale-box{background:#fff !important}
}

/* ============================================
   BASE COMUNE A TUTTI I BOTTONI
   ============================================ */
button{
  font-family:'Inter',-apple-system,system-ui,sans-serif;
  cursor:pointer;
  transition:background-color var(--transition-fast),
             border-color var(--transition-fast),
             box-shadow var(--transition-fast),
             color var(--transition-fast),
             transform var(--transition-fast),
             filter var(--transition-fast);
  -webkit-tap-highlight-color:transparent;
  user-select:none;
  position:relative;
  white-space:nowrap;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  gap:8px;
  font-weight:700;
  letter-spacing:.02em;
  line-height:1;
  border:none;
  overflow:hidden;
}
button:active:not(:disabled){transform:translateY(1px)}
button:disabled{opacity:.5;cursor:not-allowed;transform:none !important}

.btn-rosa::after,
.btn-aggiungi::after,
.btn-avv::after,
.btn-filtro::after,
.btn-rosa-danger::after,
.btn-installa::after{
  content:'';
  position:absolute;
  inset:0;
  background:radial-gradient(circle at center, rgba(255,255,255,.4), transparent 70%);
  opacity:0;
  pointer-events:none;
  transition:opacity 400ms;
}
.btn-rosa:active::after,
.btn-aggiungi:active::after,
.btn-avv:active::after,
.btn-filtro:active::after,
.btn-rosa-danger:active::after,
.btn-installa:active::after{
  opacity:1;
  transition:0s;
}

/* ============================================
   BTN AVVERSARI
   ============================================ */
.btn-avv{
  margin-left:12px;
  font-size:13px;
  padding:11px 18px;
  border-radius:var(--radius-sm);
  background:linear-gradient(135deg,var(--info),#2563eb);
  color:#fff;
  box-shadow:
    0 4px 14px rgba(37,99,235,.35),
    inset 0 1px 0 rgba(255,255,255,.25);
}
.btn-avv:hover{
  background:linear-gradient(135deg,#60a5fa,var(--info));
  transform:translateY(-2px);
  box-shadow:
    0 8px 24px rgba(37,99,235,.5),
    inset 0 1px 0 rgba(255,255,255,.35);
}
.btn-avv:active{
  transform:translateY(0);
  box-shadow:
    0 2px 8px rgba(37,99,235,.3),
    inset 0 1px 0 rgba(255,255,255,.25);
}

/* ============================================
   BTN FILTRO
   ============================================ */
.btn-filtro{
  font-size:12px;
  padding:8px 16px;
  border-radius:var(--radius-sm);
  border:1px solid rgba(255,255,255,.3);
  background:rgba(255,255,255,.1);
  color:#fff;
  font-weight:700;
  backdrop-filter:blur(6px);
  -webkit-backdrop-filter:blur(6px);
}
.btn-filtro:hover{
  background:rgba(255,255,255,.22);
  border-color:rgba(255,255,255,.5);
  transform:translateY(-1px);
  box-shadow:0 6px 16px rgba(0,0,0,.2);
}
.btn-filtro:active{
  transform:translateY(1px);
  box-shadow:0 2px 6px rgba(0,0,0,.15);
}

/* ============================================
   RUOLO CHIP
   ============================================ */
.ruolo-chip{
  font-size:12px;
  padding:8px 16px;
  border-radius:999px;
  border:1px solid rgba(255,255,255,.4);
  background:rgba(255,255,255,.95);
  color:var(--text-on-light);
  font-weight:700;
  box-shadow:0 2px 6px rgba(0,0,0,.1);
}
.ruolo-chip:hover{
  transform:translateY(-1px);
  box-shadow:0 4px 12px rgba(0,0,0,.15);
  border-color:rgba(139,92,246,.5);
}
.ruolo-chip:active{transform:translateY(1px)}
.ruolo-chip.attivo{
  background:linear-gradient(135deg,var(--info),var(--primary));
  color:#fff;
  border-color:transparent;
  box-shadow:
    0 4px 14px rgba(139,92,246,.45),
    inset 0 1px 0 rgba(255,255,255,.3);
}
.ruolo-chip.attivo:hover{
  box-shadow:
    0 6px 20px rgba(139,92,246,.6),
    inset 0 1px 0 rgba(255,255,255,.4);
}

/* ============================================
   BTN ROSA (glass)
   ============================================ */
.btn-rosa{
  font-size:12px;
  padding:10px 16px;
  border-radius:var(--radius-sm);
  /* ✅ G1-e — Restyle scuro coerente con menu ⋮ */
  border:1px solid rgba(167,139,250,.5);
  background:rgba(139,92,246,.15);
  color:#eaf2ff;
  font-weight:700;
  backdrop-filter:blur(8px);
  -webkit-backdrop-filter:blur(8px);
  box-shadow:
    0 4px 12px rgba(0,0,0,.2),
    inset 0 1px 0 rgba(255,255,255,.08);
}
.btn-rosa:hover{
  /* ✅ G1-e — Hover viola più intenso */
  background:rgba(139,92,246,.28);
  border-color:rgba(167,139,250,.75);
  transform:translateY(-2px);
  box-shadow:
    0 8px 20px rgba(139,92,246,.35),
    inset 0 1px 0 rgba(255,255,255,.15);
}
.btn-rosa:active{
  transform:translateY(0);
  box-shadow:
    0 2px 6px rgba(0,0,0,.15),
    inset 0 1px 0 rgba(255,255,255,.08);
}

/* ============================================
   BTN ROSA DANGER
   ============================================ */
.btn-rosa-danger{
  background:linear-gradient(135deg,var(--danger),var(--danger-dark));
  border-color:transparent;
  box-shadow:
    0 4px 14px rgba(220,38,38,.4),
    inset 0 1px 0 rgba(255,255,255,.2);
}
.btn-rosa-danger:hover{
  background:linear-gradient(135deg,#f87171,var(--danger));
  border-color:transparent;
  box-shadow:
    0 8px 22px rgba(220,38,38,.55),
    inset 0 1px 0 rgba(255,255,255,.3);
}
.btn-rosa-danger:active{
  box-shadow:
    0 2px 8px rgba(220,38,38,.4),
    inset 0 1px 0 rgba(255,255,255,.2);
}

/* ============================================
   BTN AGGIUNGI (azione)
   ============================================ */
.btn-aggiungi{
  padding:16px 24px;
  font-size:14px;
  font-weight:700;
  border-radius:var(--radius);
  border:1px solid rgba(255,255,255,.4);
  background:linear-gradient(135deg,rgba(255,255,255,.2),rgba(255,255,255,.1));
  backdrop-filter:blur(8px);
  -webkit-backdrop-filter:blur(8px);
  color:#fff;
  box-shadow:
    0 4px 14px rgba(0,0,0,.2),
    inset 0 1px 0 rgba(255,255,255,.18);
}
.btn-aggiungi:hover{
  background:linear-gradient(135deg,rgba(255,255,255,.32),rgba(255,255,255,.18));
  border-color:rgba(255,255,255,.6);
  transform:translateY(-2px);
  box-shadow:
    0 8px 24px rgba(0,0,0,.3),
    inset 0 1px 0 rgba(255,255,255,.28);
}
.btn-aggiungi:active{
  transform:translateY(0);
  box-shadow:
    0 2px 8px rgba(0,0,0,.2),
    inset 0 1px 0 rgba(255,255,255,.18);
}

/* ============================================
   BTN CALCOLA
   ============================================ */
.btn-calcola{
  padding:16px 32px;
  font-size:15px;
  font-weight:800;
  border-radius:var(--radius);
  background:linear-gradient(135deg,var(--success),var(--success-dark));
  color:#fff;
  box-shadow:
    0 6px 20px rgba(34,197,94,.35),
    inset 0 1px 0 rgba(255,255,255,.25);
  letter-spacing:.02em;
  flex:1 1 260px;
  min-width:200px;
  max-width:400px;
}
.btn-calcola::before{
  content:'';
  position:absolute;
  top:0;left:-100%;
  width:100%;height:100%;
  background:linear-gradient(90deg,transparent,rgba(255,255,255,.35),transparent);
  transition:left 600ms ease;
  pointer-events:none;
  z-index:1;
}
.btn-calcola::after{display:none}
.btn-calcola:hover{
  background:linear-gradient(135deg,#4ade80,var(--success));
  transform:translateY(-2px);
  box-shadow:
    0 10px 28px rgba(34,197,94,.55),
    inset 0 1px 0 rgba(255,255,255,.35);
}
.btn-calcola:hover::before{left:100%}
.btn-calcola:active{
  transform:translateY(0);
  box-shadow:
    0 3px 10px rgba(34,197,94,.4),
    inset 0 1px 0 rgba(255,255,255,.25);
}

/* ============================================
   BTN INSTALLA
   ============================================ */
.btn-installa{
  margin-left:auto;
  padding:11px 20px;
  font-size:13px;
  font-weight:800;
  border-radius:var(--radius-sm);
  background:linear-gradient(135deg,var(--info),var(--primary));
  color:#fff;
  box-shadow:
    0 4px 14px rgba(139,92,246,.4),
    inset 0 1px 0 rgba(255,255,255,.25);
}
.btn-installa:hover{
  background:linear-gradient(135deg,#60a5fa,var(--primary-light));
  transform:translateY(-2px);
  box-shadow:
    0 8px 22px rgba(139,92,246,.6),
    inset 0 1px 0 rgba(255,255,255,.35);
}
.btn-installa:active{
  transform:translateY(0);
  box-shadow:
    0 2px 8px rgba(139,92,246,.4),
    inset 0 1px 0 rgba(255,255,255,.25);
}

/* ============================================
   SELETTORE ROSA
   ============================================ */
.rosa-selector{
  display:flex;
  flex-wrap:wrap;
  gap:10px;
  align-items:center;
  padding:16px 18px;
  /* ✅ G1-a — Rimosso margin-bottom:18px (ora gestito da gap di .top) */
  margin-bottom: 0;
  background:rgba(255,255,255,.06);
  border:1px solid rgba(255,255,255,.15);
  border-radius:var(--radius);
  position: relative;
  z-index: 200;
  overflow: visible;
  /* ✅ G1-a — Occupa lo spazio disponibile nel flex di .top */
  flex: 1 1 auto;
  min-width: 0;
}
}
.rosa-label{
  font-size:13px;
  font-weight:700;
  color:var(--text-on-dark);
  margin-right:4px;
}
.rosa-select{
  font-size:13px;
  padding:10px 36px 10px 14px;
  border-radius:var(--radius-sm);
  border:1px solid #cfd8e3;
  background-color:#fff;
  color:var(--text-on-light);
  font-weight:600;
  min-width:200px;
  cursor:pointer;
  transition:border-color var(--transition-fast),
             box-shadow var(--transition-fast);
  appearance:none;
  -webkit-appearance:none;
  background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%233a4a63' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat:no-repeat;
  background-position:right 12px center;
}
.rosa-select:hover{
  border-color:var(--primary);
  box-shadow:0 0 0 3px rgba(139,92,246,.15);
}

.rosa-divider{
  width:1px;
  height:28px;
  background:rgba(255,255,255,.15);
  margin:0 4px;
}

/* ============================================
   GRIGLIA GIOCATORI
   ============================================ */
.grid{
  display:grid;
  grid-template-columns:repeat(auto-fill,minmax(240px,1fr));
  gap:16px;
}

.pcard{
  border:1.5px solid rgba(255,255,255,.5);
  border-left-width:5px;
  border-left-color:transparent;
  border-radius:20px;
  padding:0;
  transition:box-shadow var(--transition),
             transform var(--transition);
  background:rgba(255,255,255,.96);
  color:var(--text-on-light);
  box-shadow:var(--shadow-md);
  position:relative;
  overflow:hidden;	/* ✅ Bug-1 fix: taglia i figli (incluso ::before) agli angoli arrotondati */
}

.pcard::before{
  content:'';
  position:absolute;
  top:0;left:0;right:0;
  height:4px;
  background:linear-gradient(90deg,var(--info),var(--primary));
  transition:opacity var(--transition);
  clip-path: inset(0 round 20px 20px 0 0);
}

.pcard.compilata{
  box-shadow:
    0 6px 20px rgba(0,0,0,.25),
    0 0 0 2px rgba(139,92,246,.3);
}

.pcard.role-P{background:var(--p-bg);border-color:var(--p-bd);border-left-color:var(--p-bd)}
.pcard.role-P::before{background:linear-gradient(90deg,var(--p-bd),#f59e0b)}
.pcard.role-D{background:var(--d-bg);border-color:var(--d-bd);border-left-color:var(--d-bd)}
.pcard.role-D::before{background:linear-gradient(90deg,var(--d-bd),#10b981)}
.pcard.role-C{background:var(--c-bg);border-color:var(--c-bd);border-left-color:var(--c-bd)}
.pcard.role-C::before{background:linear-gradient(90deg,var(--c-bd),var(--primary))}
.pcard.role-A{background:var(--a-bg);border-color:var(--a-bd);border-left-color:var(--a-bd)}
.pcard.role-A::before{background:linear-gradient(90deg,var(--a-bd),#f43f5e)}

.pcard:hover{
  transform:translateY(-4px);
  box-shadow:0 20px 40px rgba(0,0,0,.3);
}

/* ============================================
   HEADER della card
   ============================================ */
.pcard-header{
  display:flex;
  align-items:center;
  gap:10px;
  padding:14px 16px 12px;
  border-bottom:1px solid rgba(0,0,0,.06);
}

.pcard-ruolo{
  flex-shrink:0;
  min-width:52px;
  height:44px;
  padding:0 10px;
  border-radius:12px;
  display:flex;
  align-items:center;
  justify-content:center;
  font-size:11px;
  font-weight:800;
  color:#fff;
  text-shadow:0 1px 2px rgba(0,0,0,.25);
  box-shadow:
    0 4px 12px rgba(0,0,0,.2),
    inset 0 -2px 0 rgba(0,0,0,.15);
  background:linear-gradient(135deg,var(--neutral),var(--neutral-dark));
  letter-spacing:.05em;
  text-transform:uppercase;
  transition:transform var(--transition-fast);
}

.pcard:hover .pcard-ruolo{
  transform:scale(1.06) rotate(-2deg);
}

.pcard.role-P .pcard-ruolo{background:linear-gradient(135deg,#e0a83a,#f59e0b)}
.pcard.role-D .pcard-ruolo{background:linear-gradient(135deg,#34c759,#10b981)}
.pcard.role-C .pcard-ruolo{background:linear-gradient(135deg,var(--info),var(--primary))}
.pcard.role-A .pcard-ruolo{background:linear-gradient(135deg,var(--danger),#f43f5e)}

.pcard-info{
  flex:1;
  min-width:0;
  display:flex;
  flex-direction:column;
  gap:2px;
}

/* ============================================
   RETTANGOLO NOME — CON FRECCIA ▾ E ✕
   ============================================ */
.pcard-nome-box{
  position:relative;
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:6px;
  min-height:34px;
  padding:6px 8px 6px 12px;
  border-radius:var(--radius-sm);
  background:rgba(255,255,255,.6);
  border:1.5px solid rgba(0,0,0,.08);
  font-size:12px;
  font-weight:800;
  color:var(--text-on-light);
  max-width:100%;
  overflow:hidden;
  box-shadow:0 1px 3px rgba(0,0,0,.06);
  transition:background-color var(--transition-fast),
             border-color var(--transition-fast),
             box-shadow var(--transition-fast);
}

.pcard-nome-box.vuoto{cursor:text}
.pcard-nome-box.pieno{cursor:pointer}

/* Bordo del colore ruolo tramite box-shadow interno */
.pcard.role-P .pcard-nome-box{
  background:rgba(224,168,58,.15);
  border-color:transparent;
  box-shadow:inset 0 0 0 1.5px rgba(224,168,58,.3);
}
.pcard.role-D .pcard-nome-box{
  background:rgba(52,199,89,.15);
  border-color:transparent;
  box-shadow:inset 0 0 0 1.5px rgba(52,199,89,.3);
}
.pcard.role-C .pcard-nome-box{
  background:rgba(59,130,246,.15);
  border-color:transparent;
  box-shadow:inset 0 0 0 1.5px rgba(59,130,246,.3);
}
.pcard.role-A .pcard-nome-box{
  background:rgba(239,68,68,.15);
  border-color:transparent;
  box-shadow:inset 0 0 0 1.5px rgba(239,68,68,.3);
}

.pcard-nome-box.pieno{
  border-style:solid;
}

.pcard-nome-box:hover{
  box-shadow:
    inset 0 0 0 1.5px currentColor,
    0 0 0 3px rgba(139,92,246,.15),
    0 2px 8px rgba(139,92,246,.15);
}

.pcard-nome{
  display:block;
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis;
  flex:1;
  min-width:0;
  pointer-events:none;
  color:inherit;
}

.pcard-freccia{
  flex-shrink:0;
  font-size:12px;
  font-weight:800;
  color:var(--text-body-light);
  opacity:.75;
  pointer-events:none;
  transition:transform var(--transition-fast),color var(--transition-fast);
}

.pcard-nome-box:hover .pcard-freccia{
  color:var(--primary);
  transform:scale(1.15);
}

.pcard-nome-box .pcard-nome-input{
  position:absolute;
  inset:0;
  width:100%;
  height:100%;
  background:transparent;
  border:none;
  color:transparent;
  caret-color:transparent;
  font-size:12px;
  font-family:'Inter',sans-serif;
  padding:0 60px 0 12px;
  margin:0;
  outline:none;
  z-index:1;
  cursor:pointer;
  -webkit-appearance:none;
  appearance:none;
  pointer-events:auto;
}

.pcard-nome-box .pcard-nome-input::-ms-clear{display:none}
.pcard-nome-box .pcard-nome-input::-webkit-search-cancel-button{display:none}

.pcard-sub{
  font-size:11px;
  color:var(--text-hint);
  font-weight:600;
  padding-left:4px;
}

/* ============================================
   BODY della card
   ============================================ */
.pcard-body{
  padding:14px 16px 18px;
}

.pclose{
  flex-shrink:0;
  cursor:pointer;
  background:rgba(0,0,0,.06);
  border:none;
  color:#b91c1c;
  font-size:16px;
  font-weight:800;
  line-height:1;
  padding:0;
  width:32px;
  height:32px;
  min-width:32px;
  min-height:32px;
  border-radius:9px;
  display:flex;
  align-items:center;
  justify-content:center;
  transition:background-color var(--transition-fast),
             transform var(--transition-fast);
}

.pclose:hover{
  background:#fee2e2;
  transform:scale(1.1);
}
.pclose:active{
  transform:scale(0.95);
}

@media (hover:none) and (pointer:coarse){
  .pclose{
    width:44px;
    height:44px;
    min-width:44px;
    min-height:44px;
    top:6px;
    right:6px;
  }
}

.pcard select{
  width:100%;
  font-size:13px;
  margin-top:4px;
  box-sizing:border-box;
  border:1.5px solid #cfd8e3;
  border-radius:var(--radius-sm);
  padding:10px 36px 10px 14px;
  font-family:'Inter',sans-serif;
  transition:border-color var(--transition-fast),
             box-shadow var(--transition-fast);
  cursor:pointer;
  background-color:#fff;
  font-weight:600;
  color:var(--text-on-light);
  appearance:none;
  -webkit-appearance:none;
  background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%233a4a63' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat:no-repeat;
  background-position:right 12px center;
}
.pcard select:focus{
  border-color:var(--primary);
  box-shadow:
    0 0 0 3px rgba(139,92,246,.15),
    0 0 20px rgba(139,92,246,.25);
  outline:none;
}

.pcard label{
  font-size:10px;
  color:var(--text-body-light);
  display:block;
  margin-top:12px;
  font-weight:800;
  text-transform:uppercase;
  letter-spacing:.08em;
}

/* ============================================
   BOTTONI AZIONI
   ============================================ */
.azioni{
  display:flex;
  flex-wrap:wrap;
  gap:12px;
  margin-top:1.5rem;
}

/* ============================================
   RISULTATI
   ============================================ */
.card{
  background:rgba(255,255,255,.98);
  color:var(--text-on-light);
  border-radius:20px;
  padding:1.5rem;
  margin-top:1.5rem;
  overflow-x:auto;
  box-shadow:var(--shadow-lg);
  animation:cardIn 400ms var(--ease-smooth);
}
@keyframes cardIn{
  from{opacity:0;transform:translateY(20px)}
  to{opacity:1;transform:translateY(0)}
}
.tot{
  font-weight:800;
  font-size:15px;
  margin-bottom:14px;
  padding-bottom:14px;
  border-bottom:2px solid rgba(139,92,246,.15);
}
table{width:100%;border-collapse:collapse;font-size:13px}
th{
  color:var(--text-muted-light);font-size:11px;text-transform:uppercase;
  letter-spacing:.08em;font-weight:700;
  padding:12px 10px;
}
th,td{
  padding:12px 10px;text-align:left;
  border-bottom:1px solid #eef1f6;
  white-space:nowrap;
}
tbody tr{
  transition:background-color var(--transition-fast);
}
tbody tr:hover td{background:#f7faff}
tbody tr:nth-child(even) td{background:rgba(240,244,250,.5)}
tbody tr:nth-child(even):hover td{background:#f0f4fa}

tr.riga-P td{
  background:linear-gradient(90deg, #fff3d6, #ffe9b8) !important;
  border-left:4px solid #e0a83a;
}
tr.riga-D td{
  background:linear-gradient(90deg, #dcf5e2, #c4ebd0) !important;
  border-left:4px solid #34c759;
}
tr.riga-C td{
  background:linear-gradient(90deg, #dcecff, #c5dfff) !important;
  border-left:4px solid #3b82f6;
}
tr.riga-A td{
  background:linear-gradient(90deg, #ffe1e6, #ffc9d2) !important;
  border-left:4px solid #ef4444;
}
tr.riga-P:hover td{ background:linear-gradient(90deg, #ffedb8, #ffd98a) !important; }
tr.riga-D:hover td{ background:linear-gradient(90deg, #c4ebd0, #a8e0b8) !important; }
tr.riga-C:hover td{ background:linear-gradient(90deg, #c5dfff, #a8d0ff) !important; }
tr.riga-A:hover td{ background:linear-gradient(90deg, #ffc9d2, #ffb3c0) !important; }

/* ============================================
   VISUALIZZAZIONI — Chart.js
   ============================================ */
.visualizzazioni{
  margin-top:2rem;
  animation:cardIn 500ms var(--ease-smooth);
}

.visualizzazioni-title{
  font-size:16px;
  font-weight:800;
  color:var(--text-on-dark);
  margin:0 0 16px;
  letter-spacing:-.02em;
}

.charts-grid{
  display:grid;
  grid-template-columns:repeat(auto-fit,minmax(280px,1fr));
  gap:16px;
}

.chart-card{
  background:rgba(255,255,255,.97);
  color:var(--text-on-light);
  border-radius:20px;
  padding:20px;
  box-shadow:
    0 6px 20px rgba(0,0,0,.25),
    inset 0 1px 0 rgba(255,255,255,.5);
  transition:transform var(--transition),
             box-shadow var(--transition);
}
.chart-card:hover{
  transform:translateY(-2px);
  box-shadow:
    0 12px 40px rgba(0,0,0,.35),
    inset 0 1px 0 rgba(255,255,255,.5);
}
.chart-card-wide{
  grid-column:1 / -1;
}
.chart-card h4{
  font-size:12px;
  font-weight:700;
  color:var(--text-muted-light);
  margin:0 0 14px;
  text-transform:uppercase;
  letter-spacing:.08em;
}

.chart-wrapper{
  position:relative;
  width:100%;
  height:240px;
}
.chart-wrapper-bar{
  height:320px;
}
.chart-wrapper canvas{
  position:absolute;
  top:0;
  left:0;
  width:100% !important;
  height:100% !important;
  display:block;
}

/* ============================================
   HEATMAP
   ============================================ */
.heatmap{
  display:grid;
  grid-template-columns:repeat(auto-fit,minmax(80px,1fr));
  gap:8px;
}
.heatmap-cell{
  position:relative;
  padding:12px 8px 18px 8px;
  border-radius:12px;
  text-align:center;
  font-size:12px;
  font-weight:700;
  color:#fff;
  transition:transform var(--transition-fast),
             box-shadow var(--transition-fast);
  cursor:default;
}
.heatmap-cell:hover{
  transform:scale(1.08);
  box-shadow:0 6px 16px rgba(0,0,0,.25);
}
.heatmap-cell .nome{
  display:block;
  font-size:11px;
  font-weight:600;
  opacity:.9;
  margin-bottom:2px;
  text-overflow:ellipsis;
  overflow:hidden;
  white-space:nowrap;
}
.heatmap-cell .avv{
  display:block;
  font-size:13px;
  font-weight:800;
}
.heatmap-cell.veryEasy{background:linear-gradient(135deg,#22c55e,#16a34a)}
.heatmap-cell.easy{background:linear-gradient(135deg,#84cc16,#65a30d)}
.heatmap-cell.medium{background:linear-gradient(135deg,#eab308,#ca8a04)}
.heatmap-cell.hard{background:linear-gradient(135deg,#f97316,#ea580c)}
.heatmap-cell.veryHard{background:linear-gradient(135deg,#ef4444,#dc2626)}
.heatmap-cell.empty{background:linear-gradient(135deg,#94a3b8,#64748b)}

.heatmap-cell.veryEasy::after{content:'★★';position:absolute;bottom:4px;left:50%;transform:translateX(-50%);font-size:8px;opacity:.5}
.heatmap-cell.easy::after{content:'★';position:absolute;bottom:4px;left:50%;transform:translateX(-50%);font-size:8px;opacity:.5}
.heatmap-cell.medium::after{content:'◆';position:absolute;bottom:4px;left:50%;transform:translateX(-50%);font-size:8px;opacity:.5}
.heatmap-cell.hard::after{content:'●';position:absolute;bottom:4px;left:50%;transform:translateX(-50%);font-size:8px;opacity:.5}
.heatmap-cell.veryHard::after{content:'●●';position:absolute;bottom:4px;left:50%;transform:translateX(-50%);font-size:8px;opacity:.5}

/* ============================================
   TOAST
   ============================================ */
.toast{
  position:fixed;
  bottom:calc(24px + env(safe-area-inset-bottom,0px));
  left:50%;
  transform:translateX(-50%) translateY(150%);
  background:rgba(18,33,58,.95);
  backdrop-filter:blur(16px) saturate(180%);
  -webkit-backdrop-filter:blur(16px) saturate(180%);
  color:#fff;
  padding:14px 24px;
  border-radius:14px;
  font-size:13px;font-weight:600;
  box-shadow:0 16px 48px rgba(0,0,0,.5);
  border:1px solid rgba(255,255,255,.15);
  transition:transform 350ms var(--ease-smooth);
  z-index:100;
  max-width:90vw;
  text-align:center;
}
.toast:empty{display:none}
.toast.show{transform:translateX(-50%) translateY(0)}
.toast.success{
  background:linear-gradient(135deg,rgba(34,197,94,.95),rgba(21,128,61,.95));
}
.toast.error{
  background:linear-gradient(135deg,rgba(220,38,38,.95),rgba(185,28,28,.95));
}

/* ============================================
   MODALE BASE
   ============================================ */
.modale-backdrop{
  position:fixed;inset:0;
  background:rgba(8,18,38,.75);
  backdrop-filter:blur(12px);
  -webkit-backdrop-filter:blur(12px);
  display:flex;align-items:flex-start;justify-content:center;
  z-index:200;padding:1rem;
  padding-top:calc(90px + env(safe-area-inset-top,0px));
  animation:fadeIn 200ms var(--ease-smooth);
  overflow-y:auto;
}

/* ✅ FIX C.1.g.3-b — La modale di conferma (#modale) deve stare SOPRA
   le altre modali (es. #modaleEditorTabelle), altrimenti la conferma
   "Reset default" appare dietro l'editor. */
#modale{
  z-index: 250;
}

.modale-backdrop.hidden{display:none}

@media (max-width:768px){
  .modale-backdrop{backdrop-filter:blur(6px);-webkit-backdrop-filter:blur(6px)}
}

.modale-box{
  /* ✅ G1-e-modale — Restyle scuro coerente con menu ⋮ e modale pesi */
  background: rgba(20, 25, 50, 0.97);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #eaf2ff;
  border-radius:20px;
  padding:28px;
  max-width:460px;width:100%;
  box-shadow:
    0 32px 80px rgba(0, 0, 0, 0.6),
    inset 0 1px 0 rgba(255, 255, 255, 0.08);
  animation:slideDown 300ms var(--ease-smooth);
  margin-top:0;
  /* ✅ FIX MOBILE — Spazio extra in fondo per la barra di navigazione smartphone */
  padding-bottom: calc(28px + env(safe-area-inset-bottom, 0px));
}
.modale-box h3{
  margin:0 0 14px;
  font-size:20px;
  /* ✅ G1-e-modale — Titolo bianco */
  color: #ffffff;
  font-weight:800;
  letter-spacing:-.02em;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}
.modale-box p{
  margin:0 0 24px;
  font-size:14px;
  /* ✅ G1-e-modale — Testo chiaro */
  color: rgba(234, 242, 255, 0.8);
  line-height:1.6;
}
.modale-box input[type="text"]{
  width:100%;font-size:14px;padding:12px 14px;
  /* ✅ G1-e-modale — Input scuro con testo chiaro */
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.18);
  color: #eaf2ff;
  border-radius:var(--radius-sm);
  box-sizing:border-box;margin-bottom:18px;
  font-family:'Inter',sans-serif;
  transition:border-color var(--transition-fast),
             background-color var(--transition-fast),
             box-shadow var(--transition-fast);
}
.modale-box input[type="text"]::placeholder{
  color: rgba(234, 242, 255, 0.4);
}
.modale-box input[type="text"]:focus{
  /* ✅ G1-e-modale — Focus viola */
  background: rgba(139, 92, 246, 0.12);
  border-color: rgba(167, 139, 250, 0.7);
  box-shadow:0 0 0 4px rgba(139, 92, 246, 0.25);
  outline:none;
}
}
.modale-azioni{
  display:flex;
  gap:10px;
  justify-content:flex-end;
  flex-wrap:wrap;
  /* ✅ FIX MOBILE — Spazio extra in fondo per la barra di navigazione dello smartphone */
  padding-bottom: env(safe-area-inset-bottom, 0);
  margin-bottom: env(safe-area-inset-bottom, 0);
}
.modale-azioni button{
  padding:13px 24px;
  font-size:13px;
  font-weight:700;
  border-radius:var(--radius-sm);
  border:none;
  font-family:'Inter',sans-serif;
  flex:1 1 auto;
  min-width:120px;
}
.modale-btn-annulla{
  /* ✅ G1-e-modale — Annulla scuro */
  background: rgba(255, 255, 255, 0.08);
  color: #eaf2ff;
  border: 1px solid rgba(255, 255, 255, 0.15);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05);
}
.modale-btn-annulla:hover{
  /* ✅ G1-e-modale — Hover chiaro su fondo scuro */
  background: rgba(255, 255, 255, 0.15);
  border-color: rgba(255, 255, 255, 0.3);
  transform:translateY(-1px);
  box-shadow: 0 6px 16px rgba(0,0,0,.3);
}
.modale-btn-annulla:active{
  transform:translateY(1px);
  box-shadow: 0 2px 6px rgba(0,0,0,.2);
}
}
.modale-btn-conferma{
  background:linear-gradient(135deg,var(--info),var(--primary));
  color:#fff;
  box-shadow:0 4px 14px rgba(139,92,246,.45),inset 0 1px 0 rgba(255,255,255,.25);
}
.modale-btn-conferma:hover{
  background:linear-gradient(135deg,#60a5fa,var(--primary-light));
  transform:translateY(-1px);
  box-shadow:0 8px 22px rgba(139,92,246,.6),inset 0 1px 0 rgba(255,255,255,.35);
}
.modale-btn-conferma:active{
  transform:translateY(1px);
  box-shadow:0 2px 8px rgba(139,92,246,.45);
}
.modale-btn-conferma.danger{
  background:linear-gradient(135deg,var(--danger),var(--danger-dark));
  box-shadow:0 4px 14px rgba(220,38,38,.45),inset 0 1px 0 rgba(255,255,255,.2);
}
.modale-btn-conferma.danger:hover{
  background:linear-gradient(135deg,#f87171,var(--danger));
  box-shadow:0 8px 22px rgba(220,38,38,.6),inset 0 1px 0 rgba(255,255,255,.3);
}

@keyframes fadeIn{
  from{opacity:0}
  to{opacity:1}
}
@keyframes slideDown{
  from{transform:translateY(-30px);opacity:0}
  to{transform:translateY(0);opacity:1}
}

.modale-errore{
  margin: -14px 0 16px 0;
  padding: 8px 12px;
  font-size: 13px;
  font-weight: 600;
  color: var(--danger);
  background: rgba(239, 68, 68, 0.08);
  border-left: 3px solid var(--danger);
  border-radius: 6px;
  line-height: 1.4;
  text-align: left;
  animation: modaleErroreIn 200ms var(--ease-smooth);
}

.modale-errore.hidden{
  display: none !important;
}

@keyframes modaleErroreIn{
  from{
    opacity: 0;
    transform: translateY(-4px);
  }
  to{
    opacity: 1;
    transform: translateY(0);
  }
}

/* ============================================
   MODALE PESI — base + restyle scuro unificati
   ============================================ */
.modale-box-pesi{
  max-width: 520px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  padding: 0;
  overflow: hidden;
  background: rgba(20, 25, 50, 0.95) !important;
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border: 1px solid rgba(255, 255, 255, 0.15);
  box-shadow:
    0 24px 60px rgba(0, 0, 0, 0.6),
    inset 0 1px 0 rgba(255, 255, 255, 0.08);
  color: #eaf2ff;
}

.modale-box-pesi h3{
  margin-bottom: 8px;
  color: #ffffff;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
  padding-top: 24px;
  padding-left: 24px;
  padding-right: 24px;
}

.modale-box-pesi .modale-pesi-desc{
  margin: 0 0 16px;
  font-size: 13px;
  color: rgba(234, 242, 255, 0.75);
  line-height: 1.5;
  padding-left: 24px;
  padding-right: 24px;
}

.modale-box-pesi .pesi-scroll{
  flex: 1 1 auto;
  overflow-y: auto;
  overflow-x: visible; /* ✅ Permette al tooltip di uscire lateralmente */
  padding: 0 20px 0 24px; /* ✅ Più spazio a destra per il tooltip */
  scrollbar-width: thin;
}

.modale-box-pesi .pesi-scroll::-webkit-scrollbar{
  width: 8px;
}
.modale-box-pesi .pesi-scroll::-webkit-scrollbar-thumb{
  background: rgba(167, 139, 250, 0.3);
  border-radius: 4px;
}
.modale-box-pesi .pesi-scroll::-webkit-scrollbar-thumb:hover{
  background: rgba(167, 139, 250, 0.5);
}
.modale-box-pesi .pesi-scroll::-webkit-scrollbar-track{
  background: transparent;
}

.modale-box-pesi .pesi-gruppo{
  margin-bottom: 20px;
}
.modale-box-pesi .pesi-gruppo:last-of-type{
  margin-bottom: 8px;
}

.pesi-gruppo-titolo{
  margin: 0 0 12px;
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: #c4b5fd;
  padding-bottom: 6px;
  border-bottom: 1px solid rgba(167, 139, 250, 0.35);
}

.modale-box-pesi .peso-item{
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(139, 92, 246, 0.08);
  border: 1px solid rgba(167, 139, 250, 0.15);
  transition: background-color 200ms var(--ease-smooth);
  overflow: visible; /* ✅ Aggiunto per far uscire il tooltip */
}

.modale-box-pesi .peso-item:hover{
  background: rgba(139, 92, 246, 0.15);
  border-color: rgba(167, 139, 250, 0.3);
}

.modale-box-pesi .peso-item label{
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  font-size: 13px;
  font-weight: 700;
  color: #eaf2ff;
  cursor: pointer;
}

.modale-box-pesi .peso-item output{
  font-size: 13px;
  font-weight: 800;
  color: #c4b5fd;
  font-variant-numeric: tabular-nums;
  background: rgba(139, 92, 246, 0.25);
  border: 1px solid rgba(167, 139, 250, 0.3);
  padding: 2px 8px;
  border-radius: 6px;
  min-width: 48px;
  text-align: center;
}

.modale-box-pesi .peso-desc{
  font-size: 11px;
  font-weight: 500;
  color: rgba(234, 242, 255, 0.55);
  line-height: 1.4;
  margin: 0;
}

.modale-box-pesi .peso-item input[type="range"]{
  width: 100%;
  height: 6px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.1);
  appearance: none;
  -webkit-appearance: none;
  cursor: pointer;
  accent-color: var(--primary);
  margin-top: 2px;
}

.modale-box-pesi .peso-item input[type="range"]::-webkit-slider-thumb{
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #a78bfa;
  box-shadow: 0 2px 8px rgba(167, 139, 250, 0.6);
  cursor: pointer;
  transition: transform 150ms;
}
.modale-box-pesi .peso-item input[type="range"]::-webkit-slider-thumb:hover{
  transform: scale(1.15);
}
.modale-box-pesi .peso-item input[type="range"]::-moz-range-thumb{
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #a78bfa;
  border: none;
  box-shadow: 0 2px 8px rgba(167, 139, 250, 0.6);
  cursor: pointer;
}

.modale-box-pesi .modale-azioni{
  flex-shrink: 0;
  padding: 16px 24px calc(24px + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(10, 15, 35, 0.6);
}

.modale-box-pesi .modale-btn-annulla{
  background: rgba(255, 255, 255, 0.08);
  color: #eaf2ff;
  border: 1px solid rgba(255, 255, 255, 0.15);
}
.modale-box-pesi .modale-btn-annulla:hover{
  background: rgba(255, 255, 255, 0.15);
  border-color: rgba(255, 255, 255, 0.3);
}

.modale-box-pesi .modale-btn-conferma{
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #fff;
  border: none;
}
.modale-box-pesi .modale-btn-conferma:hover{
  background: linear-gradient(135deg, var(--primary-light), var(--primary));
  box-shadow: 0 8px 22px rgba(139, 92, 246, 0.55);
}

@media (max-width: 600px){
  .modale-box-pesi{
    padding: 18px 14px;
    max-width: calc(100vw - 20px);
    max-height: 90vh;
    background: rgba(20, 25, 50, 0.98) !important;
  }
  .modale-box-pesi .peso-item{
    padding: 8px 10px;
    margin-bottom: 10px;
  }
  .modale-box-pesi .peso-item label{
    font-size: 12px;
  }
  .modale-box-pesi .peso-item output{
    font-size: 12px;
    min-width: 42px;
  }
  .modale-box-pesi .pesi-scroll{
    padding: 0 16px;
    scrollbar-width: thin;
  }
    .modale-box-pesi .modale-azioni{
    padding: 12px 16px calc(18px + env(safe-area-inset-bottom, 0px));
  }
  .modale-box-pesi h3,
  .modale-box-pesi .modale-pesi-desc{
    padding-left: 16px;
    padding-right: 16px;
  }
  .modale-box-pesi h3{
    padding-top: 18px;
  }
}

/* ============================================
   PESI (ex-pannello legacy, non più usato)
   ============================================ */
.peso-item{
  display:flex;flex-direction:column;gap:8px;
  font-size:12px;color:var(--text-on-dark);
  background:rgba(255,255,255,.08);
  padding:12px 16px;
  border-radius:var(--radius-sm);
  border:1px solid rgba(255,255,255,.1);
  transition:background-color var(--transition-fast),
             border-color var(--transition-fast);
}
.peso-item:hover{
  background:rgba(255,255,255,.12);
  border-color:rgba(255,255,255,.2);
}
.peso-item > span{
  font-weight:700;font-size:11px;
  text-transform:uppercase;letter-spacing:.08em;
  color:var(--text-muted-dark);
}
.peso-item input[type="range"]{
  width:100%;
  cursor:pointer;
  accent-color:var(--primary);
  height:6px;
  border-radius:3px;
}
.peso-item output{
  font-weight:800;
  color:#7dd3fc;
  font-family:'Inter',monospace;
  font-size:13px;
  text-align:right;
  font-variant-numeric:tabular-nums;
}

/* ============================================
   INFO GIORNATA / API
   ============================================ */
/* ✅ G1-f-E — .giornata-info rimosso: le info sono nella modale Informazioni */

/* ============================================
   ✅ G1-a — PROGRESS BAR (regole base + layout flex)
   ============================================ */
.progress-bar{
  /* ✅ G1-a fix overflow — usa flex-basis:100% + box-sizing per non uscire dal .top */
  flex: 1 1 100%;
  min-width: 0;
  box-sizing: border-box;
  margin-top: 8px;
  padding: 14px 18px;
  background: rgba(255,255,255,.06);
  border: 1px solid rgba(255,255,255,.15);
  border-radius: var(--radius);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.08);
  transition: box-shadow var(--transition);
}

.progress-bar.completo{
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,.08),
    0 0 0 2px rgba(34, 197, 94, 0.35);
}

.progress-bar-header{
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.progress-bar-icon{
  font-size: 18px;
  line-height: 1;
}

.progress-bar-text{
  flex: 1;
  font-size: 13px;
  color: #eaf2ff;
  font-weight: 600;
  display: flex;
  align-items: baseline;
  gap: 6px;
}

.progress-bar-text strong{
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  color: #c4b5fd;
  font-size: 14px;
}

.progress-bar-label{
  color: rgba(234, 242, 255, 0.7);
  font-weight: 500;
  font-size: 12px;
}

.progress-bar-percent{
  font-size: 13px;
  font-weight: 800;
  color: #c4b5fd;
  font-variant-numeric: tabular-nums;
  background: rgba(139, 92, 246, 0.2);
  border: 1px solid rgba(167, 139, 250, 0.3);
  border-radius: 6px;
  padding: 2px 8px;
  min-width: 48px;
  text-align: center;
}

.progress-bar-track{
  width: 100%;
  height: 8px;
  border-radius: 4px;
  background: rgba(255,255,255,.08);
  overflow: hidden;
  position: relative;
}

.progress-bar-fill{
  height: 100%;
  border-radius: 4px;
  background: linear-gradient(90deg, var(--info), var(--primary), var(--primary-light));
  transition: width 350ms var(--ease-smooth), background 350ms var(--ease-smooth);
  box-shadow: 0 0 12px rgba(139, 92, 246, 0.5);
}

.progress-bar.completo .progress-bar-fill{
  background: linear-gradient(90deg, var(--success), #4ade80);
  box-shadow: 0 0 12px rgba(34, 197, 94, 0.6);
}

/* Su mobile, riduci leggermente padding e font */
@media (max-width: 480px){
  .progress-bar{
    padding: 12px 14px;
  }
  .progress-bar-text{
    font-size: 12px;
  }
  .progress-bar-text strong{
    font-size: 13px;
  }
  .progress-bar-label{
    font-size: 11px;
  }
  .progress-bar-percent{
    font-size: 12px;
    min-width: 42px;
  }
}
}
.api-status{
  margin-top:4px;
  font-size:12px;
  color: #ffffff;
  font-weight: 600;
  text-shadow: 0 1px 2px rgba(0,0,0,.35);
}

/* ============================================
   FILTRI RUOLI
   ============================================ */
.check-group{
  display:flex;
  flex-wrap:wrap;
  gap:10px;
  margin-top:14px;
}

/* ============================================
   MODULO SELECTOR
   ============================================ */
.modulo-selector{
  position: relative;
  display: inline-block;
  vertical-align: middle;
  /* ✅ G1-a — Spinge a destra su desktop */
  margin-left: auto;
  z-index: 100;
  /* ✅ G1-a — Non cresce, resta compatto */
  flex: 0 0 auto;
}

/* ✅ G1-a — Su mobile annulla margin-left: auto per evitare spazio vuoto */
@media (max-width: 768px){
  .modulo-selector{
    margin-left: 0;
  }
}

.modulo-btn{
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  background: rgba(255,255,255,.10);
  border: 1px solid rgba(255,255,255,.20);
  border-radius: 999px;
  cursor: pointer;
  transition: all 200ms ease;
  color: #ffffff;
  font-family: 'Inter', sans-serif;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .02em;
}

.modulo-btn:hover{
  background: rgba(255,255,255,.15);
  border-color: rgba(255,255,255,.35);
  transform: translateY(-1px);
}

.modulo-btn:active{
  transform: translateY(0) scale(0.96);
}

.modulo-btn:focus-visible{
  outline: 2px solid #fff;
  outline-offset: 3px;
}

.modulo-btn svg{
  display: block;
  width: 24px;
  height: 24px;
  border-radius: 6px;
  opacity: 0.85;
}

.modulo-label{
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.modulo-dropdown{
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  left: auto;
  z-index: 9999;
  min-width: 200px;
  max-height: 320px;
  overflow-y: auto;
  margin: 0;
  padding: 6px;
  list-style: none;
  /* ✅ G1-c — Restyle scuro coerente con il menu ⋮ */
  background: rgba(20, 25, 50, 0.97);
  backdrop-filter: blur(16px) saturate(180%);
  -webkit-backdrop-filter: blur(16px) saturate(180%);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 14px;
  box-shadow:
    0 12px 40px rgba(0, 0, 0, 0.5),
    0 2px 8px rgba(0, 0, 0, 0.25),
    inset 0 1px 0 rgba(255, 255, 255, 0.08);
  animation: dropdownIn 180ms cubic-bezier(.4,0,.2,1);
}
.modulo-dropdown.hidden{
  display: none;
}

.modulo-dropdown li{
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 14px;
  font-size: 13.5px;
  font-weight: 600;
  /* ✅ G1-c — Testo chiaro su sfondo scuro */
  color: #eaf2ff;
  border-radius: 8px;
  cursor: pointer;
  transition: background-color 180ms ease, color 180ms ease;
  user-select: none;
  white-space: nowrap;
}

.modulo-dropdown li:hover{
  /* ✅ G1-c — Hover viola come menu ⋮ */
  background: rgba(139, 92, 246, 0.18);
  color: #ffffff;
}

.modulo-dropdown li[aria-selected="true"]{
  /* ✅ G1-c — Voce attiva */
  background: rgba(139, 92, 246, 0.22);
  color: #ffffff;
  font-weight: 800;
}

.modulo-dropdown li[aria-selected="true"]::after{
  content: '✓';
  font-size: 12px;
  /* ✅ G1-c — Check viola chiaro */
  color: #c4b5fd;
  margin-left: 8px;
}

.modulo-dropdown::-webkit-scrollbar{
  width: 6px;
}
.modulo-dropdown::-webkit-scrollbar-thumb{
  /* ✅ G1-c — Scrollbar viola su sfondo scuro */
  background: rgba(167, 139, 250, 0.35);
  border-radius: 3px;
}
.modulo-dropdown::-webkit-scrollbar-thumb:hover{
  background: rgba(167, 139, 250, 0.55);
}

@media (max-width: 600px){
  .modulo-btn svg{
    width: 22px;
    height: 22px;
  }
  .modulo-dropdown{
    min-width: 180px;
  }
}

/* ✅ G1-b-fix — Su mobile, la tendina modulo si apre verso DESTRA
   (il pulsante è a sinistra di .top per via di flex-wrap) */
@media (max-width: 768px){
  .modulo-dropdown{
    right: auto;
    left: 0;
  }
}

.top,
.content,
section,
details{
  overflow: visible !important;
}

.modulo-selector{
  position: relative;
  z-index: 100;
}

.modulo-dropdown{
  z-index: 9999 !important;
}

/* ============================================
   ROSE DROPDOWN
   ============================================ */
.rosa-dropdown-wrapper{
  position: relative;
  display: inline-block;
}

.rosa-btn{
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-width: 180px;
  /* ✅ FIX: limita la larghezza massima e tronca i nomi lunghi */
  max-width: 100%;
  padding: 10px 14px;
  font-size: 13px;
  font-weight: 600;
  /* ✅ G1-d-fix — Stato a riposo: viola trasparente (come hover precedente) */
  color: #eaf2ff;
  background: rgba(139, 92, 246, 0.18);
  backdrop-filter: blur(12px) saturate(180%);
  -webkit-backdrop-filter: blur(12px) saturate(180%);
  border: 1px solid rgba(167, 139, 250, 0.55);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background-color 200ms ease, border-color 200ms ease, box-shadow 200ms ease;
  box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.18);
  /* ✅ FIX: impedisce al testo di uscire */
  overflow: hidden;
}

/* ✅ FIX: il nome della rosa si tronca con "..." quando è troppo lungo */
.rosa-btn #rosaBtnLabel{
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: left;
}

.rosa-btn .rosa-arrow{
  flex-shrink: 0;
}

.rosa-btn:hover{
  /* ✅ G1-d-fix — Hover: viola più intenso */
  background: rgba(139, 92, 246, 0.30);
  border-color: rgba(167, 139, 250, 0.75);
  box-shadow: 0 0 0 4px rgba(139, 92, 246, 0.25);
}

.rosa-btn[aria-expanded="true"]{
  /* ✅ G1-d-fix — Stato aperto: ancora più viola */
  background: rgba(139, 92, 246, 0.38);
  border-color: rgba(167, 139, 250, 0.85);
  box-shadow: 0 0 0 4px rgba(139, 92, 246, 0.3);
}
}

.rosa-btn[aria-expanded="true"] .rosa-arrow{
  transform: rotate(180deg);
}

.rosa-arrow{
  flex-shrink: 0;
  width: 14px;
  height: 14px;
  /* ✅ G1-d — Freccia chiara su sfondo scuro */
  color: #c4b5fd;
  opacity: 1;
  transition: transform 200ms ease;
}

.rosa-dropdown{
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  z-index: 9999;
  min-width: 220px;
  max-width: calc(100vw - 40px);
  max-height: 320px;
  overflow-y: auto;
  overflow-x: hidden;
  margin: 0;
  padding: 6px;
  list-style: none;
  /* ✅ G1-d — Restyle scuro coerente con menu ⋮ */
  background: rgba(20, 25, 50, 0.97);
  backdrop-filter: blur(16px) saturate(180%);
  -webkit-backdrop-filter: blur(16px) saturate(180%);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 14px;
  box-shadow:
    0 12px 40px rgba(0, 0, 0, 0.5),
    0 2px 8px rgba(0, 0, 0, 0.25),
    inset 0 1px 0 rgba(255, 255, 255, 0.08);
  animation: dropdownIn 180ms cubic-bezier(.4,0,.2,1);
}

.rosa-dropdown.hidden{
  display: none;
}

.rosa-dropdown li{
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 10px 8px 14px;
  font-size: 13.5px;
  font-weight: 600;
  /* ✅ G1-d — Testo chiaro */
  color: #eaf2ff;
  border-radius: 8px;
  cursor: pointer;
  transition: background-color 180ms ease, color 180ms ease;
  user-select: none;
}

.rosa-dropdown li:hover{
  /* ✅ G1-d — Hover viola */
  background: rgba(139, 92, 246, 0.18);
  color: #ffffff;
}

.rosa-dropdown li[aria-selected="true"]{
  /* ✅ G1-d — Attiva */
  background: rgba(139, 92, 246, 0.22);
  color: #ffffff;
  font-weight: 800;
}

.rosa-dropdown li .rosa-nome{
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding-right: 8px;
}

.rosa-dropdown li .rosa-actions{
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}

.rosa-action-btn{
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  padding: 0;
  border: none;
  border-radius: 6px;
  background: transparent;
  /* ✅ G1-d — Icone chiare */
  color: rgba(234, 242, 255, 0.7);
  cursor: pointer;
  transition: all 150ms ease;
}

.rosa-action-btn:hover{
  /* ✅ G1-d — Hover su fondo scuro */
  background: rgba(255, 255, 255, 0.12);
  color: #ffffff;
}

.rosa-action-btn.delete:hover{
  /* ✅ G1-d — Delete rosso su fondo scuro */
  background: rgba(239, 68, 68, 0.3);
  color: #fca5a5;
}

.rosa-action-btn svg{
  width: 14px;
  height: 14px;
  display: block;
}

@media (max-width: 600px){
  .rosa-dropdown{
    min-width: 0;
    width: max-content;
    max-width: calc(100vw - 32px);
    left: 0;
    right: auto;
  }
  .rosa-dropdown li{
    padding: 8px 8px 8px 12px;
    font-size: 12px;
  }
  .rosa-action-btn{
    width: 24px;
    height: 24px;
  }
  .rosa-action-btn svg{
    width: 12px;
    height: 12px;
  }
}

@media (max-width: 400px){
  .rosa-dropdown{
    left: auto;
    right: 0;
    min-width: 180px;
    max-width: calc(100vw - 16px);
  }
  .rosa-dropdown li .rosa-nome{
    font-size: 11px;
  }
}

/* ============================================
   DOWNLOAD DROPDOWN (legacy, rimosso dalla UI)
   ============================================ */
.download-dropdown-wrapper{
  position: relative;
  display: inline-block;
  z-index: 100;
}

.download-dropdown-wrapper .btn-rosa{
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.download-arrow{
  transition: transform 200ms ease;
}

.download-dropdown-wrapper .btn-rosa[aria-expanded="true"] .download-arrow{
  transform: rotate(180deg);
}

.download-dropdown{
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  left: auto;
  z-index: 9999;
  min-width: 0;
  max-width: calc(100vw - 24px);
  margin: 0;
  padding: 6px;
  list-style: none;
  background: #fff;
  border-radius: var(--radius-sm);
  box-shadow:
    0 12px 40px rgba(0,0,0,.35),
    0 2px 8px rgba(0,0,0,.15);
  animation: dropdownIn 180ms cubic-bezier(.4,0,.2,1);
}

.download-dropdown.hidden{
  display: none;
}

.download-dropdown li{
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-on-light);
  border-radius: 8px;
  cursor: pointer;
  transition: background-color 150ms ease;
  user-select: none;
  white-space: normal;
  word-break: break-word;
  overflow-wrap: anywhere;
}

.download-dropdown li:hover,
.download-dropdown li:focus-visible{
  background: rgba(139, 92, 246, 0.1);
  outline: none;
}

.download-dropdown li svg{
  flex-shrink: 0;
  color: var(--text-muted-light);
}

@media (max-width: 600px){
  .download-dropdown{
    right: auto;
    left: 0;
    min-width: 0;
    width: auto;
    max-width: calc(100vw - 32px);
  }
  .download-dropdown li{
    padding: 10px 12px;
    font-size: 12px;
  }
}

/* ============================================
   MOBILE BAR
   ============================================ */
.mobile-bar{
  display: none;
}

@media (max-width: 768px){
  .mobile-bar{
    display: flex;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 90;
    padding: 8px 12px calc(8px + env(safe-area-inset-bottom, 0px));
    background: rgba(20, 20, 45, 0.92);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border-top: 1px solid rgba(255,255,255,.15);
    box-shadow: 0 -4px 20px rgba(0,0,0,.35);
    gap: 8px;
  }

  .mobile-bar-btn{
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    padding: 10px 6px;
    background: rgba(255,255,255,.08);
    border: 1px solid rgba(255,255,255,.15);
    border-radius: 12px;
    color: #ffffff;
    font-family: 'Inter', sans-serif;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: .02em;
    cursor: pointer;
    min-height: 52px;
    transition: background-color 200ms, transform 150ms;
    -webkit-tap-highlight-color: transparent;
  }

  .mobile-bar-btn:hover,
  .mobile-bar-btn:active{
    background: rgba(255,255,255,.18);
    transform: translateY(-1px);
  }

  .mobile-bar-btn.primary{
    background: linear-gradient(135deg, #22c55e, #16a34a);
    border-color: transparent;
    box-shadow: 0 4px 14px rgba(34,197,94,.45);
  }

  .mobile-bar-btn.primary:hover,
  .mobile-bar-btn.primary:active{
    background: linear-gradient(135deg, #4ade80, #22c55e);
  }

  .azioni{
    display: none !important;
  }

  body{
    padding-bottom: calc(80px + env(safe-area-inset-bottom, 0px)) !important;
  }

  .toast{
    bottom: calc(80px + env(safe-area-inset-bottom, 0px));
  }
}

/* ============================================
   MENU SHEET — bottom sheet mobile
   ============================================ */
.menu-sheet-backdrop{
  position:fixed;
  inset:0;
  z-index:150;
  background:rgba(8,18,38,.6);
  backdrop-filter:blur(8px);
  -webkit-backdrop-filter:blur(8px);
  display:flex;
  align-items:flex-end;
  justify-content:center;
  animation:fadeIn 200ms var(--ease-smooth);
  padding:0;
}

.menu-sheet-backdrop.hidden{display:none}

.menu-sheet{
  width:100%;
  max-width:520px;
  background:rgba(20,25,50,.98);
  color:#eaf2ff;
  border-top-left-radius:24px;
  border-top-right-radius:24px;
  padding:12px 16px calc(20px + env(safe-area-inset-bottom,0px));
  box-shadow:0 -8px 40px rgba(0,0,0,.5);
  border-top:1px solid rgba(255,255,255,.15);
  animation:sheetUp 320ms cubic-bezier(.34,1.2,.64,1);
  max-height:80vh;
  overflow-y:auto;
}

@keyframes sheetUp{
  from{transform:translateY(100%)}
  to{transform:translateY(0)}
}

.menu-sheet-handle{
  width:44px;
  height:4px;
  border-radius:2px;
  background:rgba(255,255,255,.25);
  margin:0 auto 14px;
}

.menu-sheet-title{
  font-size:16px;
  font-weight:800;
  margin:0 0 14px;
  color:#fff;
  text-align:center;
  letter-spacing:-.01em;
}

.menu-sheet-list{
  list-style:none;
  margin:0;
  padding:0;
  display:flex;
  flex-direction:column;
  gap:4px;
}

.menu-sheet-list li{
  display:flex;
  align-items:center;
  gap:14px;
  padding:14px 16px;
  border-radius:12px;
  font-size:15px;
  font-weight:600;
  color:#eaf2ff;
  cursor:pointer;
  transition:background-color 180ms ease, transform 120ms ease;
  user-select:none;
  min-height:52px;
}

.menu-sheet-list li:hover,
.menu-sheet-list li:focus-visible{
  background:rgba(255,255,255,.10);
  outline:none;
}

.menu-sheet-list li:active{
  background:rgba(255,255,255,.16);
  transform:scale(0.98);
}

.menu-sheet-list li svg{
  flex-shrink:0;
  color:#a78bfa;
}

.menu-sheet-list li.menu-sheet-item-danger svg{
  color:#f87171;
}

.menu-sheet-list li.menu-sheet-item-danger{
  color:#fca5a5;
}

.menu-sheet-close{
  display:block;
  width:100%;
  margin-top:12px;
  padding:14px;
  background:rgba(255,255,255,.06);
  border:1px solid rgba(255,255,255,.15);
  border-radius:12px;
  color:#eaf2ff;
  font-family:'Inter',sans-serif;
  font-size:14px;
  font-weight:700;
  cursor:pointer;
  transition:background-color 180ms ease;
}

.menu-sheet-close:hover,
.menu-sheet-close:active{
  background:rgba(255,255,255,.14);
}

.menu-sheet-separator{
  height: 1px;
  border: none;
  margin: 6px 10px;
  background: rgba(255, 255, 255, 0.15);
}

.menu-sheet-status{
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  font-size: 12px;
  font-weight: 600;
  color: rgba(234, 242, 255, 0.65);
  list-style: none;
  cursor: default;
  user-select: none;
}

.menu-sheet-status::before{
  content: '';
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.5;
}

@media (min-width:769px){
  .menu-sheet-backdrop{display:none !important}
}

/* ============================================
   CARD "+"
   ============================================ */
.pcard-add{
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  min-height: 240px;
  padding: 20px;
  background: rgba(255, 255, 255, 0.06);
  border: 2px dashed rgba(255, 255, 255, 0.35);
  border-radius: 20px;
  color: rgba(255, 255, 255, 0.75);
  cursor: pointer;
  user-select: none;
  transition:
    background-color 250ms var(--ease-smooth),
    border-color 250ms var(--ease-smooth),
    transform 200ms var(--ease-smooth),
    box-shadow 250ms var(--ease-smooth);
  -webkit-tap-highlight-color: transparent;
}

.pcard-add-icon{
  display: flex;
  align-items: center;
  justify-content: center;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: rgba(139, 92, 246, 0.2);
  border: 2px solid rgba(139, 92, 246, 0.5);
  color: var(--primary-light);
  font-size: 32px;
  font-weight: 300;
  line-height: 1;
  transition:
    background-color 250ms var(--ease-smooth),
    border-color 250ms var(--ease-smooth),
    color 250ms var(--ease-smooth),
    transform 250ms var(--ease-smooth);
}

.pcard-add-icon svg{
  display: block;
}

.pcard-add-label{
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-align: center;
  text-transform: uppercase;
  opacity: 0.75;
  transition: opacity 250ms var(--ease-smooth);
}

@media (hover: hover){
  .pcard-add:hover{
    background: rgba(139, 92, 246, 0.12);
    border-color: rgba(139, 92, 246, 0.7);
    border-style: solid;
    transform: translateY(-4px);
    box-shadow:
      0 12px 32px rgba(139, 92, 246, 0.3),
      inset 0 1px 0 rgba(255, 255, 255, 0.1);
    color: #fff;
  }
  .pcard-add:hover .pcard-add-icon{
    background: rgba(139, 92, 246, 0.4);
    border-color: var(--primary-light);
    color: #fff;
    transform: scale(1.1) rotate(90deg);
  }
  .pcard-add:hover .pcard-add-label{
    opacity: 1;
  }
}

.pcard-add:active{
  transform: translateY(0) scale(0.98);
}

.pcard-add:focus-visible{
  outline: 2px solid var(--primary-light);
  outline-offset: 4px;
}

@media (max-width: 480px){
  .pcard-add{
    min-height: 180px;
  }
  .pcard-add-icon{
    width: 56px;
    height: 56px;
    font-size: 28px;
  }
  .pcard-add-label{
    font-size: 12px;
  }
}

/* ============================================
   SCHERMATA INIZIALE
   ============================================ */
.schermata-iniziale{
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: calc(100vh - 120px);
  padding: 40px 20px;
}

.schermata-iniziale-box{
  width: 100%;
  max-width: 440px;
  padding: 36px 28px;
  background: var(--glass-bg);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  box-shadow:
    0 20px 60px rgba(0, 0, 0, 0.35),
    inset 0 1px 0 rgba(255, 255, 255, 0.1);
  text-align: center;
}

.schermata-iniziale-title{
  margin: 0 0 12px;
  font-size: 22px;
  font-weight: 800;
  color: #fff;
  letter-spacing: -0.02em;
  line-height: 1.3;
  text-wrap: balance;
}

.schermata-iniziale-desc{
  margin: 0 0 24px;
  font-size: 14px;
  color: var(--text-muted-dark);
  font-weight: 500;
  line-height: 1.5;
}

.schermata-iniziale-input-wrapper{
  display: flex;
  justify-content: center;
  margin-bottom: 8px;
}

.schermata-iniziale-input{
  width: 140px;
  height: 72px;
  padding: 0;
  font-family: 'Inter', -apple-system, system-ui, sans-serif;
  font-size: 36px;
  font-weight: 800;
  text-align: center;
  color: #fff;
  background: rgba(255, 255, 255, 0.1);
  border: 2px solid rgba(255, 255, 255, 0.25);
  border-radius: var(--radius);
  outline: none;
  transition:
    border-color 200ms var(--ease-smooth),
    background-color 200ms var(--ease-smooth),
    box-shadow 200ms var(--ease-smooth);
  -moz-appearance: textfield;
  appearance: textfield;
}

.schermata-iniziale-input::-webkit-outer-spin-button,
.schermata-iniziale-input::-webkit-inner-spin-button{
  -webkit-appearance: none;
  margin: 0;
}

.schermata-iniziale-input:focus{
  background: rgba(139, 92, 246, 0.15);
  border-color: var(--primary-light);
  box-shadow: 0 0 0 4px rgba(139, 92, 246, 0.25);
}

.schermata-iniziale-hint{
  margin: 0 0 28px;
  font-size: 12px;
  color: var(--text-subtle-dark);
  font-weight: 500;
}

.schermata-iniziale-btn{
  width: 100%;
  max-width: 260px;
  padding: 16px 32px;
  font-family: 'Inter', -apple-system, system-ui, sans-serif;
  font-size: 15px;
  font-weight: 800;
  letter-spacing: 0.02em;
  color: #fff;
  background: linear-gradient(135deg, var(--success), var(--success-dark));
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  box-shadow:
    0 6px 20px rgba(34, 197, 94, 0.35),
    inset 0 1px 0 rgba(255, 255, 255, 0.25);
  transition:
    transform 150ms var(--ease-smooth),
    box-shadow 200ms var(--ease-smooth),
    filter 200ms var(--ease-smooth);
  -webkit-tap-highlight-color: transparent;
}

.schermata-iniziale-btn:hover{
  transform: translateY(-2px);
  box-shadow:
    0 10px 28px rgba(34, 197, 94, 0.55),
    inset 0 1px 0 rgba(255, 255, 255, 0.35);
  filter: brightness(1.05);
}

.schermata-iniziale-btn:active{
  transform: translateY(0);
  box-shadow:
    0 3px 10px rgba(34, 197, 94, 0.4),
    inset 0 1px 0 rgba(255, 255, 255, 0.25);
}

.schermata-iniziale-btn:focus-visible{
  outline: 2px solid #fff;
  outline-offset: 3px;
}

/* ============================================
   ✅ STEP 4 — SCHERMATA SCELTA MODALITÀ
   ============================================ */
.schermata-modalita{
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: calc(100vh - 120px);
  padding: 40px 20px;
}

.schermata-modalita-box{
  width: 100%;
  max-width: 720px;
  padding: 40px 32px;
  background: var(--glass-bg);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  box-shadow:
    0 20px 60px rgba(0, 0, 0, 0.35),
    inset 0 1px 0 rgba(255, 255, 255, 0.1);
  text-align: center;
}

.schermata-modalita-title{
  margin: 0 0 12px;
  font-size: 26px;
  font-weight: 800;
  color: #fff;
  letter-spacing: -0.02em;
  line-height: 1.3;
}

.schermata-modalita-desc{
  margin: 0 0 32px;
  font-size: 14px;
  color: var(--text-muted-dark);
  font-weight: 500;
}

.modalita-grid{
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

.modalita-card{
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 24px 20px;
  /* ✅ Step 11 — sfondo scuro vetroso come menu ⋮ */
  background: rgba(20, 25, 50, 0.97);
  backdrop-filter: blur(16px) saturate(180%);
  -webkit-backdrop-filter: blur(16px) saturate(180%);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 20px;
  color: #eaf2ff;
  font-family: 'Inter', sans-serif;
  cursor: pointer;
  transition:
    background-color 250ms var(--ease-smooth),
    border-color 250ms var(--ease-smooth),
    transform 200ms var(--ease-smooth),
    box-shadow 250ms var(--ease-smooth);
  text-align: center;
  box-shadow:
    0 12px 40px rgba(0, 0, 0, 0.5),
    0 2px 8px rgba(0, 0, 0, 0.25),
    inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.modalita-card:hover{
  background: rgba(30, 35, 65, 0.98);
  border-color: rgba(167, 139, 250, 0.5);
  transform: translateY(-4px);
  box-shadow:
    0 16px 48px rgba(139, 92, 246, 0.35),
    0 4px 12px rgba(0, 0, 0, 0.3),
    inset 0 1px 0 rgba(255, 255, 255, 0.12);
}

.modalita-card:active{
  transform: translateY(0) scale(0.98);
}

.modalita-card:focus-visible{
  outline: 2px solid #fff;
  outline-offset: 4px;
}

.modalita-icon{
  font-size: 48px;
  line-height: 1;
  margin-bottom: 4px;
}
/* ✅ Step 11 — Immagini modalità (Mantra + Classic) */
.modalita-icon-img{
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  max-width:300px;
  aspect-ratio: 1 / 1;
  margin: 0 auto 12px;
  overflow: hidden;
  border-radius:60px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  transition: transform 300ms var(--ease-smooth),
              box-shadow 300ms var(--ease-smooth);
}

.modalita-icon-img img{
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  border-radius: 20px;
}

.modalita-card:hover .modalita-icon-img{
  transform: scale(1.03);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.5);
}

.modalita-nome{
  margin: 0;
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -0.01em;
  /* ✅ Step 11 — colore viola come menu ⋮ */
  color: #c4b5fd;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
  transition: color 200ms var(--ease-smooth);
}

.modalita-card:hover .modalita-nome{
  color: #ffffff;
}

.modalita-ruoli{
  margin: 4px 0 0;
  font-size: 12.5px;
  font-weight: 600;
  color: rgba(234, 242, 255, 0.75);
  line-height: 1.5;
}

.modalita-moduli{
  margin: 0;
  font-size: 11.5px;
  font-weight: 500;
  color: rgba(234, 242, 255, 0.55);
}

@media (max-width: 600px){
  .schermata-modalita{
    padding: 24px 16px;
  }
  .schermata-modalita-box{
    padding: 28px 20px;
    border-radius: var(--radius);
  }
  .schermata-modalita-title{
    font-size: 22px;
  }
  .schermata-modalita-desc{
    margin-bottom: 24px;
  }
  .modalita-grid{
    grid-template-columns: 1fr;
    gap: 14px;
  }
  .modalita-card{
    padding: 22px 18px;
  }
  .modalita-icon{
    font-size: 40px;
  }
  .modalita-nome{
    font-size: 18px;
  }
}

@media (prefers-reduced-transparency: reduce){
  .schermata-modalita-box{
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    background: rgba(20, 20, 40, 0.95);
  }
}

@media (max-width: 480px){
  .schermata-iniziale{
    min-height: calc(100vh - 100px);
    padding: 24px 16px;
  }
  .schermata-iniziale-box{
    padding: 28px 20px;
    border-radius: var(--radius);
  }
  .schermata-iniziale-title{
    font-size: 19px;
  }
  .schermata-iniziale-desc{
    font-size: 13px;
    margin-bottom: 20px;
  }
  .schermata-iniziale-input{
    width: 120px;
    height: 64px;
    font-size: 32px;
  }
  .schermata-iniziale-hint{
    margin-bottom: 24px;
  }
  .schermata-iniziale-btn{
    padding: 14px 24px;
    font-size: 14px;
  }
}

@media (prefers-reduced-transparency: reduce){
  .schermata-iniziale-box{
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    background: rgba(20, 20, 40, 0.95);
  }
}

@media print{
  .schermata-iniziale{
    display: none !important;
  }
}

body.fanta-loading .top,
body.fanta-loading #rows,
body.fanta-loading .azioni,
body.fanta-loading #visualizzazioni{
  display: none !important;
}

/* ============================================
   APPBAR MENU ⋮ (Desktop)
   ============================================ */
.appbar-menu-wrapper{
  display: none;
  position: relative;
  margin-left: 8px;
  z-index: 100;
}

@media (min-width: 769px){
  .appbar-menu-wrapper{
    display: inline-block;
  }
}

.appbar-menu-btn{
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  padding: 0;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.18);
  color: var(--text-on-dark);
  cursor: pointer;
  transition:
    background-color 200ms var(--ease-smooth),
    border-color 200ms var(--ease-smooth),
    transform 150ms var(--ease-smooth),
    box-shadow 200ms var(--ease-smooth);
  -webkit-tap-highlight-color: transparent;
}

.appbar-menu-btn svg{
  display: block;
  transition: transform 250ms var(--ease-smooth);
}

.appbar-menu-btn:hover{
  background: rgba(255, 255, 255, 0.16);
  border-color: rgba(255, 255, 255, 0.35);
  transform: translateY(-1px);
  box-shadow:
    0 6px 16px rgba(0, 0, 0, 0.2),
    inset 0 1px 0 rgba(255, 255, 255, 0.15);
}

.appbar-menu-btn:active{
  transform: translateY(0);
  background: rgba(255, 255, 255, 0.12);
}

.appbar-menu-btn:focus-visible{
  outline: 2px solid var(--primary-light);
  outline-offset: 2px;
}

.appbar-menu-btn[aria-expanded="true"]{
  background: rgba(139, 92, 246, 0.18);
  border-color: rgba(139, 92, 246, 0.5);
}

.appbar-menu-btn[aria-expanded="true"] svg{
  transform: rotate(90deg);
}

/* Dropdown menu ⋮ (unico, completo) */
.appbar-menu-dropdown{
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  left: auto;
  /* rimosso transform: translateX(-50%) */
  min-width: 220px;
  margin: 0;
  padding: 6px;
  list-style: none;
  background: rgba(20, 25, 50, 0.95);
  backdrop-filter: blur(16px) saturate(180%);
  -webkit-backdrop-filter: blur(16px) saturate(180%);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 14px;
  box-shadow:
    0 12px 40px rgba(0, 0, 0, 0.45),
    0 2px 8px rgba(0, 0, 0, 0.2),
    inset 0 1px 0 rgba(255, 255, 255, 0.08);
  z-index: 9999;
  animation: dropdownIn 180ms cubic-bezier(.4, 0, .2, 1);
}

.appbar-menu-dropdown.hidden{
  display: none;
}

.appbar-menu-dropdown li[role="menuitem"]{
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 13.5px;
  font-weight: 600;
  color: #eaf2ff;
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
  transition:
    background-color 180ms ease,
    color 180ms ease;
}

.appbar-menu-dropdown li[role="menuitem"]:hover,
.appbar-menu-dropdown li[role="menuitem"]:focus-visible{
  background: rgba(139, 92, 246, 0.18);
  color: #ffffff;
  outline: none;
}

.appbar-menu-dropdown li[role="menuitem"]:active{
  background: rgba(139, 92, 246, 0.28);
}

.appbar-menu-dropdown li[role="menuitem"] svg{
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  color: #a78bfa;
  transition: color 180ms ease;
}

.appbar-menu-dropdown li[role="menuitem"]:hover svg{
  color: #c4b5fd;
}

.appbar-menu-separator{
  height: 1px;
  margin: 6px 10px;
  padding: 0;
  background: rgba(255, 255, 255, 0.12);
  list-style: none;
  pointer-events: none;
}

.appbar-menu-status{
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  font-size: 12px;
  font-weight: 600;
  color: rgba(234, 242, 255, 0.65);
  list-style: none;
  cursor: default;
  user-select: none;
}

.appbar-menu-status::before{
  content: '';
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.5;
}

/* Animazione standard per dropdown non centrati (rosa, modulo, download, giocatori) */
@keyframes dropdownIn{
  from{
    opacity: 0;
    transform: translateY(-8px) scale(0.98);
  }
  to{
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* ============================================
   SHEET IMPORT/EXPORT
   ============================================ */
.sheet-ie-backdrop{
  position: fixed;
  inset: 0;
  z-index: 160;
  background: rgba(8, 18, 38, 0.6);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 0;
}

.sheet-ie-backdrop.hidden{
  display: none;
}

.sheet-ie-backdrop .menu-sheet{
  width: 100%;
  max-width: 520px;
  background: rgba(20, 25, 50, 0.98);
  color: #eaf2ff;
  border-top-left-radius: 24px;
  border-top-right-radius: 24px;
  padding: 12px 16px calc(20px + env(safe-area-inset-bottom, 0px));
  box-shadow: 0 -8px 40px rgba(0, 0, 0, 0.5);
  border-top: 1px solid rgba(255, 255, 255, 0.15);
  animation: sheetUp 320ms cubic-bezier(.34, 1.2, .64, 1);
  max-height: 80vh;
  overflow-y: auto;
}

/* ============================================
   CARD VUOTE — Stile scuro (v1.7)
   Solo le card senza nome (stato .vuoto) hanno sfondo scuro vetroso.
   Le card con nome mantengono il colore del ruolo.
   ============================================ */

/* Sfondo della card vuota */
.pcard:has(.pcard-nome-box.vuoto){
  background: rgba(20, 25, 50, 0.92);
  border-color: rgba(255, 255, 255, 0.15);
  border-left-color: rgba(167, 139, 250, 0.4);
  color: #eaf2ff;
  box-shadow:
    0 6px 20px rgba(0, 0, 0, 0.35),
    inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

/* Barra in alto viola per le vuote */
.pcard:has(.pcard-nome-box.vuoto)::before{
  background: linear-gradient(90deg, rgba(139, 92, 246, 0.8), rgba(167, 139, 250, 0.6));
}

/* Hover */
.pcard:has(.pcard-nome-box.vuoto):hover{
  box-shadow:
    0 12px 32px rgba(139, 92, 246, 0.3),
    inset 0 1px 0 rgba(255, 255, 255, 0.1);
  border-left-color: rgba(167, 139, 250, 0.8);
}

/* Badge ruolo — grigio scuro */
.pcard:has(.pcard-nome-box.vuoto) .pcard-ruolo{
  background: linear-gradient(135deg, rgba(100, 116, 139, 0.9), rgba(71, 85, 105, 0.9));
}

/* Box nome vuoto — bordo tratteggiato viola */
.pcard:has(.pcard-nome-box.vuoto) .pcard-nome-box.vuoto,
.pcard .pcard-nome-box.vuoto{
  background: rgba(139, 92, 246, 0.10) !important;
  border-style: dashed !important;
  border-color: rgba(167, 139, 250, 0.45) !important;
  box-shadow: none !important;
  color: rgba(234, 242, 255, 0.7);
}

/* Freccia ▾ */
.pcard:has(.pcard-nome-box.vuoto) .pcard-freccia{
  color: rgba(234, 242, 255, 0.5);
}

/* Sottotitolo "#1" */
.pcard:has(.pcard-nome-box.vuoto) .pcard-sub{
  color: rgba(234, 242, 255, 0.45);
}

/* Etichette */
.pcard:has(.pcard-nome-box.vuoto) label{
  color: rgba(234, 242, 255, 0.75);
}

/* Checkbox stato fisico */
.pcard:has(.pcard-nome-box.vuoto) .pcard-stato-fisico label{
  color: rgba(234, 242, 255, 0.8);
}

/* Pulsante ✕ chiusura */
.pcard:has(.pcard-nome-box.vuoto) .pclose{
  background: rgba(255, 255, 255, 0.1);
  color: #fca5a5;
}

.pcard:has(.pcard-nome-box.vuoto) .pclose:hover{
  background: rgba(239, 68, 68, 0.3);
  color: #fff;
}

/* Regole ruolo disattivate per le vuote */
.pcard:has(.pcard-nome-box.vuoto).role-P,
.pcard:has(.pcard-nome-box.vuoto).role-D,
.pcard:has(.pcard-nome-box.vuoto).role-C,
.pcard:has(.pcard-nome-box.vuoto).role-A{
  background: rgba(20, 25, 50, 0.92);
}

/* Fallback per browser senza :has() */
@supports not selector(:has(*)){
  .pcard-nome-box.vuoto{
    background: rgba(20, 25, 50, 0.4);
    border-color: rgba(255, 255, 255, 0.2);
  }
}

/* ============================================
   DROPDOWN GIOCATORI CUSTOM (v1.8)
   ============================================ */
.giocatori-dropdown{
  position: absolute;
  z-index: 9999;
  min-width: 220px;
  max-width: 320px;
  max-height: 260px;
  overflow-y: auto;
  margin: 4px 0 0 0;
  padding: 6px;
  list-style: none;
  background: rgba(20, 25, 50, 0.97);
  backdrop-filter: blur(16px) saturate(180%);
  -webkit-backdrop-filter: blur(16px) saturate(180%);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 12px;
  box-shadow:
    0 12px 40px rgba(0, 0, 0, 0.5),
    0 2px 8px rgba(0, 0, 0, 0.25),
    inset 0 1px 0 rgba(255, 255, 255, 0.08);
  animation: dropdownIn 180ms cubic-bezier(.4, 0, .2, 1);
}

.giocatori-dropdown.hidden{
  display: none;
}

.giocatori-dropdown li{
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  color: #eaf2ff;
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
  overflow: hidden;
  transition: background-color 150ms ease, color 150ms ease;
}

.giocatori-dropdown li:hover,
.giocatori-dropdown li.attivo{
  background: rgba(139, 92, 246, 0.22);
  color: #ffffff;
}

.giocatori-dropdown li .giocatore-nome{
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.giocatori-dropdown li .giocatore-sigla{
  flex-shrink: 0;
  font-size: 11px;
  font-weight: 700;
  color: #a78bfa;
  background: rgba(139, 92, 246, 0.2);
  padding: 2px 6px;
  border-radius: 4px;
  letter-spacing: .04em;
}

.giocatori-dropdown li.vuoto{
  justify-content: center;
  color: rgba(234, 242, 255, 0.45);
  font-style: italic;
  font-weight: 500;
  cursor: default;
}

.giocatori-dropdown li.vuoto:hover{
  background: transparent;
}

.giocatori-dropdown::-webkit-scrollbar{
  width: 6px;
}
.giocatori-dropdown::-webkit-scrollbar-thumb{
  background: rgba(167, 139, 250, 0.35);
  border-radius: 3px;
}
.giocatori-dropdown::-webkit-scrollbar-thumb:hover{
  background: rgba(167, 139, 250, 0.55);
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width:600px){
  .content{padding:1rem}
  .top{padding:16px}
  .grid{grid-template-columns:1fr}
  .btn-calcola{width:100%;max-width:none}
  .btn-aggiungi{
    flex:1 1 auto;
  }
  .chart-wrapper{height:220px}
  .chart-wrapper-bar{height:280px}

  .card{
    padding:1rem 0.75rem;
    overflow-x:visible;
  }
    .card table{
    font-size:11px;
    width:100%;
    min-width:0;
    /* ✅ FIX MOBILE — Rimuovi table-layout:fixed per adattare le colonne */
  }
  .card th,
  .card td{
    padding:8px 4px;
    white-space:normal;
    word-break:break-word;
  }
    /* ✅ FIX MOBILE — Colonne flessibili che si adattano */
  .card table th,
  .card table td{
    padding:8px 4px;
    white-space:normal;
    word-break:break-word;
    font-size:11px;
  }

  /* Tabella Titolari (4 colonne): Ruolo, Giocatore, Valore, Avversario */
  .card table th:nth-child(1),
  .card table td:nth-child(1){ width:18%; }

  .card table th:nth-child(2),
  .card table td:nth-child(2){ width:42%; }

  .card table th:nth-child(3),
  .card table td:nth-child(3){ width:20%; }

  .card table th:nth-child(4),
  .card table td:nth-child(4){ width:20%; }

  /* Tabella Panchina (5 colonne): #, Ruolo, Giocatore, Valore, Avversario */
  .card table th:nth-child(5),
  .card table td:nth-child(5){ width:14%; }

  .card .tot{
    font-size:13px;
  }
    .valore-bar{
    width:100%;
    max-width:60px;
    font-size:9px;
    height:16px;
    line-height:16px;
  }
  .valore-bar .valore-text{
    padding-left:3px;
  }
  .valore-bar .valore-text{
    padding-left:4px;
  }
  .card table small{
    font-size:10px;
    opacity:.7;
    display:block;
  }
}

/* ============================================
   STAMPA / PDF
   ============================================ */
@media print{
  body{
    background:#fff !important;color:#000 !important;
    animation:none;
  }
  body::before{display:none}
  .appbar,.top,#rows,.azioni,
  .btn-installa,.toast,.giornata-info,.api-status,
  .rosa-selector,.modale-backdrop,.visualizzazioni,
  .skeleton-overlay,.background-particles,.check-group{
    display:none !important;
  }
  .card{
    box-shadow:none;border:1px solid #ccc;
    page-break-inside:avoid;
    border-radius:0;
    animation:none;
  }
  .content{padding:0;max-width:none}
  th{color:#000}
  tbody tr:hover td{background:transparent}
}

/* ============================================
   RESPONSIVE AVANZATO
   ============================================ */
body{
  font-size:clamp(14px, 1vw + 12px, 16px);
}
.appbar h1{
  font-size:clamp(16px, 2.5vw, 22px);
}
.visualizzazioni-title{
  font-size:clamp(14px, 2vw, 18px);
}
.card .tot{
  font-size:clamp(13px, 1.6vw, 15px);
}

/* ============================================
   SMARTPHONE PICCOLI (≤360px)
   ============================================ */
@media (max-width:360px){
  .content{padding:0.75rem}
  .top{padding:12px 14px}
  .legend{font-size:12px}

  .appbar{
    padding:10px 14px calc(10px + env(safe-area-inset-top,0px));
    gap:8px;
  }
  .appbar .logo-img{width:38px;height:38px}
  .appbar h1{font-size:16px}
  .appbar .sub{font-size:10px}

  .rosa-selector{
    padding:10px 12px;
    gap:6px;
  }
  .rosa-label{font-size:11px;margin-right:2px}
  .rosa-select{
    min-width:0;
    flex:1 1 100%;
    padding:8px 28px 8px 10px;
    font-size:12px;
    background-position:right 8px center;
  }
  .btn-rosa{
    padding:8px 10px;
    font-size:11px;
    gap:4px;
    flex:1 1 calc(50% - 3px);
  }
  .btn-rosa svg{width:12px;height:12px}

  .btn-calcola{
    padding:12px 20px;
    font-size:14px;
    min-width:0;
    width:100%;
    max-width:none;
  }

  .btn-aggiungi,
  .btn-copia,
  .btn-stampa{
    padding:12px 14px;
    font-size:12px;
    flex:1 1 100%;
  }

  .grid{grid-template-columns:1fr;gap:12px}

  .pcard-header{padding:10px 12px 8px;gap:8px}
  .pcard-ruolo{
    min-width:42px;
    height:36px;
    font-size:10px;
    border-radius:10px;
  }
  .pcard-nome-box{
    min-height:30px;
    padding:5px 6px 5px 10px;
    font-size:11px;
  }
  .pcard-sub{font-size:10px}
  .pcard-status{width:20px;height:20px;font-size:10px}
  .pcard-body{padding:10px 12px 14px}
  .pcard select{font-size:12px;padding:8px 30px 8px 10px}

  .modale-box{padding:18px 14px;border-radius:16px;max-width:calc(100vw - 24px)}
  .modale-box h3{font-size:16px}
  .modale-box p{font-size:13px}
  .modale-azioni button{padding:10px 14px;font-size:12px;min-width:0}

  .chart-wrapper{height:200px}
  .chart-wrapper-bar{height:240px}

  .peso-item{padding:10px 12px;font-size:11px}
  .peso-item > span{font-size:10px}

  .toast{
    padding:10px 16px;
    font-size:12px;
    max-width:calc(100vw - 24px);
  }
  .card{
    padding:0.75rem 0.5rem;
    overflow-x:visible;
  }
  .card table{
    font-size:11px;
    width:100%;
    min-width:0;
    table-layout:fixed;
  }
  .card th,
  .card td{
    padding:6px 3px;
    white-space:normal;
    word-break:break-word;
  }
  .card th:nth-child(1), .card td:nth-child(1){ width:14%; }
  .card th:nth-child(2), .card td:nth-child(2){ width:38%; }
  .card th:nth-child(3), .card td:nth-child(3){ width:28%; }
  .card th:nth-child(4), .card td:nth-child(4){ width:20%; }

  .valore-bar{
    width:100%;
    max-width:70px;
    font-size:9px;
    height:16px;
    line-height:16px;
  }
}

/* ============================================
   SMARTPHONE MEDI/GRANDI (361-480px)
   ============================================ */
@media (min-width:361px) and (max-width:480px){
  .content{padding:1rem}
  .top{padding:14px 16px}

  .rosa-selector{
    padding:12px 14px;
    gap:8px;
  }
  .rosa-select{flex:1 1 auto;min-width:160px}
  .btn-rosa{
    flex:0 1 auto;
    padding:9px 12px;
    font-size:12px;
  }

  .btn-calcola{
    width:100%;
    max-width:none;
    min-width:0;
  }

  .btn-aggiungi,
  .btn-copia,
  .btn-stampa{
    flex:1 1 calc(50% - 6px);
    padding:13px 16px;
    font-size:13px;
  }

  .grid{grid-template-columns:1fr;gap:12px}

  .pcard-ruolo{min-width:46px;height:40px}
  .pcard-nome-box{min-height:32px}

  .modale-box{
    padding:22px 18px;
    max-width:calc(100vw - 32px);
  }

  .chart-wrapper{height:220px}
  .chart-wrapper-bar{height:260px}
}

/* ============================================
   SMARTPHONE LANDSCAPE
   ============================================ */
@media (max-height:500px) and (orientation:landscape){
  .appbar{
    position:static;
    padding:10px 16px;
  }
  .appbar .logo-img{width:36px;height:36px}
  .appbar .sub{display:none}
  .content{padding:0.75rem 1rem}

  .chart-wrapper{height:180px}
  .chart-wrapper-bar{height:200px}
}

/* ============================================
   TABLET (481-1024px)
   ============================================ */
@media (min-width:481px) and (max-width:1024px){
  .content{padding:1.25rem;max-width:100%}
  .top{padding:18px 20px}

  .rosa-selector{
    padding:14px 16px;
    gap:8px;
  }
  .rosa-select{min-width:180px}
  .btn-rosa{padding:10px 14px;font-size:12px}

  .grid{
    grid-template-columns:repeat(auto-fill,minmax(240px,1fr));
    gap:14px;
  }

  .btn-calcola{flex:1 1 240px;max-width:none}
  .btn-aggiungi,
  .btn-copia,
  .btn-stampa{flex:1 1 auto}

  .modale-box{max-width:520px}
  .chart-wrapper{height:260px}
  .chart-wrapper-bar{height:340px}
}

/* ============================================
   TABLET GRANDE / FOLDABLE (1025-1400px)
   ============================================ */
@media (min-width:1025px){
  .grid{grid-template-columns:repeat(auto-fill,minmax(260px,1fr))}
  .chart-wrapper{height:280px}
  .chart-wrapper-bar{height:380px}
}

.chart-wrapper{
  aspect-ratio:1 / 1;
  height:auto;
  max-height:280px;
}
.chart-wrapper-bar{
  aspect-ratio:16 / 9;
  height:auto;
  max-height:380px;
}

/* ============================================
   TOUCH TARGET MINIMO
   ============================================ */
@media (hover:none) and (pointer:coarse){
  button,
  select,
  .pcard-nome-box{
    min-height:44px;
  }
  .pcard:hover{
    transform:none;
    box-shadow:var(--shadow-md);
  }
  .btn-calcola:hover{transform:none}
  .btn-rosa:hover{transform:none}
  .btn-aggiungi:hover,
  .btn-copia:hover,
  .btn-stampa:hover{transform:none}
  .btn-avv:hover{transform:none}
}

/* ============================================
   IPHONE CON NOTCH
   ============================================ */
@supports (padding:max(0px)){
  .appbar{
    padding-left:max(20px, env(safe-area-inset-left,0px));
    padding-right:max(20px, env(safe-area-inset-right,0px));
    padding-top:max(16px, env(safe-area-inset-top,0px));
  }
  .content{
    padding-left:max(1.5rem, env(safe-area-inset-left,0px));
    padding-right:max(1.5rem, env(safe-area-inset-right,0px));
    padding-bottom:max(2rem, env(safe-area-inset-bottom,0px));
  }
  .toast{
    bottom:max(24px, calc(env(safe-area-inset-bottom,0px) + 16px));
  }
}

@media (orientation:landscape) and (max-height:600px){
  .appbar{padding-top:10px;padding-bottom:10px}
  .content{padding-top:1rem}
}

@media (prefers-reduced-motion:reduce){
  .pcard, .btn-calcola{animation:none}
}

@media (-webkit-min-device-pixel-ratio:2), (min-resolution:192dpi){
  .pcard{border-width:1px}
  .pcard-nome-box{border-width:1px}
  button{border-width:1px}
}

@media (max-width:320px){
  .content{padding:0.5rem}
  .pcard-header{padding:8px 10px}
  .pcard-ruolo{min-width:36px;height:32px;font-size:9px}
  .pcard-nome-box{font-size:10px;padding:4px 5px 4px 8px}
  .btn-rosa{font-size:10px;padding:6px 8px}
  .appbar h1{font-size:14px}
}

/* ============================================
   BARRA PERCENTUALE VALORE
   ============================================ */
.valore-bar{
  position:relative;
  display:inline-block;
  width:100%;
  max-width:100px;
  height:20px;
  border-radius:10px;
  background:rgba(0,0,0,.08);
  overflow:hidden;
  vertical-align:middle;
  font-size:11px;
  font-weight:700;
  line-height:20px;
}

.valore-bar .valore-fill{
  position:absolute;
  top:0;left:0;
  height:100%;
  border-radius:10px;
  transition:width 400ms cubic-bezier(.4,0,.2,1);
}

.valore-bar .valore-text{
  position:relative;
  z-index:2;
  color:#12213a;
  text-shadow:0 1px 2px rgba(255,255,255,.6);
  padding-left:6px;
}

.valore-high .valore-fill{background:linear-gradient(90deg,#22c55e,#16a34a)}
.valore-mid  .valore-fill{background:linear-gradient(90deg,#eab308,#ca8a04)}
.valore-low  .valore-fill{background:linear-gradient(90deg,#f97316,#ea580c)}
.valore-verylow .valore-fill{background:linear-gradient(90deg,#ef4444,#dc2626)}

.card table tr[style*="opacity"] td{
  color:#666;
}

/* ============================================
   FIX v1.8.4 — Card vuota: focus con sfondo viola
   Usa .in-focus (aggiunta via JS) + :focus-within come fallback.
   ============================================ */

.pcard-nome-box.vuoto.in-focus,
.pcard-nome-box.vuoto:focus,
.pcard-nome-box.vuoto:focus-within,
.pcard-nome-box.vuoto:active{
  background: rgba(139, 92, 246, 0.20) !important;
  border-style: solid !important;
  border-color: rgba(167, 139, 250, 0.7) !important;
  box-shadow:
    inset 0 0 0 1.5px rgba(167, 139, 250, 0.5),
    0 0 0 3px rgba(139, 92, 246, 0.25) !important;
  color: #eaf2ff !important;
}

.pcard-nome-box.vuoto.in-focus .pcard-nome-input,
.pcard-nome-box.vuoto:focus-within .pcard-nome-input,
.pcard-nome-box.vuoto .pcard-nome-input:focus{
  color: #eaf2ff !important;
  -webkit-text-fill-color: #eaf2ff !important;
  caret-color: #a78bfa !important;
  background: transparent !important;
}

/* Nasconde placeholder quando in focus */
.pcard-nome-box.vuoto.in-focus .pcard-nome,
.pcard-nome-box.vuoto.in-focus .pcard-freccia{
  opacity: 0 !important;
  pointer-events: none !important;
}

/* ============================================
   FIX v1.9.0 — Input nome: sfondo TRASPARENTE su card vuota
   L'input dentro una card vuota (.pcard-nome-box.vuoto)
   deve SEMPRE avere background trasparente, anche in focus.
   ============================================ */

/* Input dentro box vuoto — sfondo trasparente, sempre */
.pcard-nome-box.vuoto .pcard-nome-input,
.pcard-nome-box.vuoto .pcard-nome-input:focus,
.pcard-nome-box.vuoto .pcard-nome-input:focus-visible,
.pcard-nome-box.vuoto .pcard-nome-input:active,
.pcard-nome-box.vuoto.in-focus .pcard-nome-input{
  background: transparent !important;
  background-color: transparent !important;
  border: none !important;
  box-shadow: none !important;
  outline: none !important;
  color: #eaf2ff !important;
  -webkit-text-fill-color: #eaf2ff !important;
  caret-color: #a78bfa !important;
}

/* Override anche in caso di autofill del browser */
.pcard-nome-box.vuoto .pcard-nome-input:-webkit-autofill,
.pcard-nome-box.vuoto .pcard-nome-input:-webkit-autofill:hover,
.pcard-nome-box.vuoto .pcard-nome-input:-webkit-autofill:focus{
  -webkit-box-shadow: 0 0 0 1000px transparent inset !important;
  box-shadow: 0 0 0 1000px transparent inset !important;
  -webkit-text-fill-color: #eaf2ff !important;
  transition: background-color 5000s ease-in-out 0s;
}

/* ============================================
   FIX v1.9.0 — Input trasparente SEMPRE
   Impedisce che l'input abbia sfondo bianco al focus.
   ============================================ */
.pcard-nome-box.vuoto .pcard-nome-input,
.pcard-nome-box.vuoto .pcard-nome-input:focus,
.pcard-nome-box.vuoto .pcard-nome-input:focus-visible,
.pcard-nome-box.vuoto .pcard-nome-input:active{
  background: transparent !important;
  background-color: transparent !important;
  color: #eaf2ff !important;
  -webkit-text-fill-color: #eaf2ff !important;
  caret-color: #a78bfa !important;
  border: none !important;
  box-shadow: none !important;
  outline: none !important;
}

/* ============================================
   FIX A.6.1-a — Blocca scroll body quando dropdown giocatori è aperto
   ============================================ */
body.dropdown-aperto{
  overflow: hidden;
}

/* ============================================
   ✅ G1-f-B — MODALE INFORMAZIONI
   ============================================ */
.modale-box-info{
  max-width: 440px;
}

.info-lista{
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 8px 0 20px;
}

.info-item{
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 14px;
  background: rgba(139, 92, 246, 0.08);
  border: 1px solid rgba(167, 139, 250, 0.18);
  border-radius: 10px;
  transition: background-color 180ms var(--ease-smooth);
}

.info-item:hover{
  background: rgba(139, 92, 246, 0.14);
  border-color: rgba(167, 139, 250, 0.3);
}

.info-icon{
  flex-shrink: 0;
  font-size: 20px;
  line-height: 1;
  margin-top: 2px;
}

.info-text{
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.info-text strong{
  font-size: 11px;
  font-weight: 800;
  color: #c4b5fd;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.info-text span{
  font-size: 13.5px;
  font-weight: 600;
  color: #eaf2ff;
  line-height: 1.4;
  word-break: break-word;
}

@media (max-width: 480px){
  .info-item{
    padding: 10px 12px;
  }
  .info-icon{
    font-size: 18px;
  }
  .info-text strong{
    font-size: 10px;
  }
  .info-text span{
    font-size: 13px;
  }
}

/* ============================================
   ✅ G1-f-C — MODALE GUIDA
   ============================================ */
.modale-box-guida{
  max-width: 520px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  padding: 0;
  overflow: hidden;
}

.modale-box-guida h3{
  padding: 24px 24px 8px;
  margin: 0 0 8px;
}

.guida-scroll{
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 8px 24px 20px;
  scrollbar-width: thin;
}

.guida-scroll::-webkit-scrollbar{
  width: 8px;
}
.guida-scroll::-webkit-scrollbar-thumb{
  background: rgba(167, 139, 250, 0.3);
  border-radius: 4px;
}
.guida-scroll::-webkit-scrollbar-thumb:hover{
  background: rgba(167, 139, 250, 0.5);
}
.guida-scroll::-webkit-scrollbar-track{
  background: transparent;
}

.guida-passo{
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 14px;
  margin-bottom: 10px;
  background: rgba(139, 92, 246, 0.08);
  border: 1px solid rgba(167, 139, 250, 0.18);
  border-radius: 12px;
  transition: background-color 180ms var(--ease-smooth);
}

.guida-passo:hover{
  background: rgba(139, 92, 246, 0.14);
  border-color: rgba(167, 139, 250, 0.3);
}

.guida-passo-numero{
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #fff;
  font-size: 15px;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 12px rgba(139, 92, 246, 0.4);
  font-variant-numeric: tabular-nums;
}

.guida-passo-contenuto{
  flex: 1;
  min-width: 0;
}

.guida-passo-contenuto h4{
  margin: 0 0 6px;
  font-size: 14px;
  font-weight: 800;
  color: #ffffff;
  letter-spacing: -0.01em;
}

.guida-passo-contenuto p{
  margin: 0;
  font-size: 13px;
  color: rgba(234, 242, 255, 0.8);
  line-height: 1.55;
}

.guida-passo-contenuto strong{
  color: #c4b5fd;
  font-weight: 700;
}

.guida-suggerimento{
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 14px;
  margin-top: 14px;
  background: rgba(34, 197, 94, 0.1);
  border: 1px solid rgba(34, 197, 94, 0.3);
  border-radius: 10px;
}

.guida-suggerimento-icon{
  flex-shrink: 0;
  font-size: 20px;
  line-height: 1;
  margin-top: 2px;
}

.guida-suggerimento p{
  margin: 0;
  font-size: 13px;
  color: rgba(234, 242, 255, 0.85);
  line-height: 1.5;
}

.guida-suggerimento strong{
  color: #86efac;
  font-weight: 700;
}

.guida-suggerimento kbd{
  display: inline-block;
  padding: 2px 6px;
  font-family: 'Inter', monospace;
  font-size: 11px;
  font-weight: 700;
  color: #eaf2ff;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 4px;
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.3);
}

.modale-box-guida .modale-azioni{
  flex-shrink: 0;
   padding: 16px 24px calc(24px + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(10, 15, 35, 0.5);
}

@media (max-width: 480px){
  .guida-scroll{
    padding: 8px 16px 16px;
  }
  .modale-box-guida h3{
    padding: 18px 16px 8px;
  }
  .modale-box-guida .modale-azioni{
    padding: 12px 16px 16px;
  }
  .guida-passo{
    padding: 12px;
    gap: 10px;
  }
  .guida-passo-numero{
    width: 28px;
    height: 28px;
    font-size: 13px;
  }
  .guida-passo-contenuto h4{
    font-size: 13px;
  }
  .guida-passo-contenuto p{
    font-size: 12.5px;
  }
}

/* ============================================
   MODALE IMPORT CSV — 3 pulsanti in riga
   ============================================ */
.modale-azioni-3 {
  display: flex;
  gap: 8px;
  justify-content: stretch;
}

.modale-azioni-3 button {
  flex: 1 1 0;
  min-width: 0;
  font-size: 12px;
  padding: 12px 8px;
}

@media (max-width: 480px) {
  .modale-azioni-3 {
    flex-wrap: wrap;
  }
  .modale-azioni-3 button {
    flex: 1 1 100%;
    font-size: 13px;
    padding: 14px 12px;
  }
}

/* ============================================
   FIX — Rosa: nome lungo che sborda
   ============================================ */
.rosa-btn{
  overflow: hidden;
}

.rosa-btn #rosaBtnLabel{
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: left;
}

.rosa-btn .rosa-arrow{
  flex-shrink: 0;
}

/* ============================================
   FIX v2 — Rosa: LIMITA LA LARGHEZZA DEL WRAPPER
   (il wrapper è inline-block e si allarga col contenuto,
    serve max-width per forzare la troncatura)
   ============================================ */
.rosa-dropdown-wrapper{
  max-width: 240px;   /* ← larghezza massima del pulsante rosa */
  min-width: 0;
}

/* Su mobile ancora più stretto */
@media (max-width: 600px){
  .rosa-dropdown-wrapper{
    max-width: 200px;
  }
}

@media (max-width: 400px){
  .rosa-dropdown-wrapper{
    max-width: 160px;
  }
}

/* Su desktop, permettiti più spazio */
@media (min-width: 769px){
  .rosa-dropdown-wrapper{
    max-width: 320px;
  }
}

/* ============================================
   ✅ FIX DEFINITIVO ROSA — Dropdown centrato sul pulsante
   Funziona su mobile e desktop senza uscire dallo schermo.
   ============================================ */

/* 1) Il wrapper limita la larghezza del pulsante (tronca il nome con …) */
.rosa-dropdown-wrapper{
  position: relative;   /* riferimento per il dropdown */
  display: inline-block;
  max-width: 240px;     /* desktop */
  min-width: 0;
}

@media (max-width: 600px){
  .rosa-dropdown-wrapper{ max-width: 200px; }
}

@media (max-width: 400px){
  .rosa-dropdown-wrapper{ max-width: 160px; }
}

/* 2) Il pulsante si adatta al wrapper e tronca il nome */
.rosa-btn{
  max-width: 100%;
  min-width: 0;
  overflow: hidden;
}

.rosa-btn #rosaBtnLabel{
  flex: 1 1 0;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: left;
}

.rosa-btn .rosa-arrow{
  flex-shrink: 0;
}

/* 3) Il dropdown si apre CENTRATO sul pulsante
      e non esce mai dallo schermo */
.rosa-dropdown{
  left: 50%;
  right: auto;
  transform: translateX(-50%);

  min-width: 240px;
  max-width: min(340px, calc(100vw - 32px));
  width: max-content;

  /* Animazione che rispetta il transform centrato */
  animation: dropdownInCentered 180ms cubic-bezier(.4, 0, .2, 1);
}

/* 4) Su schermi molto stretti (≤380px): il centraggio
      rimane valido perché max-width impedisce l'uscita */
@media (max-width: 380px){
  .rosa-dropdown{
    min-width: 200px;
    max-width: calc(100vw - 20px);
  }
}

/* Animazione unica per tutti i dropdown centrati (menu ⋮) */
@keyframes dropdownInCentered{
  from{
    opacity: 0;
    transform: translateX(-50%) translateY(-8px) scale(0.98);
  }
  to{
    opacity: 1;
    transform: translateX(-50%) translateY(0) scale(1);
  }
}

/* ============================================
   ✅ STEP A.4 — MODALE MODIFICATORI
   ============================================ */
.modale-box-modificatori{
  max-width: 520px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  padding: 0;
  overflow: hidden;
  background: rgba(20, 25, 50, 0.95) !important;
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border: 1px solid rgba(255, 255, 255, 0.15);
  box-shadow:
    0 24px 60px rgba(0, 0, 0, 0.6),
    inset 0 1px 0 rgba(255, 255, 255, 0.08);
  color: #eaf2ff;
}

.modale-box-modificatori h3{
  margin: 0;
  padding: 24px 24px 8px;
  color: #ffffff;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

.modale-box-modificatori .modale-modificatori-desc{
  margin: 0 0 16px;
  padding: 0 24px;
  font-size: 13px;
  color: rgba(234, 242, 255, 0.75);
  line-height: 1.5;
}

.modale-box-modificatori .modificatori-scroll{
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 0 24px;
  scrollbar-width: thin;
}

.modale-box-modificatori .modificatori-scroll::-webkit-scrollbar{
  width: 8px;
}
.modale-box-modificatori .modificatori-scroll::-webkit-scrollbar-thumb{
  background: rgba(167, 139, 250, 0.3);
  border-radius: 4px;
}
.modale-box-modificatori .modificatori-scroll::-webkit-scrollbar-thumb:hover{
  background: rgba(167, 139, 250, 0.5);
}

/* Item singolo modificatore */
.modificatore-item{
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px;
  margin-bottom: 10px;
  border-radius: 12px;
  background: rgba(139, 92, 246, 0.08);
  border: 1px solid rgba(167, 139, 250, 0.18);
  transition: background-color 180ms ease, border-color 180ms ease;
}

.modificatore-item:hover{
  background: rgba(139, 92, 246, 0.14);
  border-color: rgba(167, 139, 250, 0.3);
}

.modificatore-item.attivo{
  background: rgba(139, 92, 246, 0.18);
  border-color: rgba(167, 139, 250, 0.5);
}

/* Checkbox stile toggle */
.modificatore-item input[type="checkbox"]{
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  margin-top: 2px;
  cursor: pointer;
  accent-color: var(--primary);
}

.modificatore-contenuto{
  flex: 1;
  min-width: 0;
}

.modificatore-nome{
  display: block;
  font-size: 14px;
  font-weight: 800;
  color: #ffffff;
  margin-bottom: 4px;
  letter-spacing: -0.01em;
  cursor: pointer;
}

.modificatore-desc{
  display: block;
  font-size: 12px;
  color: rgba(234, 242, 255, 0.7);
  line-height: 1.4;
  margin: 0;
}

/* Opzione annidata (es. "includi portiere") */
.modificatore-opzione-annidata{
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
  padding: 8px 10px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  font-size: 12px;
  color: rgba(234, 242, 255, 0.85);
}

.modificatore-opzione-annidata input[type="checkbox"]{
  width: 16px;
  height: 16px;
  margin-top: 0;
}

.modificatore-opzione-annidata label{
  cursor: pointer;
  user-select: none;
}

/* Stato disabilitato quando il modificatore principale è off */
.modificatore-opzione-annidata.disabilitata{
  opacity: 0.4;
  pointer-events: none;
}

/* Gruppi (Classic / Mantra) */
.modificatori-gruppo{
  margin-bottom: 20px;
}

.modificatori-gruppo-titolo{
  margin: 0 0 12px;
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #c4b5fd;
  padding-bottom: 6px;
  border-bottom: 1px solid rgba(167, 139, 250, 0.35);
}

.modale-box-modificatori .modale-azioni{
  flex-shrink: 0;
  padding: 16px 24px calc(24px + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(10, 15, 35, 0.6);
}

.modale-box-modificatori .modale-btn-annulla{
  background: rgba(255, 255, 255, 0.08);
  color: #eaf2ff;
  border: 1px solid rgba(255, 255, 255, 0.15);
}
.modale-box-modificatori .modale-btn-annulla:hover{
  background: rgba(255, 255, 255, 0.15);
  border-color: rgba(255, 255, 255, 0.3);
}

.modale-box-modificatori .modale-btn-conferma{
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #fff;
  border: none;
}
.modale-box-modificatori .modale-btn-conferma:hover{
  background: linear-gradient(135deg, var(--primary-light), var(--primary));
  box-shadow: 0 8px 22px rgba(139, 92, 246, 0.55);
}

@media (max-width: 600px){
  .modale-box-modificatori h3{
    padding: 18px 16px 8px;
  }
  .modale-box-modificatori .modale-modificatori-desc{
    padding: 0 16px;
    margin-bottom: 12px;
  }
  .modale-box-modificatori .modificatori-scroll{
    padding: 0 16px;
  }
    .modale-box-modificatori .modale-azioni{
    padding: 12px 16px calc(18px + env(safe-area-inset-bottom, 0px));
  }
  .modificatore-item{
    padding: 12px;
  }
}

/* ============================================
   ✅ STEP A.6 — CARD MODIFICATORI
   ============================================ */
.card-modificatori .modificatore-riga{
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 12px 14px;
  margin-bottom: 8px;
  border-radius: 10px;
  background: rgba(139, 92, 246, 0.06);
  border: 1px solid rgba(139, 92, 246, 0.15);
  transition: background-color 180ms ease;
}

.card-modificatori .modificatore-riga:hover{
  background: rgba(139, 92, 246, 0.12);
}

.card-modificatori .modificatore-riga.modificatore-non-attivo{
  opacity: 0.6;
  background: rgba(0, 0, 0, 0.03);
}

.card-modificatori .modificatore-riga-info{
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.card-modificatori .modificatore-riga-info strong{
  font-size: 13px;
  font-weight: 800;
  color: var(--text-on-light);
}

.card-modificatori .modificatore-riga-info small{
  font-size: 11.5px;
  color: var(--text-muted-light);
  line-height: 1.4;
}

.card-modificatori .modificatore-riga-valore{
  flex-shrink: 0;
  font-size: 16px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  padding: 4px 12px;
  border-radius: 8px;
  min-width: 56px;
  text-align: center;
}

.card-modificatori .mod-positivo{
  color: #15803d;
  background: rgba(34, 197, 94, 0.12);
  border: 1px solid rgba(34, 197, 94, 0.3);
}

.card-modificatori .mod-negativo{
  color: #b91c1c;
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid rgba(239, 68, 68, 0.3);
}

.card-modificatori .mod-neutro{
  color: var(--text-body-light);
  background: rgba(0, 0, 0, 0.05);
  border: 1px solid rgba(0, 0, 0, 0.1);
}

.card-modificatori .modificatori-totale{
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  margin-top: 12px;
  border-radius: 12px;
  background: linear-gradient(135deg, rgba(139, 92, 246, 0.12), rgba(139, 92, 246, 0.05));
  border: 2px solid rgba(139, 92, 246, 0.25);
}

.card-modificatori .modificatori-totale strong{
  font-size: 14px;
  font-weight: 800;
  color: var(--text-on-light);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.card-modificatori .modificatori-totale span{
  font-size: 20px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  padding: 4px 14px;
  border-radius: 8px;
}

/* Responsive */
@media (max-width: 600px){
  .card-modificatori .modificatore-riga{
    padding: 10px 12px;
  }
  .card-modificatori .modificatore-riga-info strong{
    font-size: 12px;
  }
  .card-modificatori .modificatore-riga-info small{
    font-size: 11px;
  }
  .card-modificatori .modificatore-riga-valore{
    font-size: 14px;
    padding: 3px 9px;
    min-width: 46px;
  }
  .card-modificatori .modificatori-totale strong{
    font-size: 12px;
  }
  .card-modificatori .modificatori-totale span{
    font-size: 17px;
  }
}

/* ============================================
   ✅ STEP 2 — Toggle "Mostra tutte le rose" + badge modalità
   ============================================ */

/* Toggle in fondo al dropdown */
.rosa-dropdown li.rosa-toggle-tutte {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  margin-top: 6px;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
  padding-top: 12px;
  font-size: 12px;
  font-weight: 600;
  color: rgba(234, 242, 255, 0.75);
  cursor: pointer;
  border-radius: 8px;
  transition: background-color 180ms ease, color 180ms ease;
  user-select: none;
}

.rosa-dropdown li.rosa-toggle-tutte:hover {
  background: rgba(139, 92, 246, 0.15);
  color: #ffffff;
}

.rosa-toggle-icon {
  flex-shrink: 0;
  font-size: 14px;
  line-height: 1;
}

.rosa-toggle-label {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Badge modalità accanto al nome della rosa */
.rosa-dropdown .rosa-nome {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 0;
}

.rosa-badge {
  display: inline-block;
  flex-shrink: 0;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.rosa-badge-mantra {
  background: rgba(139, 92, 246, 0.25);
  color: #c4b5fd;
  border: 1px solid rgba(167, 139, 250, 0.4);
}

.rosa-badge-classic {
  background: rgba(59, 130, 246, 0.25);
  color: #93c5fd;
  border: 1px solid rgba(96, 165, 250, 0.4);
}

/* ============================================
   ✅ BADGE MODALITÀ NELL'HEADER
   ============================================ */

.appbar-modalita-badge{
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 6px 16px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin-left: auto;
  margin-right: auto;
  white-space: nowrap;
  user-select: none;
  transition: background-color 250ms ease, color 250ms ease,
              border-color 250ms ease, box-shadow 250ms ease;
  position: relative;
  z-index: 1;
}

/* Default / Mantra (viola) */
.appbar-modalita-badge[data-modalita="mantra"],
.appbar-modalita-badge:not([data-modalita]){
  background: rgba(139, 92, 246, 0.22);
  color: #c4b5fd;
  border: 1px solid rgba(167, 139, 250, 0.55);
  box-shadow:
    0 4px 14px rgba(139, 92, 246, 0.3),
    inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

/* Classic (blu) */
.appbar-modalita-badge[data-modalita="classic"]{
  background: rgba(59, 130, 246, 0.22);
  color: #93c5fd;
  border: 1px solid rgba(96, 165, 250, 0.55);
  box-shadow:
    0 4px 14px rgba(59, 130, 246, 0.3),
    inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

/* Su mobile: ridotto ma sempre visibile */
@media (max-width: 600px){
  .appbar-modalita-badge{
    padding: 4px 10px;
    font-size: 10px;
    letter-spacing: 0.08em;
  }
}

/* Su schermi molto piccoli: nascondi se troppo stretto */
@media (max-width: 380px){
  .appbar-modalita-badge{
    display: none;
  }
}

/* ============================================
   ✅ BADGE MODALITÀ NELL'HEADER
   ============================================ */

.appbar-modalita-badge{
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 6px 16px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin-left: auto;
  margin-right: auto;
  white-space: nowrap;
  user-select: none;
  transition: background-color 250ms ease, color 250ms ease,
              border-color 250ms ease, box-shadow 250ms ease;
}

/* Default / Mantra (viola) */
.appbar-modalita-badge[data-modalita="mantra"],
.appbar-modalita-badge:not([data-modalita]){
  background: rgba(139, 92, 246, 0.22);
  color: #c4b5fd;
  border: 1px solid rgba(167, 139, 250, 0.55);
  box-shadow:
    0 4px 14px rgba(139, 92, 246, 0.3),
    inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

/* Classic (blu) */
.appbar-modalita-badge[data-modalita="classic"]{
  background: rgba(59, 130, 246, 0.22);
  color: #93c5fd;
  border: 1px solid rgba(96, 165, 250, 0.55);
  box-shadow:
    0 4px 14px rgba(59, 130, 246, 0.3),
    inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

/* Su mobile: ridotto ma sempre visibile */
@media (max-width: 600px){
  .appbar-modalita-badge{
    padding: 4px 10px;
    font-size: 10px;
    letter-spacing: 0.08em;
    margin-left: 8px;
    margin-right: 0;
  }
}

/* ============================================
   ✅ FIX DEFINITIVO MOBILE — Tabelle nel risultato
   Per evitare che le tabelle Titolari/Panchina/Tribuna
   escano dallo schermo su mobile.
   ============================================ */

@media (max-width: 768px){
  /* Forza il contenitore card a non superare la larghezza schermo */
  .card{
    overflow-x: hidden !important;
    max-width: 100% !important;
    width: 100% !important;
    box-sizing: border-box;
  }

  /* Tabella dentro la card: no overflow, no larghezza fissa */
  .card table{
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    table-layout: auto !important;
    font-size: 11px !important;
    border-collapse: collapse;
  }

  /* Celle: non forzare larghezze, lascia auto */
  .card th,
  .card td{
    padding: 6px 3px !important;
    white-space: normal !important;
    word-break: break-word;
    overflow-wrap: anywhere;
    font-size: 10px !important;
    line-height: 1.2;
    vertical-align: middle;
  }

  /* Intestazioni tabella più piccole */
  .card th{
    font-size: 9px !important;
    text-transform: uppercase;
    letter-spacing: 0;
    padding: 6px 2px !important;
  }

  /* Neutralizza le regole di larghezza fisse */
  .card table th:nth-child(1),
  .card table td:nth-child(1),
  .card table th:nth-child(2),
  .card table td:nth-child(2),
  .card table th:nth-child(3),
  .card table td:nth-child(3),
  .card table th:nth-child(4),
  .card table td:nth-child(4),
  .card table th:nth-child(5),
  .card table td:nth-child(5){
    width: auto !important;
  }

    /* ✅ Fix tabelle mobile — priorità a Giocatore e Valore */
  /* Colonna 1 (Ruolo o #): compatta */
  .card table th:first-child,
  .card table td:first-child{
    width: 1%;
    white-space: nowrap;
    text-align: center;
    padding: 6px 4px !important;
  }

  /* ✅ NON forziamo più la colonna 2 (Giocatore) — lascia respirare */
  .card table th:nth-child(2),
  .card table td:nth-child(2){
    width: auto;
    min-width: 0;
  }

  /* ✅ Valore: barra piccola ma leggibile */
  .valore-bar{
    width: 100% !important;
    max-width: 50px !important;
    min-width: 42px;
    font-size: 9px !important;
    height: 14px !important;
    line-height: 14px !important;
    padding: 0 3px;
  }

  .valore-bar .valore-text{
    padding-left: 3px !important;
    font-size: 9px;
  }

  /* Testo piccolo (PV, FM, ecc.) */
  .card table small{
    font-size: 8px !important;
    opacity: 0.75;
    display: block;
    line-height: 1.1;
  }

  /* Titolo card */
  .card .tot{
    font-size: 12px !important;
    padding-bottom: 8px;
    margin-bottom: 8px;
  }

  /* ✅ Padding celle più stretto su mobile */
  .card th,
  .card td{
    padding: 6px 3px !important;
  }
}

/* ============================================
   ✅ B.3 — Badge capitano/vice cliccabili
   ============================================ */

/* ✅ C.1.h — Badge capitano/vice (stile cerchio elegante) */
.badge-ruolo {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  /* ✅ Forza cerchio perfetto, mai ovale */
  width: 18px;
  height: 18px;
  min-width: 18px;
  min-height: 18px;
  max-width: 18px;
  max-height: 18px;
  aspect-ratio: 1 / 1;
  flex-shrink: 0;
  flex-grow: 0;
  box-sizing: border-box;
  
  /* ✅ Maggiore distanza dal nome */
  margin-left: 6px;
  margin-right: 0;
  padding: 0;
  border-radius: 50%;
  font-size: 10px;
  font-weight: 800;
  cursor: pointer;
  border: 1.5px solid transparent;
  background: rgba(0, 0, 0, 0.05);
  color: rgba(0, 0, 0, 0.35);
  transition: all 180ms cubic-bezier(.4,0,.2,1);
  vertical-align: middle;
  line-height: 1;
  font-family: 'Inter', sans-serif;
  letter-spacing: 0;
  user-select: none;
  text-align: center;
  overflow: hidden;
  white-space: nowrap;
}

.badge-ruolo:hover {
  transform: scale(1.15);
  box-shadow: 0 2px 8px rgba(139, 92, 246, 0.3);
}

/* Capitano: oro/ambra */
.badge-capitano.attivo {
  background: linear-gradient(135deg, #fbbf24, #f59e0b);
  border-color: #d97706;
  color: #ffffff;
  box-shadow: 0 2px 6px rgba(217, 119, 6, 0.4);
  text-shadow: 0 1px 1px rgba(0, 0, 0, 0.2);
}

.badge-capitano.attivo:hover {
  box-shadow: 0 4px 12px rgba(217, 119, 6, 0.6);
}

/* Vice: viola */
.badge-vice.attivo {
  background: linear-gradient(135deg, #a78bfa, #8b5cf6);
  border-color: #7c3aed;
  color: #ffffff;
  box-shadow: 0 2px 6px rgba(139, 92, 246, 0.4);
  text-shadow: 0 1px 1px rgba(0, 0, 0, 0.2);
}

.badge-vice.attivo:hover {
  box-shadow: 0 4px 12px rgba(139, 92, 246, 0.6);
}

/* Mobile: leggermente più piccolo */
@media (max-width: 600px) {
  .badge-ruolo {
    width: 16px;
    height: 16px;
    min-width: 16px;
    min-height: 16px;
    max-width: 16px;
    max-height: 16px;
    font-size: 9px;
    margin-left: 5px;
    border-width: 1px;
  }
}

/* ============================================
   ✅ STEP C.1.b — Pulsante "Modifica parametri"
   ============================================ */
.modale-btn-modifica-parametri{
  display: block;
  width: calc(100% - 48px);
  margin: 12px 24px 0;
  padding: 12px 16px;
  font-family: 'Inter', sans-serif;
  font-size: 13px;
  font-weight: 700;
  color: #c4b5fd;
  background: rgba(139, 92, 246, 0.12);
  border: 1px solid rgba(167, 139, 250, 0.4);
  border-radius: 10px;
  cursor: pointer;
  transition: background-color 200ms ease, border-color 200ms ease, color 200ms ease;
}

.modale-btn-modifica-parametri:hover{
  background: rgba(139, 92, 246, 0.24);
  border-color: rgba(167, 139, 250, 0.7);
  color: #ffffff;
}

.modale-btn-modifica-parametri:active{
  background: rgba(139, 92, 246, 0.32);
}

@media (max-width: 600px){
  .modale-btn-modifica-parametri{
    width: calc(100% - 32px);
    margin: 10px 16px 0;
    font-size: 12px;
    padding: 11px 14px;
  }
}

/* ============================================
   ✅ STEP C.1.b — Modale Editor Tabelle
   ============================================ */
.modale-box-editor{
  position: relative; 
  max-width: 560px;
  /* ✅ FIX C.1.c.3-d — Altezza fissa per far funzionare flex+overflow */
  height: 85vh;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  padding: 0;
  overflow: hidden;
  background: rgba(20, 25, 50, 0.95) !important;
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border: 1px solid rgba(255, 255, 255, 0.15);
  box-shadow:
    0 24px 60px rgba(0, 0, 0, 0.6),
    inset 0 1px 0 rgba(255, 255, 255, 0.08);
  color: #eaf2ff;
}

/* ✅ FIX C.1.c.3-d — Altezza fissa anche per il contenuto */
.editor-contenuto{
  display: flex;
  flex-direction: column;
  flex: 1 1 0;
  min-height: 0;
  max-height: 100%;
  overflow: hidden;
  padding: 0 24px 12px;
}

.modale-box-editor h3{
  margin: 0;
  /* ✅ C.1.g.3-d — Spazio per ← e ✕ in alto, padding ridotto al minimo */
  padding: 52px 60px 8px 60px;
  color: #ffffff;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
  text-align: center;
}

.modale-editor-desc{
  margin: 0 0 16px;
  padding: 0 24px;
  font-size: 13px;
  color: rgba(234, 242, 255, 0.75);
  line-height: 1.5;
}

.editor-selettore{
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 24px 16px;
}

.editor-selettore label{
  font-size: 13px;
  font-weight: 700;
  color: rgba(234, 242, 255, 0.85);
}

.editor-selettore select{
  flex: 1;
  padding: 10px 36px 10px 14px;
  font-family: 'Inter', sans-serif;
  font-size: 13px;
  font-weight: 600;
  color: #12213a;
  background-color: #ffffff;
  border: 1px solid #cfd8e3;
  border-radius: 10px;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%233a4a63' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
}

/* Le option native: sfondo chiaro, testo scuro (Windows/Chrome) */
.editor-selettore select option{
  background-color: #ffffff;
  color: #12213a;
  font-weight: 600;
}

.editor-selettore select:focus{
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.15);
}

/* ============================================
   ✅ FIX C.1.c.3-c (v2) — Layout editor: scroll solo sulla tabella
   Struttura:
     .editor-contenuto (flex column, no scroll)
       └── .editor-tabella-wrapper (scrollabile)
             └── <table class="editor-tabella">
       └── .editor-btn-aggiungi (fisso in fondo)
   ============================================ */
.editor-contenuto{
  display: flex;
  flex-direction: column;
  flex: 1 1 0;
  min-height: 0;
  overflow: hidden;
  padding: 0 24px 12px;
}

/* Wrapper scrollabile attorno alla tabella */
.editor-tabella-wrapper{
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  background: rgba(255, 255, 255, 0.03);
  border-radius: 10px;
  scrollbar-width: thin;
}

.editor-tabella-wrapper::-webkit-scrollbar{
  width: 8px;
}
.editor-tabella-wrapper::-webkit-scrollbar-thumb{
  background: rgba(167, 139, 250, 0.3);
  border-radius: 4px;
}
.editor-tabella-wrapper::-webkit-scrollbar-thumb:hover{
  background: rgba(167, 139, 250, 0.5);
}

/* Tabella dentro il wrapper */
.editor-tabella{
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.editor-tabella thead{
  position: sticky;
  top: 0;
  z-index: 2;
  background: rgba(30, 35, 65, 0.98);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.editor-tabella th{
  padding: 10px 14px;
  text-align: left;
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #c4b5fd;
  border-bottom: 1px solid rgba(167, 139, 250, 0.25);
}

.editor-tabella td{
  padding: 10px 14px;
  color: #eaf2ff;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.editor-tabella tbody tr:last-child td{
  border-bottom: none;
}

.editor-tabella tbody tr:hover td{
  background: rgba(139, 92, 246, 0.06);
}

.editor-tabella-valore{
  font-weight: 800;
  text-align: right;
  color: #c4b5fd;
}

/* Pulsante "Aggiungi fascia" — fisso sotto la tabella (NON sticky) */
.editor-btn-aggiungi{
  flex-shrink: 0;
  display: block;
  width: 100%;
  margin-top: 12px;
  padding: 12px 16px;
  font-family: 'Inter', sans-serif;
  font-size: 13px;
  font-weight: 700;
  color: #c4b5fd;
  background: rgba(139, 92, 246, 0.10);
  border: 1.5px dashed rgba(167, 139, 250, 0.5);
  border-radius: 10px;
  cursor: pointer;
  text-align: center;
  transition: background-color 200ms ease, border-color 200ms ease, color 200ms ease;
}

.editor-btn-aggiungi:hover:not(:disabled){
  background: rgba(139, 92, 246, 0.22);
  border-color: rgba(167, 139, 250, 0.8);
  border-style: solid;
  color: #ffffff;
}

.editor-btn-aggiungi:active:not(:disabled){
  background: rgba(139, 92, 246, 0.30);
  transform: translateY(1px);
}

.editor-btn-aggiungi:disabled{
  opacity: 0.45;
  cursor: not-allowed;
  border-style: solid;
  border-color: rgba(167, 139, 250, 0.2);
}

/* Avviso limite */
.editor-avviso-limite{
  flex-shrink: 0;
  margin: 8px 0 0;
  font-size: 11.5px;
  font-style: italic;
  color: rgba(234, 242, 255, 0.5);
  text-align: center;
}

@media (max-width: 600px){
  .editor-contenuto{
    padding: 0 16px 12px;
  }
  .editor-tabella th,
  .editor-tabella td{
    padding: 8px 10px;
    font-size: 12px;
  }
  .editor-btn-aggiungi{
    padding: 10px 14px;
    font-size: 12px;
  }
}


/* ============================================
   ✅ STEP C.1.c.2 — Input editabili nella tabella editor
   ============================================ */

.editor-input{
  width: 90px;
  padding: 6px 10px;
  font-family: 'Inter', sans-serif;
  font-size: 13px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: #eaf2ff;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 8px;
  text-align: right;
  outline: none;
  transition: border-color 150ms ease, background-color 150ms ease, box-shadow 150ms ease;
  -moz-appearance: textfield;
  appearance: textfield;
}

.editor-input::-webkit-outer-spin-button,
.editor-input::-webkit-inner-spin-button{
  -webkit-appearance: none;
  margin: 0;
}

.editor-input:hover{
  background: rgba(255, 255, 255, 0.10);
  border-color: rgba(255, 255, 255, 0.28);
}

.editor-input:focus{
  background: rgba(139, 92, 246, 0.12);
  border-color: rgba(167, 139, 250, 0.7);
  box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.2);
}

.editor-input-valore{
  width: 70px;
  text-align: center;
  color: #c4b5fd;
}

.editor-input.editor-input-invalido{
  border-color: #ef4444 !important;
  background: rgba(239, 68, 68, 0.12) !important;
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.18) !important;
}

/* Colonna azioni */
.editor-tabella-azioni-col{
  width: 50px;
  text-align: center !important;
}

.editor-btn-elimina{
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  font-size: 14px;
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid rgba(239, 68, 68, 0.3);
  border-radius: 8px;
  color: #fca5a5;
  cursor: pointer;
  transition: background-color 150ms ease, border-color 150ms ease, transform 120ms ease;
}

.editor-btn-elimina:hover{
  background: rgba(239, 68, 68, 0.25);
  border-color: rgba(239, 68, 68, 0.5);
  color: #ffffff;
  transform: scale(1.06);
}

.editor-btn-elimina:active{
  transform: scale(0.95);
}

/* Pulsante Salva disabilitato */
.modale-box-editor .modale-btn-conferma:disabled{
  opacity: 0.45;
  cursor: not-allowed;
  filter: grayscale(0.5);
}

.modale-box-editor .modale-btn-conferma:disabled:hover{
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  box-shadow: none;
  transform: none;
}

/* Mobile */
@media (max-width: 600px){
  .editor-input{
    width: 76px;
    padding: 5px 8px;
    font-size: 12px;
  }
  .editor-input-valore{
    width: 58px;
  }
  .editor-btn-elimina{
    width: 28px;
    height: 28px;
    font-size: 12px;
  }
}

/* ============================================
   ✅ FIX C.1.c.2-a — Toast sopra la modale
   ============================================ */
.toast.toast-sopra-modale{
  z-index: 300;   /* sopra .modale-backdrop (200) e .menu-sheet-backdrop (150) */
}

/* Su mobile: altezza minore */
@media (max-width: 600px){
  .modale-box-editor{
    height: 85vh;
    max-height: 85vh;
  }
}

/* ✅ FIX C.1.g.3-b — Modale di conferma sopra le altre modali */
#modale {
  z-index: 250;
}

#modale.hidden {
  /* Non ha senso quando è nascosta, ma per coerenza */
  z-index: 250;
}

/* ============================================
   ✅ C.1.g.3-c — Bottone ✕ per chiudere la modale Editor
   ============================================ */
.modale-btn-chiudi{
  position: absolute;
  top: 16px;
  right: 16px;
  width: 36px;
  height: 36px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Inter', sans-serif;
  font-size: 18px;
  font-weight: 700;
  color: rgba(234, 242, 255, 0.7);
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 10px;
  cursor: pointer;
  transition: background-color 180ms ease, border-color 180ms ease, color 180ms ease, transform 120ms ease;
  z-index: 10;
}

.modale-btn-chiudi:hover{
  background: rgba(255, 255, 255, 0.14);
  border-color: rgba(255, 255, 255, 0.25);
  color: #ffffff;
  transform: scale(1.05);
}

.modale-btn-chiudi:active{
  transform: scale(0.95);
}

@media (max-width: 600px){
  .modale-btn-chiudi{
    top: 12px;
    right: 12px;
    width: 32px;
    height: 32px;
    font-size: 16px;
  }
}

/* ============================================
   ✅ C.1.g.3-d — Bottone ← Indietro per la modale Editor
   ============================================ */
.modale-btn-indietro{
  position: absolute;
  top: 16px;
  left: 16px;
  width: 36px;
  height: 36px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Inter', sans-serif;
  font-size: 20px;
  font-weight: 700;
  color: rgba(234, 242, 255, 0.7);
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 10px;
  cursor: pointer;
  transition: background-color 180ms ease, border-color 180ms ease, color 180ms ease, transform 120ms ease;
  z-index: 10;
}

.modale-btn-indietro:hover{
  background: rgba(255, 255, 255, 0.14);
  border-color: rgba(255, 255, 255, 0.25);
  color: #ffffff;
  transform: scale(1.05);
}

.modale-btn-indietro:active{
  transform: scale(0.95);
}

@media (max-width: 600px){
  .modale-btn-indietro{
    top: 12px;
    left: 12px;
    width: 32px;
    height: 32px;
    font-size: 18px;
  }
}

/* ============================================
   ✅ C.1.g.3-d — Fix layout mobile: pulsanti sempre visibili
   ============================================ */
@media (max-width: 600px){
  .modale-box-editor{
    height: 90vh;
    max-height: 90vh;
  }

  .modale-box-editor h3{
    padding: 16px 56px 4px 56px;  /* lascia spazio per ← e ✕ */
  }

  .modale-editor-desc{
    padding: 0 16px;
    margin-bottom: 8px;
    font-size: 12px;
  }

  .editor-selettore{
    padding: 0 16px 10px;
  }

  .editor-contenuto{
    padding: 0 12px 8px;
  }

  .modale-box-editor .modale-azioni{
    padding: 10px 12px;
    gap: 6px;
  }

  .modale-box-editor .modale-azioni button{
    font-size: 12px;
    padding: 10px 12px;
    min-width: 0;
    flex: 1 1 auto;
  }
}

/* ============================================
   TOOLTIP INFORMATIVI (Modale Pesi) - FIX DEFINITIVO
   ============================================ */
.tooltip-icon {
  position: relative;
  cursor: help;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: rgba(167, 139, 250, 0.25);
  color: #c4b5fd;
  font-size: 10px;
  font-weight: bold;
  font-family: serif;
  margin-left: 6px;
  transition: background 0.2s;
}

.tooltip-icon:hover {
  background: rgba(167, 139, 250, 0.5);
  color: #fff;
}

/* Contenitore del tooltip - FISSO AL CENTRO DELLO SCHERMO */
.tooltip-icon::after {
  content: attr(data-tooltip);
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  
  width: max-content;
  max-width: min(300px, calc(100vw - 40px));
  
  background: rgba(20, 25, 50, 0.98);
  color: #eaf2ff;
  padding: 12px 16px;
  border-radius: 10px;
  font-size: 12px;
  font-weight: 500;
  white-space: normal;
  text-align: center;
  line-height: 1.5;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s, visibility 0.2s;
  z-index: 9999;
  border: 1px solid rgba(167, 139, 250, 0.4);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.7);
  pointer-events: none;
}

/* Freccia del tooltip */
.tooltip-icon::before {
  content: '';
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -100%);
  border-width: 6px;
  border-style: solid;
  border-color: transparent transparent rgba(20, 25, 50, 0.98) transparent;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s, visibility 0.2s;
  z-index: 9999;
  pointer-events: none;
}

/* Mostra il tooltip all'hover */
.tooltip-icon:hover::after,
.tooltip-icon:hover::before {
  opacity: 1;
  visibility: visible;
}

/* Avvicina l'icona "i" al nome e spinge il valore a destra */
.modale-box-pesi .peso-item label > span.tooltip-icon {
  margin-right: auto;
}

/* ============================================
   ✅ PULSANTI RESET/SALVA PER SINGOLA SEZIONE (Modale Pesi)
   ============================================ */
.pesi-gruppo-azioni {
  display: flex;
  gap: 10px;
  justify-content: stretch; /* I pulsanti occupano tutta la larghezza */
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px dashed rgba(167, 139, 250, 0.2);
}

.btn-pesi-sezione-reset,
.btn-pesi-sezione-salva {
  flex: 1; /* Si dividono lo spazio in parti uguali */
  padding: 10px 14px;
  font-size: 12px;
  font-weight: 700;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: 'Inter', sans-serif;
  text-align: center;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

/* Stile "outline" per il reset (meno invadente) */
.btn-pesi-sezione-reset {
  background: transparent;
  color: #c4b5fd;
  border: 1px solid rgba(167, 139, 250, 0.4);
}

.btn-pesi-sezione-reset:hover {
  background: rgba(167, 139, 250, 0.15);
  border-color: rgba(167, 139, 250, 0.8);
  color: #fff;
}

/* Stile "pieno" per il salva (più evidente) */
.btn-pesi-sezione-salva {
  background: rgba(139, 92, 246, 0.25);
  color: #fff;
  border: 1px solid rgba(139, 92, 246, 0.5);
  box-shadow: 0 2px 8px rgba(139, 92, 246, 0.15);
}

.btn-pesi-sezione-salva:hover {
  background: rgba(139, 92, 246, 0.45);
  box-shadow: 0 4px 12px rgba(139, 92, 246, 0.3);
}



/* ============================================
   ✅ FIX LAYOUT: Pulsanti globali fissi in fondo
   ============================================ */

/* Assicura che la modale sia un flex container a colonna */
.modale-box-pesi {
  display: flex !important;
  flex-direction: column !important;
  overflow: hidden !important;
}

/* Il contenitore scrollabile prende tutto lo spazio disponibile */
.modale-box-pesi .pesi-scroll {
  flex: 1 1 auto !important;
  overflow-y: auto !important;
  overflow-x: hidden !important;
  padding-bottom: 20px !important; /* Spazio extra prima dei pulsanti */
}

/* I pulsanti globali stanno fissi in fondo, con sfondo scuro */
.modale-box-pesi .modale-azioni-globali {
  flex-shrink: 0 !important;
  background: rgba(10, 15, 35, 0.98) !important;
  border-top: 1px solid rgba(255, 255, 255, 0.15) !important;
  padding: 14px 20px 16px !important;
  display: flex !important;
  gap: 10px !important;
  margin: 0 !important;
  border-radius: 0 0 20px 20px !important;
}

.modale-box-pesi .modale-azioni-globali .modale-btn-annulla,
.modale-box-pesi .modale-azioni-globali .modale-btn-conferma {
  flex: 1 1 0 !important;
  font-size: 13px !important;
  padding: 12px 10px !important;
  text-align: center;
  white-space: normal !important;
  line-height: 1.2;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 46px;
}

/* Nasconde i vecchi separatori se sono rimasti nell'HTML */
.separatore-azioni-globali,
.label-azioni-globali {
  display: none !important;
}

/* Aggiusta il padding dei titoli per fare spazio alla freccia ← */
.modale-box-info h3,
.modale-box-guida h3 {
  padding-left: 50px; /* Spazio per la freccia */
  text-align: left;
}

.modale-box-pesi h3 {
  padding-left: 50px; /* Spazio per la freccia */
}

.modale-box-modificatori h3 {
  padding-left: 50px;
}

/* Sposta la freccia per la modale Pesi (che ha il padding-top dell'h3 a 24px) */
#pesiIndietro {
  top: 20px; 
}

/* Assicura che la freccia stia sopra e cliccabile */
.modale-box-guida,
.modale-box-modificatori {
  position: relative !important;
  z-index: 10;
}

/* Diamo spazio al titolo per non farlo finire sotto la freccia */
.modale-box-guida h3,
.modale-box-modificatori h3 {
  padding-left: 50px !important;
}

/* Assicura che la freccia sia cliccabile e sopra lo scroll */
.modale-btn-indietro {
  z-index: 999 !important;
  pointer-events: auto !important;
}

/* ============================================
   ✅ NUOVA GUIDA v2 — Accordion
   ============================================ */

.guida-intro {
  margin: 0 0 16px;
  font-size: 13px;
  color: rgba(234, 242, 255, 0.75);
  line-height: 1.55;
  font-style: italic;
}

.guida-sezione {
  margin-bottom: 10px;
  background: rgba(139, 92, 246, 0.08);
  border: 1px solid rgba(167, 139, 250, 0.18);
  border-radius: 12px;
  overflow: hidden;
  transition: background-color 180ms ease, border-color 180ms ease;
}

.guida-sezione:hover {
  background: rgba(139, 92, 246, 0.14);
  border-color: rgba(167, 139, 250, 0.3);
}

.guida-sezione[open] {
  background: rgba(139, 92, 246, 0.12);
  border-color: rgba(167, 139, 250, 0.4);
}

.guida-sezione-titolo {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  font-size: 14px;
  font-weight: 800;
  color: #ffffff;
  cursor: pointer;
  user-select: none;
  list-style: none;
  transition: color 180ms ease;
}

.guida-sezione-titolo::-webkit-details-marker {
  display: none;
}
.guida-sezione-titolo::marker {
  display: none;
  content: '';
}

.guida-sezione-titolo::after {
  content: '▾';
  font-size: 12px;
  color: #c4b5fd;
  transition: transform 200ms ease;
  margin-left: 10px;
  flex-shrink: 0;
}

.guida-sezione[open] > .guida-sezione-titolo::after {
  transform: rotate(180deg);
}

.guida-sezione-titolo:hover {
  color: #c4b5fd;
}

.guida-sezione-contenuto {
  padding: 4px 16px 16px;
  font-size: 13px;
  color: rgba(234, 242, 255, 0.85);
  line-height: 1.55;
}

.guida-sezione-contenuto p {
  margin: 0 0 10px;
}

.guida-sezione-contenuto p:last-child {
  margin-bottom: 0;
}

.guida-sezione-contenuto em {
  color: rgba(234, 242, 255, 0.55);
  font-style: italic;
}

.guida-sezione-contenuto strong {
  color: #c4b5fd;
  font-weight: 700;
}

.guida-sezione-contenuto ul {
  margin: 6px 0 10px;
  padding-left: 20px;
}

.guida-sezione-contenuto li {
  margin-bottom: 6px;
}

.guida-sezione-contenuto kbd {
  display: inline-block;
  padding: 2px 6px;
  font-family: 'Inter', monospace;
  font-size: 11px;
  font-weight: 700;
  color: #eaf2ff;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 4px;
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.3);
}

/* Su mobile: padding ridotti */
@media (max-width: 480px) {
  .guida-sezione-titolo {
    padding: 12px 14px;
    font-size: 13px;
  }
  .guida-sezione-contenuto {
    padding: 4px 14px 14px;
    font-size: 12.5px;
  }
}

/* ============================================
   🎨 RESTYLE CARD VUOTE E PIENE (v1.9.9)
   ============================================ */

/* 1. Effetto base della card: più profondità e stacco */
.pcard {
  transition: all 250ms cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25), inset 0 1px 0 rgba(255,255,255,0.1);
}

.pcard:hover {
  transform: translateY(-4px) scale(1.01);
  box-shadow: 0 16px 32px rgba(0, 0, 0, 0.4), inset 0 1px 0 rgba(255,255,255,0.2);
  z-index: 10;
}

/* 2. Card Piene (con nome): bordo vetroso più marcato */
.pcard.pieno {
  border-width: 1.5px;
  border-style: solid;
  background: linear-gradient(145deg, rgba(255,255,255,0.05), rgba(255,255,255,0.01));
}

/* 3. Card Vuote: sfondo più elegante con bordo tratteggiato luminoso */
.pcard:has(.pcard-nome-box.vuoto) {
  background: rgba(20, 25, 50, 0.6) !important;
  backdrop-filter: blur(12px);
  border: 1.5px dashed rgba(167, 139, 250, 0.3) !important;
}

.pcard:has(.pcard-nome-box.vuoto):hover {
  border-color: rgba(167, 139, 250, 0.6) !important;
  background: rgba(30, 35, 60, 0.8) !important;
}

/* 4. Box del Nome: effetto input moderno */
.pcard-nome-box {
  border-radius: 12px;
  padding: 10px 12px;
  transition: all 200ms ease;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.pcard-nome-box:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(167, 139, 250, 0.5);
  box-shadow: 0 0 12px rgba(139, 92, 246, 0.2);
}

/* 5. Bottoni Stato Fisico (Infortunato / Squalificato) */
.pcard-stato-fisico {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

.pcard-stato-fisico label {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 10px;
  font-size: 11px;
  font-weight: 700;
  color: rgba(234, 242, 255, 0.7);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  cursor: pointer;
  transition: all 200ms ease;
  user-select: none;
}

.pcard-stato-fisico label:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}

/* Quando la checkbox è spuntata (usiamo :has per colorare l'intera label) */
.pcard-stato-fisico label:has(input[type="checkbox"]:checked) {
  background: rgba(139, 92, 246, 0.25);
  border-color: rgba(167, 139, 250, 0.6);
  color: #fff;
  box-shadow: 0 0 10px rgba(139, 92, 246, 0.2);
}

/* Nascondiamo la checkbox nativa (è brutta) e usiamo solo l'emoji */
.pcard-stato-fisico input[type="checkbox"] {
  display: none;
}

/* ============================================
   🎨 FIX ALLINEAMENTO E STATO FISICO (v1.9.9-b)
   ============================================ */

/* 1. Allineamento riga superiore (Ruolo, Nome, X) */
.pcard-header {
  display: flex;
  align-items: center; /* Centra verticalmente tutti gli elementi */
  gap: 10px;
  padding: 12px 14px;
}

.pcard-ruolo {
  height: 40px;
  min-width: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

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

.pclose {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(239, 68, 68, 0.1);
  color: #fca5a5;
  border-radius: 8px;
  border: 1px solid rgba(239, 68, 68, 0.2);
  transition: all 200ms ease;
  margin-left: auto;
}

.pclose:hover {
  background: rgba(239, 68, 68, 0.3);
  color: #fff;
  transform: scale(1.05);
}

/* 2. Bottoni Stato Fisico */
.pcard-stato-fisico {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

.pcard-stato-fisico label {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 10px;
  font-size: 11px;
  font-weight: 700;
  color: rgba(234, 242, 255, 0.7);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  cursor: pointer;
  transition: all 200ms ease;
  user-select: none;
}

.pcard-stato-fisico label span {
  font-size: 12px;
  line-height: 1;
  pointer-events: none;
}

.pcard-stato-fisico label:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}

.pcard-stato-fisico label:has(input[type="checkbox"]:checked) {
  background: rgba(139, 92, 246, 0.25);
  border-color: rgba(167, 139, 250, 0.6);
  color: #fff;
  box-shadow: 0 0 10px rgba(139, 92, 246, 0.2);
}

.pcard-stato-fisico input[type="checkbox"] {
  display: none;
}

/* ============================================
   🎨 FIX DEFINITIVO LAYOUT CARD E STATO FISICO (v2.2)
   ============================================ */

/* 1. Allineamento riga superiore (Ruolo, Nome, X) */
.pcard-header {
  display: flex !important;
  align-items: center !important; /* Forza l'allineamento verticale al centro */
  gap: 12px !important;
  padding: 14px 16px !important;
  background: transparent !important;
}

/* 2. Il badge del ruolo */
.pcard-ruolo {
  flex-shrink: 0 !important;
  height: 44px !important;
  min-width: 52px !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  border-radius: 12px !important;
}

/* 3. Il blocco centrale (Nome + Sottotitolo) */
.pcard-info {
  flex: 1 !important;
  min-width: 0 !important;
  display: flex !important;
  flex-direction: column !important;
  justify-content: center !important;
  gap: 4px !important;
}

/* 4. Il box del nome */
.pcard-nome-box {
  position: relative !important;
  display: flex !important;
  align-items: center !important;
  background: rgba(255, 255, 255, 0.8) !important; 
  border: 1px solid rgba(0, 0, 0, 0.1) !important;
  border-radius: 8px !important;
  padding: 6px 10px !important;
  min-height: 36px !important;
  margin: 0 !important;
}

/* 5. Il sottotitolo (R3 · FIO, ecc.) */
.pcard-sub {
  font-size: 11px !important;
  color: #555 !important;
  font-weight: 600 !important;
  margin-left: 4px !important;
  white-space: nowrap !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
}

/* 6. La X di chiusura */
.pclose {
  flex-shrink: 0 !important;
  width: 38px !important;
  height: 38px !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  background: rgba(220, 38, 38, 0.15) !important; 
  color: #b91c1c !important; 
  border-radius: 10px !important;
  border: 1px solid rgba(220, 38, 38, 0.3) !important;
  margin: 0 !important;
}

/* 7. Bottoni Stato Fisico */
.pcard-stato-fisico {
  display: flex !important;
  gap: 8px !important;
  margin-top: 8px !important;
  width: 100% !important;
}

.pcard-stato-fisico label {
  flex: 1 1 0% !important;
  min-width: 0 !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  gap: 4px !important;
  padding: 8px 4px !important;
  font-size: 11px !important;
  font-weight: 800 !important;
  color: #12213a !important; 
  background: rgba(255, 255, 255, 0.6) !important;
  border: 1px solid rgba(0, 0, 0, 0.1) !important;
  border-radius: 8px !important;
  cursor: pointer !important;
  overflow: hidden !important;
  white-space: nowrap !important;
  margin: 0 !important;
}

.pcard-stato-fisico label span:first-child {
  font-size: 13px !important; 
  transform: scale(0.85) !important; 
}

.pcard-stato-fisico label span:last-child {
  font-size: 10px !important; 
}

/* Colore attivo */
.pcard-stato-fisico label:has(input[type="checkbox"]:checked) {
  background: #8b5cf6 !important;
  border-color: #7c3aed !important;
  color: #ffffff !important;
}
.pcard-stato-fisico input[type="checkbox"] {
  display: none !important;
}

/* ============================================
   🎨 FIX CENTRATURA IMPORT/EXPORT
   ============================================ */

/* Forza lo sheet Importa/Esporta a comportarsi come una modale classica */
.sheet-ie-backdrop {
  align-items: center !important; /* Centra verticalmente */
  justify-content: center !important; /* Centra orizzontalmente */
  padding-top: 0 !important; /* Rimuove l'offset dal basso */
  padding-bottom: 0 !important;
}

/* Diamo al box interno un aspetto a "card" centrata (non più a foglio che sale) */
.sheet-ie-backdrop .menu-sheet {
  border-radius: 20px !important; /* Angoli arrotondati su tutti i lati */
  max-width: 400px !important; /* Larghezza massima tipica delle modali */
  width: 90% !important;
  max-height: 85vh !important;
  padding: 24px 20px !important;
  margin: 0 !important;
  border: 1px solid rgba(255, 255, 255, 0.15) !important;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.6) !important;
  animation: modalePop 350ms cubic-bezier(.34,1.56,.64,1) !important; /* Usa l'animazione delle altre modali */
}

/* Adatta il titolo e il contenuto per la nuova forma */
.sheet-ie-backdrop .menu-sheet-title {
  text-align: center !important;
  padding-left: 0 !important;
  margin-bottom: 20px !important;
  font-size: 18px !important;
}

/* Riposiziona la freccia e la X per la forma a card */
.sheet-ie-backdrop .modale-btn-indietro {
  top: 20px !important;
  left: 20px !important;
}

.sheet-ie-backdrop .modale-btn-chiudi {
  top: 20px !important;
  right: 20px !important;
}

/* Aggiusta le voci della lista per la nuova forma */
.sheet-ie-backdrop .menu-sheet-list li {
  padding: 14px 16px !important;
  border-radius: 10px !important;
  margin-bottom: 8px !important;
  background: rgba(255, 255, 255, 0.05) !important;
}
.sheet-ie-backdrop .menu-sheet-list li:hover {
  background: rgba(255, 255, 255, 0.1) !important;
}

/* --------------------------------------------
   1. PILLOLE DEI RUOLI (Card)
   -------------------------------------------- */
.pcard-ruolo[data-ruolo="PC"] { background-color: #b91c1c !important; color: #fff !important; }
.pcard-ruolo[data-ruolo="A"]  { background-color: #dc2626 !important; color: #fff !important; }
.pcard-ruolo[data-ruolo="T"], 
.pcard-ruolo[data-ruolo="W"]  { background-color: #d946ef !important; color: #fff !important; }
.pcard-ruolo[data-ruolo="C"]  { background-color: #2563eb !important; color: #fff !important; }
.pcard-ruolo[data-ruolo="M"]  { background-color: #3b82f6 !important; color: #fff !important; }
.pcard-ruolo[data-ruolo="E"]  { background-color: #3b82f6 !important; color: #fff !important; }
.pcard-ruolo[data-ruolo="B"]  { background-color: #22c55e !important; color: #fff !important; }
.pcard-ruolo[data-ruolo="DC"], 
.pcard-ruolo[data-ruolo="DD"], 
.pcard-ruolo[data-ruolo="DS"] { background-color: #15803d !important; color: #fff !important; }
.pcard-ruolo[data-ruolo="POR"], 
.pcard-ruolo[data-ruolo="P"]  { background-color: #f59e0b !important; color: #fff !important; }

/* --------------------------------------------
   2. RIGHE DELLA TABELLA (Risultati)
   -------------------------------------------- */

/* Forza il testo SCURO su tutte le righe della tabella, TRANNE che nella pillola del ruolo */
.card table tr td:not(:has(.ruolo-badge)) {
  color: #12213a !important;
}

/* Forza lo sfondo trasparente per i badge/emoji nella tabella */
.card table tr td .badge-ruolo {
  color: #fff !important;
}

/* Colori di sfondo delle righe (per renderle coerenti con i ruoli) */
tr.riga-P td { background-color: #fff3d6 !important; border-left: 4px solid #e0a83a !important; }
tr.riga-D td { background-color: #dcf5e2 !important; border-left: 4px solid #34c759 !important; }
tr.riga-C td { background-color: #dcecff !important; border-left: 4px solid #3b82f6 !important; }
tr.riga-A td { background-color: #ffe1e6 !important; border-left: 4px solid #ef4444 !important; }

/* ---------------------------------------------------
   3. X DI CHIUSURA CARD (Pulsante rosso)
   --------------------------------------------------- */
.pclose {
  background: rgba(220, 38, 38, 0.15) !important; 
  color: #b91c1c !important; 
  border: 1px solid rgba(220, 38, 38, 0.3) !important;
}
.pclose:hover {
  background: rgba(220, 38, 38, 0.3) !important;
  color: #fff !important;
}

/* Nuova riga per Trequartisti e Ali (Mantra) */
tr.riga-TW td { 
  background-color: #fce7f3 !important; /* Rosa molto chiaro */
  border-left: 4px solid #d946ef !important; /* Fucsia */
}

/* ============================================
   🎨 FIX DEFINITIVO PILLOLE RUOLO (v8.0 - Pulito)
   ============================================ */

/* v84-bis — colonna Ruolo larga quanto il badge, senza tagliarlo */
.card table tr td:has(.ruolo-badge) {
  width: 1%;
  min-width: 64px;
  white-space: nowrap;
  padding-left: 4px;
  padding-right: 4px;
  overflow: visible;
}

/* v84-bis — icona ballottaggio in panchina */
.ballottaggio-icon {
  display: inline-block;
  margin-left: 4px;
  cursor: help;
  font-size: 13px;
  vertical-align: middle;
}

/* 1. Stile base della pillola (Effetto 3D) */
.ruolo-badge {
  display: inline-block !important;
  padding: 4px 8px !important;
  border-radius: 6px !important;
  font-size: 11px !important;
  font-weight: 800 !important;
  text-align: center !important;
  min-width: 40px !important;
  border: 1px solid rgba(255, 255, 255, 0.4) !important;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.2) !important;
  text-transform: uppercase !important;
  color: #ffffff !important;
  -webkit-text-fill-color: #ffffff !important;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3) !important;
}

/* 3. Colore SFONDO Gradiente per il Portiere (POR o P) */
.ruolo-badge.badge-ruolo-POR,
.ruolo-badge.badge-ruolo-P {
  background: linear-gradient(135deg, #fbbf24, #d97706) !important;
}

/* 4. Colori per gli altri ruoli */
.ruolo-badge.badge-ruolo-DC,
.ruolo-badge.badge-ruolo-DD,
.ruolo-badge.badge-ruolo-DS,
.ruolo-badge.badge-ruolo-D,
.ruolo-badge.badge-ruolo-B {
  background: linear-gradient(135deg, #22c55e, #15803d) !important;
}

.ruolo-badge.badge-ruolo-M,
.ruolo-badge.badge-ruolo-C,
.ruolo-badge.badge-ruolo-E {
  background: linear-gradient(135deg, #3b82f6, #2563eb) !important;
}

.ruolo-badge.badge-ruolo-W,
.ruolo-badge.badge-ruolo-T {
  background: linear-gradient(135deg, #e879f9, #c026d3) !important;
}

.ruolo-badge.badge-ruolo-A,
.ruolo-badge.badge-ruolo-PC {
  background: linear-gradient(135deg, #f87171, #dc2626) !important;
}

/* ============================================
   ✅ STEP A.5.5 — SELETTORE RUOLI A CHIP
   Componente riusabile Classic (singolo) / Mantra (multi 1–3).
   Vive dentro .pcard-body (fondo chiaro) → colori dedicati.
   Riusa il modello visivo di .pcard-stato-fisico.
   ============================================ */

/* Contenitore del selettore (dentro .pcard-body) */
.selettore-ruoli {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
  align-items: center;
}

/* Riga dei chip ruolo */
.selettore-ruoli-chip {
  appearance: none;
  -webkit-appearance: none;
  border: 1px solid rgba(18, 33, 58, 0.18);
  background: rgba(255, 255, 255, 0.95);
  color: var(--text-on-light, #12213a);
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 12px;
  font-weight: 800;
  line-height: 1;
  cursor: pointer;
  transition: var(--transition-fast, 120ms ease);
  min-height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.selettore-ruoli-chip:hover {
  border-color: var(--primary, #8b5cf6);
  color: var(--primary-dark, #6d28d9);
}

.selettore-ruoli-chip:active {
  transform: scale(0.97);
}

.selettore-ruoli-chip.attivo {
  background: linear-gradient(135deg, var(--info, #3b82f6), var(--primary, #8b5cf6));
  border-color: transparent;
  color: #ffffff;
  box-shadow: 0 4px 12px rgba(139, 92, 246, 0.35);
}

.selettore-ruoli-chip.attivo:hover {
  color: #ffffff;
  border-color: transparent;
}

.selettore-ruoli-chip.disabilitato {
  opacity: 0.4;
  pointer-events: none;
}

.selettore-ruoli-chip.principale {
  outline: 2px solid var(--primary-light, #a78bfa);
  outline-offset: 2px;
  box-shadow: 0 0 0 4px rgba(167, 139, 250, 0.25);
}

/* Contatore n/3 (solo Mantra) */
.selettore-ruoli-contatore {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted-light, #64748b);
  margin-left: auto;
}

/* Tag in alto (selezionati) — tocco rimuove, pressione lunga = principale */
.selettore-ruoli-tag {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  width: 100%;
  margin-top: 6px;
}

.selettore-ruoli-tag-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border-radius: 999px;
  background: rgba(20, 25, 50, 0.92);
  color: #eaf2ff;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  transition: var(--transition-fast, 120ms ease);
}

.selettore-ruoli-tag-item:active {
  transform: scale(0.97);
}

.selettore-ruoli-tag-item.principale {
  outline: 2px solid var(--primary-light, #a78bfa);
  outline-offset: 1px;
}

.selettore-ruoli-tag-item .tag-rimuovi {
  font-size: 13px;
  line-height: 1;
  opacity: 0.75;
}

/* Errore inline (riuso --danger su fondo chiaro) */
.selettore-ruoli-errore {
  width: 100%;
  margin-top: 6px;
  padding: 6px 10px;
  font-size: 11px;
  font-weight: 700;
  color: #b91c1c;
  background: rgba(239, 68, 68, 0.10);
  border-left: 3px solid var(--danger, #ef4444);
  border-radius: 6px;
}

/* Variante per card scura vuota (nome-box vuoto): adatta i chip al fondo scuro */
.pcard:has(.pcard-nome-box.vuoto) .selettore-ruoli-chip {
  background: rgba(20, 25, 50, 0.85);
  color: var(--text-on-dark, #eaf2ff);
  border-color: rgba(255, 255, 255, 0.18);
}

.pcard:has(.pcard-nome-box.vuoto) .selettore-ruoli-chip:hover {
  border-color: var(--primary-light, #a78bfa);
  color: #ffffff;
}

.pcard:has(.pcard-nome-box.vuoto) .selettore-ruoli-contatore {
  color: var(--text-muted-dark, #94a3b8);
}

/* Media query — risparmio spazio e touch target */
@media (max-width: 480px) {
  .selettore-ruoli {
    gap: 6px;
    margin-top: 8px;
  }
  .selettore-ruoli-chip {
    padding: 6px 10px;
    font-size: 11px;
    min-height: 30px;
  }
  .selettore-ruoli-tag-item {
    font-size: 10px;
    padding: 4px 8px;
  }
}

@media (hover: none) and (pointer: coarse) {
  .selettore-ruoli-chip {
    min-height: 44px;
  }
  .selettore-ruoli-tag-item {
    min-height: 36px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .selettore-ruoli-chip,
  .selettore-ruoli-tag-item {
    transition: none;
  }
}

/* v84-grafica — Allineamento Tabelle */
.card table th, .card table td { vertical-align: middle !important; }
.text-center { text-align: center !important; }
.text-left { text-align: left !important; padding-left: 12px !important; }
.text-right { text-align: right !important; }
.font-bold { font-weight: 700 !important; }

/* v84-grafica — Tabella Ballottaggi */
.badge-perc {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 6px;
  border: 1px solid transparent;
  vertical-align: middle;
}
.badge-perc-tit {
  background-color: #dcfce7;
  color: #166534;
  border-color: #bbf7d0;
}
.badge-perc-ris {
  background-color: #f1f5f9;
  color: #475569;
  border-color: #e2e8f0;
}

/* v84-grafica — Tabella Ballottaggi compatta */
.tabella-ballottaggi {
  width: 100%;
  table-layout: fixed;
}
.tabella-ballottaggi th,
.tabella-ballottaggi td {
  padding: 8px 4px;
  vertical-align: middle;
}
.tabella-ballottaggi th.text-right,
.tabella-ballottaggi td.text-right {
  padding-right: 8px; /* Distanzia leggermente dal 'vs' */
}
.tabella-ballottaggi th.text-left,
.tabella-ballottaggi td.text-left {
  padding-left: 8px;
}

/* ============================================
   CAMPO DA CALCIO (Vista dall'alto) - Realistico
   ============================================ */
.campo-calcio {
  position: relative;
  width: 100%;
  max-width: 600px;
  margin: 0 auto;
  aspect-ratio: 2 / 3; /* Formato verticale */
  background: repeating-linear-gradient(
    to bottom,
    #2e7d32,
    #2e7d32 10%,
    #388e3c 10%,
    #388e3c 20%
  ); /* Erba a strisce */
  border: 2px solid #fff;
  border-radius: 8px;
  overflow: hidden;
  box-sizing: border-box;
}

/* Cerchio di centrocampo */
.campo-calcio::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 0;
  width: 100%;
  height: 2px;
  background: rgba(255, 255, 255, 0.6);
  transform: translateY(-50%);
}
.campo-calcio::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 80px;
  height: 80px;
  border: 2px solid rgba(255, 255, 255, 0.6);
  border-radius: 50%;
  transform: translate(-50%, -50%);
}

/* Aree di rigore (semplificate con bordi) */
.campo-calcio .area-rigore-top {
  position: absolute;
  top: 0;
  left: 20%;
  width: 60%;
  height: 15%;
  border: 2px solid rgba(255, 255, 255, 0.6);
  border-top: none;
}
.campo-calcio .area-rigore-bottom {
  position: absolute;
  bottom: 0;
  left: 20%;
  width: 60%;
  height: 15%;
  border: 2px solid rgba(255, 255, 255, 0.6);
  border-bottom: none;
}

/* Contenitore per i giocatori (posizionamento assoluto) */
.campo-contenitore-giocatori {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none; /* Permette ai click di passare attraverso se serve */
}

.giocatore-campo {
  position: absolute;
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  padding: 6px 8px;
  box-shadow: 0 4px 8px rgba(0,0,0,0.3), inset 0 -2px 0 rgba(0,0,0,0.1);
  min-width: 85px;
  text-align: center;
  color: #0f172a; 
  border: 1px solid rgba(255,255,255,0.5);
  border-bottom: 3px solid rgba(0,0,0,0.2);
  z-index: 10;
  pointer-events: auto;
  background: #ffffff;
  backdrop-filter: blur(4px);
  transition: transform 0.2s ease;
  line-height: 1.1; /* Avvicina il ruolo al nome */
}

/* Effetto hover */
.giocatore-campo:hover {
  transform: translate(-50%, -50%) scale(1.05);
  z-index: 20;
}

/* Il badge del ruolo (più piccolo e distanziato) */
.giocatore-campo .ruolo-badge {
  font-size: 9px;
  color: #64748b; /* Grigio medio */
  margin-bottom: 2px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  background: rgba(0,0,0,0.05); /* Sfondo leggerissimo per staccare */
  padding: 2px 6px;
  border-radius: 4px;
}

/* Il nome del giocatore (più grande e in grassetto) */
.giocatore-campo .nome-giocatore {
  font-size: 13px;
  font-weight: 900; /* Molto spesso */
  color: #0f172a;
  text-shadow: 0 1px 0 rgba(255,255,255,0.8); /* Effetto rilievo */
  white-space: nowrap; /* Evita che il nome vada a capo */
  overflow: hidden;
  text-overflow: ellipsis; /* Se il nome è troppo lungo, mette i puntini */
  max-width: 90px;
}

/* Colori per ruolo (più tenui e realistici) */
.giocatore-campo.portiere { 
  background-color: #fef08a; /* Giallo */
  border-color: #ca8a04; 
}
.giocatore-campo.difensore { 
  background-color: #bbf7d0; /* Verde */
  border-color: #16a34a; 
}
.giocatore-campo.centrocampista { 
  background-color: #bfdbfe; /* Blu */
  border-color: #2563eb; 
}
.giocatore-campo.attaccante { 
  background-color: #fecaca; /* Rosso */
  border-color: #dc2626; 
}

.giocatore-campo.trequartista { 
  background-color: #fbcfe8; /* Rosa/Viola */
  border-color: #db2777; 
}

/* ============================================
   STILE PULSANTE CONDIVIDI CAMPO
   ============================================ */
#btnCondividiTutto {
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
  color: #ffffff !important; /* Forza il bianco */
  background: linear-gradient(135deg, #10b981 0%, #059669 100%) !important; 
  border: none;
  border-radius: 30px; 
  cursor: pointer;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
  transition: all 0.2s ease;
}

#btnCondividiTutto:hover {
  background: linear-gradient(135deg, #059669 0%, #047857 100%) !important;
  transform: translateY(-2px); 
}

#btnCondividiTutto:disabled {
  background: #94a3b8 !important;
  cursor: not-allowed;
}