:root {
  /* Color (UI-SPEC Color section) */
  --color-bg: #FFFFFF;
  --color-surface: #F5F5F5;
  --color-accent: #1A1A1A;
  --color-text-primary: #1A1A1A;
  --color-text-secondary: #6B6B6B;
  --color-success: #16A34A;
  --color-border: #E5E5E5;
  --color-focus-ring: #1A1A1A;

  /* Spacing scale (UI-SPEC Spacing — multiples of 4) */
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 16px;
  --space-lg: 24px;
  --space-xl: 32px;
  --space-2xl: 48px;
  --space-3xl: 64px;

  /* Typography (UI-SPEC Typography) */
  --font-stack: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-size-label: 14px;
  --font-size-body: 16px;
  --font-size-heading: 24px;
  --font-size-display: 36px;
  --font-weight-regular: 400;
  --font-weight-bold: 700;

  /* Layout */
  --content-max-width: 640px;
  --radius: 8px;
  --tap-min: 44px;
}

*, *::before, *::after { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font-stack);
  font-size: var(--font-size-body);
  font-weight: var(--font-weight-regular);
  line-height: 1.5;
  color: var(--color-text-primary);
  background: var(--color-bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* Section visibility — router uses [hidden] attribute. Do not override it. */
.screen {
  max-width: var(--content-max-width);
  margin: 0 auto;
  padding: var(--space-md);
}

/* Landing-specific (UI-SPEC Copywriting + Component Inventory Section 8) */
#landing {
  padding-top: var(--space-2xl);
  padding-bottom: var(--space-2xl);
}
.display {
  font-size: var(--font-size-display);
  font-weight: var(--font-weight-bold);
  line-height: 1.1;
  margin: 0 0 var(--space-2xl) 0;
}
.value-prop {
  font-size: var(--font-size-body);
  color: var(--color-text-secondary);
  margin: 0 0 var(--space-xl) 0;
  max-width: 36em;
}

/* Buttons (UI-SPEC Component Inventory Section 5 + sticky bar CTA) */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: var(--tap-min);
  min-width: var(--tap-min);
  padding: 12px 20px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  font-family: inherit;
  font-size: var(--font-size-body);
  font-weight: var(--font-weight-bold);
  cursor: pointer;
  background: var(--color-bg);
  color: var(--color-text-primary);
}
.btn-primary {
  background: var(--color-accent);
  color: #FFFFFF;
}
.btn-secondary {
  background: var(--color-bg);
  color: var(--color-text-primary);
  border-color: var(--color-border);
}

/* Focus indicators — non-negotiable (UI-SPEC Accessibility, A11Y-04) */
:focus { outline: none; }
:focus-visible {
  outline: 2px solid var(--color-focus-ring);
  outline-offset: 2px;
}
/* Heading focus from router — visible only when programmatically focused */
h1[tabindex]:focus-visible,
h2[tabindex]:focus-visible {
  outline-offset: 4px;
}

/* Section transitions — instant by design (CONTEXT D-05). No CSS transition. */
/* prefers-reduced-motion: covered by absence of animations */

/* Tablet+ breakpoint reserved for grid; landing scales naturally */
@media (min-width: 768px) {
  #landing { padding-top: var(--space-3xl); }
}

/* ── Select screen ──────────────────────────────────────────────── */

/* Visually hidden utility */
.visually-hidden {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0, 0, 0, 0); white-space: nowrap;
  border: 0;
}

/* Search input (UI-SPEC Component 3) */
.search-row { margin: var(--space-md) 0; }
.search-input {
  width: 100%;
  min-height: var(--tap-min);
  padding: 0 var(--space-md);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  font-family: inherit;
  font-size: var(--font-size-body);
  color: var(--color-text-primary);
  box-sizing: border-box;
}
.search-input::placeholder { color: var(--color-text-secondary); }

/* Group section (UI-SPEC Component 2) */
.group-section { margin-bottom: var(--space-lg); }
.group-section[hidden] { display: none; }
.group-header {
  font-size: var(--font-size-label);
  font-weight: var(--font-weight-regular);
  color: var(--color-text-secondary);
  margin: var(--space-lg) 0 var(--space-md) 0;
}
.group-section:first-of-type .group-header { margin-top: 0; }

/* Grid + tiles (UI-SPEC Component 1 and 7) */
.group-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-sm);
}
@media (min-width: 768px) {
  .group-grid {
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
  }
}

.team-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-xs);
  min-height: var(--tap-min);
  min-width: var(--tap-min);
  padding: var(--space-sm);
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  font-family: inherit;
  font-size: var(--font-size-label);
  font-weight: var(--font-weight-regular);
  color: var(--color-text-primary);
  cursor: pointer;
  position: relative;
  text-align: center;
}
@media (prefers-reduced-motion: no-preference) {
  .team-tile {
    transition: background-color 80ms ease, color 80ms ease;
  }
}
.team-tile:hover { background: var(--color-surface); }
.team-tile[aria-pressed="true"] {
  background: var(--color-accent);
  color: #FFFFFF;
  border-color: var(--color-accent);
}
.team-tile-flag { font-size: 28px; line-height: 1; }
.team-tile-name { font-size: var(--font-size-label); }
.team-tile-check {
  position: absolute;
  top: 4px; right: 4px;
  width: 16px; height: 16px;
  color: var(--color-success);
  display: none;
  font-weight: var(--font-weight-bold);
}
.team-tile[aria-pressed="true"] .team-tile-check { display: block; }

/* Sticky bottom bar (UI-SPEC Component 4) */
#select { padding-bottom: var(--space-3xl); }
.sticky-bar {
  position: sticky;
  bottom: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-md);
  background: var(--color-bg);
  border-top: 1px solid var(--color-border);
  padding: var(--space-md);
  padding-bottom: calc(var(--space-md) + env(safe-area-inset-bottom, 0px));
  min-height: 64px;
  margin: 0 calc(-1 * var(--space-md));
}
.sticky-count { font-size: var(--font-size-label); color: var(--color-text-primary); flex: 1; }
.sticky-bar[data-selected="0"] .sticky-count { color: var(--color-text-secondary); }
.sticky-cta { white-space: nowrap; }

/* Subscribe screen (UI-SPEC Component 5, 6) */
#subscribe { padding-top: var(--space-xl); padding-bottom: var(--space-xl); }
.subscribe-subhead {
  font-size: var(--font-size-body);
  color: var(--color-text-secondary);
  margin: 0 0 var(--space-xl) 0;
}
.subscribe-actions {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
  margin-bottom: var(--space-xl);
}
.subscribe-btn {
  width: 100%;
  justify-content: center;
}
.copy-fallback {
  margin-bottom: var(--space-xl);
}
.copy-fallback-input {
  width: 100%;
  min-height: var(--tap-min);
  padding: 0 var(--space-md);
  font-family: inherit;
  font-size: var(--font-size-label);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  color: var(--color-text-primary);
}

/* Confirmation block (UI-SPEC Component 6) */
.confirmation {
  background: var(--color-surface);
  border-radius: var(--radius);
  padding: var(--space-lg);
  text-align: center;
  margin-bottom: var(--space-xl);
}
.confirmation[hidden] { display: none; }
.confirmation-icon {
  font-size: 24px;
  color: var(--color-success);
  font-weight: var(--font-weight-bold);
  margin-bottom: var(--space-md);
}
.confirmation-heading {
  font-size: var(--font-size-heading);
  font-weight: var(--font-weight-bold);
  margin: 0 0 var(--space-md) 0;
  color: var(--color-text-primary);
}
.confirmation-body {
  font-size: var(--font-size-body);
  color: var(--color-text-secondary);
  margin: 0;
}

/* Refine link */
.refine-row { text-align: center; margin: var(--space-md) 0; }
.refine-link {
  font-size: var(--font-size-label);
  color: var(--color-text-primary);
  text-decoration: underline;
  cursor: pointer;
  display: inline-block;
  min-height: var(--tap-min);
  line-height: var(--tap-min);
}
