/* Pectus: gesso e petrolio, con l'ambra come segnale. Il motivo ricorrente è il torace del logo con gli archi. */
:root {
  --bg: #edf1f0;
  --surface: #ffffff;
  --ink: #10262e;
  --ink-2: #4a6068;
  --line: #d0dad9;
  --petrol: #0e5a66;
  --petrol-ink: #ffffff;
  --air: #d3e9e6;
  --signal: #f4b63f;
  --signal-ink: #a86c00;
  --alert: #b3371f;
  --medal-off: #d3dcdb;
  --medal-off-2: #bfcac9;
  --medal-off-face: #eef2f1;
  --r-s: 8px;
  --r-m: 14px;
  --r-l: 26px;
  --font-d: "Bricolage Grotesque", "Segoe UI", system-ui, sans-serif;
  --font-b: "Atkinson Hyperlegible", "Segoe UI", system-ui, sans-serif;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0a1b20;
    --surface: #11292f;
    --ink: #e7f0ee;
    --ink-2: #9db3b5;
    --line: #25434b;
    --petrol: #6fcdd1;
    --petrol-ink: #06242a;
    --air: #17404a;
    --signal-ink: #f4b63f;
    --alert: #ff8d76;
    --medal-off: #23434b;
    --medal-off-2: #2f535c;
    --medal-off-face: #183239;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 400 1.0625rem/1.5 var(--font-b);
}
h1, h2, h3 { font-family: var(--font-d); line-height: 1.12; margin: 0; text-wrap: balance; }
h1 { font-size: clamp(1.9rem, 7.5vw, 2.5rem); font-weight: 700; letter-spacing: -0.02em; }
h2 { font-size: 1.3rem; font-weight: 650; letter-spacing: -0.01em; }
h3 { font-size: 1.0625rem; font-weight: 650; }
p { margin: 0; }
p + p { margin-top: 0.7em; }
a { color: inherit; }
ul, ol { margin: 0; padding: 0; list-style: none; }
img, svg { display: block; max-width: 100%; }
small, .small { font-size: 0.875rem; }
.muted { color: var(--ink-2); }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid var(--signal-ink); outline-offset: 2px; border-radius: 4px; }
#view:focus { outline: none; }

#app { max-width: 34rem; margin: 0 auto; padding: 20px 20px calc(92px + env(safe-area-inset-bottom)); }

/* Testata di pagina */
.page-head { padding: 12px 0 22px; }
.brand { display: flex; align-items: baseline; gap: 10px; margin-bottom: 18px; font: 750 1.25rem/1 var(--font-d); letter-spacing: -0.01em; }
.brand-mark { width: 30px; height: 30px; flex: none; align-self: center; }
.brand span {font: 400 0.875rem/1.2 var(--font-b); letter-spacing: 0; color: var(--ink-2); }
.page-head .date { color: var(--ink-2); margin-bottom: 6px; }
.page-head .lede { margin-top: 10px; color: var(--ink-2); max-width: 30em; }
.back { display: inline-block; padding: 10px 0; font-family: var(--font-d); font-weight: 600; }
.block { padding: 24px 0; border-top: 1px solid var(--line); }
.block > h2 { margin-bottom: 12px; }
.block > h2 + p { margin-bottom: 14px; }
.stack > * + * { margin-top: 12px; }
.note { color: var(--ink-2); font-size: 0.9375rem; }
.callout { background: var(--air); border-radius: var(--r-m); padding: 14px 16px; }
.callout.warn { background: transparent; border: 1.5px solid var(--alert); }

/* Pulsanti */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 0.7rem 1.15rem;
  border: 1.5px solid var(--ink); border-radius: var(--r-m);
  background: transparent; color: var(--ink);
  font: 600 1rem/1.1 var(--font-d); text-decoration: none; cursor: pointer;
}
.btn.primary { background: var(--petrol); border-color: var(--petrol); color: var(--petrol-ink); }
.btn.quiet { border-color: transparent; padding-inline: 0.2rem; min-height: 44px; text-decoration: underline; text-underline-offset: 3px; font-weight: 500; }
.btn.danger { border-color: var(--alert); color: var(--alert); }
.btn.wide { width: 100%; }
.btn[disabled] { opacity: 0.5; cursor: not-allowed; }
.btn-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }

/* Scelta a segmenti */
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); margin: 0; padding: 0; border: 1.5px solid var(--ink); border-radius: var(--r-m); overflow: hidden; min-width: 0; }
.seg legend { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
.seg label { display: grid; cursor: pointer; }
.seg label + label { border-left: 1.5px solid var(--ink); }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg span { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-height: 48px; padding: 6px 3px; text-align: center; font: 600 0.8125rem/1.15 var(--font-d); overflow-wrap: break-word; hyphens: auto; min-width: 0; }
@media (min-width: 440px) { .seg span { font-size: 0.9375rem; } }
.seg span small { font: 400 0.75rem/1 var(--font-b); opacity: 0.8; }
.seg input:checked + span { background: var(--ink); color: var(--bg); }
.preset-info { margin-top: 12px; padding: 14px 16px; border-left: 4px solid var(--signal); background: color-mix(in srgb, var(--ink) 6%, transparent); border-radius: 0 var(--r-m) var(--r-m) 0; }
.preset-who { font: 650 1rem/1.3 var(--font-d); }
.dose { margin: 10px 0 0; display: grid; gap: 6px; }
.dose > div { display: grid; grid-template-columns: 5.5rem 1fr; gap: 10px; align-items: baseline; }
.dose dt { color: var(--ink-2); font-size: 0.875rem; }
.dose dd { margin: 0; font-variant-numeric: tabular-nums; }
.preset-info .note { margin-top: 10px; }
.seg input:focus-visible + span { outline: 3px solid var(--signal-ink); outline-offset: -4px; }

/* Il torace del logo con gli archi: le sessioni di oggi e quelle della settimana */
.chest-mark { display: block; width: 104px; height: auto; overflow: visible; }
.chest-mark .arc { fill: none; stroke: var(--line); stroke-width: 7; stroke-linecap: round; }
.chest-mark .arc.on { stroke: var(--signal); }
.chest-mark .chest { fill: none; stroke: var(--ink); stroke-width: 9; stroke-linecap: round; stroke-linejoin: round; }
.chest-mark.mini { width: 26px; margin: 0 auto; }
.chest-mark.mini .arc { stroke-width: 12; }
.chest-mark.mini .chest { stroke-width: 14; }

.today { display: grid; grid-template-columns: auto 1fr; gap: 22px; align-items: stretch; padding-bottom: 26px; }
.today .chest-mark { align-self: center; }
.today-main { display: flex; flex-direction: column; gap: 14px; justify-content: space-between; min-width: 0; }
@media (max-width: 380px) { .today { gap: 16px; } .today .chest-mark { width: 78px; } }

.week { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; text-align: center; }
.week .d { display: block; font: 600 0.8125rem/1 var(--font-d); color: var(--ink-2); margin-bottom: 8px; }
.week .is-today .d { color: var(--ink); text-decoration: underline; text-decoration-thickness: 2.5px; text-underline-offset: 4px; text-decoration-color: var(--signal); }

.facts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin: 0; }
.facts > div { display: flex; flex-direction: column; justify-content: space-between; gap: 4px; }
.facts dt { color: var(--ink-2); font-size: 0.875rem; line-height: 1.25; }
.facts dd { margin: 2px 0 0; font: 700 1.9rem/1 var(--font-d); font-variant-numeric: tabular-nums; }

.level { display: grid; gap: 8px; }
.level-top { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.level-top strong { font: 700 1.3rem/1 var(--font-d); }
.meter { height: 10px; background: var(--line); border-radius: 2px; overflow: hidden; }
.meter > span { display: block; height: 100%; background: var(--petrol); }

/* Esercizi */
/* Illustrazioni degli esercizi (js/figures.js): immagine ferma o video, sempre 3:2 su fondo crema. */
.ex-video, .ex-still { display: block; width: 100%; height: auto; aspect-ratio: 3 / 2; object-fit: cover; border-radius: var(--r-m); background: #efe6da; }
.fig-frame { border-radius: var(--r-l); overflow: hidden; }
.fig-frame .ex-video, .fig-frame .ex-still { border-radius: 0; }

.steps > li { padding: 24px 0; border-top: 1px solid var(--line); }
.steps .step-n { color: var(--ink-2); font: 600 0.9375rem/1 var(--font-d); margin-bottom: 6px; }
.steps h2 + p { margin-top: 8px; color: var(--ink-2); }
.ex-list { margin-top: 12px; }
.ex-row { display: grid; grid-template-columns: 96px 1fr; gap: 14px; align-items: center; padding: 10px 0; text-decoration: none; border-top: 1px solid var(--line); }
.ex-row .ex-still { border-radius: var(--r-s); }
.ex-row strong { display: block; font: 650 1.0625rem/1.2 var(--font-d); }
.ex-row span span { color: var(--ink-2); font-size: 0.9375rem; }
.howto { counter-reset: s; }
.howto li { counter-increment: s; display: grid; grid-template-columns: 1.6rem 1fr; padding: 7px 0; }
.howto li::before { content: counter(s); font: 700 1rem/1.5 var(--font-d); color: var(--petrol); }
.plain li { padding: 4px 0 4px 1.1rem; position: relative; }
.plain li::before { content: ""; position: absolute; left: 0; top: 0.8em; width: 9px; height: 3px; background: var(--signal-ink); }

/* Guida */
details { border-top: 1px solid var(--line); }
details:last-of-type { border-bottom: 1px solid var(--line); }
summary { display: flex; justify-content: space-between; gap: 16px; align-items: center; padding: 16px 0; cursor: pointer; list-style: none; font: 650 1.125rem/1.2 var(--font-d); }
summary::-webkit-details-marker { display: none; }
summary::after { content: "+"; font-weight: 400; font-size: 1.5rem; line-height: 0.8; color: var(--petrol); }
details[open] summary::after { content: "\2212"; }
details .body { padding: 0 0 18px; max-width: 34em; }

/* Moduli */
label.f, .f { display: block; }
.f > span, .f-label { display: block; font-size: 0.9375rem; margin-bottom: 5px; }
input[type="text"], input[type="email"], input[type="password"], input[type="number"], input[type="date"], input[type="time"], select, textarea {
  width: 100%; min-height: 48px; padding: 0.6rem 0.75rem;
  border: 1.5px solid var(--ink-2); border-radius: var(--r-s);
  background: var(--surface); color: var(--ink); font: inherit;
}
textarea { min-height: 96px; resize: vertical; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.check { display: grid; grid-template-columns: 24px 1fr; gap: 10px; align-items: start; cursor: pointer; }
.check input { width: 22px; height: 22px; margin: 2px 0 0; accent-color: var(--petrol); }
.switch-row { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 10px 0; }
.switch-row input[type="checkbox"] { width: 24px; height: 24px; accent-color: var(--petrol); flex: none; }
.switch-row input[type="number"], .switch-row select { width: 6.5rem; flex: none; }
.times { display: flex; flex-wrap: wrap; gap: 8px; }
.times input { width: 7rem; }

/* Calendario e grafici */
.cal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.cal-head strong { font: 650 1.0625rem/1 var(--font-d); text-transform: capitalize; }
.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal .wd { text-align: center; font-size: 0.75rem; color: var(--ink-2); padding-bottom: 2px; }
.cal .c { aspect-ratio: 1; display: grid; place-items: center; border-radius: var(--r-s); background: var(--surface); font-size: 0.875rem; font-variant-numeric: tabular-nums; }
.cal .c.l1 { background: var(--air); }
.cal .c.l2 { background: var(--petrol); color: var(--petrol-ink); }
.cal .c.l3 { background: var(--signal); color: #10262e; font-weight: 700; }
.cal .c.now { outline: 2px solid var(--ink); outline-offset: -2px; }
.cal .c.out { background: transparent; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 10px; font-size: 0.8125rem; color: var(--ink-2); }
.legend i { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }
.chart { width: 100%; height: auto; }
.chart .ln { fill: none; stroke: var(--petrol); stroke-width: 3; stroke-linejoin: round; stroke-linecap: round; }
.chart .pt { fill: var(--surface); stroke: var(--petrol); stroke-width: 3; }
.chart .ax { stroke: var(--line); stroke-width: 1; }
.chart text { fill: var(--ink-2); font: 400 11px var(--font-b); }
.rows li { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 8px 0; border-top: 1px solid var(--line); }
.rows li:first-child { border-top: 0; }

/* Comunità */
.g-signin { display: grid; gap: 8px; margin-bottom: 4px; }
.g-signin #g-btn { min-height: 44px; color-scheme: light; }
.or { display: flex; align-items: center; gap: 12px; margin: 14px 0; color: var(--ink-2); font-size: 0.9375rem; }
.or::before, .or::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.post { padding: 18px 0; border-top: 1px solid var(--line); }
.post-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; margin-bottom: 8px; }
.post-head strong { font: 650 1.0625rem/1.2 var(--font-d); }
.tag { display: inline-block; padding: 2px 9px; border: 1.5px solid var(--ink-2); border-radius: 99px; font-size: 0.8125rem; line-height: 1.3; }
.post-text { white-space: pre-wrap; overflow-wrap: anywhere; }
.post-photos { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 8px; margin-top: 12px; }
.post-photos img { width: 100%; aspect-ratio: 3 / 4; object-fit: cover; border-radius: var(--r-m); background: var(--line); }
.ai-box { margin-top: 12px; background: var(--air); border-radius: var(--r-m); padding: 12px 14px; font-size: 0.9375rem; }
.ai-box h3 { margin-bottom: 4px; }
.post-actions { display: flex; flex-wrap: wrap; gap: 2px 18px; margin-top: 6px; }
.post-actions .btn.quiet[aria-pressed="true"] { font-weight: 700; text-decoration-color: var(--signal-ink); text-decoration-thickness: 3px; }
.comments { margin-top: 8px; padding-left: 14px; border-left: 3px solid var(--line); }
.comments li { padding: 8px 0; }
.comments form { display: grid; grid-template-columns: 1fr auto; gap: 8px; margin-top: 8px; }

/* Barra delle sezioni */
.tabs {
  position: fixed; left: 50%; bottom: 0; transform: translateX(-50%);
  display: grid; grid-template-columns: repeat(5, 1fr);
  width: 100%; max-width: 34rem; padding-bottom: env(safe-area-inset-bottom);
  background: var(--surface); border-top: 1px solid var(--line); z-index: 5;
}
.tabs a { position: relative; padding: 18px 2px 16px; text-align: center; text-decoration: none; color: var(--ink-2); font: 600 0.8125rem/1 var(--font-d); }
.tabs a[aria-current="page"] { color: var(--ink); }
.tabs a[aria-current="page"]::before { content: ""; position: absolute; top: -1px; left: 50%; width: 30px; height: 5px; margin-left: -15px; background: var(--signal); }
@media (min-width: 420px) { .tabs a { font-size: 0.9375rem; } }

/* Avvisi e finestre */
#toast { position: fixed; left: 50%; bottom: calc(84px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 40; width: max-content; max-width: min(30rem, calc(100vw - 32px)); pointer-events: none; }
#toast p { background: var(--ink); color: var(--bg); padding: 12px 16px; border-radius: var(--r-m); font-size: 0.9375rem; }
dialog { width: min(30rem, calc(100vw - 28px)); max-height: calc(100dvh - 28px); border: 0; border-radius: var(--r-l); padding: 26px 22px; background: var(--surface); color: var(--ink); }
dialog::backdrop { background: rgba(8, 24, 29, 0.72); }
dialog h1 { font-size: 1.75rem; margin-bottom: 14px; }

/* Sessione guidata: sempre su fondo petrolio scuro */
#overlay { position: fixed; inset: 0; z-index: 30; overflow: auto; }
.pl {
  --bg: #0b2a31; --surface: #123a43; --ink: #eaf3f1; --ink-2: #9dbabc; --line: #25525c;
  --petrol: #7fd3d6; --petrol-ink: #06242a; --air: #1b4650; --signal-ink: #f4b63f;
  min-height: 100dvh; display: grid; grid-template-rows: auto 1fr auto; gap: 12px;
  background: var(--bg); color: var(--ink);
  padding: calc(14px + env(safe-area-inset-top)) 20px calc(20px + env(safe-area-inset-bottom));
}
.pl-in { width: 100%; max-width: 32rem; margin: 0 auto; }
.pl-top { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.pl-top .btn { min-height: 44px; padding: 0.4rem 0.9rem; font-size: 0.9375rem; }
.pl-count { color: var(--ink-2); font-size: 0.9375rem; display: flex; flex-direction: column; align-items: center; gap: 2px; text-align: center; line-height: 1.2; }
.pl-clock { color: var(--ink); font: 700 1.125rem/1 var(--font-d); font-variant-numeric: tabular-nums; letter-spacing: 0.01em; }
.pl-body { display: flex; flex-direction: column; justify-content: center; gap: 18px; }
.pl-ex { color: var(--ink-2); font: 600 1rem/1.2 var(--font-d); }
.pl-phase { font: 700 clamp(2rem, 9vw, 2.75rem)/1.05 var(--font-d); letter-spacing: -0.02em; }
.pl-stage { display: flex; align-items: center; justify-content: center; gap: clamp(12px, 4vw, 30px); padding: 8px 0; }
/* Sotto il video, il torace con gli archi: grande quanto resta in altezza. */
.pl-stage .pl-meter { width: min(44vw, 230px, calc(29svh * 120 / 212)); height: auto; aspect-ratio: 120 / 212; flex: none; overflow: visible; }
.pl-meter .arc { fill: none; stroke: var(--line); stroke-width: 6; stroke-linecap: round; }
.pl-meter .arc.on { stroke: var(--signal); }
.pl-meter.drain .arc.on { stroke: var(--petrol); }
/* Ultimi 3 secondi di riposo: gli archi rimasti e il numero si accendono di giallo, come un semaforo. */
.pl-meter.drain.ready .arc.on { stroke: var(--signal); }
.pl-num.ready { color: var(--signal); }
.pl-meter .chest { fill: none; stroke: var(--ink); stroke-width: 9; stroke-linecap: round; stroke-linejoin: round; }
.pl-num { font: 800 clamp(4.25rem, 21vw, 7rem)/0.9 var(--font-d); font-variant-numeric: tabular-nums; min-width: 1.2em; text-align: center; }
.pl-meta { display: flex; flex-wrap: wrap; gap: 4px 18px; color: var(--ink-2); }
.pl-meta strong { color: var(--ink); }
.pl-fig { max-width: 420px; margin: 0 auto; width: 100%; }
/* Il video dell'esercizio, grande, che si muove a tempo con le fasi. */
.pl-live .ex-video, .pl-live .ex-still { border-radius: var(--r-l); max-height: 31svh; }
.pl-fig.small { max-width: 120px; margin: 0; flex-shrink: 0; }
.pl-fig.small .ex-still { border-radius: var(--r-s, 10px); }
.pl-ctl { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.pl-ctl.one { grid-template-columns: 1fr; }
.pl-ctl .wide { grid-column: 1 / -1; }
.pl .btn.primary { background: var(--signal); border-color: var(--signal); color: #10262e; }
.pl .seg input:checked + span { background: var(--ink); color: var(--bg); }
.pl h1 { font-size: clamp(1.9rem, 8vw, 2.4rem); }
.pl textarea { background: var(--surface); }

@media (prefers-reduced-motion: no-preference) {
  .pl-meter .arc { transition: stroke 0.18s linear; }
  /* Il contatore si aggiorna ogni 100 ms: la transizione ammorbidisce i passi. */
  .pl-meter .chest { transition: d 0.1s linear; }
  .pl-meter .arcs { transition: transform 0.1s linear; }
  .meter > span { transition: width 0.4s ease; }
}

/* Diario della campana a vuoto */
.bell-timer { text-align: center; }
.bell-clock { font: 750 clamp(3rem, 16vw, 4.2rem)/1 var(--font-d); letter-spacing: -0.03em; font-variant-numeric: tabular-nums; }
.facts dd small { font-size: 0.95rem; font-weight: 600; margin-left: 2px; }
.bell-bars { position: relative; display: grid; grid-template-columns: repeat(14, 1fr); gap: 4px; height: 130px; padding-bottom: 18px; }
.bell-bars .bb { position: relative; display: flex; align-items: flex-end; height: 100%; }
.bell-bars .bb span { display: block; width: 100%; min-height: 2px; background: var(--petrol); border-radius: 3px 3px 0 0; }
.bell-bars .bb.ok span { background: var(--signal); }
.bell-bars .bb i { position: absolute; bottom: -18px; left: 0; right: 0; text-align: center; font: 600 0.6875rem/1 var(--font-d); font-style: normal; color: var(--ink-2); }
.bell-goal { position: absolute; left: 0; right: 0; height: 0; border-top: 2px dashed var(--ink-2); opacity: 0.6; pointer-events: none; }
.link-rows li a { display: block; padding: 4px 0; font-family: var(--font-d); font-weight: 600; }

/* Barra in alto: marchio, giorni di fila, punti della settimana, menu */
.topbar {
  position: sticky; top: 0; z-index: 6;
  display: flex; align-items: center; gap: 8px;
  margin: -20px -20px 0; padding: calc(8px + env(safe-area-inset-top)) 20px 8px;
  background: var(--bg);
}
.tb-brand { display: inline-flex; align-items: center; gap: 9px; min-height: 44px; text-decoration: none; font: 750 1.125rem/1 var(--font-d); letter-spacing: -0.01em; }
.tb-brand .brand-mark { width: 30px; height: 30px; }
.tb-stats { display: flex; gap: 6px; margin-left: auto; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; min-height: 44px; padding: 0 12px;
  border: 1.5px solid var(--line); border-radius: 99px; background: var(--surface);
  font: 700 0.9375rem/1 var(--font-d); font-variant-numeric: tabular-nums; text-decoration: none;
}
.chip .chest-mark.tiny { width: 17px; }
.chip .chest-mark.tiny .arc { stroke-width: 13; }
.chip .chest-mark.tiny .chest { stroke-width: 15; }
.chip .coin { width: 18px; height: 18px; }
.chip .coin circle { fill: var(--signal); }
.chip .coin path { fill: none; stroke: #10262e; stroke-width: 2.6; stroke-linecap: round; }
.menu-btn { display: grid; place-items: center; width: 44px; height: 44px; padding: 0; border: 0; border-radius: var(--r-m); background: transparent; color: var(--ink); cursor: pointer; }
.menu-btn svg, .menu-close svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; }
@media (max-width: 359px) { .tb-brand span { display: none; } .chip { padding: 0 10px; } }

/* Menu laterale */
dialog.menu {
  margin: 0 0 0 auto; width: min(22.5rem, 88vw); height: 100dvh; max-height: 100dvh; max-width: none;
  padding: 0; border-radius: var(--r-l) 0 0 var(--r-l); overflow-y: auto; overscroll-behavior: contain;
}
.menu-in { padding: calc(10px + env(safe-area-inset-top)) 20px calc(28px + env(safe-area-inset-bottom)); }
.menu-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.menu-title { font: 750 1.375rem/1 var(--font-d); letter-spacing: -0.01em; }
.menu-close { display: grid; place-items: center; width: 44px; height: 44px; margin-right: -10px; padding: 0; border: 0; border-radius: var(--r-m); background: transparent; color: var(--ink); cursor: pointer; }
.menu-account { display: grid; grid-template-columns: 46px 1fr; gap: 12px; align-items: center; padding: 12px 14px; border-radius: var(--r-m); background: var(--air); text-decoration: none; }
.menu-account strong { display: block; font: 700 1.0625rem/1.2 var(--font-d); }
.menu-account small { color: var(--ink-2); }
.mini-medal { width: 46px; }
.menu-h { margin: 22px 0 2px; color: var(--ink-2); font: 650 0.8125rem/1 var(--font-d); letter-spacing: 0.06em; text-transform: uppercase; }
.menu-list a, .profile-link {
  display: flex; justify-content: space-between; align-items: center; gap: 12px; min-height: 50px;
  text-decoration: none; font: 600 1rem/1.25 var(--font-d);
}
.menu-list li + li a { border-top: 1px solid var(--line); }
.menu-list a::after, .profile-link::after { content: ""; flex: none; width: 8px; height: 8px; margin-right: 4px; border-top: 2px solid var(--ink-2); border-right: 2px solid var(--ink-2); transform: rotate(45deg); }
.menu-lang { margin-top: 22px; }
.profile-link strong { display: block; font: 650 1.0625rem/1.2 var(--font-d); }
.profile-link small { display: block; color: var(--ink-2); font: 400 0.875rem/1.3 var(--font-b); }
@media (prefers-reduced-motion: no-preference) {
  dialog.menu[open] { animation: menu-in 0.24s cubic-bezier(0.2, 0.8, 0.2, 1); }
  dialog.menu.closing { transform: translateX(100%); transition: transform 0.18s ease-in; }
  dialog.menu[open]::backdrop { animation: fade-in 0.24s ease; }
  .menu-list a { transition: color 0.15s; }
  .menu-list a:hover { color: var(--petrol); }
  .chip, .menu-btn, .medal-btn .medal, .btn { transition: transform 0.15s ease, border-color 0.15s ease, background-color 0.15s ease; }
  .chip:hover { border-color: var(--ink-2); transform: translateY(-1px); }
  .btn:active, .chip:active, .menu-btn:active { transform: translateY(1px); }
}
@keyframes menu-in { from { transform: translateX(100%); } }
@keyframes fade-in { from { opacity: 0; } }

/* Medaglie */
.medal { display: block; width: 100%; height: auto; overflow: visible; }
.medal.locked .glyph [stroke] { stroke: var(--ink-2); }
.medal.locked .glyph text { fill: var(--ink-2); }
.medal.locked .glyph { opacity: 0.75; }
.medals { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px 10px; margin-top: 12px; }
.medals.shelf { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.medal-btn {
  display: flex; flex-direction: column; align-items: center; gap: 6px; width: 100%; height: 100%;
  padding: 6px 2px; border: 0; border-radius: var(--r-m); background: none; color: inherit;
  font: inherit; text-align: center; cursor: pointer;
}
.medal-btn .medal { width: min(86px, 100%); margin-bottom: 2px; }
.medal-btn:hover .medal { transform: translateY(-2px); }
.medal-btn:active .medal { transform: scale(0.97); }
.medal-btn strong { font: 650 0.875rem/1.2 var(--font-d); }
.medal-btn small { color: var(--ink-2); font-size: 0.75rem; font-variant-numeric: tabular-nums; }
.medals li:not(.got) .medal-btn strong { color: var(--ink-2); }
.medal-meter { display: block; width: 68%; height: 5px; border-radius: 3px; background: var(--line); overflow: hidden; }
.medal-meter > span { display: block; height: 100%; background: var(--petrol); }
.level-card { display: grid; grid-template-columns: 74px 1fr; gap: 16px; align-items: center; }
.lv-medal { width: 74px; }

/* La festa per una medaglia o un livello nuovo */
dialog.celebrate { width: min(23rem, calc(100vw - 32px)); padding: 26px 22px 22px; text-align: center; }
.cel-stage { position: relative; display: grid; place-items: center; width: 230px; height: 230px; margin: 0 auto 6px; }
.cel-stage.quiet { width: 150px; height: 170px; }
.cel-stage .medal.big { position: relative; z-index: 1; width: 148px; }
.cel-stage.quiet .medal.big { width: 128px; }
.cel-burst { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.cel-burst path { fill: none; stroke-width: 5; stroke-linecap: round; }
.cel-burst .b1 { stroke: var(--signal); }
.cel-burst .b2 { stroke: var(--petrol); }
.cel-kicker { color: var(--signal-ink); font: 700 0.8125rem/1 var(--font-d); letter-spacing: 0.08em; text-transform: uppercase; }
dialog.celebrate h2 { margin: 8px 0; font-size: 1.75rem; }
.cel-text { margin-bottom: 20px; color: var(--ink-2); }
@media (prefers-reduced-motion: no-preference) {
  dialog.celebrate[open] { animation: pop-in 0.22s ease-out; }
  dialog.celebrate[open] .cel-stage:not(.quiet) .medal.big { animation: medal-in 0.85s cubic-bezier(0.2, 1.3, 0.4, 1) both; }
  dialog.celebrate[open] .cel-burst { animation: burst 0.9s 0.25s cubic-bezier(0.1, 0.8, 0.3, 1) both; }
}
@keyframes pop-in { from { transform: scale(0.94); opacity: 0; } }
@keyframes medal-in { 0% { transform: scale(0.3) rotateY(160deg); opacity: 0; } 55% { opacity: 1; } 100% { transform: none; } }
@keyframes burst { 0% { transform: scale(0.35) rotate(-24deg); opacity: 0; } 35% { opacity: 1; } 100% { transform: none; opacity: 1; } }

/* Accesso */
.auth-ways { margin-top: 16px; }
.auth-mail { display: grid; gap: 12px; }
.auth-mail.sent { padding: 16px; border-radius: var(--r-m); background: var(--air); }
.code-form { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; align-items: end; }
.code-form input { font: 700 1.375rem/1 var(--font-d); letter-spacing: 0.25em; text-align: center; font-variant-numeric: tabular-nums; }
.auth-more { margin-top: 20px; }
.auth-more .body { padding-top: 4px; }
.btn.quiet.small { min-height: 0; padding: 2px 0; font-size: 0.875rem; }

/* Profilo */
.profile-head { display: grid; grid-template-columns: 64px 1fr; gap: 14px; align-items: center; }
.profile-head .avatar { width: 64px; }
.profile-head h1 { overflow-wrap: anywhere; }
.profile-head .lede { margin-top: 6px; }

/* Classifica */
.board li {
  display: grid; grid-template-columns: 34px minmax(0, 1fr) auto; gap: 12px; align-items: center;
  min-height: 58px; padding: 8px 10px; border-top: 1px solid var(--line);
}
.board li:first-child { border-top: 0; }
.board li.me { border-top-color: transparent; border-radius: var(--r-m); background: var(--air); }
.board li.me + li { border-top-color: transparent; }
.rank-n { color: var(--ink-2); font: 700 1rem/1 var(--font-d); text-align: center; font-variant-numeric: tabular-nums; }
.rank-coin { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 50%; color: #10262e; font: 800 0.9375rem/1 var(--font-d); box-shadow: inset 0 0 0 3px rgba(255, 255, 255, 0.5); }
.rank-coin.gold { background: #e9a92c; }
.rank-coin.silver { background: #b7c4c6; }
.rank-coin.bronze { background: #c7834a; }
.who strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font: 650 1.0625rem/1.2 var(--font-d); }
.who small { color: var(--ink-2); }
.pts { font: 800 1.25rem/1 var(--font-d); text-align: right; font-variant-numeric: tabular-nums; }
.pts small { display: block; margin-top: 3px; color: var(--ink-2); font: 400 0.75rem/1 var(--font-b); }
.board-you { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.board-you > div { display: flex; flex-direction: column; justify-content: space-between; gap: 6px; }
.board-you strong { font: 750 1.75rem/1 var(--font-d); font-variant-numeric: tabular-nums; }
.vh { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
