@font-face {
  font-family: "Inter";
  src: url("../vendor/inter/inter-latin-wght-normal.woff2") format("woff2");
  font-weight: 100 900; font-style: normal; font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Inter";
  src: url("../vendor/inter/inter-latin-ext-wght-normal.woff2") format("woff2");
  font-weight: 100 900; font-style: normal; font-display: swap;
  unicode-range: U+0100-02AF, U+0304, U+0308, U+0329, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

:root {
  --bg: #f3f5f8;
  --card: #ffffff;
  --ink: #111827;
  --muted: #5d6675;
  --line: #e2e6ec;
  --field: #f7f8fa;
  --brand: #0f1b2d;
  --brand-2: #1b2f4e;
  --brand-ink: #ffffff;
  --accent: #e8611a;
  --accent-ink: #ffffff;
  --accent-soft: #fdeee4;
  --warn: #9a5a00;
  --warn-bg: #fff4dc;
  --ok: #18794e;
  --ok-bg: #e3f5ec;
  --lane: #ecd9b6;
  --lane-edge: #b99b6c;
  --gutter: #c9c4bb;
  --approach: #f3e8d2;
  --marks: #5b4630;
  --pin: #ffffff;
  --oil: 214, 98, 30;
  --path: #1d5fd1;
  --path-alt: rgba(29, 95, 209, 0.25);
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.05), 0 6px 20px rgba(16, 24, 40, 0.05);
  --radius: 16px;
  --nav-h: 64px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b1018; --card: #141b26; --ink: #e8ecf2; --muted: #98a2b3; --line: #253041; --field: #1a2230;
    --brand: #0b1626; --brand-2: #16263f; --brand-ink: #ffffff;
    --accent: #ff7a33; --accent-ink: #1b0d03; --accent-soft: #3a2314;
    --warn: #f0c060; --warn-bg: #3a2f14; --ok: #6fd3a0; --ok-bg: #12301f;
    --lane: #4a3d2a; --lane-edge: #6e5a3c; --gutter: #222a36; --approach: #3b3122; --marks: #d9c39e; --pin: #f4f4f4;
    --oil: 240, 130, 58; --path: #7fb2ff; --path-alt: rgba(127, 178, 255, 0.28);
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px rgba(0, 0, 0, 0.25);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0b1018; --card: #141b26; --ink: #e8ecf2; --muted: #98a2b3; --line: #253041; --field: #1a2230;
  --brand: #0b1626; --brand-2: #16263f; --brand-ink: #ffffff;
  --accent: #ff7a33; --accent-ink: #1b0d03; --accent-soft: #3a2314;
  --warn: #f0c060; --warn-bg: #3a2f14; --ok: #6fd3a0; --ok-bg: #12301f;
  --lane: #4a3d2a; --lane-edge: #6e5a3c; --gutter: #222a36; --approach: #3b3122; --marks: #d9c39e; --pin: #f4f4f4;
  --oil: 240, 130, 58; --path: #7fb2ff; --path-alt: rgba(127, 178, 255, 0.28);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px rgba(0, 0, 0, 0.25);
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.5 "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-feature-settings: "cv11", "ss01";
  -webkit-font-smoothing: antialiased;
  padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom));
}
@media (min-width: 900px) { body { padding-bottom: 0; } }
h1, h2, h3 { margin: 0; line-height: 1.2; }
h2 { font-size: 1.08rem; font-weight: 700; letter-spacing: -0.01em; display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
h3 { font-size: 0.92rem; margin: 18px 0 8px; color: var(--muted); font-weight: 600; }
.step {
  display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 50%;
  background: var(--accent); color: var(--accent-ink); font-size: 0.85rem; font-weight: 700;
}


.layout {
  display: grid; gap: 16px; padding: 12px 16px 40px; max-width: 1240px; margin: 0 auto;
  grid-template-columns: minmax(0, 1fr);
}
@media (min-width: 980px) {
  .layout { grid-template-columns: minmax(0, 470px) minmax(0, 1fr); align-items: start; }
  .col-result { position: sticky; top: 12px; }
}
.col-inputs { display: grid; gap: 16px; min-width: 0; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 16px; min-width: 0; box-shadow: var(--shadow); }

label { display: grid; gap: 4px; font-size: 0.85rem; color: var(--muted); }
input, select {
  font: inherit; font-size: 16px; /* 16px: evita lo zoom automatico di iOS quando si tocca un campo */ color: var(--ink); background: var(--field);
  border: 1px solid var(--line); border-radius: 9px; padding: 8px 10px; min-width: 0; width: 100%;
}
input:focus-visible, select:focus-visible, button:focus-visible, .btn:focus-within { outline: 2px solid var(--accent); outline-offset: 1px; }

.grid-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 12px; }
.grid-fields .wide { grid-column: 1 / -1; }
.calc { display: grid; gap: 4px; font-size: 0.85rem; color: var(--muted); align-content: start; }
.calc strong { color: var(--ink); font-size: 1rem; padding: 8px 0; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font: inherit; font-weight: 600; cursor: pointer; border-radius: 10px; padding: 9px 14px;
  border: 1px solid var(--line); background: var(--field); color: var(--ink);
}
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; box-shadow: 0 2px 8px rgba(232, 97, 26, 0.28); }
.btn:hover { filter: brightness(0.98); }
.btn:active { transform: translateY(1px); }
.btn.small { padding: 5px 10px; font-size: 0.85rem; margin-top: 6px; }
.btn.ghost { background: transparent; color: var(--muted); }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.actions select { flex: 1 1 160px; width: auto; }

.status { margin-top: 10px; padding: 10px 12px; border-radius: 10px; background: var(--accent-soft); font-size: 0.88rem; }
.status progress { width: 100%; margin-top: 6px; accent-color: var(--accent); }
.warn { margin: 10px 0 0; padding: 8px 12px; border-radius: 10px; background: var(--warn-bg); color: var(--warn); font-size: 0.86rem; }
.hint { color: var(--muted); font-size: 0.82rem; margin: 10px 0 0; }

details summary { cursor: pointer; color: var(--muted); font-size: 0.88rem; margin-top: 10px; }
#preview { display: block; max-width: 100%; margin-top: 8px; border-radius: 8px; border: 1px solid var(--line); }

.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { border-collapse: collapse; width: 100%; font-size: 0.85rem; }
th { text-align: left; font-weight: 600; color: var(--muted); padding: 4px 4px; white-space: nowrap; font-size: 0.78rem; }
td { padding: 2px 3px; }
table.loads { min-width: 430px; }
table.loads input { padding: 5px 4px; text-align: center; min-width: 2.6em; border-radius: 7px; }
table.loads td.num { text-align: right; color: var(--muted); white-space: nowrap; padding-right: 6px; }
table.loads button { border: 0; background: transparent; color: var(--muted); cursor: pointer; font-size: 1.1rem; padding: 2px 6px; }
table.loads tr.flag input { border-color: var(--warn); }

.profile { width: 100%; display: block; background: var(--field); border-radius: 10px; border: 1px solid var(--line); }

.slider { display: grid; gap: 6px; margin-top: 12px; }
.slider label { display: flex; justify-content: space-between; color: var(--ink); font-size: 0.92rem; }
.slider output { font-weight: 700; font-variant-numeric: tabular-nums; }
input[type="range"] { padding: 0; border: 0; background: transparent; accent-color: var(--accent); height: 28px; }

.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; margin-top: 12px; }
.seg button { font: inherit; border: 0; background: var(--field); color: var(--ink); padding: 8px 16px; cursor: pointer; }
.seg button[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); font-weight: 600; }

.result-grid { display: grid; gap: 14px; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 640px) {
  .result-grid { grid-template-columns: auto minmax(0, 1fr); grid-template-areas: "lane nums" "lane more"; grid-template-rows: auto 1fr; align-content: start; column-gap: 18px; }
  .result-nums { grid-area: nums; }
  .lane-wrap { grid-area: lane; }
  .result-more { grid-area: more; align-self: start; }
}
.lane-wrap { justify-self: center; display: grid; justify-items: center; gap: 8px; }
#lane { display: block; cursor: zoom-in; }

/* Pista a schermo intero */
dialog.lane-dialog {
  width: 100%; max-width: 100%; height: 100%; max-height: 100%; margin: 0; border: 0; border-radius: 0;
  padding: calc(8px + env(safe-area-inset-top)) 12px 0; display: none; flex-direction: column; background: var(--bg);
}
dialog.lane-dialog[open] { display: flex; }
dialog.lane-dialog:focus { outline: none; }
.lane-full-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.lane-full-head .seg { margin-top: 0; }
.lane-full-body { flex: 1; min-height: 0; display: grid; place-items: center; overflow: hidden; }
.mini-bar.static { position: static; box-shadow: none; margin: 0 -12px; cursor: default; }

.best { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.best .tile { background: var(--accent-soft); border-radius: 12px; padding: 10px 12px; }
.best .tile span { display: block; font-size: 0.78rem; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.03em; }
.best .tile strong { display: block; font-size: 1.35rem; font-variant-numeric: tabular-nums; }
.best .tile small { color: var(--muted); font-size: 0.78rem; }
.best .msg { grid-column: 1 / -1; color: var(--muted); }
.extra { color: var(--muted); font-size: 0.86rem; margin: 10px 0 0; }

table.lines td, table.lines th { padding: 6px 6px; border-bottom: 1px solid var(--line); font-variant-numeric: tabular-nums; }
table.lines tbody tr { cursor: pointer; }
table.lines tbody tr:hover { background: var(--field); }
table.lines tbody tr[aria-selected="true"] { background: var(--accent-soft); font-weight: 600; }

.toast {
  position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%);
  background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 10px; font-size: 0.9rem;
  max-width: calc(100% - 32px);
}

/* Riepiloghi sempre visibili */
.summary { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.summary-main { display: grid; min-width: 0; }
.summary-main strong { font-size: 1.05rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.meta { color: var(--muted); font-size: 0.85rem; font-weight: 400; }
.badge { flex: none; font-size: 0.78rem; font-weight: 600; padding: 4px 9px; border-radius: 999px; }
.badge.ok { background: var(--ok-bg); color: var(--ok); }
.badge.bad { background: var(--warn-bg); color: var(--warn); }

/* Menu richiudibili */
details.drawer { margin-top: 14px; border-top: 1px solid var(--line); }
details.drawer > summary {
  list-style: none; display: flex; align-items: center; gap: 6px; cursor: pointer;
  padding: 12px 0 2px; margin: 0; color: var(--ink); font-weight: 600; font-size: 0.92rem;
}
details.drawer > summary::-webkit-details-marker { display: none; }
details.drawer > summary::after { content: "▾"; margin-left: auto; color: var(--muted); transition: transform 0.15s; }
details.drawer[open] > summary::after { transform: rotate(180deg); }
.drawer-body { padding-top: 6px; }
details.sub { margin-top: 12px; }
details.sub > summary { font-weight: 600; color: var(--muted); font-size: 0.88rem; margin: 0 0 6px; }

/* Palla scelta */
.ball-pick {
  display: grid; grid-template-columns: 64px minmax(0, 1fr) auto; gap: 12px; align-items: center; width: 100%;
  font: inherit; color: inherit; text-align: left; cursor: pointer;
  background: var(--field); border: 1px solid var(--line); border-radius: 14px; padding: 10px 12px;
}
.ball-pick:hover { border-color: var(--accent); }
.ball-img { display: block; width: 64px; height: 64px; }
.ball-img img, .ball-img svg { width: 100%; height: 100%; object-fit: contain; display: block; }
.ball-info { display: grid; gap: 2px; min-width: 0; }
.ball-info small { color: var(--muted); font-size: 0.8rem; }
.ball-info strong { font-size: 1.05rem; }
.change { color: var(--accent); font-weight: 600; font-size: 0.88rem; }
.chips { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 2px; }
.chip { font-size: 0.74rem; padding: 2px 7px; border-radius: 999px; background: var(--card); border: 1px solid var(--line); color: var(--muted); }

/* Finestra di scelta della palla */
dialog {
  width: min(760px, calc(100% - 24px)); max-height: calc(100% - 24px); padding: 16px;
  border: 1px solid var(--line); border-radius: 16px; background: var(--card); color: var(--ink);
}
dialog::backdrop { background: rgba(0, 0, 0, 0.45); }
.dlg-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.dlg-head h2 { margin: 0; }
.icon-btn { font: inherit; font-size: 1.5rem; line-height: 1; border: 0; background: transparent; color: var(--muted); cursor: pointer; padding: 4px 8px; }
.filter { display: flex; gap: 6px; overflow-x: auto; padding: 8px 0 2px; scrollbar-width: thin; }
.filter button {
  flex: none; font: inherit; font-size: 0.82rem; cursor: pointer; padding: 5px 11px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--field); color: var(--ink);
}
.filter button[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); border-color: transparent; font-weight: 600; }
.ball-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; margin-top: 12px; }
.ball-card {
  display: grid; justify-items: center; gap: 2px; text-align: center; font: inherit; color: inherit; cursor: pointer;
  background: var(--field); border: 1px solid var(--line); border-radius: 14px; padding: 12px 8px;
}
.ball-card:hover, .ball-card[aria-pressed="true"] { border-color: var(--accent); }
.ball-card[aria-pressed="true"] { background: var(--accent-soft); }
.ball-card .ball-img { width: 84px; height: 84px; margin-bottom: 4px; }
.ball-card small { color: var(--muted); font-size: 0.76rem; }
.ball-card strong { font-size: 0.92rem; }
.ball-card .meta { font-size: 0.74rem; }

/* Velocità e giri: barra più pulsanti − / + per regolare a scatti */
.stepper { display: grid; grid-template-columns: 44px minmax(0, 1fr) 44px; gap: 8px; align-items: center; }
.step-btn {
  width: 44px; height: 44px; border-radius: 50%; font: inherit; font-size: 1.4rem; line-height: 1; cursor: pointer;
  border: 1px solid var(--line); background: var(--field); color: var(--ink); touch-action: manipulation;
}
.step-btn:active { background: var(--accent-soft); }

/* Pulsanti visibili solo su touch (fotocamera) o solo con il mouse */
.only-touch { display: none !important; }
@media (pointer: coarse) {
  .only-touch { display: inline-flex !important; }
  .no-touch { display: none !important; }
}

/* Barra fissa con i numeri della linea (solo telefono e tablet) */
.mini-bar {
  position: fixed; left: 0; right: 0; bottom: calc(var(--nav-h) + env(safe-area-inset-bottom)); z-index: 20;
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 4px;
  padding: 8px 12px;
  background: var(--card); color: var(--ink); border: 0; border-top: 1px solid var(--line);
  box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.12); font: inherit; text-align: center; cursor: pointer;
}
.mini-bar span { display: grid; font-size: 0.7rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.03em; font-weight: 600; }
.mini-bar strong { font-size: 1.15rem; color: var(--ink); text-transform: none; letter-spacing: 0; font-variant-numeric: tabular-nums; }
.mini-bar.msg { grid-template-columns: 1fr; font-size: 0.85rem; color: var(--muted); }
@media (min-width: 980px) { .mini-bar:not(.static) { display: none !important; } }
@media (max-width: 979px) { body.has-bar { padding-bottom: calc(var(--nav-h) + 62px + env(safe-area-inset-bottom)); } }

/* Telefono: scelta della palla a schermo intero */
@media (max-width: 640px) {
  dialog { width: 100%; max-width: 100%; height: 100%; max-height: 100%; margin: 0; border: 0; border-radius: 0; padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); }
  .dlg-head { position: sticky; top: -12px; background: var(--card); padding-top: 4px; z-index: 1; }
  .ball-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* Profilo e sezioni */
.top-title { flex: 1; min-width: 0; }
.profile-chip {
  font: inherit; font-weight: 600; font-size: 0.88rem; cursor: pointer; padding: 7px 14px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--card); color: var(--ink); max-width: 40vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.profile-chip.in::before { content: "● "; color: var(--ok); }
body.off-calc .mini-bar { display: none !important; }
.page { max-width: 760px; margin: 0 auto; padding: 12px 16px 40px; display: grid; gap: 16px; }
.page > div { display: grid; gap: 16px; }
.page h2 .meta { margin-left: 4px; }
.back { justify-self: start; }

.banner {
  max-width: 1208px; margin: 10px auto 0; padding: 10px 14px; border-radius: 12px; background: var(--accent-soft);
  display: flex; gap: 12px; align-items: center; justify-content: space-between; font-size: 0.9rem;
}
@media (max-width: 1240px) { .banner { margin: 10px 16px 0; } }

.save-search { margin-top: 12px; width: 100%; }

.list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.item { display: flex; align-items: center; gap: 6px; border: 1px solid var(--line); border-radius: 12px; background: var(--field); }
.item-main {
  flex: 1; min-width: 0; display: grid; gap: 2px; text-align: left; font: inherit; color: inherit; cursor: pointer;
  background: transparent; border: 0; padding: 10px 12px;
}
.item-main .meta { font-size: 0.8rem; }

.people { list-style: none; margin: 10px 0 0; padding: 0; display: grid; gap: 8px; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
.person {
  width: 100%; display: grid; gap: 2px; text-align: left; font: inherit; color: inherit; cursor: pointer;
  background: var(--field); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px;
}
.person:hover, .item-main:hover { color: var(--accent); }

.my-balls { display: grid; gap: 8px; margin-bottom: 12px; }
.my-ball { display: grid; grid-template-columns: 56px minmax(0, 1fr); gap: 4px 10px; align-items: center; border: 1px solid var(--line); border-radius: 12px; padding: 8px 10px; background: var(--field); }
.my-ball .ball-img { width: 56px; height: 56px; }
.my-ball-info { display: grid; gap: 2px; min-width: 0; }
.my-ball-info small { color: var(--muted); font-size: 0.78rem; }
.my-ball-actions { grid-column: 2; display: flex; align-items: center; gap: 6px; }
.my-ball-actions .icon-btn { margin-left: auto; }
label.inline { display: flex; align-items: center; gap: 6px; font-size: 0.8rem; }
label.inline select { width: auto; padding: 4px 6px; font-size: 14px; }

.form { display: grid; gap: 12px; }
textarea { font: inherit; font-size: 16px; color: var(--ink); background: var(--field); border: 1px solid var(--line); border-radius: 9px; padding: 8px 10px; resize: vertical; width: 100%; }
.code-box { margin: 14px 0; padding: 12px; border-radius: 12px; background: var(--field); border: 1px solid var(--line); display: grid; gap: 8px; justify-items: start; }
.code-box code { font-size: 1.15rem; font-weight: 700; letter-spacing: 0.06em; user-select: all; }
#auth-dialog, #search-dialog { max-width: 460px; }

/* Account */
.seg.wide { display: flex; width: 100%; margin: 0 0 14px; }
.seg.wide button { flex: 1; }
.pw { position: relative; display: block; }
.pw input { padding-right: 44px; }
.pw-toggle { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); border: 0; background: transparent; cursor: pointer; font-size: 1rem; padding: 6px 8px; opacity: 0.6; }
.form.highlight { background: var(--accent-soft); padding: 12px; border-radius: 12px; margin-bottom: 14px; }
.logout { margin-top: 16px; }
#auth-body .drawer { margin-top: 10px; }

/* Punteggi */
.stats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-bottom: 10px; }
@media (min-width: 640px) { .stats { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.stat { background: var(--field); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; min-width: 0; }
.stat span { display: block; font-size: 0.74rem; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.03em; }
.stat strong { display: block; font-size: 1.4rem; font-variant-numeric: tabular-nums; }
.stat small { display: block; color: var(--muted); font-size: 0.76rem; }
.chart svg { width: 100%; height: auto; display: block; }
.chart .grid { stroke: var(--line); stroke-width: 1; }
.chart .lbl { fill: var(--muted); font-size: 12px; font-family: system-ui, sans-serif; }
.chart .dot { fill: var(--accent); opacity: 0.75; }
.chart .ma { fill: none; stroke: var(--path); stroke-width: 2.5; }
.chart .bar { fill: var(--accent); opacity: 0.8; }
.legend-line { font-size: 0.78rem; color: var(--muted); display: flex; align-items: center; gap: 6px; margin: 4px 0 0; }
.sw-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--accent); display: inline-block; }
.sw-line { width: 16px; height: 3px; background: var(--path); display: inline-block; margin-left: 8px; }
.day { padding: 10px 0; border-top: 1px solid var(--line); }
.day-head { display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: baseline; }
.day-games { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.game-chip { font: inherit; font-weight: 700; font-variant-numeric: tabular-nums; cursor: pointer; padding: 6px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--field); color: var(--ink); }
.game-chip.good { background: var(--accent-soft); border-color: transparent; }
.game-chip small { font-weight: 400; color: var(--muted); margin-left: 4px; font-size: 0.7rem; }

/* Tabellino */
.sheet { display: grid; grid-template-columns: repeat(9, minmax(0, 1fr)) minmax(0, 1.45fr); border: 1px solid var(--ink); border-radius: 6px; overflow: hidden; margin: 10px 0; background: var(--card); }
.sf { border-left: 1px solid var(--line); min-width: 0; }
.sf:first-child { border-left: 0; }
.sf.cur { background: var(--accent-soft); }
.sf-n { font-size: 0.65rem; color: var(--muted); text-align: center; border-bottom: 1px solid var(--line); }
.sf-m { display: flex; justify-content: flex-end; height: 1.35rem; }
.sf-m span { flex: 0 0 44%; text-align: center; font-size: 0.8rem; font-weight: 700; border-left: 1px solid var(--line); border-bottom: 1px solid var(--line); line-height: 1.35rem; }
.sf.ten .sf-m span { flex-basis: 33.3%; }
.sf-c { text-align: center; font-weight: 700; font-size: 0.92rem; font-variant-numeric: tabular-nums; height: 1.6rem; line-height: 1.6rem; }

/* Inserimento */
dialog.wide-dialog { max-width: 620px; }
.entry { border: 1px solid var(--line); border-radius: 12px; padding: 10px; margin-bottom: 12px; background: var(--field); }
.entry-head { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 6px; align-items: center; margin-bottom: 8px; }
.keypad { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.key { font: inherit; font-size: 1.25rem; font-weight: 700; padding: 12px 0; border-radius: 10px; border: 1px solid var(--line); background: var(--card); color: var(--ink); cursor: pointer; touch-action: manipulation; }
.key.accent { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.key:disabled { opacity: 0.3; cursor: default; }
.deck { display: grid; gap: 8px; justify-items: center; margin: 8px 0; }
.deck > div { display: flex; gap: 10px; }
.pin { width: 46px; height: 46px; border-radius: 50%; font: inherit; font-weight: 700; cursor: pointer; border: 2px solid var(--line); background: var(--card); color: var(--muted); touch-action: manipulation; }
.pin[aria-pressed="true"] { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.pin.off { opacity: 0.15; }
.game-total { font-size: 2.6rem; font-weight: 800; margin: 0; font-variant-numeric: tabular-nums; }
.found { border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; margin: 10px 0; background: var(--field); }
.found-head { display: flex; justify-content: space-between; align-items: baseline; }
.found-total { font-size: 1.6rem; font-weight: 800; }
.photo-prev { max-width: 100%; border-radius: 8px; margin-top: 8px; display: block; }

/* Installazione */
.install { white-space: nowrap; }
@media (max-width: 480px) { .install { padding: 6px 10px; font-size: 0.8rem; } }
.install-body ol, .install-body ul { padding-left: 20px; line-height: 1.6; }
#install-dialog { max-width: 480px; }

/* ---------- Struttura dell'app: barra in alto, navigazione, home ---------- */
.appbar {
  position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 12px;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px; background: var(--brand); color: var(--brand-ink);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.06);
}
.brand { display: flex; align-items: center; gap: 10px; color: inherit; text-decoration: none; font-weight: 800; letter-spacing: -0.02em; font-size: 1.05rem; }
.brand img { border-radius: 8px; }
.appbar-title { font-size: 1.05rem; font-weight: 700; letter-spacing: -0.01em; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.appbar-actions { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.appbar .profile-chip { background: rgba(255, 255, 255, 0.1); border-color: rgba(255, 255, 255, 0.18); color: var(--brand-ink); }
.appbar .install { background: transparent; color: var(--brand-ink); border-color: rgba(255, 255, 255, 0.25); }
/* telefono: in alto il titolo della sezione, il marchio solo nella home */
@media (max-width: 899px) {
  .brand span { display: none; }
  body[data-view="home"] .appbar-title { visibility: hidden; }
  body[data-view="home"] .brand span { display: inline; }
}
@media (min-width: 900px) { .appbar-title { display: none; } }

.topnav { display: none; }
@media (min-width: 900px) {
  .topnav { display: flex; gap: 4px; margin-left: 24px; }
  .topnav a { display: flex; align-items: center; gap: 8px; padding: 8px 14px; border-radius: 10px; color: rgba(255, 255, 255, 0.72); text-decoration: none; font-weight: 600; font-size: 0.92rem; }
  .topnav a svg { width: 18px; height: 18px; }
  .topnav a:hover { color: #fff; background: rgba(255, 255, 255, 0.06); }
  .topnav a[aria-current="page"] { color: #fff; background: rgba(255, 255, 255, 0.12); }
}
.topnav svg, .bottomnav svg, .tile-ic svg, .tile-go svg, .qa svg { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.bottomnav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 25; display: grid; grid-template-columns: repeat(5, 1fr);
  height: calc(var(--nav-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
  background: var(--card); border-top: 1px solid var(--line); box-shadow: 0 -4px 20px rgba(16, 24, 40, 0.06);
}
.bottomnav a { display: grid; place-items: center; align-content: center; gap: 3px; color: var(--muted); text-decoration: none; font-size: 0.7rem; font-weight: 600; }
.bottomnav a svg { width: 24px; height: 24px; }
.bottomnav a[aria-current="page"] { color: var(--accent); }
@media (min-width: 900px) { .bottomnav { display: none; } }

.view.page, .layout { padding-top: 16px; }
.banner { margin-top: 12px; }

/* Home */
.home { padding: 0 0 32px; }
.home .quick, .home .tiles, .home .home-grid { max-width: 1132px; margin-left: auto; margin-right: auto; }
.hero { background: linear-gradient(160deg, var(--brand) 0%, var(--brand-2) 100%); color: var(--brand-ink); padding: 18px 16px 30px; position: relative; overflow: hidden; }
.hero::after { content: ""; position: absolute; right: -60px; top: -40px; width: 260px; height: 260px; border-radius: 50%; background: radial-gradient(circle, rgba(232, 97, 26, 0.35), transparent 70%); }
@media (min-width: 900px) { .hero { padding: 36px 32px 48px; } }
.hero-in { position: relative; z-index: 1; max-width: 1100px; margin: 0 auto; }
.hero-kicker { margin: 0; color: rgba(255, 255, 255, 0.7); font-weight: 500; }
.hero-title { font-size: 1.9rem; font-weight: 800; letter-spacing: -0.03em; margin: 2px 0 6px; color: #fff; display: block; }
.hero-sub { margin: 0; color: rgba(255, 255, 255, 0.78); max-width: 560px; }
.hero-actions { margin-top: 16px; }
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; margin-top: 18px; }
.kpis div { background: rgba(255, 255, 255, 0.08); border: 1px solid rgba(255, 255, 255, 0.12); border-radius: 12px; padding: 10px; }
.kpis span { display: block; font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.05em; color: rgba(255, 255, 255, 0.65); font-weight: 600; }
.kpis strong { display: block; font-size: 1.35rem; font-weight: 800; font-variant-numeric: tabular-nums; color: #fff; }
.quick { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; padding: 0 16px; margin-top: -22px; position: relative; z-index: 2; }
.qa {
  display: flex; align-items: center; gap: 12px; text-align: left; font: inherit; color: var(--ink); cursor: pointer;
  background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 14px; box-shadow: var(--shadow);
}
.qa svg { width: 28px; height: 28px; flex: none; color: var(--accent); }
.qa strong { display: block; font-size: 0.95rem; }
.qa small { display: block; color: var(--muted); font-size: 0.78rem; }
@media (max-width: 420px) { .qa { flex-direction: column; align-items: flex-start; gap: 8px; } }
.tiles { display: grid; grid-template-columns: 1fr; gap: 10px; padding: 0 16px; margin-top: 16px; }
@media (min-width: 640px) { .tiles { grid-template-columns: 1fr 1fr; } }
@media (min-width: 1000px) { .tiles { grid-template-columns: repeat(4, 1fr); } }
.tile-nav {
  display: flex; align-items: center; gap: 14px; text-align: left; font: inherit; color: var(--ink); cursor: pointer;
  background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 16px; box-shadow: var(--shadow);
  transition: transform 0.12s, border-color 0.12s;
}
.tile-nav:hover { border-color: var(--accent); transform: translateY(-1px); }
.tile-ic { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); flex: none; }
.tile-ic svg { width: 24px; height: 24px; }
.tile-tx { flex: 1; min-width: 0; }
.tile-tx strong { display: block; font-size: 1rem; }
.tile-tx small { display: block; color: var(--muted); font-size: 0.82rem; }
.tile-go { color: var(--muted); }
.tile-go svg { width: 18px; height: 18px; }
.home-grid { display: grid; gap: 12px; padding: 0 16px; margin-top: 16px; }
@media (min-width: 900px) { .home-grid { grid-template-columns: repeat(2, 1fr); } }
.card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.card-head h3 { margin: 0; color: var(--ink); font-size: 1rem; }
.link { font: inherit; font-weight: 600; color: var(--accent); background: none; border: 0; cursor: pointer; padding: 4px; }
.mini-kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; margin-top: 10px; }
.mini-kpis div { background: var(--accent-soft); border-radius: 10px; padding: 8px; text-align: center; }
.mini-kpis span { display: block; font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); font-weight: 600; }
.mini-kpis strong { display: block; font-size: 1.3rem; font-weight: 800; font-variant-numeric: tabular-nums; }

/* Classifiche */
.lb .filter { padding-top: 6px; }
.lb .filter button:disabled { opacity: 0.4; cursor: default; }
.lb-me { margin: 6px 0 0; padding: 8px 12px; border-radius: 10px; background: var(--accent-soft); font-size: 0.92rem; }
.podium { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-top: 12px; align-items: end; }
.pod {
  display: grid; justify-items: center; gap: 2px; font: inherit; color: var(--ink); cursor: pointer; text-align: center;
  background: var(--field); border: 1px solid var(--line); border-radius: 14px; padding: 12px 6px; min-width: 0;
}
.pod strong { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 0.92rem; }
.pod-pos { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; font-weight: 800; color: #fff; }
.pod-val { font-size: 1.35rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.pod small { color: var(--muted); font-size: 0.72rem; }
.pod.gold { order: 2; padding-top: 18px; padding-bottom: 18px; border-color: #e7b416; }
.pod.silver { order: 1; }
.pod.bronze { order: 3; }
.pod.gold .pod-pos, .lb-pos.m1 { background: #d4a20f; color: #fff; }
.pod.silver .pod-pos, .lb-pos.m2 { background: #8f99a8; color: #fff; }
.pod.bronze .pod-pos, .lb-pos.m3 { background: #b9733f; color: #fff; }
.pod.me, .lb-row.me { box-shadow: inset 0 0 0 2px var(--accent); }
.lb-list { list-style: none; margin: 12px 0 0; padding: 0; display: grid; gap: 6px; }
.lb-list.compact { margin-top: 8px; }
.lb-row {
  width: 100%; display: flex; align-items: center; gap: 12px; font: inherit; color: var(--ink); cursor: pointer; text-align: left;
  background: var(--field); border: 1px solid var(--line); border-radius: 12px; padding: 9px 12px;
}
.lb-pos { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; background: var(--card); border: 1px solid var(--line); flex: none; font-variant-numeric: tabular-nums; }
.lb-name { flex: 1; min-width: 0; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb-name small { display: block; color: var(--muted); font-weight: 400; font-size: 0.75rem; }
.lb-val { font-weight: 800; font-variant-numeric: tabular-nums; font-size: 1.1rem; }
