* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: #0a0e1a;
  color: #e0e0e0;
  min-height: 100vh;
}

header {
  text-align: center;
  padding: 2.5rem 1rem 1.5rem;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}

.site-logo {
  display: block;
  max-width: 420px;
  width: 100%;
  height: auto;
  margin: 0 auto;
}

.mission {
  color: #b0b8cc;
  margin-top: 0.8rem;
  font-size: 1.05rem;
  line-height: 1.5;
  max-width: 640px;
  margin-left: auto;
  margin-right: auto;
}

.source {
  color: #555;
  font-size: 0.8rem;
  margin-top: 0.4rem;
}

.source a {
  color: #6e7fff;
  text-decoration: none;
}

.source a:hover {
  text-decoration: underline;
}

/* Tabs */
.tabs {
  display: flex;
  justify-content: center;
  gap: 0.5rem;
  padding: 1rem;
  position: sticky;
  top: 0;
  background: rgba(10, 14, 26, 0.95);
  backdrop-filter: blur(12px);
  z-index: 100;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}

.tab {
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.1);
  color: #8890a4;
  padding: 0.6rem 2rem;
  font-size: 0.95rem;
  font-weight: 600;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
}

.tab:hover {
  background: rgba(255,255,255,0.08);
  color: #ccc;
}

.tab.active {
  background: linear-gradient(135deg, rgba(255,68,68,0.15), rgba(255,136,0,0.15));
  border-color: rgba(255,100,50,0.4);
  color: #ff8844;
}

/* Data explainer */
.data-explainer {
  max-width: 780px;
  margin: 0 auto;
  padding: 1rem 1.5rem;
  text-align: center;
}

.data-explainer p {
  font-size: 0.88rem;
  color: #8890a4;
  line-height: 1.55;
}

.data-explainer a {
  color: #6e7fff;
  text-decoration: none;
  font-weight: 600;
}

.data-explainer a:hover {
  text-decoration: underline;
  color: #93bbfd;
}

/* Main */
main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1.5rem 1rem 3rem;
}

.race-section {
  display: none;
}

.race-section.active {
  display: block;
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
  gap: 1rem;
}

.section-header h2 {
  font-size: 1.4rem;
  font-weight: 700;
  color: #ddd;
}

/* Chamber control summary */
.control-bar {
  display: flex;
  align-items: center;
  gap: 1rem;
  font-size: 0.85rem;
  font-weight: 600;
}

.control-bar .party-odds {
  padding: 0.35rem 0.8rem;
  border-radius: 6px;
  font-variant-numeric: tabular-nums;
}

.control-bar .dem {
  background: rgba(59, 130, 246, 0.15);
  color: #60a5fa;
  border: 1px solid rgba(59,130,246,0.3);
}

.control-bar .rep {
  background: rgba(239, 68, 68, 0.15);
  color: #f87171;
  border: 1px solid rgba(239,68,68,0.3);
}

/* Control tooltip */
.control-tooltip-wrap {
  position: relative;
  display: flex;
  align-items: center;
  gap: 1rem;
  cursor: default;
}

.control-tooltip {
  display: none;
  position: absolute;
  bottom: calc(100% + 12px);
  right: 0;
  width: 240px;
  padding: 0.7rem 0.85rem;
  background: #1e2336;
  color: #c8cede;
  font-size: 0.78rem;
  font-weight: 400;
  line-height: 1.45;
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
  z-index: 200;
  pointer-events: none;
}

.control-tooltip::before {
  content: '';
  position: absolute;
  bottom: -7px;
  right: 40px;
  width: 12px;
  height: 12px;
  background: #1e2336;
  border-right: 1px solid rgba(255,255,255,0.12);
  border-bottom: 1px solid rgba(255,255,255,0.12);
  transform: rotate(45deg);
}

.control-tooltip-wrap:hover .control-tooltip {
  display: block;
}

/* Race grid */
.race-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 1rem;
}

/* Race card */
.race-card {
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.07);
  border-radius: 12px;
  padding: 1.25rem;
  transition: border-color 0.2s, transform 0.15s;
}

.race-card:hover {
  border-color: rgba(255,255,255,0.15);
  transform: translateY(-2px);
}

.race-card.tossup {
  border-color: rgba(255, 200, 0, 0.3);
  box-shadow: 0 0 20px rgba(255, 200, 0, 0.05);
}

.race-name {
  font-size: 1.05rem;
  font-weight: 700;
  color: #eee;
  margin-bottom: 0.2rem;
}

.race-type {
  font-size: 0.75rem;
  color: #666;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.8rem;
}

/* Probability bar */
.prob-bar-container {
  margin-bottom: 0.6rem;
}

.prob-bar {
  display: flex;
  height: 32px;
  border-radius: 8px;
  overflow: hidden;
  background: rgba(255,255,255,0.05);
}

.prob-bar .dem-fill {
  background: linear-gradient(90deg, #2563eb, #3b82f6);
  display: flex;
  align-items: center;
  justify-content: flex-start;
  padding-left: 8px;
  font-size: 0.8rem;
  font-weight: 700;
  color: white;
  min-width: 0;
  transition: width 0.6s ease;
}

.prob-bar .rep-fill {
  background: linear-gradient(90deg, #dc2626, #ef4444);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding-right: 8px;
  font-size: 0.8rem;
  font-weight: 700;
  color: white;
  min-width: 0;
  transition: width 0.6s ease;
}

.prob-bar .dem-fill span,
.prob-bar .rep-fill span {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: clip;
}

/* Candidate labels */
.candidates {
  display: flex;
  justify-content: space-between;
  font-size: 0.8rem;
  gap: 0.5rem;
}

.candidates .dem-label {
  color: #60a5fa;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.candidates .rep-label {
  color: #f87171;
  font-weight: 600;
  text-align: right;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Card footer with support link and volume */
.card-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 0.5rem;
}

.dem-support-link {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 700;
  color: #60a5fa;
  text-decoration: none;
  padding: 0.25rem 0.6rem;
  border: 1px solid rgba(59, 130, 246, 0.3);
  border-radius: 6px;
  background: rgba(59, 130, 246, 0.08);
  transition: all 0.2s;
}

.dem-support-link:hover {
  background: rgba(59, 130, 246, 0.2);
  border-color: rgba(59, 130, 246, 0.5);
  color: #93bbfd;
}

/* Closeness badge */
.closeness-badge {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  margin-bottom: 0.6rem;
}

.closeness-badge.tossup {
  background: rgba(255, 200, 0, 0.15);
  color: #fbbf24;
  border: 1px solid rgba(255, 200, 0, 0.3);
}

.closeness-badge.lean {
  background: rgba(168, 85, 247, 0.12);
  color: #c084fc;
  border: 1px solid rgba(168, 85, 247, 0.3);
}

.closeness-badge.likely {
  background: rgba(100, 116, 139, 0.15);
  color: #94a3b8;
  border: 1px solid rgba(100,116,139,0.3);
}

.closeness-badge.safe {
  background: rgba(50, 60, 80, 0.3);
  color: #64748b;
  border: 1px solid rgba(100,116,139,0.15);
}

/* Volume */
.volume {
  font-size: 0.7rem;
  color: #555;
  text-align: right;
  margin-left: auto;
}

/* Loading */
.loading {
  grid-column: 1 / -1;
  text-align: center;
  padding: 3rem;
  color: #555;
  font-size: 1rem;
}

.loading::after {
  content: '';
  display: inline-block;
  width: 18px;
  height: 18px;
  border: 2px solid #333;
  border-top-color: #ff8844;
  border-radius: 50%;
  margin-left: 0.5rem;
  vertical-align: middle;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.error {
  grid-column: 1 / -1;
  text-align: center;
  padding: 2rem;
  color: #f87171;
  background: rgba(239,68,68,0.08);
  border: 1px solid rgba(239,68,68,0.2);
  border-radius: 8px;
}

/* How You Can Help bar */
.help-bar {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1.5rem 1rem 0.5rem;
}

.help-bar h2 {
  font-size: 1.1rem;
  font-weight: 700;
  color: #ddd;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 1rem;
  text-align: center;
}

.help-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 0.75rem;
}

.help-card {
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.07);
  border-radius: 12px;
  padding: 1.1rem;
  text-align: center;
  transition: border-color 0.2s, transform 0.15s;
}

.help-card:hover {
  border-color: rgba(255,255,255,0.18);
  transform: translateY(-2px);
}

.help-card .icon {
  display: block;
  font-size: 1.8rem;
  margin-bottom: 0.5rem;
  line-height: 1;
}

.help-card h3 {
  font-size: 0.9rem;
  font-weight: 700;
  color: #eee;
  margin-bottom: 0.35rem;
}

.help-card p {
  font-size: 0.78rem;
  color: #8890a4;
  line-height: 1.45;
}

.help-card a {
  color: #60a5fa;
  text-decoration: none;
  font-weight: 600;
}

.help-card a:hover {
  text-decoration: underline;
  color: #93bbfd;
}

@media (max-width: 900px) {
  .help-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (max-width: 500px) {
  .help-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .help-card {
    padding: 0.9rem 0.7rem;
  }
}

footer {
  text-align: center;
  padding: 2rem;
  color: #444;
  font-size: 0.75rem;
  border-top: 1px solid rgba(255,255,255,0.04);
}

@media (max-width: 600px) {
  .race-grid {
    grid-template-columns: 1fr;
  }

  .section-header {
    flex-direction: column;
    align-items: flex-start;
  }
}
