:root{
  color-scheme: light dark;
  --bg: #F7F8FC;
  --panel: rgba(255,255,255,.92);
  --panel-solid: #FFFFFF;
  --text: #0F172A;
  --muted: rgba(15,23,42,.62);
  --border: rgba(15,23,42,.12);
  --primary: #4F46E5;
  --shadow: 0 18px 40px rgba(15,23,42,.08);
  --accent: #4f46e5;
  --accentSoft: rgba(79,70,229,.10);
  --danger: #e11d48;
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial;
  --pad: 18px;
  --radius: 14px;
  --radius2: 18px;
  --w: 1040px;
}

@media (prefers-color-scheme: dark){
  :root{
  --bg: #0B1220;
  --panel: rgba(17,24,39,.72);
  --panel-solid: #111827;
  --text: #E5E7EB;
  --muted: rgba(229,231,235,.65);
  --border: rgba(229,231,235,.14);
  --primary: #818CF8;
  --shadow: 0 18px 50px rgba(0,0,0,.35);
  --accent: #4f46e5;
  --accentSoft: rgba(79,70,229,.10);
  --danger: #e11d48;
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial;
  --pad: 18px;
  --radius: 14px;
  --radius2: 18px;
  --w: 1040px;
  }
}


*{box-sizing:border-box;}
html,body{
  background: var(--bg);
  color: var(--text);
  height:100%;
}

body{
  margin:0;
  font-family:var(--font);
  background:
    radial-gradient(900px 450px at 15% -10%, rgba(79,70,229,.10), transparent 55%),
    radial-gradient(700px 420px at 90% 0%, rgba(14,165,233,.08), transparent 55%),
    var(--bg);
  color:var(--text);
}

.wrap{max-width:var(--w); margin:0 auto; padding:0 18px;}
.muted{color:var(--muted);}
.h1{margin:0; font-size:22px; letter-spacing:.2px;}
a{color:inherit; text-decoration:none;}
.link{color:var(--muted); text-decoration:underline; text-underline-offset:3px;}
.link:hover{color:var(--text);}

.topbar{
  position:sticky; top:0;
  backdrop-filter: blur(10px);
  background: rgba(246,247,251,.75);
  border-bottom:1px solid var(--border);
  z-index:10;
}
.topbar__inner{
  display:flex; align-items:center; justify-content:space-between;
  padding:14px 18px;
}

.brand{display:flex; align-items:center; gap:12px;}
.brand__logo{
  width:38px; height:38px;
  border-radius:14px;
  display:grid; place-items:center;
  background: linear-gradient(135deg, rgba(79,70,229,.95), rgba(79,70,229,.35));
  color:#fff;
  border:1px solid rgba(79,70,229,.25);
  box-shadow: var(--shadow);
  font-weight:800;
}
.brand__name{font-weight:750; font-size:14px;}
.brand__tag{font-size:12px; color:var(--muted); margin-top:1px;}

.actions{display:flex; gap:10px; align-items:center;}

.btn{
  display:inline-flex; align-items:center; justify-content:center;
  gap:8px;
  padding:10px 12px;
  border-radius:14px;
  border:1px solid var(--border);
  background: var(--panel);
  color:var(--text);
  box-shadow: 0 6px 18px rgba(15,23,42,.06);
  cursor:pointer;
  font-weight:650;
  font-size:13px;
}
.btn:hover{border-color: rgba(79,70,229,.25); box-shadow: 0 10px 24px rgba(15,23,42,.09);}
.btn--primary{
  background: linear-gradient(135deg, rgba(79,70,229,.95), rgba(79,70,229,.55));
  color:#fff;
  border-color: rgba(79,70,229,.35);
}
.btn--ghost{background: rgba(255,255,255,.6);}
.btn--danger{
  background: linear-gradient(135deg, rgba(225,29,72,.95), rgba(225,29,72,.45));
  border-color: rgba(225,29,72,.35);
  color:#fff;
}

.panel{
  margin-top:18px;
  padding: var(--pad);
  border-radius: var(--radius2);
  background: var(--panel);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.panel__head{
  display:flex; align-items:center; justify-content:space-between; gap:14px;
  margin-bottom:12px;
}

.day{
  margin-top:18px;
  padding: 14px 16px;
  border-radius: var(--radius2);
  background: rgba(255,255,255,.65);
  border:1px solid var(--border);
}

.day__head{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
}
.day__title{
  margin:6px 0 10px;
  font-size:18px;
  letter-spacing:.2px;
}

.badge{
  padding:7px 11px;
  border-radius:999px;
  font-weight:800;
  font-size:12px;
  background: var(--accentSoft);
  border:1px solid rgba(79,70,229,.20);
  color: rgba(79,70,229,.95);
}

.day--today{
  background: rgba(34,197,94,.12);
  border-color: rgba(34,197,94,.35);
  box-shadow: 0 0 0 3px rgba(34,197,94,.10);
}

.section-title{
  margin-top:8px;
  font-size:12px;
  letter-spacing:.12em;
  text-transform:uppercase;
  color: var(--muted);
  font-weight:800;
}
.section-title--spaced{ margin-top:16px; }

.flatlist{
  list-style:none;
  padding:0;
  margin:8px 0 0;
  display:flex;
  flex-direction:column;
  gap:8px;
}

.flatitem{
  display:flex;
  justify-content:space-between;
  align-items:flex-start;
  gap:12px;
  padding:10px 12px;
  border-radius: 14px;
  border:1px solid var(--border);
  background: rgba(255,255,255,.9);
}

.flatitem__main{
  line-height:1.25rem;
}

.flatitem__meta{
  display:flex;
  gap:10px;
  align-items:center;
  white-space:nowrap;
  font-size:12px;
}

.time{
  padding:6px 10px;
  border-radius:999px;
  border:1px solid rgba(79,70,229,.18);
  background: rgba(79,70,229,.06);
  color: rgba(79,70,229,.95);
  font-weight:800;
}

.form .grid{
  display:grid;
  grid-template-columns: 1fr 1fr;
  gap:14px;
}
@media(max-width:820px){
  .form .grid{grid-template-columns:1fr;}
  .field{min-width:0;}
  .flatitem{flex-direction:column; align-items:flex-start;}
  .flatitem__meta{width:100%; justify-content:space-between;}
}

.field{display:flex; flex-direction:column; gap:6px; min-width:220px;}
label{font-size:12px; color:var(--muted);}
small{font-size:12px;}
input{
  height:40px;
  padding:10px 12px;
  border-radius:14px;
  border:1px solid var(--border);
  background: rgba(255,255,255,.95);
  color:var(--text);
  outline:none;
}
input:focus{
  border-color: rgba(79,70,229,.35);
  box-shadow: 0 0 0 4px rgba(79,70,229,.12);
}

.form__actions{
  display:flex; gap:10px; align-items:center; margin-top:14px; flex-wrap:wrap;
}

.footer{padding:22px 18px; font-size:12px;}

.h2{
  margin:0 0 10px;
  font-size:14px;
  color: var(--text);
  font-weight: 850;
  letter-spacing:.01em;
}

.inlineform{
  display:flex;
  gap:10px;
  align-items:center;
}

.inlineinput{
  height:36px;
  padding:8px 10px;
  border-radius:12px;
  border:1px solid var(--border);
  background: rgba(255,255,255,.95);
  min-width: 240px;
}

.btn--sm{
  padding:8px 10px;
  border-radius:12px;
  font-size:12px;
}


.day__link{
  color: inherit;
  text-decoration: none;
}
.day__link:hover{
  text-decoration: underline;
  text-underline-offset: 4px;
}

.dateinput{
  height:36px;
  padding:8px 10px;
  border-radius:12px;
  border:1px solid var(--border);
  background: rgba(255,255,255,.95);
}

/* Evidenziazione righe: APRE (blu tenue) / CHIUDE (rosso tenue) */
.flatitem--open{
  border-color: rgba(79,70,229,.18);
  background: rgba(79,70,229,.04);
}
.flatitem--close{
  border-color: rgba(225,29,72,.18);
  background: rgba(225,29,72,.04);
}


.inlineform--danger{margin-left: 6px;}


.rowactions{
  display:flex;
  gap:10px;
  align-items:center;
  flex-wrap: wrap;
}

/* Header dropdown menu */
.menu{
  position: relative;
  display: inline-block;
}
.menu__panel{
  position: absolute;
  right: 0;
  top: calc(100% + 10px);
  min-width: 220px;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: rgba(255,255,255,.98);
  box-shadow: 0 18px 40px rgba(15, 23, 42, .10);
  display: none;
  z-index: 50;
}
.menu__panel--open{
  display: block;
}
.menu__item{
  display: block;
  padding: 10px 12px;
  border-radius: 12px;
  color: var(--text);
  text-decoration: none;
}
.menu__item:hover{
  background: rgba(15,23,42,.04);
}
.menu__sep{
  height: 1px;
  background: var(--border);
  margin: 6px 8px;
}

/* Chips */
.chip{
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  font-size: 12px;
  color: var(--muted);
  margin-left: 10px;
}
.chip--date{
  color: var(--text);
  background: rgba(79,70,229,.04);
  border-color: rgba(79,70,229,.18);
}
.chip--muted{
  background: rgba(15,23,42,.03);
}

.selectinput{
  height:36px;
  padding:8px 10px;
  border-radius:12px;
  border:1px solid var(--border);
  background: rgba(255,255,255,.95);
  min-width: 160px;
}


/* Badge competizione (subtle) */
.badge{
  display:inline-flex;
  align-items:center;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  font-size: 12px;
  color: var(--muted);
  background: rgba(15,23,42,.03);
  white-space: nowrap;
  margin-right: 10px;
}
.badge--comp{
  opacity: .9;
}
/* Dark mode fixes */
@media (prefers-color-scheme: dark){
  .topbar{ background: rgba(11,18,32,.72); }

  /* Buttons */
  .btn--ghost{ background: rgba(255,255,255,.06); border-color: rgba(255,255,255,.10); }

  /* Inputs */
  .input, .dateinput, .inlineinput, .selectinput{
    background: rgba(17,24,39,.85);
    color: var(--text);
    border-color: rgba(255,255,255,.12);
  }
  .input::placeholder, .inlineinput::placeholder{ color: rgba(229,231,235,.45); }

  /* Day cards / list rows that were using white tints */
  .day, .flatitem, .rowbox{
    background: rgba(17,24,39,.55);
    border-color: rgba(255,255,255,.10);
  }

  .day--today{
    background: rgba(34,197,94,.18);
    border-color: rgba(34,197,94,.55);
    box-shadow: 0 0 0 3px rgba(34,197,94,.18);
  }

  /* Open/Close subtle tints keep their hue but darker */
  .flatitem--open{ background: rgba(79,70,229,.14); }
  .flatitem--close{ background: rgba(225,29,72,.14); }

  /* Chips / badges */
  .chip, .badge{ background: rgba(255,255,255,.06); border-color: rgba(255,255,255,.10); color: rgba(229,231,235,.75); }

  /* Panels inside dropdown menu (if present) */
  .menu__panel{ background: rgba(17,24,39,.92); border-color: rgba(255,255,255,.10); }
}


/* Matches list: date first */
.flatdate{
  font-size: 14px;
  color: var(--muted);
  margin-right: 12px;
}
.flatdate--muted{ opacity: .7; }
.flatname{ font-weight: 700; }


/* Weekly view */
.weekgrid{
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 12px;
  margin-top: 16px;
}
@media (max-width: 1100px){
  .weekgrid{ grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 640px){
  .weekgrid{ grid-template-columns: 1fr; }
}
.weekday{
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 14px;
  box-shadow: var(--shadow);
  min-height: 180px;
}
.weekday--today{
  outline: 2px solid rgba(34,197,94,.35);
  background: linear-gradient(180deg, rgba(34,197,94,.10), rgba(34,197,94,.04));
}
.weekday__head{
  display:flex;
  align-items:flex-start;
  justify-content:space-between;
  gap: 10px;
  margin-bottom: 10px;
}
.weekday__dow{
  font-weight: 800;
  letter-spacing: .02em;
}
.weekday__date{
  color: var(--muted);
  font-size: 13px;
  margin-top: 2px;
}
.pill{
  display:inline-flex;
  align-items:center;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,.06);
  font-size: 12px;
  color: var(--muted);
}
.pill--today{
  border-color: rgba(34,197,94,.35);
  background: rgba(34,197,94,.10);
  color: rgba(34,197,94,.85);
}
.small{ font-size: 13px; }
/* Weekly view tweaks */
.weekday__date{
  font-size: 12px;
  opacity: .8;
}
.weekday__dow{
  font-size: 18px;
  line-height: 1.1;
}
.timelead{
  font-weight: 800;
  letter-spacing: .02em;
  margin-right: 6px;
}
/* Weekly view event sizing */
.weekgrid .flatitem__main{
  font-size: 14px;
  line-height: 1.25;
}
.weekgrid .timelead{ font-size: 14px; }
.weekgrid .flatitem__main strong{ font-weight: 800; }
.weekgrid .flatitem__meta .link{ font-size: 13px; }
.weekgrid .badge{ display:none; }
/* Weekly view event sizing */
.weekgrid .flatitem__main{
  font-size: 13px;
  line-height: 1.15;
}
.weekgrid .wline1{
  font-size: 13px;
  line-height: 1.1;
}
.weekgrid .timelead{
  font-size: 13px;
  font-weight: 900;
  margin-right: 6px;
}
.weekgrid .matchlead{
  font-size: 13px;
  font-weight: 800;
}
.weekgrid .wline2{
  margin-top: 4px;
  font-size: 11.5px;
  color: var(--muted);
  opacity: .9;
}
.weekgrid .flatitem__meta .link{
  font-size: 12px;
}


/* Weekly layout: 5 giorni (lun-ven) sopra, weekend sotto */
.weekgrid--workdays{
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 14px;
}
.weekgrid--weekend{
  margin-top: 14px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}
@media (max-width: 980px){
  .weekgrid--workdays,
  .weekgrid--weekend{
    grid-template-columns: 1fr;
  }
}



/* Weekly view (cards) */
.pagehead{display:flex;align-items:flex-start;justify-content:space-between;gap:16px;margin-bottom:14px}
.weeknav{display:flex;gap:10px;flex-wrap:wrap;margin:10px 0 18px}
.weeklist{list-style:none;padding:0;margin:10px 0 0;display:flex;flex-direction:column;gap:10px}

.wcard{
  border:1px solid rgba(255,255,255,.08);
  border-radius:16px;
  padding:10px 12px;
  background:rgba(255,255,255,.03);
}
.wcard--open{ border-color:rgba(99,102,241,.25); background:rgba(99,102,241,.12); }
.wcard--close{ border-color:rgba(239,68,68,.22); background:rgba(239,68,68,.10); }

.wtime{font-size:13px;font-weight:700;letter-spacing:.01em}
.wmatch{font-size:13px;font-weight:700;margin-top:2px}
.wphase{font-size:12px;opacity:.75;margin-top:3px}

.matchday{
  margin-top:10px;
  margin-bottom:4px;
  font-size:14px;        /* prima era 12px */
  font-weight:800;
  color:#f97316;         /* arancione */
  letter-spacing:.06em;
  text-transform:uppercase;
}

.sr-only{
  position: absolute;
  left: -9999px;
  top: -9999px;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.share-panel{
  display:flex;
  flex-direction:column;
  gap:16px;
}

.share-block{
  padding:14px;
  border-radius:16px;
  border:1px solid var(--border);
  background: rgba(255,255,255,.52);
}

.share-copy{
  margin:8px 0 10px;
}

.share-textarea{
  width:100%;
  min-height:88px;
  padding:12px 14px;
  border-radius:14px;
  border:1px solid var(--border);
  background: rgba(255,255,255,.95);
  color:var(--text);
  resize:vertical;
  font: inherit;
  line-height:1.45;
}

.share-note{
  padding:12px 14px;
  border-radius:14px;
  border:1px solid rgba(79,70,229,.18);
  background: rgba(79,70,229,.06);
  color:var(--text);
}

@media (prefers-color-scheme: dark){
  .share-block{
    background: rgba(17,24,39,.45);
    border-color: rgba(255,255,255,.10);
  }

  .share-textarea{
    background: rgba(17,24,39,.88);
    border-color: rgba(255,255,255,.12);
    color: var(--text);
  }

  .share-note{
    background: rgba(79,70,229,.14);
    border-color: rgba(129,140,248,.28);
  }
}
