:root {
  --navy: #1A3A52;
  --teal: #00A896;
  --coral: #EF6461;
  --gold: #D4A84B;
  --green: #1D8C6B;
  --amber: #C88300;
  --grey: #6C757D;
  --light: #F4F6F8;
  --paper: #FFFFFF;
  --line: #E5E7EB;
  --text: #222222;
  --muted: #64748B;

  /* ATP brand palette — sourced from amazingteamperformance.co.uk so the
     voting tool reads as the same product. The dark pill buttons + cream
     gradient background are the signature pieces. */
  --atp-dark: #292929;
  --atp-orange: #dd7500;
  --atp-orange-tint: #faead9;
  --atp-cream-1: #ebefd5;
  --atp-cream-2: #f1f1d5;
  --atp-line: #afacad;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  /* Inter is the preferred family but woff2 is not yet shipped — system fallback for M1.
     Track shipping the self-hosted woff2 as a follow-up before TWFRS go-live. */
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  /* ATP marketing-site cream gradient — visually unifies the voter tool with
     the rest of the brand. */
  background: linear-gradient(180deg,
    var(--atp-cream-1) 0%,
    var(--atp-cream-2) 40%,
    #ffffff 100%) no-repeat;
  background-attachment: fixed;
  color: var(--text);
  min-height: 100vh;
}

.container {
  max-width: 920px;
  margin: 0 auto;
  padding: 32px 24px 80px;
}

/* Header */
header {
  text-align: center;
  margin-bottom: 28px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--line);
}
header h1 {
  font-size: 26px;
  font-weight: 700;
  color: var(--navy);
  margin: 0 0 6px;
  letter-spacing: -0.01em;
}
header .sub {
  font-size: 14px;
  color: var(--muted);
  margin: 0;
}
header .zeal {
  font-size: 11px;
  color: var(--muted);
  margin-top: 10px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

/* ATP brand mark — wraps the official SVG logo. The link goes to the
   marketing site so voters who follow the mark land in the right place. */
.atp-mark {
  display: inline-flex;
  align-items: center;
  margin-bottom: 18px;
  text-decoration: none;
  border-radius: 8px;
  outline-offset: 4px;
}
.atp-mark:focus-visible {
  outline: 2px solid var(--atp-orange);
}
.atp-logo {
  display: block;
  height: 44px;
  width: auto;
}

/* Tabs */
.tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 24px;
  background: var(--paper);
  padding: 6px;
  border-radius: 12px;
  border: 1px solid var(--line);
}
.tab {
  flex: 1;
  padding: 10px 16px;
  background: transparent;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  color: var(--muted);
  cursor: pointer;
  transition: all 0.2s;
  font-family: inherit;
}
.tab.active {
  background: var(--navy);
  color: white;
}

/* Card */
.card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 24px 28px;
  margin-bottom: 18px;
}

.card h2 {
  font-size: 18px;
  font-weight: 700;
  color: var(--navy);
  margin: 0 0 6px;
}
.card .lede {
  font-size: 14px;
  color: var(--muted);
  margin: 0 0 18px;
  line-height: 1.5;
}

/* Vote stage */
.dots-meter {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  background: linear-gradient(135deg, rgba(0,168,150,0.08) 0%, rgba(26,58,82,0.04) 100%);
  border: 1px solid rgba(0,168,150,0.2);
  border-radius: 10px;
  padding: 14px 18px;
  margin-bottom: 20px;
}
.dots-meter-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--navy);
}
.dots-meter-count {
  font-size: 22px;
  font-weight: 700;
  color: var(--teal);
  font-variant-numeric: tabular-nums;
}
.dots-meter-count .total {
  color: var(--muted);
  font-size: 14px;
  font-weight: 500;
}

.anchor {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  background: var(--light);
  border: 1px solid var(--line);
  border-radius: 10px;
  margin-bottom: 8px;
  transition: border-color 0.15s;
}
.anchor.has-dots {
  background: rgba(0,168,150,0.05);
  border-color: rgba(0,168,150,0.3);
}
.anchor-label {
  font-size: 14px;
  color: var(--text);
  flex: 1;
  line-height: 1.4;
}

.dot-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}
.dot-btn {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  color: var(--navy);
  font-weight: 600;
  transition: all 0.15s;
  line-height: 1;
  padding: 0;
  font-family: inherit;
}
.dot-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.dot-display {
  min-width: 70px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  flex-wrap: wrap;
}
.dot {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: var(--teal);
  box-shadow: 0 1px 2px rgba(0,168,150,0.3);
}
.dot-empty-text {
  font-size: 12px;
  color: var(--muted);
  font-style: italic;
}

.submit-row {
  display: flex;
  gap: 12px;
  margin-top: 24px;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
}

.submit-row-actions {
  display: flex;
  gap: 10px;
}

.btn-primary {
  background: var(--atp-dark);
  color: white;
  border: none;
  padding: 12px 28px;
  /* Pill shape — matches the marketing site's CTA buttons. */
  border-radius: 999px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.15s, opacity 0.15s;
  font-family: inherit;
  letter-spacing: 0.01em;
}
.btn-primary:hover:not(:disabled) {
  background: #1f1f1f;
}
.btn-primary:focus-visible {
  outline: 2px solid var(--atp-orange);
  outline-offset: 2px;
}
.btn-primary:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.btn-secondary {
  background: white;
  color: var(--atp-dark);
  border: 1px solid var(--atp-line);
  padding: 10px 20px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
  transition: background-color 0.15s, border-color 0.15s;
}
.btn-secondary:hover {
  background: var(--atp-orange-tint);
  border-color: var(--atp-dark);
}
.btn-secondary:focus-visible {
  outline: 2px solid var(--atp-orange);
  outline-offset: 2px;
}

.helper-text {
  font-size: 13px;
  color: var(--muted);
  flex: 1;
}

/* Submitted confirmation */
.submitted-confirm {
  background: linear-gradient(135deg, rgba(29,140,107,0.08) 0%, rgba(0,168,150,0.04) 100%);
  border: 1px solid rgba(29,140,107,0.3);
  border-radius: 12px;
  padding: 20px 24px;
  text-align: center;
}
.submitted-confirm h3 {
  margin: 0 0 8px;
  color: var(--green);
  font-size: 17px;
}
.submitted-confirm p {
  margin: 0;
  font-size: 14px;
  color: var(--text);
  line-height: 1.5;
}

/* Results stage */
.results-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  padding: 14px 18px;
  background: var(--light);
  border-radius: 10px;
  flex-wrap: wrap;
  gap: 12px;
}
.results-meta-stat {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.results-meta-label {
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
}
.results-meta-value {
  font-size: 20px;
  font-weight: 700;
  color: var(--navy);
  font-variant-numeric: tabular-nums;
}
.results-meta-value .of {
  font-size: 13px;
  color: var(--muted);
  font-weight: 500;
}

.result-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
  padding: 10px 14px;
  background: var(--light);
  border-radius: 8px;
  border: 1px solid transparent;
}
.result-row.top { background: rgba(212,168,75,0.08); border-color: rgba(212,168,75,0.3); }
.result-rank {
  font-size: 13px;
  font-weight: 700;
  color: var(--muted);
  min-width: 28px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}
.result-row.top .result-rank { color: var(--gold); }
.result-label {
  flex: 1;
  font-size: 14px;
  color: var(--text);
  line-height: 1.4;
}
.result-bar-wrap {
  flex: 0 0 200px;
  height: 14px;
  background: white;
  border: 1px solid var(--line);
  border-radius: 7px;
  overflow: hidden;
  position: relative;
}
.result-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--teal) 0%, var(--navy) 100%);
  border-radius: 7px;
  transition: width 0.5s ease;
}
.result-row.top .result-bar {
  background: linear-gradient(90deg, var(--gold) 0%, var(--amber) 100%);
}
.result-count {
  min-width: 36px;
  text-align: right;
  font-size: 13px;
  font-weight: 700;
  color: var(--navy);
  font-variant-numeric: tabular-nums;
}
.result-row.top .result-count { color: var(--amber); }

.top-banner {
  background: linear-gradient(135deg, rgba(212,168,75,0.1) 0%, rgba(200,131,0,0.05) 100%);
  border: 1px solid rgba(212,168,75,0.4);
  border-radius: 10px;
  padding: 14px 18px;
  margin: 20px 0 16px;
  font-size: 13px;
  color: var(--navy);
  line-height: 1.5;
}
.top-banner strong { color: var(--amber); }
.top-banner.muted {
  background: rgba(108,117,125,0.08);
  border-color: rgba(108,117,125,0.3);
}
.top-banner.muted strong { color: var(--grey); }

.empty-results {
  text-align: center;
  padding: 60px 20px;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.5;
}
.empty-results .icon {
  font-size: 36px;
  margin-bottom: 12px;
  display: block;
  opacity: 0.5;
}

/* Footer */
footer {
  margin-top: 40px;
  padding-top: 24px;
  border-top: 1px solid var(--line);
}
.footer-meta {
  text-align: center;
  font-size: 11px;
  color: var(--muted);
  letter-spacing: 0.05em;
  margin-bottom: 18px;
}
.footer-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  text-align: center;
}
.powered-by {
  font-size: 12px;
  color: var(--navy);
  letter-spacing: 0.02em;
}
.powered-by strong {
  color: var(--teal);
  font-weight: 700;
}
.copyright {
  font-size: 10px;
  color: var(--muted);
  letter-spacing: 0.04em;
}

/* Loading */
.loading {
  text-align: center;
  padding: 40px 20px;
  color: var(--muted);
  font-size: 14px;
}

/* Landing card (no slug in URL) */
.landing {
  text-align: center;
  padding: 40px 20px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.6;
}
.landing strong {
  color: var(--navy);
}

/* Hover styles only on devices with a true hover capability — prevents
   "sticky" hover ghosts on touch devices after a tap. */
@media (hover: hover) {
  .tab:not(.active):hover {
    background: var(--light);
    color: var(--navy);
  }
  .anchor:hover {
    border-color: rgba(0,168,150,0.4);
  }
  .dot-btn:hover:not(:disabled) {
    background: var(--navy);
    color: white;
    border-color: var(--navy);
  }
  .btn-primary:hover:not(:disabled) {
    background: #00917F;
    box-shadow: 0 2px 8px rgba(0,168,150,0.3);
  }
  .btn-secondary:hover {
    background: var(--light);
    border-color: var(--navy);
  }
}

@media (max-width: 600px) {
  .container { padding: 20px 16px 60px; }
  .card { padding: 18px 18px; }
  header h1 { font-size: 22px; }
  .anchor { flex-direction: column; align-items: stretch; gap: 10px; }
  .dot-controls { justify-content: space-between; }
  .result-bar-wrap { flex: 0 0 120px; }
}
