:root {
  --navy: #0B1F3A;
  --lime: #D4F542;
  --bg: #F6F7F2;
  --surface: #FFFFFF;
  --ink: #0B1F3A;
  --muted: #56606E;
  --line: #E2E5DC;
  --chip: #ECEFE6;
  --accent-ink: #0B1F3A;   /* text on lime */
  --warn-bg: #FFF4D6;
  --warn-ink: #7A5200;
  --radius: 16px;
  --tabbar-h: 64px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #07152A;
    --surface: #0F2442;
    --ink: #F1F3EC;
    --muted: #A9B3C1;
    --line: #1F3556;
    --chip: #172E4F;
    --warn-bg: #3A2E0E;
    --warn-ink: #F4D58A;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: "DM Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.4;
  padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
}
button, input { font: inherit; color: inherit; }
a { color: inherit; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
svg { flex: none; }

/* Top bar */
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: var(--navy); color: #F6F7F2;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
}
.brand { display: flex; align-items: center; gap: 8px; max-width: 720px; margin: 0 auto; }
.brand-mark { width: 26px; height: 26px; color: var(--lime); }
.brand-name { font-weight: 700; font-size: 22px; letter-spacing: -0.04em; }
.beta {
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em;
  background: var(--lime); color: var(--navy); border-radius: 999px; padding: 2px 8px;
}

main { max-width: 720px; margin: 0 auto; padding: 0 16px 24px; }
.view-head { padding: 20px 0 8px; }
h1 { margin: 0; font-size: 28px; letter-spacing: -0.02em; }
.sub { margin: 2px 0 0; color: var(--muted); font-size: 14px; }

/* Chips */
.filters { display: flex; gap: 8px; overflow-x: auto; padding: 6px 0; scrollbar-width: none; }
.filters::-webkit-scrollbar { display: none; }
.chip {
  flex: none; border: 1px solid var(--line); background: var(--surface);
  border-radius: 999px; padding: 8px 14px; min-height: 40px; font-size: 14px; cursor: pointer;
}
.chip[aria-pressed="true"] { background: var(--navy); border-color: var(--navy); color: #F6F7F2; }
@media (prefers-color-scheme: dark) {
  .chip[aria-pressed="true"] { background: var(--lime); border-color: var(--lime); color: var(--navy); }
}

/* Lists and cards */
.list { display: flex; flex-direction: column; gap: 12px; padding-top: 8px; }
.day-head {
  margin: 14px 0 0; font-size: 13px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.06em; color: var(--muted);
}
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; display: flex; flex-direction: column; gap: 10px;
}
.card-top { display: flex; gap: 14px; align-items: flex-start; }
.date-badge {
  flex: none; width: 56px; border-radius: 12px; background: var(--lime); color: var(--navy);
  text-align: center; padding: 6px 0 7px; line-height: 1.05;
}
.date-badge .d { display: block; font-size: 24px; font-weight: 700; }
.date-badge .m { display: block; font-size: 12px; font-weight: 700; text-transform: uppercase; }
.card h2 { margin: 0; font-size: 18px; line-height: 1.25; letter-spacing: -0.01em; }
.meta { margin: 3px 0 0; color: var(--muted); font-size: 14px; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tag { background: var(--chip); border-radius: 8px; padding: 3px 8px; font-size: 13px; }
.facts { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; margin: 0; font-size: 14px; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; }
.warn {
  background: var(--warn-bg); color: var(--warn-ink); border-radius: 10px;
  padding: 8px 10px; font-size: 13px;
}
.actions { display: flex; flex-wrap: wrap; gap: 8px; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 44px; padding: 10px 14px; border-radius: 12px; border: 1px solid transparent;
  font-weight: 700; font-size: 15px; text-decoration: none; cursor: pointer; white-space: nowrap;
}
.btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.btn-primary { background: var(--navy); color: #F6F7F2; }
.btn-lime { background: var(--lime); color: var(--navy); }
.btn-ghost { background: var(--surface); border-color: var(--line); color: var(--ink); }
@media (prefers-color-scheme: dark) {
  .btn-primary { background: var(--lime); color: var(--navy); }
}
.btn-link { background: none; border: none; padding: 10px 4px; color: var(--muted); font-weight: 500; text-decoration: underline; }

/* Circoli toolbar */
.toolbar { display: flex; gap: 8px; padding: 6px 0; }
.search {
  flex: 1; display: flex; align-items: center; gap: 8px; background: var(--surface);
  border: 1px solid var(--line); border-radius: 12px; padding: 0 12px; min-height: 44px;
}
.search svg { width: 18px; height: 18px; fill: none; stroke: var(--muted); stroke-width: 2; stroke-linecap: round; }
.search input { flex: 1; border: 0; background: transparent; outline: none; min-width: 0; }
.search:focus-within { outline: 2px solid var(--lime); outline-offset: 1px; }
.segmented {
  display: grid; grid-template-columns: 1fr 1fr; background: var(--chip); border-radius: 12px;
  padding: 4px; margin: 8px 0 4px;
}
.segmented button {
  border: 0; background: transparent; border-radius: 9px; min-height: 38px; font-weight: 500; cursor: pointer;
}
.segmented button[aria-selected="true"] { background: var(--surface); font-weight: 700; box-shadow: 0 1px 2px rgba(0,0,0,.08); }
.platform { font-size: 12px; font-weight: 700; border-radius: 999px; padding: 2px 8px; background: var(--chip); }
.platform.playtomic { background: #CFF3EA; color: #0B4F43; }
.dist { font-weight: 700; color: var(--ink); }
.club-tornei { font-size: 14px; font-weight: 700; background: none; border: 0; padding: 0; text-align: left; text-decoration: underline; cursor: pointer; color: var(--ink); }

/* Map */
#clubs-map {
  height: calc(100vh - 300px); min-height: 360px; border-radius: var(--radius);
  overflow: hidden; border: 1px solid var(--line); margin-top: 8px;
}
.pin { background: none; border: 0; }
.leaflet-popup-content { font-family: "DM Sans", system-ui, sans-serif; margin: 12px 14px; }
.leaflet-popup-content h3 { margin: 0 0 2px; font-size: 15px; }
.leaflet-popup-content p { margin: 0 0 8px; color: #56606E; }
.leaflet-popup-content .btn { min-height: 36px; padding: 6px 12px; font-size: 14px; color: #F6F7F2; }

/* Empty states */
.empty { text-align: center; padding: 40px 16px; color: var(--muted); }
.empty strong { display: block; color: var(--ink); font-size: 17px; margin-bottom: 4px; }

/* Tab bar */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: grid; grid-template-columns: 1fr 1fr;
  background: var(--surface); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.tab {
  height: var(--tabbar-h); border: 0; background: none; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 3px; font-size: 12px; font-weight: 500;
  color: var(--muted); cursor: pointer;
}
.tab svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.tab[aria-current="page"] { color: var(--ink); font-weight: 700; }
.tab[aria-current="page"] svg { stroke: var(--ink); }

.toast {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(var(--tabbar-h) + 16px + env(safe-area-inset-bottom)); z-index: 40;
  background: var(--navy); color: #F6F7F2; padding: 10px 16px; border-radius: 12px;
  font-size: 14px; max-width: calc(100% - 32px); box-shadow: 0 6px 20px rgba(0,0,0,.2);
}

:focus-visible { outline: 3px solid var(--lime); outline-offset: 2px; }
