:root {
  --paper: #E8EBEF;
  --surface: #FFFFFF;
  --ink: #1B1F2A;
  --muted: #596173;
  --rule: #C9CED7;
  --stamp: #3A2FB8;
  --stamp-soft: #8D86D9;
  --stamp-wash: #E4E1FA;
  --danger: #A3262A;

  --display: 'Sofia Sans Extra Condensed', 'Arial Narrow', sans-serif;
  --text: 'Sofia Sans', system-ui, sans-serif;
  --radius: 14px;
  --gutter: 20px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #141726;
    --surface: #1D2134;
    --ink: #E9EBF2;
    --muted: #A0A6B8;
    --rule: #343A55;
    --stamp: #A79EFF;
    --stamp-soft: #7169C4;
    --stamp-wash: #2A2850;
    --danger: #FF8A8E;
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --paper: #141726;
  --surface: #1D2134;
  --ink: #E9EBF2;
  --muted: #A0A6B8;
  --rule: #343A55;
  --stamp: #A79EFF;
  --stamp-soft: #7169C4;
  --stamp-wash: #2A2850;
  --danger: #FF8A8E;
  color-scheme: dark;
}

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

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--text);
  font-size: 1.0625rem;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

button, select { font: inherit; color: inherit; }

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

.wrap {
  max-width: 30rem;
  margin: 0 auto;
  padding: max(24px, env(safe-area-inset-top)) var(--gutter) max(28px, env(safe-area-inset-bottom));
}

.screen {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}

/* Type */

h1, h2 {
  font-family: var(--display);
  font-weight: 800;
  letter-spacing: -0.01em;
  line-height: 0.95;
  margin: 0;
}

h1 { font-size: clamp(3.25rem, 16vw, 4.75rem); }
h2 { font-size: clamp(2.25rem, 10vw, 2.875rem); }

h3 {
  font-size: 1.125rem;
  font-weight: 700;
  line-height: 1.3;
  margin: 0 0 4px;
}

p { margin: 0; max-width: 34ch; }

.lede { font-size: 1.1875rem; line-height: 1.45; }
.muted { color: var(--muted); }
.small { font-size: 0.9375rem; }

a { color: var(--stamp); text-underline-offset: 3px; }

/* The 100-dot turnout grid */

.dots {
  display: grid;
  grid-template-columns: repeat(10, 1fr);
  gap: clamp(5px, 1.6vw, 8px);
  width: 100%;
}

.dots span {
  aspect-ratio: 1;
  border-radius: 50%;
  background: var(--rule);
}

.dots span.on { background: var(--stamp); }

.dots.animate span.on {
  animation: stamp 260ms cubic-bezier(.2, .9, .3, 1.4) both;
  animation-delay: calc(var(--i) * 28ms + 200ms);
}

@keyframes stamp {
  from { transform: scale(0.2); background: var(--rule); }
  to { transform: scale(1); background: var(--stamp); }
}

/* Start screen */

.start h1 { margin-bottom: 22px; }
.start .dots { max-width: min(100%, 32dvh, 300px); margin-bottom: 20px; }
.start .lede { margin-bottom: 10px; }
.start .actions { margin-top: auto; padding-top: 24px; display: grid; gap: 10px; }

/* Buttons */

.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 56px;
  padding: 14px 20px;
  border-radius: var(--radius);
  border: 0;
  font-weight: 700;
  font-size: 1.0625rem;
  text-decoration: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: transform 120ms ease;
}

.btn:active { transform: scale(0.98); }
.btn-primary { background: var(--stamp); color: var(--surface); }
.btn-quiet { background: transparent; color: var(--ink); border: 1.5px solid var(--rule); }
.btn[disabled] { opacity: 0.5; cursor: default; }

/* Question screens */

.q-head {
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: 44px;
  margin-bottom: 36px;
}

.back {
  border: 0;
  background: none;
  padding: 10px 12px 10px 0;
  color: var(--muted);
  font-weight: 500;
  cursor: pointer;
}

.back[hidden] { display: block; visibility: hidden; }

.progress { flex: 1; display: flex; gap: 4px; }

.progress span {
  flex: 1;
  height: 4px;
  border-radius: 2px;
  background: var(--rule);
  transition: background 200ms ease;
}

.progress span.done { background: var(--stamp); }

.q-step { color: var(--muted); font-size: 0.9375rem; font-variant-numeric: tabular-nums; }

.q-title { font-size: clamp(2.75rem, 13vw, 3.5rem); margin-bottom: 10px; }

.options {
  margin-top: auto;
  padding-top: 32px;
  display: grid;
  gap: 10px;
}

.option {
  display: flex;
  align-items: center;
  width: 100%;
  min-height: 58px;
  padding: 14px 18px;
  text-align: left;
  font-size: 1.125rem;
  font-weight: 500;
  background: var(--surface);
  border: 1.5px solid var(--rule);
  border-radius: var(--radius);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: border-color 120ms ease, background 120ms ease, transform 120ms ease;
}

.option:active { transform: scale(0.99); }

.option[aria-pressed="true"] {
  border-color: var(--stamp);
  background: var(--stamp-wash);
}

.options.grid-2 { grid-template-columns: 1fr 1fr; }
.options.grid-2 .option { justify-content: center; text-align: center; font-variant-numeric: tabular-nums; }

.select {
  width: 100%;
  min-height: 58px;
  padding: 14px 44px 14px 18px;
  font-size: 1.125rem;
  background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='9' viewBox='0 0 14 9'%3E%3Cpath d='M1 1l6 6 6-6' fill='none' stroke='%23596173' stroke-width='2'/%3E%3C/svg%3E") no-repeat right 18px center;
  border: 1.5px solid var(--rule);
  border-radius: var(--radius);
  appearance: none;
}

.error {
  color: var(--danger);
  font-weight: 500;
}

/* Results */

.results header { margin-bottom: 28px; }
.results header h2 { margin-bottom: 10px; }

.compare {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
  margin-bottom: 12px;
}

.compare .dots { gap: 3px; margin-bottom: 10px; }

.compare .big {
  font-family: var(--display);
  font-weight: 800;
  font-size: 2.5rem;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.compare p { font-size: 0.9375rem; line-height: 1.35; color: var(--muted); }

.block {
  padding: 28px 0 4px;
  border-top: 1px solid var(--rule);
  margin-top: 28px;
}

.block > p { margin-bottom: 16px; }

.group-title {
  font-size: 0.9375rem;
  font-weight: 700;
  color: var(--muted);
  margin: 18px 0 8px;
}

.bars { display: grid; gap: 14px; }

.bar-label {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 6px;
  font-size: 1rem;
}

.bar-val { font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.bar-val small { font-weight: 400; color: var(--muted); font-size: 0.875rem; }

.mine-tag { color: var(--muted); font-size: 0.875rem; font-weight: 500; margin-left: 6px; }

.bar-track {
  height: 10px;
  border-radius: 4px;
  background: color-mix(in srgb, var(--rule) 55%, transparent);
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  width: var(--w);
  border-radius: 4px;
  background: var(--stamp-soft);
  transition: width 600ms cubic-bezier(.2, .8, .2, 1);
}

.bars.pending .bar-fill { width: 0; }
.is-mine .bar-fill { background: var(--stamp); }

.thin { color: var(--muted); font-size: 0.875rem; font-weight: 400; }

.share {
  display: grid;
  gap: 10px;
  margin-top: 40px;
}

.foot {
  margin-top: 28px;
  font-size: 0.875rem;
  color: var(--muted);
}

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

/* Oblast map */

:root { --area-base: #F7F8FA; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --area-base: #262B42; } }
:root[data-theme="dark"] { --area-base: #262B42; }

.bgmap {
  display: block;
  width: 100%;
  height: auto;
  margin: 18px 0 12px;
  overflow: visible;
}

.area {
  fill: color-mix(in oklab, var(--stamp) var(--p), var(--area-base));
  stroke: var(--paper);
  stroke-width: 1.5;
  stroke-linejoin: round;
  vector-effect: non-scaling-stroke;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  outline: none;
}

.area.few { fill: url(#few-hatch); }
.hatch-bg { fill: var(--area-base); }
.hatch-line { stroke: var(--rule); stroke-width: 3; }

.area[aria-pressed="true"] { stroke: var(--ink); stroke-width: 2.5; }
.area:focus-visible { stroke: var(--stamp); stroke-width: 3; }

.legend {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.8125rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.legend-ramp {
  width: 72px;
  height: 8px;
  border-radius: 4px;
  background: linear-gradient(90deg, var(--area-base), var(--stamp));
  box-shadow: inset 0 0 0 1px var(--rule);
}

.legend-few {
  width: 12px;
  height: 12px;
  margin-left: 10px;
  border-radius: 3px;
  background: repeating-linear-gradient(45deg, var(--rule) 0 2px, var(--area-base) 2px 5px);
}

.region {
  margin-top: 20px;
  padding: 18px;
  border-radius: var(--radius);
  background: var(--surface);
}

.region h4 {
  font-family: var(--display);
  font-weight: 800;
  font-size: 1.75rem;
  line-height: 1;
  margin: 0 0 4px;
}

.region .bars { margin-top: 14px; }

.off-map { margin-top: 20px; }

.as-list { margin-top: 20px; }

.as-list summary {
  cursor: pointer;
  font-weight: 500;
  color: var(--stamp);
  padding: 8px 0;
}

.as-list .bars { margin-top: 12px; }
