:root {
  --bg: #ffffff;
  --header: #e3e2df;
  --ink: #111111;
  --muted: #575760;
  --line: #111111;
  --uzh: #0028a5;
  --flash: #f0f0ec;
  --flash-strong: #dce3f8;
  --error: #bf0d3e;
  --font: "Source Sans Pro", "Helvetica Neue", Helvetica, Arial, sans-serif;
  --max: min(72rem, 90vw);
  --col-rank: 7rem;
  --col-bid: 9.5rem;
  --rank-bar: 4px;
  --rank-gap: 0.9rem;
}

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

html { color-scheme: light; }

body {
  min-height: 100vh;
  font-family: var(--font);
  font-size: clamp(1rem, 1.35vw, 1.2rem);
  line-height: 1.5;
  color: var(--ink);
  background: var(--bg);
  display: flex;
  flex-direction: column;
}

.topbar {
  background: var(--header);
  border-bottom: 1px solid var(--line);
}

.topbar-inner,
.poll-nav-inner,
.main,
.foot-inner {
  width: min(100% - 4rem, var(--max));
  margin: 0 auto;
}

.topbar-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem 1.75rem;
  padding: 1.15rem 0;
  font-size: 0.95rem;
}

.brand {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.25rem 0.65rem;
  font-weight: 400;
}

.brand-org,
.brand-unit { font-weight: 600; }

.brand-sub { color: var(--muted); }

.topbar a {
  color: var(--ink);
  text-decoration: underline;
  text-underline-offset: 0.15em;
}

.topbar a:hover { text-decoration-thickness: 2px; }

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

.poll-nav {
  border-bottom: 1px solid var(--line);
  background: var(--bg);
}

.poll-nav-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.35rem 0;
  padding: 0.85rem 0 0.95rem;
}

.poll-nav-label {
  color: var(--muted);
  font-size: 0.95rem;
  margin-right: 1.1rem;
  font-weight: 600;
}

.poll-nav-list {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem 1.5rem;
  align-items: baseline;
}

.poll-nav a {
  color: var(--ink);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  font-size: 1.05rem;
  font-weight: 400;
  padding: 0.35rem 0;
  text-underline-offset: 0.22em;
  min-height: 2.5rem;
  display: inline-flex;
  align-items: center;
}

.poll-nav a:hover {
  text-decoration-thickness: 2px;
}

.poll-nav a[aria-current="page"] {
  color: var(--uzh);
  font-weight: 600;
  text-decoration: underline;
  text-decoration-thickness: 2px;
  text-decoration-color: var(--uzh);
}

.main {
  flex: 1;
  padding: 2.5rem 0 3.5rem;
}

h1 {
  font-size: clamp(1.75rem, 3.2vw, 2.35rem);
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: 0;
  margin-bottom: 0.65rem;
}

.lede {
  font-size: 1.02em;
  color: var(--muted);
  max-width: 40rem;
  margin-bottom: 1.25rem;
}

.page-tools {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem 1.25rem;
  margin-bottom: 1.5rem;
}

.btn-restart {
  appearance: none;
  font: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--ink);
  background: transparent;
  border: 1px solid var(--line);
  padding: 0.45rem 0.9rem;
  cursor: pointer;
  text-underline-offset: 0.15em;
}

.btn-restart:hover:not(:disabled) {
  color: var(--uzh);
  border-color: var(--uzh);
}

.btn-restart:disabled {
  opacity: 0.55;
  cursor: wait;
}

.btn-restart:focus-visible {
  outline: 2px solid var(--uzh);
  outline-offset: 3px;
}

.status {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.55rem 1.75rem;
  padding: 1rem 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  font-size: 0.98em;
}

.meta-item { color: var(--muted); }
.meta-item strong { color: var(--ink); font-weight: 600; }

.conn strong { color: var(--uzh); }
.conn.is-offline strong { color: var(--error); }
.conn.is-standby strong { color: var(--muted); }

.status-err {
  color: var(--error);
  font-size: 0.95em;
  margin-top: 0.85rem;
  min-height: 1.2em;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.board-wrap { margin-top: 1.75rem; }

.cols,
.row {
  display: grid;
  grid-template-columns: var(--col-rank) minmax(0, 1fr) var(--col-bid);
  gap: 0.9rem 1.5rem;
  align-items: baseline;
}

.cols {
  padding: 0.85rem 0;
  border-bottom: 1px solid var(--line);
  font-size: 0.95em;
  font-weight: 600;
  color: var(--muted);
}

.cols .bid-h,
.bid { text-align: right; }

.board { list-style: none; }

.row {
  padding: 1.15rem 0;
  border-bottom: 1px solid var(--line);
  transition: background-color 0.4s ease;
}

.row.changed,
.row.lead-changed { background: var(--flash-strong); }

.cols #h-rank,
.rank {
  border-left: var(--rank-bar) solid transparent;
  padding-left: var(--rank-gap);
  box-sizing: border-box;
}

.rank {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum";
  font-weight: 400;
  font-size: clamp(1.05rem, 1.8vw, 1.45rem);
  color: var(--muted);
  line-height: 1;
}

.rank-mark {
  width: 1.35rem;
  height: 1.35rem;
  flex: 0 0 auto;
  display: block;
}

.rank-num { min-width: 1.1ch; }

.row.top1 .rank {
  border-left-color: var(--uzh);
  color: var(--uzh);
  font-weight: 700;
  font-size: clamp(1.15rem, 2vw, 1.65rem);
}

.row.top2 .rank,
.row.top3 .rank {
  color: var(--ink);
  font-weight: 600;
  font-size: clamp(1.1rem, 1.9vw, 1.55rem);
}

.row.top2 .name,
.row.top3 .name { font-weight: 600; }

.name {
  font-size: clamp(1.1rem, 1.9vw, 1.55rem);
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.row.top1 .name { font-weight: 700; }

.row.top1 .bid {
  color: var(--uzh);
  font-weight: 700;
}

.bid {
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum";
  font-weight: 600;
  font-size: clamp(1.1rem, 1.9vw, 1.55rem);
  white-space: nowrap;
  color: var(--ink);
}

.empty {
  padding: 3rem 0;
  color: var(--muted);
  border-bottom: 1px solid var(--line);
}

footer {
  margin-top: auto;
  background: var(--header);
  border-top: 1px solid var(--line);
}

.foot-inner {
  padding: 1.15rem 0 1.4rem;
  font-size: 0.85rem;
  color: var(--muted);
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 1.5rem;
  justify-content: space-between;
}

@media (max-width: 640px) {
  .topbar-inner,
  .poll-nav-inner,
  .main,
  .foot-inner {
    width: min(100% - 2rem, var(--max));
  }

  :root {
    --col-rank: 4.75rem;
    --col-bid: minmax(6.5rem, 8.5rem);
    --rank-gap: 0.55rem;
  }

  .cols,
  .row {
    grid-template-columns: 4.75rem minmax(0, 1fr) minmax(6.5rem, 8.5rem);
    gap: 0.65rem 0.9rem;
  }

  .rank { gap: 0.4rem; }
  .rank-mark { width: 1.15rem; height: 1.15rem; }

  .poll-nav-list { gap: 0.35rem 1.15rem; }
  .poll-nav a { font-size: 1rem; }

  .name {
    white-space: normal;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
  }

  .main { padding: 2rem 0 2.75rem; }
}

@media (prefers-reduced-motion: reduce) {
  .row { transition: none; }
  .row.changed,
  .row.lead-changed {
    background: transparent;
    outline: 3px solid var(--uzh);
    outline-offset: -3px;
  }
}
