/* Mobile-only UI (iOS Safari + Android Chrome). Tokens first, then components. */
:root {
  --bg: #f6f2ea;
  --surface: #ffffff;
  --text: #1c1915;
  --muted: #736a5e;
  --line: #e6ddcd;
  --accent: #d9480f;
  --accent-ink: #ffffff;
  --accent-soft: #fde8db;
  --gold: #e8a317;
  --ok: #2b8a3e;
  --ok-soft: #dcf3e1;
  --warn-soft: #fff1c9;
  --err: #c92a2a;
  --err-soft: #fde2e2;
  --radius: 14px;
  --tabbar-h: 64px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12100d;
    --surface: #1e1a16;
    --text: #f3ede4;
    --muted: #a59a8b;
    --line: #342d25;
    --accent: #ff7a3d;
    --accent-ink: #1a0f08;
    --accent-soft: #3a2416;
    --gold: #f2b84b;
    --ok: #69db7c;
    --ok-soft: #1b3221;
    --warn-soft: #382e15;
    --err: #ff8787;
    --err-soft: #3a1c1c;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  padding-bottom: calc(var(--tabbar-h) + var(--safe-bottom) + 16px);
}
a { color: var(--accent); }
h1, h2, h3 { line-height: 1.2; margin: 1.1em 0 .45em; }
h1 { font-size: 1.55rem; letter-spacing: -.01em; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; }
p { margin: .5em 0; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }

/* --- Top bar & bottom tab bar --- */
header.top {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: calc(env(safe-area-inset-top, 0px) + 10px) 16px 10px;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}
header.top .brand { font-weight: 800; color: var(--text); text-decoration: none; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.regia .row .btn { flex-shrink: 0; }
.ref-card { background: var(--surface); border: 2px solid var(--line); border-radius: var(--radius); padding: 16px; margin: 12px 0; display: grid; gap: 10px; }
.ref-card.running { border-color: var(--accent); }
.ref-meta { font-size: .85rem; font-weight: 800; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.ref-teams { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 8px; text-align: center; }
.ref-teams strong { display: block; font-size: 1.35rem; line-height: 1.15; overflow-wrap: anywhere; }
.ref-score { display: block; font-size: 2.2rem; font-weight: 900; color: var(--accent); }
.ref-go, a.ref-end { display: flex; align-items: center; justify-content: center; width: 100%; min-height: 72px; border-radius: 16px; font-size: 1.35rem; font-weight: 900; text-decoration: none; }
.ref-go { background: var(--ok); color: #fff; border: 0; }
a.ref-end { background: var(--accent); color: var(--accent-ink); }
.ref-clock { text-align: center; }
.ref-clock-time { display: block; font: 900 3.4rem/1 ui-monospace, Menlo, monospace; }
.ref-clock-label { color: var(--muted); font-size: .85rem; font-weight: 700; }
.ref-clock.over .ref-clock-time { color: var(--err); }
.ref-top strong { font-size: 1.05rem; }
.cd { font-weight: 700; color: var(--accent); white-space: nowrap; }
.cd-under { display: block; font-size: .7rem; font-weight: 600; }
.cd-under .cd { color: var(--muted); }
main.ref-busy { opacity: .6; pointer-events: none; }
.toast.err { background: var(--err); color: #fff; }
.ref-q { text-align: center; margin: 4px 0; font-size: 1.05rem; }
.ref-picks { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.ref-pick input { position: absolute; opacity: 0; pointer-events: none; }
.ref-pick span { display: flex; align-items: center; justify-content: center; min-height: 56px; padding: 6px; border-radius: 14px; border: 2px solid var(--line); font-weight: 800; text-align: center; cursor: pointer; }
.ref-pick input:checked + span { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.ref-pick.shot span { color: var(--muted); }
.ref-board { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.ref-team { border: 2px solid var(--line); border-radius: 14px; padding: 8px; text-align: center; }
.ref-team.turn { border-color: var(--accent); background: var(--accent-soft); }
.ref-team strong { display: block; overflow-wrap: anywhere; }
.ref-player { font-size: .82rem; color: var(--muted); }
.ref-player b { color: var(--text); }
.ref-shot .rack.big { margin: 8px 0; }
.ref-shot .rack.big .cup { width: 60px; height: 60px; font-size: 1.2rem; flex-direction: column; line-height: 1; }
.ref-shot .cup.down small { font-size: .65rem; font-weight: 800; color: var(--accent); }
.ref-rack-title { text-align: center; margin: 10px 0 0; }
button.ref-miss { width: 100%; min-height: 60px; font-size: 1.2rem; background: var(--err); color: #fff; }
.ref-tools { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; align-items: center; }
.ref-clock .ref-clock-time { font-size: 2.4rem; }
.queue .row .when, .regia .when { font-weight: 800; min-width: 3.2em; }
.ko-preview .teams a, .tabellone .teams a, .teams .t a { color: inherit; text-decoration: none; }
.demo-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; padding: 6px 16px; background: var(--accent); color: var(--accent-ink); font-size: .82rem; }
.demo-bar span { flex: 1 1 auto; min-width: 0; }
.demo-bar .demo-help { min-width: 32px; font-weight: 900; }
.demo-guide { position: fixed; inset: 0; z-index: 50; background: rgba(0, 0, 0, .55); display: grid; place-items: end center; padding: 16px; }
.demo-guide[hidden] { display: none; }
.demo-guide-card { background: var(--surface); color: var(--text); border-radius: 20px; padding: 18px; width: min(100%, 520px); display: grid; gap: 10px; max-height: 90vh; overflow: auto; }
.demo-role button { width: 100%; display: grid; gap: 4px; text-align: left; justify-items: start; padding: 14px; background: var(--bg); color: var(--text); border: 2px solid var(--line); border-radius: 16px; }
.demo-role button strong { font-size: 1.1rem; }
.demo-role button span { font-weight: 500; color: var(--muted); font-size: .9rem; }
.demo-tip { display: flex; gap: 8px; align-items: flex-start; margin: 8px 16px 0; padding: 10px 12px; border-radius: 14px; background: var(--warn-soft); border: 1px solid var(--gold); font-size: .9rem; }
.demo-tip[hidden] { display: none; }
.demo-tip span { flex: 1; }
@media (max-width: 480px) { .demo-bar .long { display: none; } }
.demo-bar button.small { min-height: 32px; padding: 4px 10px; background: var(--accent-ink); color: var(--accent); }
.demo-bar button.small.ghost { background: transparent; color: var(--accent-ink); border-color: var(--accent-ink); }
header.top .staff { font-size: .85rem; font-weight: 700; color: var(--muted); text-decoration: none; padding: 6px 10px; border: 1px solid var(--line); border-radius: 999px; }
.own-actions { margin-top: 22px; text-align: center; display: grid; gap: 10px; }
header.top .me {
  flex: none; max-width: 48%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-size: .85rem; font-weight: 700; text-decoration: none;
  padding: 6px 12px; border-radius: 999px; background: var(--accent-soft); color: var(--accent);
}

nav.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  display: grid; grid-auto-flow: column; grid-auto-columns: 1fr;
  height: calc(var(--tabbar-h) + var(--safe-bottom)); padding-bottom: var(--safe-bottom);
  background: var(--surface); border-top: 1px solid var(--line);
}
nav.tabbar a {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  color: var(--muted); text-decoration: none; font-size: .7rem; font-weight: 600;
}
nav.tabbar svg { width: 24px; height: 24px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
nav.tabbar a.on { color: var(--accent); }

main { padding: 4px 16px 24px; max-width: 560px; margin: 0 auto; }
.foot { text-align: center; margin: 32px 0 8px; font-size: .85rem; }
.foot form { display: inline; }

/* --- Feedback --- */
.flash { padding: 12px 14px; border-radius: var(--radius); margin: 12px 0; background: var(--ok-soft); font-weight: 600; }
.flash.err { background: var(--err-soft); color: var(--err); }
.banner {
  display: block; margin: 12px 0; padding: 16px; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--line); color: var(--text); text-decoration: none;
}
.banner.hot { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); animation: pulse 1.6s ease-in-out infinite; }
.banner.warm { background: var(--warn-soft); border-color: var(--gold); }
.banner.gold { background: var(--gold); border-color: var(--gold); color: #1c1915; font-weight: 700; }
.banner.todo { background: var(--accent-soft); border-color: var(--accent); font-weight: 600; }
.banner .label { font-size: .78rem; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; opacity: .85; }
.banner .headline { font-size: 1.45rem; font-weight: 800; line-height: 1.2; margin: 2px 0; }
@keyframes pulse { 50% { filter: brightness(1.1); } }
@media (prefers-reduced-motion: reduce) { .banner.hot { animation: none; } }

.pill { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: .78rem; font-weight: 700; background: var(--line); color: var(--text); white-space: nowrap; }
.pill.ok { background: var(--ok-soft); color: var(--ok); }
.pill.warn { background: var(--warn-soft); }
.pill.accent { background: var(--accent-soft); color: var(--accent); }

/* --- Cards & lists --- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin: 10px 0; }
.big { font-size: 1.9rem; font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1.1; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); text-align: center; gap: 8px; }

.list { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; margin: 10px 0; }
.list > .row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  min-height: 56px; padding: 10px 14px; border-top: 1px solid var(--line); color: var(--text); text-decoration: none;
}
.list > .row:first-child { border-top: 0; }
.list .grow { flex: 1; min-width: 0; }
.list .title { font-weight: 700; overflow-wrap: break-word; }
.list .chev { color: var(--muted); font-size: 1.3rem; }
.list .row form { display: flex; gap: 6px; }
.checks { display: flex; gap: 6px; flex-shrink: 0; }
button.check { min-height: 40px; padding: 6px 10px; font-size: .85rem; background: transparent; color: var(--muted); border: 1px solid var(--line); }
button.check::before { content: "○"; }
button.check.on { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
button.check.on::before { content: "✓"; }

.progress { height: 10px; border-radius: 999px; background: var(--line); overflow: hidden; margin-top: 12px; }
.progress > span { display: block; height: 100%; background: var(--accent); border-radius: inherit; }

/* --- Matches --- */
.match { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; margin: 8px 0; }
.match.mine { border-color: var(--accent); box-shadow: inset 4px 0 var(--accent); }
.match .meta { color: var(--muted); font-size: .8rem; display: flex; justify-content: space-between; gap: 8px; }
.match .teams { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 8px; margin-top: 4px; }
.match .t { font-weight: 700; overflow-wrap: break-word; min-width: 0; color: var(--text); text-decoration: none; }
.match .t.r { text-align: right; }
.match .t.win { color: var(--ok); }
.match .sc { font-variant-numeric: tabular-nums; font-weight: 800; font-size: 1.15rem; min-width: 3.2em; text-align: center; }
.match .sc.vs { color: var(--muted); font-weight: 500; font-size: .9rem; }
.match .splits { display: flex; justify-content: space-between; font-size: .8rem; color: var(--muted); }
.match .actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; margin-top: 10px; }
.slot-head { display: flex; align-items: baseline; gap: 8px; margin: 18px 0 2px; font-weight: 800; }

/* --- Tournament progress, groups, bracket --- */
.steps { display: flex; gap: 0; overflow-x: auto; margin: 10px -16px 6px; padding: 4px 16px 8px; scrollbar-width: none; }
.step { flex: 1 0 auto; min-width: 74px; display: grid; justify-items: center; gap: 2px; position: relative; text-align: center; }
.step::before { content: ""; position: absolute; top: 14px; left: -50%; width: 100%; height: 3px; background: var(--line); z-index: 0; }
.step:first-child::before { display: none; }
.step.done::before, .step.now::before { background: var(--accent); }
.step .dot {
  position: relative; z-index: 1; width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center;
  font-size: .8rem; font-weight: 800; background: var(--surface); border: 3px solid var(--line); color: var(--muted);
}
.step.done .dot { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.step.now .dot { border-color: var(--accent); color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.step .lbl { font-size: .72rem; font-weight: 700; white-space: nowrap; }
.step .cnt { font-size: .68rem; color: var(--muted); font-variant-numeric: tabular-nums; }

.jump { display: flex; gap: 6px; overflow-x: auto; margin: 6px 0 10px; scrollbar-width: none; }
.jump a {
  flex: none; min-width: 40px; height: 36px; padding: 0 12px; border-radius: 999px; display: grid; place-items: center;
  background: var(--surface); border: 1px solid var(--line); color: var(--text); text-decoration: none; font-weight: 800; font-size: .88rem;
}
.anchor { scroll-margin-top: 70px; }

.group { margin: 18px 0; }
.group-head { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.group-head h2 { margin: 0; flex: 1; }
.group-head .badge {
  width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center;
  background: var(--accent); color: var(--accent-ink); font-weight: 900;
}
details.results { margin-top: 6px; }
details.results > summary { padding: 10px 2px; font-weight: 700; color: var(--accent); font-size: .92rem; cursor: pointer; }
.mini {
  display: grid; grid-template-columns: 1fr auto 1fr; gap: 8px; align-items: center;
  padding: 10px 12px; border-bottom: 1px solid var(--line); color: var(--text); text-decoration: none; font-size: .92rem; background: var(--surface);
}
.mini:first-of-type { border-top-left-radius: 10px; border-top-right-radius: 10px; }
.mini:last-child { border-bottom: 0; border-bottom-left-radius: 10px; border-bottom-right-radius: 10px; }
.mini .r { text-align: right; }
.mini .win { color: var(--ok); font-weight: 700; }
.mini.mine { background: var(--accent-soft); }
.match .origin { display: block; font-size: .72rem; font-weight: 700; color: var(--muted); }
.ghost-match { border-style: dashed; background: transparent; }

/* --- Tables --- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; border-radius: var(--radius); border: 1px solid var(--line); }
table { width: 100%; border-collapse: collapse; background: var(--surface); font-variant-numeric: tabular-nums; font-size: .92rem; }
th, td { padding: 9px 6px; text-align: right; border-bottom: 1px solid var(--line); white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
th { font-size: .72rem; color: var(--muted); font-weight: 700; text-transform: uppercase; }
td.name, th.name { text-align: left; white-space: normal; padding-left: 12px; }
td.name a { color: var(--text); text-decoration: none; font-weight: 700; }
tr.q td:first-child { box-shadow: inset 4px 0 var(--ok); }
tr.q3 td:first-child { box-shadow: inset 4px 0 var(--gold); }
tr.mine td { background: var(--accent-soft); }

/* --- Controls (44px+ touch targets, 16px+ inputs so iOS does not zoom) --- */
label { display: block; font-size: .85rem; color: var(--muted); font-weight: 600; margin: 12px 0 4px; }
input, select, textarea {
  width: 100%; font: inherit; font-size: 16px; color: var(--text); background: var(--surface);
  border: 1px solid var(--line); border-radius: 10px; padding: 12px; min-height: 48px; -webkit-appearance: none; appearance: none;
}
textarea { min-height: 140px; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
button, .btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 44px; padding: 10px 16px; border: 0; border-radius: 10px; cursor: pointer;
  font: inherit; font-weight: 700; text-decoration: none; background: var(--accent); color: var(--accent-ink);
}
button.wide, .btn.wide { width: 100%; min-height: 54px; font-size: 1.08rem; margin-top: 16px; }
button.ghost, .btn.ghost { background: transparent; color: var(--accent); border: 1px solid var(--line); }
button.danger { background: var(--err); color: #fff; }
button.link { background: none; border: 0; padding: 0; min-height: 0; color: var(--accent); font-weight: 600; text-decoration: underline; }
button.small, .btn.small { min-height: 38px; padding: 6px 12px; font-size: .88rem; }

.choices { display: grid; gap: 8px; margin-top: 6px; }
.choices label {
  display: flex; align-items: center; gap: 12px; margin: 0; padding: 14px; min-height: 52px;
  border: 1px solid var(--line); border-radius: 12px; background: var(--surface); color: var(--text); font-size: 1rem; font-weight: 600;
}
.choices input { width: 22px; height: 22px; min-height: 0; padding: 0; flex: none; -webkit-appearance: radio; appearance: radio; accent-color: var(--accent); }
.choices input[type=checkbox] { -webkit-appearance: checkbox; appearance: checkbox; }
.choices label:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }

.stepper { display: grid; grid-template-columns: 64px 1fr 64px; gap: 8px; margin: 6px 0 4px; }
.stepper button { font-size: 1.7rem; min-height: 64px; padding: 0; }
.stepper input { font-size: 2rem; font-weight: 800; text-align: center; min-height: 64px; -moz-appearance: textfield; }
.stepper input::-webkit-inner-spin-button, .stepper input::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.total { font-size: 2rem; font-weight: 800; text-align: center; font-variant-numeric: tabular-nums; }

table.ranked:not(.all) tr.beyond { display: none; }
table.ranked:not(.all) tr.gap td { border-top: 3px dotted var(--muted); }
table.ranked tr.mine td { background: var(--accent-soft); font-weight: 700; }
.show-all { display: block; margin: 8px auto 0; }
.my-rank { display: block; text-decoration: none; color: var(--text); background: var(--accent-soft); border-color: var(--accent); }
.my-rank .label { font-weight: 800; text-transform: uppercase; letter-spacing: .05em; }
.my-rank-row { display: flex; flex-wrap: wrap; gap: 6px 18px; margin-top: 6px; }
.my-rank-row .big { font-size: 1.5rem; font-weight: 900; }
table.compact td.name { white-space: normal; }
.presence-head { display: flex; gap: 14px; align-items: center; }
.presence-head .big { font-size: 2rem; font-weight: 900; }
.presence-group { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 4px; }
.list > .row.mine { background: var(--accent-soft); }
.table-queue .row .when { font-weight: 800; min-width: 3.2em; }
.segmented { display: flex; border: 1px solid var(--line); border-radius: 12px; padding: 3px; margin: 8px 0 12px; background: var(--surface); }
.segmented a { flex: 1; text-align: center; padding: 9px 4px; border-radius: 9px; text-decoration: none; color: var(--muted); font-weight: 700; font-size: .92rem; }
.segmented a.on { background: var(--accent); color: var(--accent-ink); }

details.section { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); margin: 10px 0; }
details.section > summary { list-style: none; padding: 16px; font-weight: 800; font-size: 1.05rem; display: flex; justify-content: space-between; align-items: center; gap: 8px; cursor: pointer; }
details.section > summary::-webkit-details-marker { display: none; }
details.section > summary::after { content: "›"; color: var(--muted); font-size: 1.4rem; transition: transform .15s; }
details.section[open] > summary::after { transform: rotate(90deg); }
details.section > .body { padding: 0 16px 16px; }
details.section .list { margin: 8px 0; }
details.section .search { top: 104px; }
details.section summary .pill { margin-left: auto; }

.subnav { position: sticky; top: 56px; z-index: 6; display: flex; gap: 6px; overflow-x: auto; padding: 8px 0; background: var(--bg); scrollbar-width: none; }
.subnav a { flex-shrink: 0; padding: 6px 12px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); color: var(--text); font-size: .88rem; font-weight: 700; text-decoration: none; }
.summary { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin: 6px 0; }
.summary .tile { background: var(--warn-soft); border-radius: var(--radius); padding: 10px 4px; text-align: center; color: var(--text); text-decoration: none; }
.summary .tile.ok { background: var(--ok-soft); }
.summary .tile .big { font-size: 1.3rem; font-weight: 800; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
button.chip { min-height: 36px; padding: 4px 12px; font-size: .85rem; background: var(--surface); color: var(--text); border: 1px solid var(--line); border-radius: 999px; }
button.chip[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
details.section { scroll-margin-top: 104px; }
#all-teams > .empty-filter { display: none; }
#all-teams[data-show]:not([data-show=""]):not(:has(> .row[data-f]:not([hidden]))) > .empty-filter { display: flex; }
#all-teams[data-show="nonpagate"] > .row:not([data-f~="nonpagate"]) { display: none; }
#all-teams[data-show="fuorigruppo"] > .row:not([data-f~="fuorigruppo"]) { display: none; }
#all-teams[data-show="senzatelefono"] > .row:not([data-f~="senzatelefono"]) { display: none; }
#all-teams[data-show="dacompletare"] > .row:not([data-f~="dacompletare"]) { display: none; }
#all-teams[data-show="dasistemare"] > .row:not([data-f~="dasistemare"]) { display: none; }
.search { position: sticky; top: 56px; z-index: 5; padding: 8px 0; background: var(--bg); }

.qr-sheet { text-align: center; }
.qr-sheet img { width: min(80vw, 420px); background: #fff; padding: 12px; border-radius: var(--radius); }
.url { word-break: break-all; font-size: .85rem; }

@media print {
  header.top, nav.tabbar, .foot, .no-print { display: none; }
  body { background: #fff; color: #000; padding: 0; }
}

/* --- Live arena --- */
:root { --t1: #2f6fed; --t1-soft: #e3ecfd; --t2: #e03131; --t2-soft: #fde4e4; --beer: #f2b84b; }
@media (prefers-color-scheme: dark) { :root { --t1: #6c9dff; --t1-soft: #1a2640; --t2: #ff6b6b; --t2-soft: #3a1c1c; } }
.arena { background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: 14px; margin: 8px 0 16px; }
.vs { display: grid; grid-template-columns: 1fr auto 1fr; gap: 8px; align-items: start; }
.vs .side { min-width: 0; }
.vs .s2 { text-align: right; }
.vs .tname { font-weight: 900; font-size: 1.1rem; line-height: 1.15; overflow-wrap: break-word; }
.vs .s1 .tname { color: var(--t1); }
.vs .s2 .tname { color: var(--t2); }
.vs .tmeta { font-size: .72rem; color: var(--muted); margin-top: 4px; line-height: 1.35; }
.clockbox { text-align: center; padding: 0 4px; }
.clock { font: 900 2rem/1 ui-monospace, SFMono-Regular, Menlo, monospace; font-variant-numeric: tabular-nums; }
.clock.hot { color: var(--err); animation: pulse 1s ease-in-out infinite; }
.clock-sub { font-size: .7rem; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.odds { display: flex; height: 10px; border-radius: 999px; overflow: hidden; margin: 14px 0 4px; background: var(--line); }
.odds .o1 { background: var(--t1); transition: width .6s; }
.odds .o2 { background: var(--t2); transition: width .6s; }
.odds-labels { display: flex; justify-content: space-between; font-weight: 800; font-size: .85rem; }
.odds-labels span:first-child { color: var(--t1); }
.odds-labels span:last-child { color: var(--t2); }
.racks { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 14px; }
.rack-title { font-size: .72rem; color: var(--muted); text-align: center; margin-bottom: 6px; }
.dot1, .dot2 { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--t1); }
.dot2 { background: var(--t2); }
.rack { display: grid; gap: 4px; justify-items: center; }
.rrow { display: flex; gap: 4px; }
.cup {
  width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; font-size: .7rem; font-weight: 800;
  border: 2px solid var(--beer); color: #5c3b00; padding: 0; min-height: 0;
}
.cup.up { background: radial-gradient(circle at 35% 35%, #ffe08a, var(--beer)); }
.cup.down { background: transparent; border-style: dashed; border-color: var(--line); color: var(--muted); opacity: .6; }
.rack.big .cup { width: 54px; height: 54px; font-size: 1.1rem; }
.rack.big { gap: 8px; margin: 16px 0; }
.rack.big .rrow { gap: 8px; }
.shooters { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.shooters .col { display: grid; gap: 8px; }
.shooter {
  display: flex; justify-content: space-between; align-items: center; width: 100%; min-height: 54px;
  color: #fff; font-weight: 800; padding: 10px 12px; border-radius: 12px;
}
.shooters .s1 .shooter { background: var(--t1); }
.shooters .s2 .shooter { background: var(--t2); }
.shooter small { font-weight: 700; opacity: .85; font-variant-numeric: tabular-nums; }
.sheet { position: fixed; inset: 0; z-index: 30; background: rgba(0, 0, 0, .45); display: flex; align-items: flex-end; }
.sheet[hidden] { display: none; }
.sheet-card {
  width: 100%; background: var(--surface); border-radius: 20px 20px 0 0; padding: 18px 16px calc(18px + var(--safe-bottom));
  box-shadow: 0 -10px 30px rgba(0, 0, 0, .2);
}
.sheet-title { text-align: center; font-size: 1.05rem; }
.sheet-actions { display: grid; gap: 8px; }
.sheet-actions .wide { margin-top: 0; }
.toast {
  position: fixed; left: 16px; right: 16px; bottom: calc(var(--tabbar-h) + var(--safe-bottom) + 12px); z-index: 25;
  background: var(--text); color: var(--bg); padding: 12px 14px; border-radius: 12px; font-weight: 700;
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
}
.toast[hidden] { display: none; }
.toast .link { color: var(--beer); }
.feed { display: grid; gap: 6px; }
.fitem { display: grid; grid-template-columns: auto 1fr auto; gap: 8px; align-items: center; background: var(--surface);
  border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; font-size: .88rem; }
.fitem.s1 { box-shadow: inset 4px 0 var(--t1); }
.fitem.s2 { box-shadow: inset 4px 0 var(--t2); }
.ftime { font-family: ui-monospace, monospace; color: var(--muted); font-size: .78rem; }
.fvotes { font-size: .75rem; color: var(--muted); }
.live-pill { display: inline-block; padding: 1px 8px; border-radius: 999px; background: var(--err); color: #fff; font-weight: 800; font-size: .7rem; text-decoration: none; margin-left: 6px; }
.live-pill.past { background: var(--line); color: var(--text); }
.awards { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 8px; }
.award { text-align: center; margin: 0; }
.award .aicon { font-size: 1.8rem; }
.rack.heat { margin: 8px 0; }
.rack.heat .cup { width: 44px; height: 44px; font-size: .9rem; }
.pills { display: flex; flex-wrap: wrap; gap: 4px; margin: 4px 0 2px; }

/* --- Public board (TV / projector / poster) --- */
body.board { padding: 0; background: #14110e; color: #f6efe4; --surface: #211c17; --line: #3a3128; --muted: #b3a593; }
body.board main { max-width: none; padding: 20px clamp(16px, 3vw, 48px) 40px; }
.board-top { display: grid; grid-template-columns: 1fr auto auto; gap: 24px; align-items: center; }
.board-title { font-size: clamp(1.6rem, 3.2vw, 3rem); font-weight: 900; letter-spacing: -.02em; }
.board-sub { color: var(--muted); font-size: clamp(.95rem, 1.4vw, 1.3rem); margin-top: 4px; }
.board-clock { font: 900 clamp(1.6rem, 3vw, 2.8rem)/1 ui-monospace, Menlo, monospace; color: var(--beer); }
.board-qr { display: grid; justify-items: center; gap: 4px; font-size: .75rem; color: var(--muted); }
.board-qr img { width: clamp(70px, 8vw, 120px); background: #fff; padding: 6px; border-radius: 10px; }
.board-steps .steps { margin: 18px 0 8px; }
body.board .step .dot { background: var(--surface); }
body.board .step.done .dot { background: var(--accent); }
.board-h { font-size: clamp(1.1rem, 1.8vw, 1.6rem); font-weight: 900; margin: 28px 0 12px; display: flex; gap: 12px; align-items: baseline; flex-wrap: wrap; }
.board-h .hint { font-size: .8em; font-weight: 600; color: var(--muted); }
.board-tables { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr)); gap: 16px; align-items: start; }
.tcolumn { display: grid; gap: 10px; }
.thead { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; padding: 8px 14px; border-radius: 14px; background: var(--beer); color: #1c1915; }
.thead .tnum { font-size: clamp(1.2rem, 1.7vw, 1.8rem); font-weight: 900; }
.thead .tgroups { font-weight: 800; font-size: clamp(.9rem, 1vw, 1.1rem); }
.tnow, .tnext { border-radius: 12px; padding: 8px 12px; font-size: clamp(1rem, 1.15vw, 1.3rem); line-height: 1.25; }
.tnow { background: var(--accent); color: #fff; }
.tnext { background: var(--surface); border: 1px solid var(--line); }
.tnow .lbl, .tnext .lbl { display: block; font-size: .7em; font-weight: 900; text-transform: uppercase; letter-spacing: .08em; opacity: .8; }
.tnow .versus, .tnext .versus { opacity: .7; font-weight: 400; }
.tnow .pair, .tnext .pair { display: block; }
.table-tabs { display: none; }
@media (max-width: 899px) {
  .table-tabs { display: flex; gap: 6px; position: sticky; top: 0; z-index: 5; padding: 8px 0; margin-bottom: 4px; background: #14110e; overflow-x: auto; scrollbar-width: none; }
  .table-tabs button { flex: 1 1 0; min-width: 0; display: grid; gap: 0; min-height: 48px; padding: 6px 4px; border-radius: 12px; background: var(--surface); color: #f6efe4; border: 1px solid var(--line); font-weight: 900; }
  .tcolumn .thead { display: none; }
  .table-tabs button small { font-size: .7rem; font-weight: 700; opacity: .75; }
  body.board[data-table="1"] .tcolumn:not([data-table="1"]) { display: none; }
  body.board[data-table="1"] .table-tabs [data-table="1"] { background: var(--beer); color: #1c1915; border-color: var(--beer); }
  body.board[data-table="2"] .tcolumn:not([data-table="2"]) { display: none; }
  body.board[data-table="2"] .table-tabs [data-table="2"] { background: var(--beer); color: #1c1915; border-color: var(--beer); }
  body.board[data-table="3"] .tcolumn:not([data-table="3"]) { display: none; }
  body.board[data-table="3"] .table-tabs [data-table="3"] { background: var(--beer); color: #1c1915; border-color: var(--beer); }
  body.board[data-table="4"] .tcolumn:not([data-table="4"]) { display: none; }
  body.board[data-table="4"] .table-tabs [data-table="4"] { background: var(--beer); color: #1c1915; border-color: var(--beer); }
  body.board[data-table="5"] .tcolumn:not([data-table="5"]) { display: none; }
  body.board[data-table="5"] .table-tabs [data-table="5"] { background: var(--beer); color: #1c1915; border-color: var(--beer); }
  body.board[data-table="6"] .tcolumn:not([data-table="6"]) { display: none; }
  body.board[data-table="6"] .table-tabs [data-table="6"] { background: var(--beer); color: #1c1915; border-color: var(--beer); }
  body.board[data-table="7"] .tcolumn:not([data-table="7"]) { display: none; }
  body.board[data-table="7"] .table-tabs [data-table="7"] { background: var(--beer); color: #1c1915; border-color: var(--beer); }
  body.board[data-table="8"] .tcolumn:not([data-table="8"]) { display: none; }
  body.board[data-table="8"] .table-tabs [data-table="8"] { background: var(--beer); color: #1c1915; border-color: var(--beer); }
  body.board main { padding: 12px 16px 32px; }
  .board-qr { display: none; }
  .board-top { grid-template-columns: 1fr; }
  .board-steps .steps { margin: 10px -16px 4px; }
  .board-h { margin: 16px 0 8px; }
}
.board-link { display: inline-block; margin-top: 10px; padding: 8px 14px; border-radius: 12px; background: var(--surface); border: 1px solid var(--line); color: var(--beer); font-weight: 800; text-decoration: none; }
.board-format { margin-top: 20px; color: var(--muted); font-size: clamp(1rem, 1.3vw, 1.4rem); font-weight: 700; }
body.board .gcard .grow .n { color: #fff; }
body.board .gcard .grow.plain:not(.here) .n { color: var(--muted); }
body.board .gcard .grow.plain .tick { color: #69db7c; }
body.board .gcard .grow.plain { padding: 7px 4px; }
body.board .gcard .grow.plain .n { font-size: clamp(1.05rem, 1.25vw, 1.45rem); }
body.board .gcard .grow.plain .pl { font-size: clamp(.8rem, .85vw, 1rem); color: var(--muted); }
.board-groups { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr)); gap: 16px; }
.gcard { background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: 14px 16px; }
.ghead { display: flex; align-items: center; gap: 10px; font-size: clamp(1.05rem, 1.5vw, 1.35rem); font-weight: 900; margin-bottom: 8px; }
.gletter { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; background: var(--accent); color: #fff; font-size: 1.3rem; }
.gcount { margin-left: auto; font-size: .8rem; color: var(--muted); font-weight: 700; }
.gcard .grow { display: grid; grid-template-columns: 26px 1fr 30px 42px 34px; gap: 6px; align-items: center; padding: 8px 4px; border-top: 1px solid var(--line); font-variant-numeric: tabular-nums; font-size: clamp(.95rem, 1.25vw, 1.15rem); }
.gcard .grow.head { font-size: .72rem; color: var(--muted); text-transform: uppercase; font-weight: 800; border-top: 0; padding-top: 0; }
.gcard .grow > span:not(.n) { text-align: right; }
.gcard .grow > span:first-child { text-align: left; color: var(--muted); }
.gcard .grow .n { font-weight: 800; overflow-wrap: anywhere; }
.gcard .grow .pt { font-weight: 900; color: var(--beer); }
.gcard .grow.q { box-shadow: inset 4px 0 #40c057; }
.gcard .grow.q3 { box-shadow: inset 4px 0 var(--beer); }
.gcard .grow.plain { grid-template-columns: 1fr; gap: 0; }
.gcard .grow.plain .pl { font-size: .8rem; color: var(--muted); text-align: left !important; }
.board-now-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr)); gap: 10px; }
.nowcard { background: var(--accent); color: #fff; border-radius: 14px; padding: 12px 14px; font-size: clamp(1rem, 1.4vw, 1.25rem); display: grid; gap: 2px; }
.nowcard .field { font-size: .75rem; font-weight: 900; text-transform: uppercase; letter-spacing: .06em; opacity: .85; }
.nowcard .vs { opacity: .7; font-weight: 400; }
.nowcard .lbl { font-size: .75rem; opacity: .8; }
.board-champion { margin: 20px 0; text-align: center; background: linear-gradient(135deg, #f2b84b, #e8a317); color: #1c1915; border-radius: 22px; padding: 24px; }
.board-champion .label { font-weight: 900; text-transform: uppercase; letter-spacing: .1em; }
.board-champion .name { font-size: clamp(2rem, 5vw, 4.5rem); font-weight: 900; }
.tree { display: flex; gap: 14px; overflow-x: auto; padding-bottom: 10px; }
.tcol { flex: 1 0 210px; display: flex; flex-direction: column; }
.tround { text-align: center; font-weight: 900; color: var(--muted); text-transform: uppercase; font-size: .8rem; letter-spacing: .06em; margin-bottom: 8px; }
.tmatches { flex: 1; display: flex; flex-direction: column; justify-content: space-around; gap: 10px; }
.tm { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; font-size: .95rem; }
.tm > div { display: flex; justify-content: space-between; gap: 8px; padding: 7px 10px; }
.tm > div + div { border-top: 1px solid var(--line); }
.tm > div span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tm .w { font-weight: 900; color: var(--beer); }
.tm.empty { border-style: dashed; color: var(--muted); }
.tm.bye { opacity: .6; }
.tm.trophy { display: grid; justify-items: center; gap: 6px; padding: 16px 10px; font-size: 2.4rem; border-color: var(--beer); }
.tm.trophy span { font-size: 1rem; font-weight: 900; white-space: normal; text-align: center; }
.tcol.champ { flex: 0 0 160px; }
/* Live pulses & Stat boxes */
.live-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #ff4136;
  display: inline-block;
  box-shadow: 0 0 0 0 rgba(255, 65, 54, 0.7);
  animation: live-pulse-dot 1.8s infinite;
  vertical-align: middle;
}
@keyframes live-pulse-dot {
  0% { transform: scale(0.9); box-shadow: 0 0 0 0 rgba(255, 65, 54, 0.7); }
  70% { transform: scale(1.05); box-shadow: 0 0 0 7px rgba(255, 65, 54, 0); }
  100% { transform: scale(0.9); box-shadow: 0 0 0 0 rgba(255, 65, 54, 0); }
}
.live-pill:not(.past) {
  animation: live-pulse-pill 1.8s infinite;
}
@keyframes live-pulse-pill {
  0% { box-shadow: 0 0 0 0 rgba(201, 42, 42, 0.7); }
  70% { box-shadow: 0 0 0 5px rgba(201, 42, 42, 0); }
  100% { box-shadow: 0 0 0 0 rgba(201, 42, 42, 0); }
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin: 14px 0 18px;
}
@media (min-width: 480px) {
  .stats-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}
.stat-box {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  transition: transform 0.15s ease, border-color 0.15s ease;
}
.stat-box:hover {
  border-color: var(--accent);
}
.stat-box .val {
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--text);
  line-height: 1.2;
}
.stat-box .lbl {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.stat-box .sub {
  font-size: 0.75rem;
  color: var(--muted);
  font-weight: 500;
}
.stat-box .sub.truncate {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.page-head {
  margin-bottom: 12px;
}
.page-head h1 {
  margin-top: 0.5em;
  margin-bottom: 0.2em;
}
nav.tabbar a:active {
  transform: scale(0.95);
}
nav.tabbar a.on svg {
  stroke-width: 2.3;
}

/* Filter chips & Group tabs */
.filter-chips {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 6px 2px 10px;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.filter-chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none;
  padding: 6px 14px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s ease;
  font-family: inherit;
}
.chip:active, .chip.on {
  background: var(--accent);
  color: var(--accent-ink);
  border-color: var(--accent);
}
.sc.live-sc {
  color: #ff4136;
  font-weight: 800;
  display: inline-flex;
  align-items: center;
}

/* Mobile-friendly Group Picker & Single/All Group Modes */
.my-group-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 14px;
  margin: 12px 0;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 4px solid var(--accent);
}
.my-group-bar.subtle {
  border-left-color: var(--line);
  padding: 10px 14px;
}
.my-group-title {
  font-size: 0.95rem;
  margin-top: 2px;
}
.group-picker {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
  margin: 12px 0;
}
.group-picker-label {
  margin-bottom: 8px;
  font-weight: 600;
}
.group-picker-letters {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(36px, 1fr));
  gap: 6px;
  margin-bottom: 8px;
}
.gbtn {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 42px;
  padding: 0;
  border-radius: 10px;
  background: var(--bg);
  border: 1px solid var(--line);
  color: var(--text);
  font-size: 1rem;
  font-weight: 800;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.15s ease;
}
.gbtn.mine-grp {
  border-color: var(--accent);
}
.gbtn .gstar {
  position: absolute;
  top: 2px;
  right: 4px;
  font-size: 0.6rem;
  color: var(--gold);
  line-height: 1;
}
.gbtn.on, .gbtn:active {
  background: var(--accent);
  color: var(--accent-ink);
  border-color: var(--accent);
}
.gbtn.on .gstar {
  color: var(--accent-ink);
}
.btn-all-gironi {
  width: 100%;
  padding: 10px 14px;
  border-radius: 10px;
  background: var(--bg);
  border: 1px solid var(--line);
  color: var(--text);
  font-size: 0.88rem;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: all 0.15s ease;
}
.btn-all-gironi .sub-lbl {
  font-weight: 500;
  opacity: 0.8;
  font-size: 0.8rem;
}
.btn-all-gironi.on, .btn-all-gironi:active {
  background: var(--accent);
  color: var(--accent-ink);
  border-color: var(--accent);
}

/* Single group mode vs All groups (standings-only) mode */
#groups-container.mode-all .group-matches {
  display: none !important;
}
#groups-container.mode-single .only-in-all-hint {
  display: none !important;
}
#groups-container.mode-all .clickable-head {
  cursor: pointer;
}
.only-in-all-hint {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--accent);
  margin-left: 6px;
}
.group-matches {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}
.matches-subhead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  margin-bottom: 8px;
}

@media (max-width: 700px) {
  .board-top { grid-template-columns: 1fr auto; }
  .board-clock { display: none; }
}

/* Phase Header & Single Synchronized Server Clock */
.phase-header-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.phase-pill {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  margin-bottom: 4px;
}
.clock-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 10px;
  background: var(--card);
  border: 1px solid var(--line);
  font-variant-numeric: tabular-nums;
  font-size: 0.85rem;
}
.clock-pill .clock-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--ok);
  box-shadow: 0 0 0 3px var(--ok-soft);
}
.clock-pill .clock-lbl {
  color: var(--muted);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* 4-Table Asynchronous Schedule Hub */
.tables-schedule-hub {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  margin: 12px 0 18px;
}
.tavolo-tabs {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin: 12px 0;
}
@media (min-width: 520px) {
  .tavolo-tabs {
    grid-template-columns: repeat(4, 1fr);
  }
}
.tavolo-tab {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--bg);
  border: 1.5px solid var(--line);
  color: var(--text);
  font-family: inherit;
  cursor: pointer;
  text-align: left;
  transition: all 0.15s ease;
}
.tavolo-tab.mine-tavolo {
  border-color: var(--accent);
}
.tavolo-tab.on {
  background: var(--accent);
  color: var(--accent-ink);
  border-color: var(--accent);
}
.tavolo-tab .tt-top {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
}
.tavolo-tab .tt-name {
  font-weight: 800;
  font-size: 0.92rem;
}
.tavolo-tab .tt-star {
  color: var(--gold);
  font-size: 0.85rem;
}
.tavolo-tab.on .tt-star {
  color: var(--accent-ink);
}
.tavolo-tab .tt-live-dot {
  margin-left: auto;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--ok);
}
.tavolo-tab.on .tt-live-dot {
  background: #fff;
}
.tavolo-tab .tt-groups {
  font-size: 0.78rem;
  font-weight: 700;
  opacity: 0.9;
}
.tavolo-tab .tt-prog {
  font-size: 0.72rem;
  opacity: 0.75;
}
.tavolo-panel {
  border-top: 1px solid var(--line);
  padding-top: 12px;
}
.tavolo-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}
.tavolo-callouts {
  display: grid;
  gap: 10px;
  margin-bottom: 10px;
}
.t-callout {
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--bg);
  border: 1px solid var(--line);
}
.t-callout.now-callout {
  border-left: 4px solid var(--accent);
}
.t-callout.next-callout {
  border-left: 4px solid var(--gold);
  background: var(--warn-soft);
}
.t-callout.mine-next {
  border: 2px solid var(--gold);
}
.tc-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
  flex-wrap: wrap;
}
.next-badge-call {
  font-size: 0.74rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  color: var(--warn);
}
.time-est {
  font-size: 0.78rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  padding: 2px 7px;
  border-radius: 6px;
  background: var(--card);
}
.tc-sub {
  margin: 0 0 6px;
}
.tavolo-queue-details {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 12px;
}
.tavolo-queue-details summary {
  cursor: pointer;
  font-weight: 700;
  font-size: 0.86rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.tavolo-groups-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px dashed var(--line);
}
.tg-btns {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.ko-tables-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 10px;
}

/* Unified Gironi Navigation & Tavolo Workspace (Opzione A) */
.gironi-main-nav {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
  margin: 10px 0 16px;
}
.gironi-main-nav .tavolo-tabs {
  margin: 0 0 8px;
}
.tavolo-workspace {
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.regia-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}
.regia-now {
  padding: 12px 14px;
  border-left: 4px solid var(--accent);
}
.regia-now .match {
  margin: 6px 0 0;
}
.regia-next {
  padding: 10px 14px;
  background: var(--warn-soft);
  border-top: 1px solid var(--line);
  border-left: 4px solid var(--gold);
}
.regia-next.mine-next {
  outline: 2px solid var(--gold);
  outline-offset: -2px;
}
.rn-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 4px;
}
.rn-teams {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 0.96rem;
}
.rn-teams a {
  text-decoration: none;
  color: var(--text);
}
.tavolo-standings-section {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.ts-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}
.tavolo-standings-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}
@media (min-width: 640px) {
  .tavolo-standings-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}
.tavolo-group-card {
  margin: 0 !important;
}
.tavolo-matches-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
}
.tm-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}
.tm-tabs {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 4px;
  margin-bottom: 10px;
}
.tm-tab {
  white-space: nowrap;
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--bg);
  border: 1px solid var(--line);
  color: var(--text);
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
}
.tm-tab.on {
  background: var(--accent);
  color: var(--accent-ink);
  border-color: var(--accent);
}
.queue-item {
  padding: 6px 0;
  border-bottom: 1px solid var(--line);
}
.queue-item:last-child {
  border-bottom: none;
}
.queue-item.is-next-up {
  background: var(--warn-soft);
  margin: 0 -8px;
  padding: 8px;
  border-radius: 8px;
}
.qi-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  font-size: 0.72rem;
  color: var(--muted);
  margin-bottom: 2px;
}
.qi-order {
  font-weight: 800;
  color: var(--accent);
}
.qi-time {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
}

/* Group Picker Header & Search */
.group-picker-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}
.group-picker-title {
  font-weight: 800;
  font-size: 1rem;
}
.group-search-input {
  max-width: 240px;
  padding: 7px 11px !important;
  font-size: 0.85rem !important;
  border-radius: 8px !important;
}

/* Team Profile Page */
.team-profile-hero {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
}
.tph-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}
.tph-badges {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.profile-rankings-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}
@media (min-width: 560px) {
  .profile-rankings-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}
.pr-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.pr-label {
  font-size: 0.74rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--muted);
}
.pr-val {
  font-size: 1.45rem;
  font-weight: 900;
  color: var(--accent);
  line-height: 1.15;
}
.pr-val small {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--muted);
}
.pr-sub {
  font-size: 0.78rem;
  color: var(--muted);
}
.couple-kpi-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  text-align: center;
}
@media (min-width: 560px) {
  .couple-kpi-row {
    grid-template-columns: repeat(6, 1fr);
  }
}
.ck-num {
  font-size: 1.25rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}
.ck-num.pos-diff { color: var(--ok); }
.ck-num.neg-diff { color: var(--danger); }
.ck-lbl {
  font-size: 0.74rem;
  color: var(--muted);
}
.couple-split-bar-wrap {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}
.csb-labels {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.82rem;
  margin-bottom: 6px;
  gap: 6px;
}
.csb-track {
  display: flex;
  height: 10px;
  border-radius: 999px;
  overflow: hidden;
  background: var(--line);
}
.csb-fill-1 {
  background: var(--accent);
}
.csb-fill-2 {
  background: var(--ok);
}
.players-profile-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}
@media (min-width: 540px) {
  .players-profile-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}
.player-profile-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
}
.ppc-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
}
.ppc-ranks {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
}
.ppc-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  text-align: center;
}
.ppc-stat {
  background: var(--bg);
  border-radius: 8px;
  padding: 8px 6px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.ppc-val {
  font-weight: 800;
  font-size: 0.98rem;
  font-variant-numeric: tabular-nums;
}
.ppc-lbl {
  font-size: 0.7rem;
  color: var(--muted);
}
.ppc-footer {
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px dashed var(--line);
  font-size: 0.8rem;
  text-align: center;
}
.slim-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}
.slim-head h1 {
  margin: 0;
  font-size: 1.35rem;
}



/* Referee table: two halves as the referee sees them, the target rack's apex facing the shooters */
.ref-bar { display: grid; grid-template-columns: 1fr auto auto; align-items: center; gap: 10px; }
.ref-bar .ref-clock { text-align: left; }
.ref-bar .ref-clock .ref-clock-time { font-size: 1.6rem; }
.ref-score-big { font-size: 2rem; font-weight: 900; display: flex; gap: 6px; align-items: baseline; }
.ref-score-big span { color: var(--muted); font-weight: 400; }
button.ref-swap { min-width: 56px; min-height: 48px; font-size: 1.5rem; background: var(--surface); color: var(--text); border: 2px solid var(--line); border-radius: 14px; }
.ref-names { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; text-align: center; }
.ref-names strong { overflow-wrap: anywhere; line-height: 1.15; }
.ref-table { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; align-items: stretch; }
.ref-table .ref-outcomes { grid-column: 1 / -1; display: grid; grid-template-columns: 2fr 1fr; gap: 8px; }
button.ref-blow { min-height: 60px; font-size: 1.05rem; background: var(--surface); color: var(--text); border: 2px solid var(--t1); }
.ref-half { border: 2px solid var(--line); border-radius: 14px; padding: 8px 6px; display: grid; gap: 8px; align-content: start; justify-items: stretch; }
.ref-half.shooting { border-color: var(--accent); background: var(--accent-soft); }
.ref-role { font-size: .72rem; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); text-align: center; }
.ref-half .ref-pick span { min-height: 64px; }
.ref-rack { display: flex; justify-content: center; align-items: center; gap: 6px; }
.ref-col { display: flex; flex-direction: column; gap: 6px; }
.ref-rack .cup { width: 46px; height: 46px; font-size: 1.05rem; flex-direction: column; line-height: 1; }
.ref-rack.big .cup { width: 36px; height: 36px; font-size: .9rem; }
.ref-rack .cup.down small { font-size: .6rem; font-weight: 800; color: var(--accent); }
.ref-undo button { width: 100%; min-height: 48px; }
button.ref-rerack { justify-self: center; min-height: 36px; }
.ref-phase { border-radius: 14px; padding: 10px 12px; text-align: center; font-size: 1.05rem; }
.ref-phase.salvezza { background: var(--warn-soft); border: 2px solid var(--gold); }
.ref-phase.overtime { background: var(--accent); color: var(--accent-ink); }
.ref-more summary { text-align: center; color: var(--muted); font-weight: 700; cursor: pointer; padding: 6px; }
.ref-more { display: grid; gap: 8px; justify-items: center; }
input[type="range"] { -webkit-appearance: auto; appearance: auto; border: 0; padding: 0; background: transparent; min-height: 44px; accent-color: var(--accent); }

/* Live page: other tables, big score, streaks, trend, players, cheering */
.live-others { display: flex; gap: 6px; overflow-x: auto; margin: 0 -16px 8px; padding: 2px 16px 6px; scrollbar-width: none; }
.live-others a { flex-shrink: 0; display: flex; gap: 6px; align-items: center; padding: 6px 10px; border-radius: 999px; background: var(--surface); border: 1px solid var(--line); color: var(--text); text-decoration: none; font-size: .82rem; white-space: nowrap; }
.live-others .tno { font-weight: 900; color: var(--accent); }
.bigscore { font: 900 2.6rem/1 system-ui, sans-serif; font-variant-numeric: tabular-nums; display: flex; gap: 6px; justify-content: center; }
.bigscore #sc1 { color: var(--t1); }
.bigscore #sc2 { color: var(--t2); }
.bigscore .dash { color: var(--muted); font-weight: 400; }
.clockbox .clock { font-size: 1.3rem; margin-top: 4px; }
.streak { display: inline-block; margin-top: 6px; padding: 2px 8px; border-radius: 999px; background: var(--warn-soft); font-size: .78rem; font-weight: 800; }
.trend-box { margin-top: 10px; }
.trend { width: 100%; height: 64px; display: block; }
.trend .mid { stroke: var(--line); stroke-dasharray: 4 4; }
.trend .line { fill: none; stroke: var(--t1); stroke-width: 2.5; vector-effect: non-scaling-stroke; }
.trend .area { fill: var(--t1); opacity: .12; }
.trend-label { text-align: center; margin-top: 2px; }
.pstats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 12px; }
.pcol { display: grid; gap: 4px; }
.prow { display: grid; grid-template-columns: 1fr auto auto; gap: 6px; align-items: baseline; font-size: .9rem; padding: 6px 8px; border-radius: 10px; background: var(--bg); }
.pcol.s1 .prow { border-left: 3px solid var(--t1); }
.pcol.s2 .prow { border-left: 3px solid var(--t2); }
.prow small { color: var(--muted); }
.cheers { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 0 0 16px; }
.cheer-col { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 8px; }
.cheer-team { width: 100%; text-align: center; font-size: .78rem; font-weight: 800; color: var(--muted); overflow-wrap: anywhere; }
button.cheer { min-height: 44px; flex: 1 1 0; min-width: 0; padding: 4px 2px; justify-content: center; background: var(--bg); color: var(--text); border: 1px solid var(--line); border-radius: 12px; font-size: 1.3rem; display: flex; gap: 4px; align-items: center; }
button.cheer small { font-size: .78rem; font-weight: 800; color: var(--muted); }
button.cheer.on { background: var(--accent-soft); border-color: var(--accent); }
button.cheer.on small { color: var(--accent); }
button.cheer:disabled { opacity: .45; }
button.cheer.pop { animation: cheer-pop .35s ease-out; }
@keyframes cheer-pop { 50% { transform: scale(1.25); } }

/* Referee table overview: the match on the table, one tap to the scoring screen */
a.ref-overview { display: grid; gap: 10px; text-decoration: none; color: var(--text); background: var(--surface); border: 2px solid var(--line); border-radius: var(--radius); padding: 16px; margin: 12px 0; }
a.ref-overview.running { border-color: var(--accent); }
.ref-ov-teams { display: grid; grid-template-columns: 1fr auto 1fr; gap: 8px; align-items: center; text-align: center; }
.ref-ov-teams strong { font-size: 1.2rem; overflow-wrap: anywhere; }
.ref-ov-score { font-weight: 900; font-size: 1.3rem; color: var(--accent); }
a.ref-overview .ref-go { display: flex; align-items: center; justify-content: center; min-height: 64px; border-radius: 16px; font-size: 1.25rem; font-weight: 900; background: var(--ok); color: #fff; }
a.ref-overview.running .ref-go { background: var(--accent); }
.ref-top a { font-weight: 800; text-decoration: none; }

/* Heatmap of cups hit: one sequential blue ramp (light = few, dark = many), reversed in dark mode so the
   low end recedes into the surface; ink switches where the ramp gets dark enough. */
:root { --h1: #cde2fb; --h2: #9ec5f4; --h3: #6da7ec; --h4: #3987e5; --h5: #256abf; --h6: #184f95; --h7: #0d366b;
        --h-ink-low: #102a4c; --h-ink-high: #ffffff; --h-zero: #f0efec; }
@media (prefers-color-scheme: dark) {
  :root { --h1: #184f95; --h2: #1c5cab; --h3: #256abf; --h4: #3987e5; --h5: #6da7ec; --h6: #9ec5f4; --h7: #cde2fb;
          --h-ink-low: #ffffff; --h-ink-high: #0d1b2e; --h-zero: #383835; }
}
.heatmap-fig { margin: 0; display: grid; gap: 8px; justify-items: center; }
.heat-title { font-weight: 800; }
.heat-headline { margin: 0; text-align: center; }
.heat-rack { display: grid; gap: 6px; justify-items: center; }
.heat-row { display: flex; gap: 6px; }
.heat-cup { position: relative; width: 58px; height: 58px; border-radius: 50%; display: grid; place-content: center; text-align: center; line-height: 1.05; border: 2px solid var(--surface); }
.heatmap-fig.compact .heat-cup { width: 38px; height: 38px; }
.heat-cup b { font-size: 1.05rem; }
.heatmap-fig.compact .heat-cup b { font-size: .85rem; }
.heat-cup small { font-size: .62rem; font-weight: 700; }
.heat-cup i { position: absolute; top: -6px; right: -4px; font-style: normal; font-size: .6rem; font-weight: 800; color: var(--muted); background: var(--surface); border-radius: 999px; padding: 0 4px; }
.heat-cup.h0 { background: var(--h-zero); color: var(--muted); border-style: dashed; border-color: var(--line); }
.heat-cup.h1 { background: var(--h1); color: var(--h-ink-low); } .heat-cup.h2 { background: var(--h2); color: var(--h-ink-low); }
.heat-cup.h3 { background: var(--h3); color: var(--h-ink-low); } .heat-cup.h4 { background: var(--h4); color: var(--h-ink-low); }
.heat-cup.h5 { background: var(--h5); color: var(--h-ink-high); } .heat-cup.h6 { background: var(--h6); color: var(--h-ink-high); }
.heat-cup.h7 { background: var(--h7); color: var(--h-ink-high); }
@media (prefers-color-scheme: dark) {
  .heat-cup.h4, .heat-cup.h5, .heat-cup.h6, .heat-cup.h7 { color: var(--h-ink-high); }
  .heat-cup.h1, .heat-cup.h2, .heat-cup.h3 { color: var(--h-ink-low); }
}
.heat-cup:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.heat-cup.top { box-shadow: 0 0 0 3px var(--accent); }
.heat-legend { display: flex; align-items: center; gap: 8px; font-size: .75rem; color: var(--muted); }
.heat-scale { width: 140px; height: 10px; border-radius: 999px; background: linear-gradient(90deg, var(--h1), var(--h4), var(--h7)); }
.heat-note { margin: 0; }
.heat-table { width: 100%; }
.heat-table summary { text-align: center; font-size: .85rem; color: var(--accent); cursor: pointer; }
.heat-table table { margin: 8px auto 0; }
.heat-players { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; width: 100%; margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); }

/* Knockout timetable of a table */
.ko-plan h3 { margin: 0 0 4px; font-size: 1rem; }
.ko-plan .muted.small { margin: 0 0 6px; }
.mini.planned { color: var(--ink); cursor: default; }
.queue-item.mine-q { background: var(--accent-soft); margin: 0 -8px; padding: 8px; border-radius: 8px; }
