/* ===== GLOBAL SPACING SYSTEM ===== */
/* Consistent spacing for all content elements */

/* Base spacing for all content sections */
p, ul, ol, h1, h2, h3, h4, h5, h6 {
    margin-bottom: 1rem;
}

/* Consistent list formatting */
ul, ol {
    padding-left: 2rem;
    margin-bottom: 1.5rem;
}

li {
    margin-bottom: 0.5rem;
    line-height: 1.6;
}

/* Section spacing */
.section-header, h2.section-header {
    margin-top: 2rem;
    margin-bottom: 1rem;
}

/* Subsection spacing */
h3, h4 {
    margin-top: 1.5rem;
    margin-bottom: 0.75rem;
}



/* Table spacing */
table {
    margin: 2rem 0;
}

/* Ballot and form spacing */
.ballot-container, .vote-tuner, .allocation-steps {
    margin: 2.5rem 0;
}

/* ===== END GLOBAL SPACING SYSTEM ===== */

/* ===== FORM ELEMENT SPACING ===== */
/* Restore proper spacing for form elements that CSS reset affects */

input[type="radio"], input[type="checkbox"] {
    margin: 0.25rem 0.5rem 0.25rem 0;
    vertical-align: middle;
}

/* ===== SPECIFIC SECTION SPACING ===== */
/* Additional spacing for key sections that need more breathing room */

/* Real Example section spacing */
.real-example-section {
    margin-top: 3rem;
    margin-bottom: 3rem;
}

.real-example-section h4 {
    margin-top: 2.5rem;
    margin-bottom: 1.5rem;
}

/* Ballot section spacing */
.ballot-section {
    margin: 2.5rem 0;
}

.ballot-section p {
    margin-bottom: 2rem;
}

/* ===== EXISTING CSS STARTS BELOW ===== */

:root {
    --bg-color: #ffffff;
    --text-color: #555;
    --text-dark: #000;
    --header-bg: #437527;
    --highlight-bg: #f0f8f0;
    --demo-border: #ddd;
    --plurality-color: #d4351c;
    --proportional-color: #2c5aa0;
    --conservative-color: #1d70b8;
    --labour-color: #d4351c;
    --libdem-color: #f47738;
    --green-color: #00703c;
    --reform-color: #28a197;
    --border-color: #ddd;
}

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

html {
    font-size: 16px;
}

body {
    margin: 0;
    padding: 0;
    border-top: 0.5rem solid var(--header-bg);
    font-family: 'Source Sans Pro', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen-Sans, Ubuntu, Cantarell, 'Helvetica Neue', sans-serif;
    color: var(--text-color);
    line-height: 1.4;
    font-size: 1rem;
}

.container {
    margin: 1.25rem auto;
    max-width: 37.5rem;
    padding: 0 0.75rem;
}

@media (min-width: 68.75rem) {
    .container {
        max-width: 62.5rem;
    }
}

@media (min-width: 90rem) {
    .container {
        max-width: 80rem; /* Give more space for interactive elements */
    }
}

.govuk-header {
    background-color: var(--header-bg);
    border-bottom: none;
    margin-bottom: 2rem;
}

.govuk-header__container {
    padding: 0 0.75rem;
    max-width: 37.5rem;
    margin: 0 auto;
    display: flex;
    align-items: center;
    min-height: 3.75rem;
}

@media (min-width: 68.75rem) {
    .govuk-header__container {
        max-width: 62.5rem;
    }
}

.govuk-header__link--homepage {
    font-family: inherit;
    font-weight: 400;
    font-size: 1.75rem;
    line-height: 1.2;
    color: #ffffff;
    text-decoration: none;
}

.content {
    padding: 0;
    font-size: 1rem;
    line-height: 1.4;
}

.content p {
    margin: 1rem 0;
    line-height: 1.4;
}

.highlight {
    font-style: italic;
    margin: 1.875rem 0;
}

.interactive-hint {
    background: var(--highlight-bg);
    padding: 1rem;
    text-align: center;
    font-weight: bold;
    font-size: 1rem;
    margin-bottom: 1.875rem;
    border-radius: 0.25rem;
}

.section-title {
    font-size: 1.25rem;
    font-weight: bold;
    padding: 0.75rem 1rem;
    text-align: center;
    margin-bottom: 1rem;
    color: white;
    border-radius: 0.25rem;
}

.plurality-title {
    background: var(--plurality-color);
}

.proportional-title {
    background: var(--proportional-color);
}

.proportional-results {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.proportional-results .results-title {
    background: var(--proportional-color);
}

.chart-legend {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 1rem;
    margin-top: 1.25rem;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.legend-color {
    width: 1rem;
    height: 1rem;
}

.legend-text {
    font-size: 0.875rem;
}

.result-bar {
    margin: 0.5rem 0;
    position: relative;
    height: 1.5rem;
    background: var(--demo-border);
    overflow: hidden;
    border: none;
    border-radius: 0;
}

.bar {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    transition: width 0.5s ease;
}

.bar-text {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    padding-left: 0.5rem;
    font-weight: bold;
    font-size: 0.75rem;
    color: white;
    text-shadow: 1px 1px 1px rgba(0,0,0,0.5);
}

.bar-text.zero-votes {
    text-shadow: none;
    color: var(--text-color);
}

.conservative { background: var(--conservative-color); }
.labour { background: var(--labour-color); }
.liberal-democrats { background: var(--libdem-color); }
.green { background: var(--green-color); }
.reform-uk { background: var(--reform-color); }

.winner-announcement {
    text-align: center;
    font-weight: bold;
    font-size: 1rem;
    margin-top: 1rem;
    padding: 0.75rem;
    border-radius: 0.25rem;
}

.plurality-winner {
    color: var(--plurality-color);
    border: none;
}

.proportional-winner {
    color: var(--proportional-color);
    border: none;
}

.section-header {
    font-size: 1.5rem;
    color: var(--text-dark);
    margin: 2.5rem 0 1.25rem 0;
    border-bottom: 2px solid var(--header-bg);
    padding-bottom: 0.5rem;
    font-weight: normal;
}

.data-link {
    color: var(--proportional-color);
    text-decoration: none;
    font-weight: bold;
}

.data-link:hover {
    text-decoration: underline;
}

.ballot-container {
    display: flex;
    flex-direction: column;
    gap: 1.875rem;
    justify-content: center;
    margin: 1.875rem 0;
}

@media (min-width: 48rem) {
    .ballot-container {
        flex-direction: row;
        gap: 1.875rem;
    }
}

.ballot {
    background: var(--bg-color);
    border: none;
    padding: 1rem;
    width: 100%;
    font-size: 0.875rem;
    transition: border-color 0.3s ease;
    cursor: pointer;
    border-radius: 0.25rem;
    margin-bottom: 1rem;
}

@media (min-width: 48rem) {
    .ballot {
        width: 200px;
    }
}

.ballot:hover {
    border-color: var(--proportional-color);
}

.ballot h4 {
    text-align: center;
    margin-bottom: 0.5rem;
    font-size: 0.875rem;
    border-bottom: 1px solid var(--demo-border);
    padding-bottom: 0.25rem;
}

.candidate-option {
    margin: 0.25rem 0;
    display: flex;
    align-items: center;
}

.candidate-option input {
    margin-right: 0.5rem;
    transform: scale(1.1);
    cursor: pointer;
}

.candidate-option label {
    cursor: pointer;
    font-size: 0.8rem;
    flex: 1;
}

.results-box {
    flex: 1;
    padding: 1.25rem;
    border: none;
    border-radius: 0;
    margin-bottom: 1rem;
    background: transparent;
}

.results-title {
    text-align: center;
    font-weight: bold;
    margin-bottom: 1rem;
    font-size: 1.125rem;
    padding: 0.5rem;
    color: white;
    border-radius: 0.25rem;
}

.plurality-results .results-title {
    background: var(--plurality-color);
}

.proportional-results .results-title {
    background: var(--proportional-color);
}

.ballot-box {
    padding: 1.5rem;
    border: none;
    border-radius: 0;
    flex: 1;
    background: transparent;
}

.ballot-box--plurality {
    border-color: var(--plurality-color);
}

.ballot-box--proportional {
    border-color: var(--proportional-color);
}

.ballot-title {
    text-align: center;
    margin-bottom: 1.5rem;
}

.ballot-title h3 {
    margin: 0 0 0.25rem 0;
    font-size: 1.125rem;
    font-weight: bold;
}

.ballot-title--plurality h3 {
    color: var(--plurality-color);
}

.ballot-title--proportional h3 {
    color: var(--proportional-color);
}

.ballot-subtitle {
    font-size: 0.875rem;
    margin: 0;
    color: var(--text-color);
}

.ballot-subtitle span {
    font-weight: bold;
}

.ballot-subtitle--plurality span {
    color: var(--plurality-color);
}

.ballot-subtitle--proportional span {
    color: var(--proportional-color);
}

.ballot-options {
    font-size: 1rem;
    line-height: 1.5;
}

.ballot-option {
    display: flex;
    align-items: center;
    margin-bottom: 1.25rem;
    padding: 0.75rem 0;
}

.ballot-option:last-child {
    margin-bottom: 0;
}

.ballot-option input[type="radio"] {
    margin-right: 1rem;
    transform: scale(1.2);
}

.ballot-option label {
    font-size: 1rem;
    line-height: 1.5;
    cursor: pointer;
    user-select: none;
    padding: 0.25rem 0;
}

.ballot-option:hover {
    background-color: rgba(0, 0, 0, 0.02);
    border-radius: 4px;
    padding: 0.75rem;
    margin: 0 0 0.5rem 0;
}

.ballot-radio, .ballot-checkbox {
    width: 1.25rem;
    height: 1.25rem;
    border: 2px solid var(--text-color);
    margin-right: 0.75rem;
    flex-shrink: 0;
}

.ballot-radio {
    border-radius: 50%;
}

.ballot-checkbox {
    position: relative;
    border-radius: 0.125rem;
}

.ballot-checkbox--checked {
    background: var(--text-color);
}

.ballot-checkbox--checked::after {
    content: '✓';
    color: white;
    font-size: 0.75rem;
    line-height: 1rem;
    text-align: center;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

.ballot-label {
    font-size: 1rem;
    font-weight: normal;
}

.ballot-label--libdem {
    color: var(--libdem-color);
    font-weight: bold;
}

.spoiler-warning, .favorites-message, .proportional-message {
    padding: 0.75rem;
    text-align: center;
    margin-top: 1rem;
    font-weight: bold;
    font-size: 0.875rem;
    border-radius: 0.25rem;
}

.spoiler-warning {
    background: #ffdde1;
    color: var(--plurality-color);
}

.favorites-message {
    background: var(--highlight-bg);
    color: var(--proportional-color);
}

.proportional-message {
    background: var(--highlight-bg);
    color: var(--proportional-color);
}

/* Mobile improvements */
@media (max-width: 47.9375rem) {
    .content {
        padding: 0;
    }
    
    .ballot-container {
        flex-direction: column;
    }
    
    .ballot-box {
        margin-bottom: 1rem;
    }
    
    .results-box {
        margin-bottom: 1rem;
    }
    
    .section-header {
        font-size: 1.25rem;
        margin: 2rem 0 1rem 0;
    }
    
    .ballot {
        width: 100%;
        margin-bottom: 0.5rem;
    }
    
    .ballot-options {
        font-size: 0.875rem;
    }
    
    .ballot-label {
        font-size: 0.875rem;
    }
    
    .govuk-header__link--homepage {
        font-size: 1.5rem;
    }
    
    .ballot-radio, .ballot-checkbox {
        width: 1.125rem;
        height: 1.125rem;
    }
    
    .ballot-checkbox--checked::after {
        font-size: 0.625rem;
        line-height: 0.875rem;
    }
}

/* Responsive grid for demo ballots */
@media (max-width: 47.9375rem) {
    #plurality-ballots,
    #proportional-ballots {
        display: grid;
        grid-template-columns: 1fr;
        gap: 0.75rem;
    }
}

@media (min-width: 48rem) and (max-width: 68.6875rem) {
    #plurality-ballots,
    #proportional-ballots {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 0.75rem;
        max-width: 400px;
        margin: 0 auto;
    }
}

@media (min-width: 68.75rem) {
    #plurality-ballots,
    #proportional-ballots {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 0.75rem;
    }
}

/* Responsive results layout */
.results-layout {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

@media (min-width: 68.75rem) {
    .results-layout {
        flex-direction: row;
    }
}

/* Demo section layout */
.demo-section {
    display: flex;
    flex-direction: column;
    gap: 2rem;
    margin: 2rem 0;
}



.demo-column {
    flex: 1;
}

.demo-column .section-title {
    margin-bottom: 1rem;
}

/* Chart responsiveness */
#proportional-chart svg {
    max-width: 100%;
    height: auto;
}

@media (max-width: 47.9375rem) {
    #proportional-chart svg {
        width: 100%;
        height: 200px;
    }
}

/* Mobile Parliamentary Chart */
.mobile-parliament-chart {
    width: 100%;
    max-width: 600px;
    margin: 0 auto;
    padding: 1rem;
    box-sizing: border-box;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.parliament-canvas {
    width: 100%;
    height: auto;
    display: block;
    max-width: 100%;
    margin: 0 auto;
}

/* Ensure both charts have exactly the same visual weight and sizing */
#official-fptp-chart,
#official-pr-chart {
    min-height: 300px;
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
}

/* Force consistent chart dimensions */
#official-fptp-chart .mobile-parliament-chart,
#official-pr-chart .mobile-parliament-chart {
    width: 100%;
    max-width: 600px;
    min-height: 300px;
}

/* Ensure canvas elements are identical in size */
#official-fptp-chart .parliament-canvas,
#official-pr-chart .parliament-canvas {
    width: 100% !important;
    max-width: 600px !important;
    height: auto !important;
}

/* Fix height difference by making Fair Share chart more compact */
#official-pr-chart .mobile-parliament-chart {
    padding: 0.5rem;
}

#official-pr-chart .parliament-legend {
    margin-top: 0.75rem;
    padding: 0.75rem;
}

/* Consistent legend styling */
.parliament-legend {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 1rem;
    margin-top: 1rem;
    padding: 1rem;
    background: rgba(0,0,0,0.02);
    border-radius: 0.5rem;
    border: 1px solid var(--border-color);
    max-width: 600px;
    margin-left: auto;
    margin-right: auto;
}

.parliament-legend .legend-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    padding: 0.25rem 0.5rem;
    background: white;
    border-radius: 0.25rem;
    border: 1px solid var(--border-color);
    transition: all 0.2s ease;
}

.parliament-legend .legend-item:hover {
    background: var(--highlight-bg);
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.parliament-legend .legend-color {
    width: 1rem;
    height: 1rem;
    border-radius: 50%;
    border: 1px solid rgba(0,0,0,0.1);
}

.parliament-legend .legend-label {
    font-size: 0.875rem;
}

/* Transfer steps styling */
.transfer-steps {
    margin-top: 1rem;
    padding: 1rem;
    background: #f8f9fa;
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    font-size: 0.95rem;
}
.transfer-steps h4 {
    margin: 0 0 0.5rem 0;
    color: var(--proportional-color);
}
.transfer-steps .step {
    margin: 0.4rem 0;
}

/* Sankey container */
.transfer-sankey {
    margin-top: 1rem;
    padding: 1rem;
    background: #fff;
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
}
.transfer-sankey svg {
    width: 100%;
    height: 360px;
}

/* Vote tuner */
.vote-tuner {
    margin-top: 1rem;
    padding: 1rem;
    background: #fff;
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
}
.vote-tuner h4 { margin: 0 0 0.5rem 0; color: var(--text-dark); }
.vote-total { margin-top: 0.5rem; font-size: 0.9rem; color: #333; }

/* Table layout for tuner */
.vote-table { width: 100%; border-collapse: collapse; margin-top: 0.5rem; }
.vote-table th, .vote-table td { padding: 0.5rem; border-bottom: none; vertical-align: middle; }
.vote-table th { text-align: left; color: var(--text-dark); }
.vote-table .controls { display: grid; grid-template-columns: 1fr 120px; gap: 0.5rem; align-items: center; }
.vote-table input[type="range"] { width: 100%; accent-color: var(--proportional-color); }
.vote-table input[type="text"] { width: 100%; padding: 0.35rem 0.45rem; }
.vote-table select { width: 100%; padding: 0.35rem 0.45rem; }

/* Responsive adjustments for mobile */
@media (max-width: 47.9375rem) {
    .mobile-parliament-chart {
        padding: 0.5rem;
    }
    
    .parliament-legend {
        gap: 0.5rem;
        padding: 0.75rem;
    }
    
    .parliament-legend .legend-item {
        font-size: 0.75rem;
        padding: 0.125rem 0.375rem;
    }
    
    .parliament-legend .legend-label {
        font-size: 0.75rem;
    }
}

/* Proportional Approval Voting Explanation Styles */
.pav-explanation {
    margin: 2rem 0;
}

.pav-explanation h3 {
    color: var(--proportional-color);
    font-size: 1.5rem;
    margin: 2rem 0 1rem 0;
}

.ballot-example {
    display: flex;
    flex-direction: column;
    gap: 2rem;
    margin: 2rem auto;
    max-width: 500px;
}



.ballot-part {
    flex: 1;
    background: #f9f9f9;
    border: none;
    border-radius: 0;
    padding: 1.5rem;
}

.ballot-part h4 {
    color: var(--text-dark);
    margin-bottom: 1rem;
}

.party-list, .candidate-list {
    list-style: none;
    padding: 0;
}



.party-checkbox, .candidate-checkbox {
    margin-right: 0.75rem;
    width: 1.25rem;
    height: 1.25rem;
    cursor: pointer;
}

.party-list label, .candidate-list label {
    cursor: pointer;
    flex: 1;
}

.candidate-approval {
    background: white;
    padding: 1rem;
    border-radius: 0.25rem;
    border: none;
}

.hint {
    color: var(--proportional-color);
    font-size: 0.9rem;
    font-style: italic;
    margin-top: 0.5rem;
}

.allocation-steps {
    margin: 2rem 0;
}

.step {
    display: flex;
    gap: 1rem;
    align-items: flex-start;
}

.step-number {
    background: var(--proportional-color);
    color: white;
    width: 2.5rem;
    height: 2.5rem;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    flex-shrink: 0;
}

.step-content h4 {
    margin: 0 0 0.5rem 0;
    color: var(--text-dark);
}

.step-content p {
    margin: 0;
    color: var(--text-color);
}

.results-table {
    width: 100%;
    border-collapse: collapse;
    margin: 2rem 0;
    overflow-x: auto;
    display: block;
}

@media (min-width: 48rem) {
    .results-table {
        display: table;
    }
}

.results-table thead {
    background: var(--proportional-color);
    color: white;
}

.results-table th, .results-table td {
    padding: 0.75rem;
    text-align: left;
    border: 1px solid var(--border-color);
}

.results-table tbody tr:nth-child(even) {
    background: #f9f9f9;
}

.results-table tbody tr:hover {
    background: var(--highlight-bg);
}

.pav-benefits {
    background: var(--highlight-bg);
    padding: 2rem;
    border-radius: 0.5rem;
    margin: 2rem 0;
}

.pav-benefits h3 {
    margin-top: 0;
}

    

    .spav-explanation {
        background: var(--highlight-bg);
        border: 1px solid var(--border-color);
        border-radius: 0.5rem;
        padding: 1.5rem;
        margin: 2rem 0;
    }

    .spav-explanation h4 {
        color: var(--text-color);
        margin: 0 0 0.75rem 0;
        font-size: 1.1rem;
    }

    .spav-explanation p {
        margin: 0 0 0.75rem 0;
    }

    

    .spav-explanation li {
        margin: 0.5rem 0;
    }

.pav-benefits li {
    margin-bottom: 0.75rem;
    line-height: 1.6;
}

/* RCV/STV Comparison Styles */
.comparison-section {
    margin: 2rem 0;
}

.comparison-grid {
    display: grid;
    gap: 2rem;
    margin: 2rem 0;
}

@media (min-width: 68.75rem) {
    .comparison-grid {
        grid-template-columns: 1fr 1fr;
    }
}

.comparison-item {
    border: 2px solid var(--border-color);
    border-radius: 0.5rem;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.comparison-item h3 {
    background: var(--proportional-color);
    color: white;
    margin: 0;
    padding: 1rem;
    font-size: 1.25rem;
}

.comparison-content {
    display: grid;
    grid-template-columns: 1fr 1fr;
    flex: 1;
}

@media (max-width: 47.9375rem) {
    .comparison-content {
        grid-template-columns: 1fr;
    }
}

.rcv-side, .proportional-side {
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
}

.rcv-side {
    background: #fff5f5;
    border-right: 1px solid var(--border-color);
}

.proportional-side {
    background: var(--highlight-bg);
}

@media (max-width: 47.9375rem) {
    .rcv-side {
        border-right: none;
        border-bottom: 1px solid var(--border-color);
    }
}

.rcv-side h4 {
    color: var(--plurality-color);
    margin: 0 0 1rem 0;
}

.proportional-side h4 {
    color: var(--proportional-color);
    margin: 0 0 1rem 0;
}





.real-world-examples {
    margin: 3rem 0;
}

.real-world-examples h3 {
    color: var(--proportional-color);
    font-size: 1.5rem;
    margin-bottom: 1.5rem;
}

.example-grid {
    display: grid;
    gap: 1.5rem;
    margin-bottom: 2rem;
}

@media (min-width: 48rem) {
    .example-grid {
        grid-template-columns: 1fr 1fr;
    }
}

.example {
    background: #f9f9f9;
    padding: 1.5rem;
    border-radius: 0.5rem;
    border-left: 4px solid var(--proportional-color);
}

.example h4 {
    margin: 0 0 0.5rem 0;
    color: var(--text-dark);
}

.example p {
    margin: 0;
    color: var(--text-color);
}

.key-takeaway {
    background: var(--highlight-bg);
    border: 2px solid var(--proportional-color);
    border-radius: 0.5rem;
    padding: 2rem;
    margin: 2rem 0;
}

.key-takeaway h3 {
    color: var(--proportional-color);
    margin: 0 0 1rem 0;
}

.key-takeaway p {
    margin: 0 0 1rem 0;
}

.key-takeaway p:last-child {
    margin: 0;
}

/* Legislative Section Styles */
.legislative-section {
    margin: 2rem 0;
}

.legislative-section h3 {
    color: var(--text-color);
    margin: 2rem 0 1rem 0;
    font-size: 1.5rem;
}

.legislative-section h4 {
    color: var(--text-color);
    margin: 1.5rem 0 0.75rem 0;
    font-size: 1.25rem;
}

.legislative-section h5 {
    color: var(--text-color);
    margin: 1.25rem 0 0.5rem 0;
    font-size: 1.1rem;
    font-weight: 600;
}

.definition-box {
    background: var(--highlight-bg);
    border: 2px solid var(--proportional-color);
    border-radius: 0.5rem;
    padding: 1.5rem;
    margin: 1rem 0;
}

.definition-box h4 {
    margin-top: 0;
    color: var(--proportional-color);
}

.definition-box p {
    margin-bottom: 0;
}

.legal-text {
    background: #f8f9fa;
    border-left: 4px solid var(--border-color);
    padding: 1.5rem;
    margin: 1rem 0;
    border-radius: 0.25rem;
}

.legal-quote {
    font-style: italic;
    color: #495057;
    margin: 0.5rem 0;
}

.legal-list {
    margin: 1rem 0 1rem 1.5rem;
    line-height: 1.8;
}

.legal-list li {
    margin: 0.5rem 0;
}



.distinction-box {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
    background: #f8f9fa;
    padding: 1.5rem;
    border-radius: 0.5rem;
    margin: 1rem 0;
}

.distinction-box p {
    margin: 0 0 0.75rem 0;
    font-weight: 600;
}



.distinction-box li {
    margin: 0.5rem 0;
}

.timeline-box {
    background: var(--highlight-bg);
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    padding: 1.5rem;
    margin: 1rem 0;
}

.timeline-box p {
    margin: 0.75rem 0;
    line-height: 1.6;
}

.timeline-box p:first-child {
    margin-top: 0;
}

.timeline-box p:last-child {
    margin-bottom: 0;
}

/* Mobile responsiveness for legislative section */
@media (max-width: 47.9375rem) {
    .distinction-box {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }

    .legal-text {
        padding: 1rem;
    }

    .legislative-section h3 {
        font-size: 1.25rem;
    }

    .legislative-section h4 {
        font-size: 1.1rem;
    }

    .legislative-section h5 {
        font-size: 1rem;
    }
}

.vote-tuner-table {
    width: 100%;
    border-collapse: collapse;
    margin: 1rem 0;
}

.vote-tuner-table th,
.vote-tuner-table td {
    padding: 0.5rem;
    text-align: left;
    border-bottom: 1px solid #ddd;
}

.vote-tuner-table th {
    background-color: #f5f5f5;
    font-weight: 600;
}

.vote-tuner-table th:nth-child(1) { width: 20%; } /* Party */
.vote-tuner-table th:nth-child(2) { width: 45%; } /* Votes */
.vote-tuner-table th:nth-child(3) { width: 15%; } /* % of Total */
.vote-tuner-table th:nth-child(4) { width: 20%; } /* Transfers To */

.vote-input-cell {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.vote-slider {
    width: 100%;
    min-width: 120px;
    height: 6px;
    accent-color: var(--proportional-color);
}

.vote-number-input {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 0.9rem;
    min-width: 100px;
}

.transfer-pref-select {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 0.9rem;
    min-width: 80px;
}

.percentage-display {
    font-weight: 500;
    color: #666;
}

.vote-tuner-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 1rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.total-votes-display {
    font-weight: 600;
    color: #333;
}

.vote-tuner-controls button {
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: background-color 0.2s;
}

.vote-tuner-controls button:first-of-type {
    background-color: var(--proportional-color);
    color: white;
}

.vote-tuner-controls button:last-of-type {
    background-color: #6c757d;
    color: white;
}

.vote-tuner-controls button:hover {
    opacity: 0.9;
}

/* Mobile optimizations */
@media (max-width: 768px) {
    .vote-tuner-table th:nth-child(1) { width: 25%; } /* Party */
    .vote-tuner-table th:nth-child(2) { width: 40%; } /* Votes */
    .vote-tuner-table th:nth-child(3) { width: 20%; } /* % of Total */
    .vote-tuner-table th:nth-child(4) { width: 15%; } /* Transfers To */
    
    .vote-slider {
        min-width: 80px;
        height: 8px; /* Slightly larger for mobile touch */
    }
    
    .vote-number-input,
    .transfer-pref-select {
        min-width: 60px;
        font-size: 0.8rem;
    }
    
    .vote-tuner-controls {
        flex-direction: column;
        align-items: stretch;
    }
    
    .vote-tuner-controls button {
        width: 100%;
        margin: 0.25rem 0;
    }
}

/* Collapsible sections */
.collapsible-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    padding: 0.5rem 0;
    border-bottom: 1px solid #eee;
    margin-bottom: 1rem;
}

.collapsible-header h3,
.collapsible-header h4 {
    margin: 0;
    cursor: pointer;
}

.collapsible-header:hover {
    background-color: #f8f9fa;
    border-radius: 4px;
    padding: 0.5rem;
    margin: 0 0 1rem 0;
}

.collapse-toggle {
    background: var(--proportional-color);
    color: white;
    border: none;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s;
}

.collapse-toggle:hover {
    background-color: #0056b3;
}

.collapsible-content {
    display: block;
    transition: all 0.3s ease;
    overflow: hidden;
}

.collapsible-content.collapsed {
    display: none;
}

/* Ensure content is visible by default */
#vote-tuner-content,
#allocation-steps-content {
    display: block;
}

/* Ensure containers maintain consistent width but allow height to collapse */
.vote-tuner,
.transfer-steps {
    width: 100%;
    overflow: hidden;
}

/* When collapsed, hide content but maintain container structure */
.collapsible-content.collapsed {
    display: none !important;
    height: 0;
    overflow: hidden;
}

/* Ensure headers maintain consistent height */
.collapsible-header {
    min-height: 60px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    padding: 1rem 0;
    border-bottom: 1px solid #eee;
    margin-bottom: 1rem;
    background-color: transparent;
}

/* When content is collapsed, remove bottom border and adjust spacing */
.collapsible-header:has(+ .collapsible-content.collapsed) {
    border-bottom: none;
    margin-bottom: 0;
}

/* Vote tuner specific styles - now styled as a section header */
.vote-tuner {
    margin: 2rem 0;
    border: none;
    background: transparent;
}

.vote-tuner .collapsible-content {
    padding: 0;
}

/* Transfer steps specific styles - now styled as a section header */
.transfer-steps {
    background: var(--highlight-bg);
    border: 1px solid var(--demo-border);
    border-radius: 8px;
    padding: 1.5rem;
    margin: 2rem 0;
}

.transfer-steps .collapsible-content {
    margin-top: 1rem;
}

/* ===== NEW TRANSFER EXPLANATION STYLES ===== */

.transfer-explanation {
    background: var(--highlight-bg);
    border: 1px solid var(--demo-border);
    border-radius: 8px;
    padding: 1.5rem;
    margin: 2rem 0;
}

.transfer-explanation h4 {
    color: var(--proportional-color);
    margin-bottom: 1rem;
}

.transfer-explanation ul {
    margin-bottom: 0;
}

.transfer-explanation li {
    margin-bottom: 0.75rem;
}

.transfer-timing {
    background: rgba(255, 255, 255, 0.7);
    border: 1px solid var(--demo-border);
    border-radius: 6px;
    padding: 1.25rem;
    margin-top: 1.5rem;
}

.transfer-timing h5 {
    color: var(--proportional-color);
    margin-bottom: 0.75rem;
    font-size: 1.1rem;
}

.transfer-timing p {
    margin-bottom: 0.75rem;
    font-size: 0.95rem;
    line-height: 1.5;
}

.transfer-timing p:last-child {
    margin-bottom: 0;
}

.transfer-explanation-demo {
    background: var(--highlight-bg);
    border: 1px solid var(--demo-border);
    border-radius: 8px;
    padding: 1.5rem;
    margin: 2rem 0;
}

.transfer-explanation-demo h4 {
    color: var(--proportional-color);
    margin-bottom: 1rem;
}

.transfer-explanation-demo ul {
    margin-bottom: 0;
}

.transfer-explanation-demo li {
    margin-bottom: 0.75rem;
}

/* ===== REGIONAL BENEFITS STYLES ===== */

.regional-benefits {
    background: var(--highlight-bg);
    border: 1px solid var(--demo-border);
    border-radius: 8px;
    padding: 1.5rem;
    margin: 2rem 0;
}

.regional-benefits h3 {
    color: var(--proportional-color);
    margin-bottom: 1rem;
}

.regional-benefits ul {
    margin-bottom: 0;
}

.regional-benefits li {
    margin-bottom: 0.75rem;
}

/* Subsection headers - consistent with main section headers but smaller */
.subsection-header {
    font-size: 1.25rem;
    color: var(--text-dark);
    margin: 2rem 0 1rem 0;
    font-weight: 600;
}

/* Fix ballot spacing by overriding the CSS reset */
.ballot-option {
    display: flex;
    align-items: center;
    margin-bottom: 1.25rem !important;
    padding: 0.75rem 0 !important;
}

.ballot-option:last-child {
    margin-bottom: 0 !important;
}

.ballot-option input[type="radio"] {
    margin-right: 1rem !important;
    transform: scale(1.2);
}

.ballot-option label {
    font-size: 1rem !important;
    line-height: 1.5 !important;
    cursor: pointer;
    user-select: none;
    padding: 0.25rem 0 !important;
}

.ballot-option:hover {
    background-color: rgba(0, 0, 0, 0.02);
    border-radius: 4px;
    padding: 0.75rem !important;
    margin: 0 0 0.5rem 0 !important;
}

/* Ensure consistent sizing for parliamentary charts */
.mobile-parliament-chart {
    width: 100%;
    max-width: 600px;
    margin: 0 auto;
}

.parliament-canvas {
    width: 100% !important;
    height: auto !important;
    max-width: 600px;
}

/* Ensure both charts have the same visual weight */
#official-fptp-chart,
#official-pr-chart {
    min-height: 300px;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* Consistent legend styling */
.parliament-legend {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 1rem;
    margin-top: 1.25rem;
    max-width: 600px;
    margin-left: auto;
    margin-right: auto;
}

.parliament-legend.compact {
    gap: 0.5rem;
    font-size: 0.8rem;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
}

.parliament-legend.compact .legend-item {
    font-size: 0.75rem;
    gap: 0.25rem;
}

.legend-color {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    border: 2px solid white;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.parliament-legend.compact .legend-color {
    width: 12px;
    height: 12px;
    border-width: 1px;
}

.legend-label {
    font-weight: 500;
}

/* Demo Section Styles */
.demo-section {
    margin: 2rem 0;
    width: 100%;
    overflow-x: hidden; /* Prevent horizontal overflow */
}

.demo-intro {
    text-align: center;
    margin-bottom: 2rem;
    color: var(--text-dark);
}

.demo-intro h3 {
    margin-bottom: 1rem;
    color: var(--header-bg);
    font-size: 1.5rem;
}

.demo-intro p {
    font-size: 1.1rem;
    margin: 0;
}



.chart-container {
    margin-bottom: 1rem;
}

.parliament-chart.compact {
    max-width: 400px; /* Slightly larger since we have more space */
    margin: 0 auto;
}

.winner-display.compact {
    font-size: 0.9rem;
    padding: 0.75rem;
    margin: 0;
}

/* Custom Scenario Styles */
.custom-scenario-form {
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 2rem;
    text-align: center;
}

.custom-scenario-form h3 {
    color: var(--text-dark);
    margin-bottom: 1rem;
}

.placeholder-content {
    margin-top: 1.5rem;
    text-align: left;
    max-width: 600px;
    margin-left: auto;
    margin-right: auto;
}



.placeholder-content li {
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--border-color);
    position: relative;
    padding-left: 1.5rem;
}

.placeholder-content li:before {
    content: "✓";
    color: var(--header-bg);
    font-weight: bold;
    position: absolute;
    left: 0;
}

.placeholder-content li:last-child {
    border-bottom: none;
}

@media (max-width: 768px) {
    .parliament-chart.compact {
        max-width: 300px; /* Slightly smaller on mobile */
    }
    
    .vote-tuner {
        padding: 1.5rem;
        margin: 1.5rem 0;
    }
    
    .vote-tuner h3 {
        font-size: 1.2rem;
    }
    
    .allocation-steps {
        padding: 1rem;
        margin: 1.5rem 0;
    }
    
    .allocation-steps h3 {
        font-size: 1.2rem;
    }
}

@media (max-width: 480px) {
    .parliament-chart.compact {
        max-width: 250px; /* Smallest size for mobile */
    }
    
    .vote-tuner {
        padding: 1rem;
    }
    
    .vote-tuner h3 {
        font-size: 1.1rem;
    }
    
    .tuner-description {
        font-size: 0.9rem;
    }
}

/* Vote Tuner Styles */
.vote-tuner {
    background: var(--highlight-bg);
    padding: 2rem; /* Increased padding for more space */
    border-radius: 8px;
    margin: 2rem 0;
    min-width: 0; /* Prevent overflow */
    width: 100%;
    border: 2px solid var(--header-bg);
}

.vote-tuner h3 {
    margin-bottom: 1rem;
    color: var(--text-dark);
    font-size: 1.3rem;
    text-align: center;
}

.tuner-description {
    text-align: center;
    margin-bottom: 1.5rem;
    color: var(--text-color);
    font-style: italic;
}

/* Vote Tuner Table Wrapper */
.vote-tuner-table-wrapper {
    width: 100%;
    overflow-x: auto; /* Allow horizontal scrolling when needed */
    margin-bottom: 1rem;
    border-radius: 4px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.vote-input-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 0; /* Remove margin since wrapper handles it */
    background: white;
    border-radius: 4px;
    overflow: hidden;
    box-shadow: none; /* Remove shadow since wrapper has it */
    min-width: 600px; /* Ensure minimum width for controls */
    table-layout: fixed; /* Better column width control */
}

.vote-input-table th,
.vote-input-table td {
    padding: 0.75rem;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
    white-space: nowrap; /* Prevent text wrapping */
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Set specific column widths */
.vote-input-table th:nth-child(1),
.vote-input-table td:nth-child(1) {
    width: 20%; /* Party name */
}

.vote-input-table th:nth-child(2),
.vote-input-table td:nth-child(2) {
    width: 35%; /* Vote controls */
}

.vote-input-table th:nth-child(3),
.vote-input-table td:nth-child(3) {
    width: 15%; /* Percentage */
}

.vote-input-table th:nth-child(4),
.vote-input-table td:nth-child(4) {
    width: 30%; /* Transfer preferences */
}

.vote-input-table th {
    background-color: var(--header-bg);
    color: white;
    font-weight: 600;
}

.vote-input-table tr:hover {
    background-color: #f8f9fa;
}

.vote-input-cell {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    min-width: 200px; /* Ensure minimum width for controls */
    width: 100%;
}

.vote-slider {
    flex: 1;
    min-width: 120px; /* Increased minimum width */
    max-width: 200px; /* Prevent excessive stretching */
    height: 6px; /* Ensure consistent height */
    -webkit-appearance: none;
    appearance: none;
    background: #ddd;
    outline: none;
    border-radius: 3px;
}

.vote-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    background: var(--header-bg);
    cursor: pointer;
    border-radius: 50%;
}

.vote-slider::-moz-range-thumb {
    width: 18px;
    height: 18px;
    background: var(--header-bg);
    cursor: pointer;
    border-radius: 50%;
    border: none;
}

.vote-number-input {
    width: 100px; /* Increased width for better readability */
    padding: 0.5rem;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    text-align: right;
    font-size: 0.9rem;
    min-width: 80px; /* Ensure minimum width */
}

.transfer-pref-select {
    padding: 0.5rem;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    background: white;
    min-width: 120px; /* Ensure dropdown has enough space */
    font-size: 0.9rem;
    width: 100%; /* Take full width of column */
}

.vote-controls {
    display: flex;
    gap: 1rem;
    align-items: center;
    flex-wrap: wrap;
}

.btn {
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 600;
    transition: all 0.2s ease;
}

.btn-primary {
    background-color: var(--header-bg);
    color: white;
}

.btn-primary:hover {
    background-color: #2d5a1a;
}

.btn-secondary {
    background-color: #6c757d;
    color: white;
}

.btn-secondary:hover {
    background-color: #5a6268;
}

.total-votes {
    font-weight: 600;
    color: var(--text-dark);
    margin-left: auto;
}

/* Allocation Steps Styles */
.allocation-steps {
  margin: 2rem 0;
  background: white;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 1.5rem;
}

.allocation-steps h3 {
  margin-bottom: 1rem;
  color: var(--text-dark);
  text-align: center;
  font-size: 1.3rem;
}

.allocation-steps p {
  text-align: center;
  margin-bottom: 1.5rem;
  color: var(--text-color);
  font-style: italic;
}

/* Allocation Table Styles */
.allocation-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 1.5rem;
  background: white;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.allocation-table thead {
  background: #f3f4f6;
  border-bottom: 2px solid #e5e7eb;
}

.allocation-table th {
  padding: 1rem;
  text-align: left;
  font-weight: 600;
  color: var(--text-dark);
  font-size: 0.9rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.allocation-table td {
  padding: 0.875rem 1rem;
  border-bottom: 1px solid #e5e7eb;
  color: var(--text-color);
}

.allocation-table tbody tr:last-child td {
  border-bottom: none;
}

.allocation-table tbody tr:hover {
  background: #f9fafb;
}

.allocation-table tbody tr.below-threshold-row {
  background: #fee2e2;
  position: relative;
}

.allocation-table tbody tr.below-threshold-row:hover {
  background: #fecaca;
}

.allocation-table tbody tr.below-threshold-row td {
  border-bottom-color: #fca5a5;
}

.allocation-table tbody tr.below-threshold-row td:first-child {
  padding-left: 2.5rem;
}

.allocation-table tbody tr.below-threshold-row td:first-child::before {
  content: "⚠️";
  position: absolute;
  left: 0.75rem;
  font-size: 0.9rem;
}

.allocation-table .party-name {
  font-weight: 600;
}

.allocation-table .votes-received,
.allocation-table .cost-per-seat,
.allocation-table .seats-gained,
.allocation-table .unused-votes {
  text-align: right;
  font-family: 'SF Mono', Monaco, 'Cascadia Code', monospace;
}

.allocation-summary {
  margin-top: 1.5rem;
  padding: 1rem;
  background: #f9fafb;
  border-radius: 6px;
  border: 1px solid #e5e7eb;
}

.allocation-summary p {
  margin: 0.5rem 0;
  font-size: 0.95rem;
  color: var(--text-color);
  text-align: left;
}

/* Allocation steps container */
.allocation-steps-container {
  background: #fafafa;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 1.5rem;
  margin-top: 1rem;
  /* No max-height - full height display */
}

/* Round-based allocation styles */
.allocation-round {
  margin-bottom: 2.5rem;
  padding-bottom: 2rem;
  border-bottom: 2px solid #e5e7eb;
}

.allocation-round:last-child {
  border-bottom: none;
  margin-bottom: 0;
  padding-bottom: 0;
}

.round-header {
  display: flex;
  align-items: center;
  margin-bottom: 1rem;
  color: var(--proportional-color);
  font-size: 1.15rem;
  font-weight: 600;
}

.round-icon {
  margin-right: 0.5rem;
  font-size: 1.2rem;
}

.round-description {
  color: var(--text-color);
  font-size: 0.95rem;
  font-weight: normal;
  font-style: italic;
}

.round-summary {
  background: #f9fafb;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  padding: 1rem;
  margin-bottom: 1.5rem;
}

.round-summary p {
  margin: 0.3rem 0;
  font-size: 0.9rem;
}

.below-threshold-notice {
  background: #fef3c7;
  border: 1px solid #fcd34d;
  border-radius: 6px;
  padding: 0.75rem 1rem;
  margin: 1rem 0;
  color: #92400e;
  font-size: 0.9rem;
}

.threshold-icon {
  margin-right: 0.5rem;
}

.transfers-container {
  margin: 1rem 0;
  padding: 0.5rem 0;
}

.transfer-step {
  padding: 0.5rem 1rem;
  margin: 0.5rem 0;
  background: #f0f9ff;
  border-left: 3px solid #0284c7;
  border-radius: 0 4px 4px 0;
  font-size: 0.9rem;
  color: #075985;
}

.transfer-icon {
  margin-right: 0.5rem;
  color: #0284c7;
}

.progress-update {
  margin-top: 1rem;
  padding: 0.5rem 0;
  color: #6b7280;
  font-size: 0.9rem;
  font-style: italic;
}

.final-result-section {
  margin-top: 2rem;
  padding: 1.5rem;
  background: linear-gradient(135deg, #f0f9ff 0%, #e0f2fe 100%);
  border: 2px solid #0284c7;
  border-radius: 8px;
}

.final-result-section h4 {
  margin: 0 0 1rem 0;
  color: #0369a1;
  font-size: 1.3rem;
  text-align: center;
}



.step {
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--border-color);
    line-height: 1.5;
}

.step:last-child {
    border-bottom: none;
}

/* Parliament Chart Styles */
.parliament-chart {
    text-align: center;
    margin: 1rem 0;
}

.mobile-parliament-chart {
    display: inline-block;
    max-width: 100%;
}

.parliament-canvas {
    display: block;
    margin: 0 auto;
    border-radius: 8px;
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

.parliament-legend {
    margin-top: 1rem;
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    justify-content: center;
}

.parliament-legend.compact {
    gap: 0.5rem;
    font-size: 0.8rem;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
}

.parliament-legend.compact .legend-item {
    font-size: 0.75rem;
    gap: 0.25rem;
}

.legend-color {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    border: 2px solid white;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.parliament-legend.compact .legend-color {
    width: 12px;
    height: 12px;
    border-width: 1px;
}

.legend-label {
    font-weight: 500;
}

.winner-display {
    text-align: center;
    padding: 1rem;
    background: var(--highlight-bg);
    border-radius: 8px;
    margin: 1rem 0;
    font-weight: 600;
    color: var(--text-dark);
}

/* Responsive adjustments */
@media (max-width: 1200px) {
    .vote-input-table {
        min-width: 500px;
    }
    
    .vote-input-cell {
        min-width: 180px;
    }
    
    .vote-slider {
        min-width: 100px;
        max-width: 150px;
    }
    
    .vote-number-input {
        width: 90px;
    }
    
    .transfer-pref-select {
        min-width: 100px;
    }
}

@media (max-width: 768px) {
    .parliament-chart.compact {
        max-width: 300px; /* Slightly smaller on mobile */
    }
    
    .vote-controls {
        flex-direction: column;
        align-items: stretch;
    }
    
    .total-votes {
        margin-left: 0;
        text-align: center;
    }
    
    .vote-tuner-table-wrapper {
        margin-bottom: 0.5rem;
    }
    
    .vote-input-table {
        min-width: 100%;
        font-size: 0.9rem;
    }
    
    .vote-input-table th,
    .vote-input-table td {
        padding: 0.5rem;
        white-space: normal; /* Allow text wrapping on mobile */
    }
    
    .vote-input-cell {
        flex-direction: column;
        gap: 0.25rem;
        min-width: 150px;
    }
    
    .vote-slider {
        min-width: 100%;
        max-width: none;
    }
    
    .vote-number-input {
        width: 100%;
        text-align: center;
    }
    
    .transfer-pref-select {
        width: 100%;
        min-width: auto;
    }
    
    /* Ensure table doesn't break layout on mobile */
    .vote-tuner {
        overflow-x: auto;
        padding: 1.5rem;
        margin: 1.5rem 0;
    }
    
    .vote-tuner h3 {
        font-size: 1.2rem;
    }
    
    .allocation-steps {
        padding: 1rem;
        margin: 1.5rem 0;
    }
    
    .allocation-steps h3 {
        font-size: 1.2rem;
    }
    
    /* Responsive styles for allocation tables */
    .allocation-steps-container {
        padding: 1rem;
    }
    
    .allocation-round {
        margin-bottom: 1.5rem;
        padding-bottom: 1rem;
    }
    
    .allocation-table {
        font-size: 0.85rem;
        overflow-x: auto;
        display: block;
    }
    
    .allocation-table th,
    .allocation-table td {
        padding: 0.5rem;
    }
    
    .allocation-table th {
        font-size: 0.75rem;
        white-space: nowrap;
    }
    
    .round-header {
        font-size: 1rem;
    }
    
    .transfer-step,
    .below-threshold-notice {
        font-size: 0.85rem;
        padding: 0.5rem;
    }
}

@media (max-width: 480px) {
    .parliament-chart.compact {
        max-width: 250px; /* Smallest size for mobile */
    }
    
    .vote-tuner {
        padding: 1rem;
    }
    
    .vote-tuner h3 {
        font-size: 1.1rem;
    }
    
    .tuner-description {
        font-size: 0.9rem;
    }
    
    .vote-input-table {
        font-size: 0.8rem;
    }
    
    .vote-input-table th,
    .vote-input-table td {
        padding: 0.25rem;
    }
    
    .vote-input-cell {
        min-width: 120px;
    }
    
    .vote-slider {
        min-width: 80px;
    }
    
    .vote-number-input {
        width: 70px;
        font-size: 0.8rem;
    }
    
    .transfer-pref-select {
        font-size: 0.8rem;
    }
    
    .allocation-table th {
        font-size: 0.7rem;
        padding: 0.4rem;
    }
    
    .allocation-table td {
        font-size: 0.8rem;
        padding: 0.4rem;
    }
}

.demo-charts {
    margin-bottom: 3rem;
}

.chart-item {
    margin-bottom: 2rem;
    text-align: center;
    max-width: 500px; /* Allow charts to be a bit larger since they're not competing for space */
    margin-left: auto;
    margin-right: auto;
}

.chart-item h4 {
    margin-bottom: 1rem;
    color: var(--text-dark);
    font-size: 1.2rem;
}

.chart-container {
    margin-bottom: 1rem;
}

.parliament-chart.compact {
    max-width: 400px; /* Slightly larger since we have more space */
    margin: 0 auto;
}

.winner-display.compact {
    font-size: 0.9rem;
    padding: 0.75rem;
    margin: 0;
}