.electionbox {
    display: grid;
    grid-template-columns: 352px 680px 300px;
    column-gap: 20px;
    row-gap: 10px;
    align-items: start;
    padding: 12px 0 18px 0;
    border-top: 1px solid #dcdcdc;
    justify-content: start;
}

.electionbox-header {
    grid-column: 1;
    margin: 0;
    font-size: 28px;
    font-weight: 700;
    line-height: 1.15;
    min-width: 0;
    overflow-wrap: break-word;
    align-self: center;
}

.sidebox {
    min-width: 0;
}

.sidebox.left {
    grid-column: 1;
}

.sidebox.current {
    grid-column: 2;
}

.sidebox.right,
.sidebox.change {
    grid-column: 3;
}

.barbox {
    margin: 0 0 14px 0;
}

.barbox.current {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 300px minmax(0, 1fr);
    column-gap: 20px;
    row-gap: 4px;
    align-items: start;
}

.barbox-header {
    margin: 0 0 6px 0;
    font-size: 13px;
    line-height: 1.2;
    color: #555;
    text-align: center;
    font-weight: 600;
    letter-spacing: 0.02em;
}

.barbox.current>.barbox-header {
    grid-column: 1 / -1;
}

.bar {
    position: relative;
    display: flex;
    align-items: stretch;
    width: 300px;
    height: 28px;
    margin: 0;
    background: #e8e8e8;
    border-radius: 999px;
    overflow: hidden;
}

.bar.change {
    position: relative;
    width: 300px;
    background: linear-gradient(90deg,
    #e4e4e4 0%,
    #d2d2d2 18%,
    #b5b5b5 46%,
    #b5b5b5 54%,
    #d2d2d2 82%,
    #e4e4e4 100%);
}

.bar.change .bar-caption {
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.75);
}

.bar.change .unit {
    width: 1.5px;
    min-width: 1.5px;
    flex: 0 0 1.5px;
}

.bar-caption {
    position: absolute;
    inset: 0;
    z-index: 3;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 8px;
    font-size: 12px;
    font-weight: 700;
    line-height: 1;
    color: #fff;
    white-space: nowrap;
    pointer-events: none;
}

.segment {
    position: relative;
    display: flex;
    height: 100%;
}

.segment.left {
    justify-content: flex-start;
    border-radius: 999px 0 0 999px;
}

.segment.right {
    justify-content: flex-end;
    border-radius: 0 999px 999px 0;
}

.bar.change .segment.left,
.bar.change .segment.right {
    position: absolute;
    top: 0;
    bottom: 0;
}

.bar.change .segment.left {
    right: 50%;
    left: auto;
    justify-content: flex-end;
    border-radius: 999px 0 0 999px;
}

.bar.change .segment.right {
    left: 50%;
    right: auto;
    justify-content: flex-start;
    border-radius: 0 999px 999px 0;
}

.segment.center {
    justify-content: center;
}

.segment-caption {
    position: absolute;
    inset: 0;
    z-index: 2;
    display: flex;
    align-items: center;
    padding: 0 8px;
    font-size: 11px;
    font-weight: 700;
    line-height: 1;
    color: #fff;
    white-space: nowrap;
    text-shadow: 0 1px 1px rgba(0, 0, 0, 0.35);
    pointer-events: none;
}

.bar.change .segment-caption {
    display: none;
}

.segment.left>.segment-caption {
    justify-content: flex-start;
}

.segment.right>.segment-caption {
    justify-content: flex-end;
}

.segment.center>.segment-caption {
    left: 50%;
    right: auto;
    width: max-content;
    transform: translateX(-50%);
    justify-content: center;
    padding: 0;
    /* position from the actual segment center so narrow center captions stay visually centered */
    text-align: center;
}

.bar.unopposed::before {
    content: "";
    position: absolute;
    inset: 0;
    z-index: 1;
    background: repeating-linear-gradient(-22deg,
    rgba(255, 255, 255, 0.00) 0 14px,
    rgba(255, 255, 255, 0.10) 14px 16px,
    rgba(0, 0, 0, 0.07) 16px 18px,
    rgba(255, 255, 255, 0.00) 18px 32px);
    pointer-events: none;
}

.bar.unopposed::after {
    content: "UNOPPOSED";
    position: absolute;
    inset: 0;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: "Copperplate", "Copperplate Gothic Bold", "Stencil", Arial, sans-serif;
    font-size: 28px;
    font-weight: 900;
    letter-spacing: 0.32em;
    line-height: 1;
    color: rgba(255, 255, 255, 0.16);
    text-transform: uppercase;
    text-shadow:
            0 1px 0 rgba(255, 255, 255, 0.55),
            0 -1px 0 rgba(0, 0, 0, 0.28),
            0 0 1px rgba(0, 0, 0, 0.18);
    mix-blend-mode: screen;
    opacity: 0.65;
    pointer-events: none;
}

.bar.unopposed .bar-caption::before {
    content: "UNOPPOSED";
    position: absolute;
    inset: 0;
    z-index: -1;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: "Copperplate", "Copperplate Gothic Bold", "Stencil", Arial, sans-serif;
    font-size: 30px;
    font-weight: 900;
    letter-spacing: 0.28em;
    line-height: 1;
    color: rgba(0, 0, 0, 0.06);
    text-transform: uppercase;
    text-shadow:
            0 1px 0 rgba(255, 255, 255, 0.14),
            0 -1px 0 rgba(0, 0, 0, 0.14);
    mix-blend-mode: multiply;
    opacity: 0.5;
    pointer-events: none;
}

.unit {
    display: block;
    width: 3px;
    min-width: 3px;
    height: 100%;
    margin: 0;
    padding: 0;
    border: 0;
    outline: 0;
    flex: 0 0 3px;
}

.partybutton {
    display: inline-block;
    align-items: center;
    justify-content: center;
    min-width: 0;
    height: 18px;
    margin: 0;
    padding: 0 10px;
    border-radius: 999px;
    color: #fff;
    font-size: 12px;
    font-weight: 700;
    line-height: 1;
}

.partybutton-caption {
    display: block;
    color: inherit;
    font: inherit;
    line-height: 18px;
}

.votenumber {
    display: block;
    font-variant-numeric: tabular-nums;
    margin: 0;
    font-size: 12px;
    line-height: 18px;
    color: #222;
}

.votebox {
    min-width: 0;
    display: grid;
    row-gap: 2px;
    width: 100%;
}

.candidatebox-header {
    margin: 0 0 4px 0;
    line-height: 1.1;
}

.votebox.left {
    grid-column: 1;
    grid-row: 2;
    justify-self: stretch;
    align-self: center;
    grid-template-columns: 1fr auto 8px minmax(6ch, auto);
    grid-template-areas:
    "name name name name"
    ". party spacer num";
}

.votebox.left .partybutton {
    margin: 0;
}

.votebox.left .candidatebox {
    display: contents;
}

.votebox.left .candidatebox-header {
    grid-area: name;
    margin: 0;
    text-align: right;
    overflow-wrap: break-word;
}

.votebox.left .partybutton {
    grid-area: party;
    justify-self: start;
    margin: 0;
}

.votebox.left .votenumber {
    grid-area: num;
    display: block;
    margin: 0;
    text-align: right;
}

.votebox.right {
    grid-column: 3;
    grid-row: 2;
    justify-self: stretch;
    align-self: center;
    grid-template-columns: minmax(6ch, auto) 8px auto 1fr;
    grid-template-areas:
    "name name name name"
    "num spacer party .";
}

.votebox.right .candidatebox {
    display: contents;
}

.votebox.right .candidatebox-header {
    grid-area: name;
    margin: 0;
    text-align: left;
    overflow-wrap: break-word;
}

.votebox.right .partybutton {
    grid-area: party;
    justify-self: end;
    margin: 0;
}

.votebox.right .votenumber {
    grid-area: num;
    display: block;
    margin: 0;
    text-align: left;
}

.bar.current {
    grid-column: 2;
    grid-row: 2;
    align-self: center;
}

/* Default: pull the current row slightly upward so it lines up with single comparison rows. */
.barbox.current>.votebox,
.barbox.current>.bar.current {
    transform: translateY(-8px);
}

/* If there are two comparison rows on the left, drop the current bar row slightly so it sits between them.
   Leave the header in place; only move the row containing voteboxes + current bar. */
.electionbox:has(.sidebox.left>.barbox:not(.invalid)+.barbox:not(.invalid)) .barbox.current>.votebox,
.electionbox:has(.sidebox.left>.barbox:not(.invalid)+.barbox:not(.invalid)) .barbox.current>.bar.current {
    transform: translateY(24px);
}

.caption,
.header {
    box-sizing: border-box;
}

.red {
    background-color: red;
}

.blue {
    background-color: blue;
}

.green {
    background-color: green;
}

.yellow {
    background-color: yellow;
}

.black {
    background-color: black;
}

.white {
    background-color: white;
}

.gray {
    background-color: gray;
}

.grey {
    background-color: grey;
}

.purple {
    background-color: purple;
}

.orange {
    background-color: orange;
}

.Red {
    background-color: red;
}

.Blue {
    background-color: blue;
}

.Green {
    background-color: green;
}

.Yellow {
    background-color: yellow;
}

.Black {
    background-color: black;
}

.White {
    background-color: white;
}

.Gray {
    background-color: gray;
}

.Purple {
    background-color: purple;
}

.Orange {
    background-color: orange;
}

.white.segment,
.White.segment,
.white.partybutton,
.White.partybutton {
    color: #111;
}

.white .segment-caption,
.White .segment-caption {
    color: #111;
}

.unit.white,
.unit.White {
    outline: 1px solid #ddd;
    outline-offset: -1px;
}

.invalid {
    display: none;
}

.configbox {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 18px;
    align-items: center;
}

/* Global options stay at the top while scrolling (opaque so the page doesn't show through) */
.configbox.global {
    position: sticky;
    top: 0;
    z-index: 10;
    box-sizing: border-box;
    width: 1372px;
    margin: 0 0 14px 0;
    padding: 10px 12px;
    border-radius: 12px;
    background: #fafafa;
    border: 1px solid rgba(0, 0, 0, 0.08);
}

.electionbox>.configbox.election {
    grid-column: 2 / -1;
    grid-row: 1;
    width: max-content;
    justify-self: end;
    justify-content: flex-end;
    align-self: center;
    margin: 0;
    padding: 8px 10px;
    flex-wrap: nowrap;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.35);
    border: 1px solid rgba(0, 0, 0, 0.06);
}

body.dark-mode .configbox.global {
    background: #232323;
    border-color: rgba(255, 255, 255, 0.12);
}

body.dark-mode .electionbox>.configbox.election {
    background: rgba(255, 255, 255, 0.04);
    border-color: rgba(255, 255, 255, 0.10);
}

.configgroup {
    display: inline-grid;
    grid-template-columns: auto auto auto;
    column-gap: 6px;
    row-gap: 0;
    align-items: center;
    min-width: max-content;
}

.configgroup-header {
    margin: 0;
    grid-column: 1;
    font-size: 12px;
    line-height: 1.1;
    color: #555;
    font-weight: 600;
}

.configgroup.theme .configgroup-header,
.configgroup.sort .configgroup-header {
    grid-row: 1;
}

.configgroup.comparison .configgroup-header,
.configgroup.include .configgroup-header,
.configgroup.unopposed .configgroup-header {
    grid-row: 1 / span 2;
}

body.dark-mode .configgroup-header {
    color: #cfcfcf;
}

.configgroup-control-label {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin: 0;
    font-size: 12px;
    line-height: 1.05;
    color: inherit;
    white-space: nowrap;
    cursor: pointer;
}

.configgroup.comparison .configgroup-control-label,
.configgroup.include .configgroup-control-label,
.configgroup.unopposed .configgroup-control-label,
.configgroup.chamber .configgroup-control-label {
    display: inline-flex;
}

.configgroup.theme .configgroup-control-label,
.configgroup.sort .configgroup-control-label {
    grid-column: auto;
}

.configgroup.chamber {
    display: inline-flex;
    flex-direction: row;
    align-items: center;
    gap: 6px;
    min-width: max-content;
}

.configgroup.chamber .configgroup-header,
.configgroup.chamber .configgroup-control-label {
    grid-column: auto;
    grid-row: auto;
    margin: 0;
}

.configgroup.sort,
.configgroup.theme {
    display: inline-flex;
    flex-direction: row;
    align-items: center;
    gap: 6px;
    min-width: max-content;
}

.configgroup.sort .configgroup-header,
.configgroup.sort .configgroup-control,
.configgroup.theme .configgroup-header,
.configgroup.theme .configgroup-control {
    grid-column: auto;
    grid-row: auto;
    margin: 0;
}

.sort-direction-button,
.configgroup-control.button.direction.sort {
    margin: 0;
    min-height: 24px;
    padding: 0 10px;
    border: 1px solid rgba(0, 0, 0, 0.12);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.6);
    color: inherit;
    font-size: 12px;
    font-weight: 400;
    line-height: 1.05;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    vertical-align: middle;
    gap: 6px;
}

/* Arrow only (the value text is hidden; title/aria-label say asc/desc), same height as the dropdowns */
.configgroup-control.button.direction.sort {
    box-sizing: border-box;
    width: 24px;
    height: 24px;
    padding: 0;
    font-size: 0;
    color: transparent;
    background-repeat: no-repeat;
    background-position: center;
    align-self: center;
    top: 0; /* not the checkbox nudge: level with the dropdowns and the labels */
}

/* Asc arrow */
.configgroup-control.button.direction.sort[value*="asc"] {
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 16 16' fill='currentColor'><path d='M8 3l4 4H9v6H7V7H4l4-4z'/></svg>");
    background-repeat: no-repeat;
    background-position: center;
}

/* Desc arrow */
.configgroup-control.button.direction.sort[value*="desc"] {
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 16 16' fill='currentColor'><path d='M8 13l-4-4h3V3h2v6h3l-4 4z'/></svg>");
    background-repeat: no-repeat;
    background-position: center;
}

/* Light arrows on the dark theme (currentColor doesn't reach a data-URI image) */
body.dark-mode .configgroup-control.button.direction.sort[value*="asc"] {
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 16 16' fill='%23e8e8e8'><path d='M8 3l4 4H9v6H7V7H4l4-4z'/></svg>");
    background-repeat: no-repeat;
    background-position: center;
}

body.dark-mode .configgroup-control.button.direction.sort[value*="desc"] {
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 16 16' fill='%23e8e8e8'><path d='M8 13l-4-4h3V3h2v6h3l-4 4z'/></svg>");
    background-repeat: no-repeat;
    background-position: center;
}

.configgroup-control.button.direction.sort i,
.sort-direction-button i {
    font-size: 12px;
    line-height: 1;
    display: inline-flex;
    align-items: center;
}


body.dark-mode .sort-direction-button,
body.dark-mode .configgroup-control.button.direction.sort {
    background-color: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.14);
    color: inherit;
}

.configgroup-control-label input {
    order: -1;
    margin: 0;
    position: relative;
    top: -2px;
}

.configgroup-control-label select,
.configgroup-control.select {
    box-sizing: border-box;
    height: 24px;
    align-self: center;
    margin: 0;
    min-height: 24px;
    padding: 0 26px 0 10px;
    border: 1px solid rgba(0, 0, 0, 0.12);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.6);
    color: inherit;
    font-size: 12px;
    font-weight: 400;
    line-height: 1.05;
    vertical-align: middle;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background-image: linear-gradient(45deg, transparent 50%, currentColor 50%), linear-gradient(135deg, currentColor 50%, transparent 50%);
    background-position: calc(100% - 14px) 10px, calc(100% - 9px) 10px;
    background-size: 5px 5px, 5px 5px;
    background-repeat: no-repeat;
}

body.dark-mode .configgroup-control-label select,
body.dark-mode .configgroup-control.select {
    background-color: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.14);
}

.configgroup.theme .configgroup-control-label {
    font-size: 0;
}

.configgroup.theme .configgroup-control.select {
    font-size: 12px;
}
/* Same width as the race boxes (352 + 680 + 300 px plus two 20 px gaps); one column per comparison source */
.statsbox {
    display: grid;
    grid-template-columns: 1fr 1fr;
    column-gap: 20px;
    box-sizing: border-box;
    width: 1372px;
    margin: 0 0 14px 0;
    padding: 10px 12px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.55);
    border: 1px solid rgba(0, 0, 0, 0.08);
}

body.dark-mode .statsbox {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.12);
}

.statsbox-header {
    grid-column: 1 / -1;
    margin: 0 0 6px 0;
    font-size: 28px;
    font-weight: 700;
    line-height: 1.15;
}

.stats-source {
    min-width: 0;
    margin: 8px 0 0 0;
}

.stats-source-header {
    font-size: 13px;
    line-height: 1.2;
    color: #555;
    font-weight: 600;
    letter-spacing: 0.02em;
}

body.dark-mode .statsbox-header,
body.dark-mode .stats-source-header,
body.dark-mode .stats-label {
    color: #e8e8e8;
}

.stats-items {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 22px;
    margin: 4px 0;
}

.stats-label {
    font-size: 12px;
    line-height: 18px;
    color: #222;
}

.stats-value {
    line-height: 1.1;
}

/* Party colors come from the database (set as --left-color/--right-color by elections.js) */
.stats-right {
    color: var(--right-color, currentColor);
}

.stats-left {
    color: var(--left-color, currentColor);
}

/* Dark mode: mixed toward white so any party color stays readable */
body.dark-mode .stats-right {
    color: color-mix(in srgb, var(--right-color, currentColor) 60%, #fff);
}

body.dark-mode .stats-left {
    color: color-mix(in srgb, var(--left-color, currentColor) 60%, #fff);
}

.stats-empty {
    font-size: 12px;
    font-style: italic;
}

.stats-graph {
    display: block;
    width: 100%;
    height: auto;
}

.stats-grid {
    stroke: rgba(128, 128, 128, 0.25);
    stroke-width: 1;
}

.stats-axis {
    stroke: rgba(128, 128, 128, 0.8);
    stroke-width: 1;
}

.stats-tick {
    font-size: 10px;
    text-anchor: end;
    fill: #888;
}

.stats-tick-x {
    text-anchor: middle;
}

.stats-mean {
    fill: none;
    stroke: #888;
    stroke-width: 2;
    stroke-dasharray: 4 3;
}

.stats-dot {
    fill: #888;
    stroke: #fff;
    stroke-width: 1;
}

.stats-dot.stats-right {
    fill: var(--right-color, #888);
}

.stats-dot.stats-left {
    fill: var(--left-color, #888);
}

body.dark-mode .stats-dot.stats-right {
    fill: color-mix(in srgb, var(--right-color, #888) 75%, #fff);
}

body.dark-mode .stats-dot.stats-left {
    fill: color-mix(in srgb, var(--left-color, #888) 75%, #fff);
}

.footer {
    margin: 24px 0 0 0;
    padding: 12px 0 0 0;
    border-top: 1px solid #dcdcdc;
    font-size: 12px;
    line-height: 18px;
    color: #555;
}

.footer a {
    color: inherit;
}

body.dark-mode .footer {
    border-top-color: #3a3a3a;
    color: #aaa;
}

.intro {
    box-sizing: border-box;
    width: 1372px;
    margin: 0 0 14px 0;
    padding: 10px 12px;
}

.intro h1 {
    margin: 0 0 4px 0;
    font-size: 28px;
    line-height: 1.15;
}

.intro p {
    margin: 0;
    font-size: 13px;
    line-height: 1.4;
    color: #555;
}

body.dark-mode .intro p {
    color: #aaa;
}

/* Pinned statistics: sticky below the global options (top is set by elections.js) */
.statsbox.pinned {
    position: sticky;
    z-index: 9;
    background: #fafafa;
}

body.dark-mode .statsbox.pinned {
    background: #232323;
}

.statsbox-header {
    display: flex;
    align-items: center;
    gap: 10px;
}

.stats-pin {
    padding: 2px 6px;
    border: 1px solid #bbb;
    border-radius: 6px;
    background: #fff;
    font-size: 15px;
    line-height: 1;
    cursor: pointer;
    filter: grayscale(1);
    opacity: 0.7;
}

/* On: green (red and blue are the party colors); the red pin emoji is hue-shifted to green */
.stats-pin.active {
    border-color: #2a9d4b;
    background: #e6f6ea;
    filter: hue-rotate(110deg);
    opacity: 1;
}

body.dark-mode .stats-pin {
    border-color: #888;
    background: #3a3a3a;
    filter: grayscale(1) brightness(1.8);
    opacity: 1;
}

body.dark-mode .stats-pin.active {
    border-color: #4cc26b;
    background: #213a29;
    filter: hue-rotate(110deg);
}

/* Narrower screens (laptops): the middle column shrinks, names wrap, full-width boxes */
@media (max-width: 1419px) {
    .electionbox {
        grid-template-columns: 300px minmax(0, 1fr) 300px;
    }

    .statsbox,
    .intro,
    .configbox.global {
        width: auto;
    }

    .electionbox>.configbox.election {
        width: auto;
        max-width: 100%;
        flex-wrap: wrap;
        justify-self: stretch;
        justify-content: flex-start;
    }
}

/* Phones: one column per race (current result, then previous/president, then swings) */
@media (max-width: 759px) {
    body {
        padding: 12px;
    }

    .electionbox {
        grid-template-columns: minmax(0, 1fr);
        row-gap: 6px;
    }

    .electionbox-header,
    .electionbox>.sidebox,
    .electionbox>.barbox {
        grid-column: 1;
    }

    .electionbox-header {
        font-size: 22px;
    }

    /* Per-race options would crowd the screen; the global options still apply */
    .electionbox>.configbox.election {
        display: none;
    }

    .electionbox>.barbox.current {
        grid-row: 2;
    }

    .electionbox>.sidebox.left {
        grid-row: 3;
    }

    .electionbox>.sidebox.right,
    .electionbox>.sidebox.change {
        grid-row: 4;
    }

    .barbox.current {
        grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
        column-gap: 12px;
    }

    .barbox.current>.votebox.left {
        grid-column: 1;
        grid-row: 2;
    }

    .barbox.current>.votebox.right {
        grid-column: 2;
        grid-row: 2;
    }

    .barbox.current>.bar.current {
        grid-column: 1 / -1;
        grid-row: 3;
    }

    /* The desktop row offsets (incl. the :has() two-row rule) don't apply in one column */
    .barbox.current>.votebox,
    .barbox.current>.bar.current {
        transform: none !important;
    }

    .bar {
        max-width: 100%;
        margin: 0 auto;
    }

    /* Sticky options and pinned stats would fill the screen */
    .configbox.global,
    .statsbox.pinned {
        position: static;
    }

    .stats-pin {
        display: none;
    }

    .statsbox {
        grid-template-columns: minmax(0, 1fr);
    }

    .configgroup,
    .configgroup.chamber,
    .configgroup.sort,
    .configgroup.theme {
        min-width: 0;
        flex-wrap: wrap;
    }

    .intro h1 {
        font-size: 24px;
    }
}

/* Share button and menu (after the intro text) */
.share {
    position: relative;
    display: inline-block;
    margin: 0 0 0 8px;
    vertical-align: middle;
}

.share-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    width: 30px;
    height: 30px;
    padding: 0;
    border: 1px solid #bbb;
    border-radius: 50%;
    background: #fff;
    color: #333;
    cursor: pointer;
}

.share-menu {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    z-index: 20;
    display: flex;
    flex-direction: column;
    min-width: 140px;
    padding: 4px 0;
    border: 1px solid #ccc;
    border-radius: 8px;
    background: #fff;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.share-menu.invalid {
    display: none;
}

.share-item {
    display: block;
    padding: 6px 12px;
    border: 0;
    background: none;
    color: #111;
    font: inherit;
    font-size: 13px;
    text-align: left;
    text-decoration: none;
    cursor: pointer;
}

.share-item:hover,
.share-item:focus {
    background: #f0f0f0;
}

body.dark-mode .share-button,
body.dark-mode .share-menu {
    border-color: #555;
    background: #2a2a2a;
    color: #e8e8e8;
}

body.dark-mode .share-item {
    color: #e8e8e8;
}

body.dark-mode .share-item:hover,
body.dark-mode .share-item:focus {
    background: #3a3a3a;
}

/* "Flip!" badge (color from the winning party, set inline) */
/* In the empty (grey) half of the change bar, at its outer end */
.flip-badge {
    position: absolute;
    top: 50%;
    z-index: 4;
    transform: translateY(-50%);
    display: inline-block;
    margin: 0;
    padding: 1px 7px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 700;
    line-height: 1.4;
    vertical-align: middle;
    letter-spacing: 0;
}

.flip-badge-caption {
    display: inline;
}

.flip-badge.left {
    left: 8px;
}

.flip-badge.right {
    right: 8px;
}
