:root {
  color-scheme: light;
  --ink: #18211f;
  --muted: #64706b;
  --line: #d2d9d4;
  --line-strong: #aeb8b3;
  --paper: #ffffff;
  --canvas: #eef2ee;
  --page: #f3f6f3;
  --accent: #087f78;
  --accent-dark: #075d59;
  --leaf: #357a4a;
  --coral: #c85448;
  --focus: #1f70b7;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
body { min-width: 320px; margin: 0; color: var(--ink); background: var(--page); }
a { color: inherit; text-decoration: none; }
button, input { font: inherit; letter-spacing: 0; }
button:focus-visible, a:focus-visible { outline: 3px solid rgb(31 112 183 / 28%); outline-offset: 2px; }

.skip-link {
  position: fixed;
  z-index: 40;
  top: 8px;
  left: 8px;
  padding: 8px 12px;
  color: #fff;
  background: var(--ink);
  transform: translateY(-150%);
}
.skip-link:focus { transform: none; }

.judge-header {
  min-height: 58px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 0 28px;
  border-bottom: 1px solid var(--line);
  background: var(--paper);
}

.brand-lockup, .header-nav {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  font-size: 14px;
}
.brand-lockup > span:last-child { color: var(--muted); }
.header-nav { justify-content: flex-end; font-size: 12px; }
.header-nav a { border-radius: 4px; padding: 7px 8px; color: var(--muted); font-weight: 650; }
.header-nav a:hover { background: var(--canvas); color: var(--ink); }

.brand-mark {
  display: grid;
  grid-template-columns: repeat(3, 5px);
  grid-template-rows: repeat(3, 5px);
  gap: 2px;
  padding: 4px;
  border-radius: 4px;
  background: #edf6f1;
}
.brand-mark span { width: 5px; height: 5px; background: var(--accent); }
.brand-mark span:nth-child(1) { grid-area: 1 / 1; }
.brand-mark span:nth-child(2) { grid-area: 1 / 2; }
.brand-mark span:nth-child(3) { grid-area: 2 / 1; }
.brand-mark span:nth-child(4) { grid-area: 3 / 1; }
.brand-mark span:nth-child(5) { grid-area: 3 / 2; background: var(--coral); }
.header-divider { width: 1px; height: 20px; background: var(--line); }

.connection-state { flex: 0 0 auto; color: var(--muted); font-size: 12px; }
.connection-state.is-online { color: var(--leaf); }
.connection-state.is-error { color: var(--coral); }

main { width: min(1480px, 100%); margin: 0 auto; padding: 28px; }
.eyebrow {
  margin: 0 0 7px;
  color: var(--accent-dark);
  font-size: 11px;
  font-weight: 750;
  letter-spacing: 0;
  text-transform: uppercase;
}
h1, h2, p { overflow-wrap: anywhere; }
h1, h2 { margin: 0; letter-spacing: 0; }

.queue-state {
  width: min(620px, 100%);
  margin: 16vh auto 0;
  text-align: center;
}
.queue-state h1 { font-size: 38px; line-height: 1.08; }
.queue-state > p:last-of-type { max-width: 500px; margin: 12px auto 0; color: var(--muted); line-height: 1.55; }
.queue-spinner {
  display: block;
  width: 28px;
  height: 28px;
  margin: 0 auto 22px;
  border: 3px solid var(--line);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.ballot-heading { position: relative; margin-bottom: 22px; padding-right: 120px; }
.ballot-heading h1 { max-width: 1080px; font-size: 30px; line-height: 1.2; }
.ballot-count {
  position: absolute;
  top: 0;
  right: 0;
  color: var(--muted);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

.candidate-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.candidate {
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--paper);
}
.candidate > header {
  min-height: 54px;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
}
.candidate-index {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border-radius: 4px;
  color: #fff;
  background: var(--ink);
  font-size: 13px;
  font-weight: 800;
}
.candidate h2 { font-size: 15px; }
.candidate-summary { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }

.viewer-stage {
  position: relative;
  min-width: 0;
  height: 460px;
  overflow: hidden;
  background: var(--canvas);
  cursor: grab;
  touch-action: none;
}
.viewer-stage:active { cursor: grabbing; }
.viewer-stage > canvas { display: block; width: 100%; height: 100%; }
.viewer-stage figcaption {
  position: absolute;
  right: 8px;
  bottom: 7px;
  padding: 3px 6px;
  border: 1px solid rgb(24 33 31 / 14%);
  border-radius: 3px;
  color: #35413d;
  background: rgb(255 255 255 / 88%);
  font-size: 10px;
  font-weight: 750;
  text-transform: uppercase;
  pointer-events: none;
}

button {
  min-height: 44px;
  border: 1px solid var(--accent);
  border-radius: 4px;
  padding: 0 18px;
  color: #fff;
  background: var(--accent);
  font-weight: 720;
  cursor: pointer;
}
button:hover { background: var(--accent-dark); }
button:disabled { cursor: wait; opacity: 0.55; }
.vote-bar {
  width: min(820px, 100%);
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin: 18px auto 0;
}
.vote-bar button[data-choice="left"], .vote-bar button[data-choice="right"] { border-color: var(--leaf); background: var(--leaf); }
.vote-bar button[data-choice="left"]:hover, .vote-bar button[data-choice="right"]:hover { background: #28623a; }
.vote-bar .quiet { border-color: var(--line-strong); color: #47524e; background: var(--paper); }
.bot-challenge { width: min(320px, 100%); min-height: 65px; margin: 12px auto 0; }
.vote-status { min-height: 20px; margin: 10px 0 0; color: var(--muted); text-align: center; font-size: 13px; }

.account-nudge {
  max-width: 520px;
  margin: 14px auto 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px 16px;
  color: var(--muted);
  background: var(--canvas);
  text-align: center;
  font-size: 14px;
}
.account-nudge a { color: var(--accent); font-weight: 700; text-decoration: underline; text-underline-offset: 3px; }

.completion-mark {
  display: block;
  width: 36px;
  height: 20px;
  margin: 0 auto 28px;
  border: 6px solid var(--leaf);
  border-top: 0;
  border-right: 0;
  transform: rotate(-45deg);
}
.completion-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-top: 22px; }
.account-cta, .secondary-cta {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--accent);
  border-radius: 4px;
  padding: 0 18px;
  color: var(--accent);
  font-size: 14px;
  font-weight: 700;
}
.account-cta:hover, .secondary-cta:hover { color: #fff; background: var(--accent); }

@media (max-width: 900px) {
  .candidate-grid { grid-template-columns: 1fr; }
  .viewer-stage { height: 380px; }
}

@media (max-width: 620px) {
  .judge-header { padding: 0 12px; }
  .header-divider, .brand-lockup > span:last-child, .header-nav a:first-child { display: none; }
  .brand-lockup, .header-nav { gap: 6px; }
  main { padding: 18px 12px 24px; }
  .queue-state h1 { font-size: 32px; }
  .ballot-heading { padding-right: 0; }
  .ballot-heading h1 { font-size: 24px; }
  .ballot-count { position: static; display: block; margin-top: 8px; }
  .viewer-stage { height: 300px; }
  .vote-bar { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 390px) {
  .candidate > header { grid-template-columns: auto 1fr; }
  .candidate-summary { grid-column: 2; }
  .vote-bar { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

.judge-status-bar {
  width: min(1480px, calc(100% - 56px));
  min-height: 28px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  margin: 0 auto -12px;
}

@media (max-width: 620px) {
  .judge-status-bar {
    width: calc(100% - 24px);
    margin-bottom: -8px;
  }
}
