:root {
  color-scheme: light;
  --bg: #f3f3f1;
  --paper: #ffffff;
  --ink: #343330;
  --muted: #6f6d68;
  --line: #3d3b38;
  --line-soft: #d9d8d3;
  --panel: #ffffff;
  --liberal: #2d79c7;
  --liberal-soft: #e2f0fb;
  --fascist: #e87818;
  --fascist-soft: #f9e4cf;
  --shadow: 0 18px 42px rgba(38, 36, 32, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(90deg, rgba(52, 51, 48, 0.035) 1px, transparent 1px) 0 0 / 34px 34px,
    linear-gradient(rgba(52, 51, 48, 0.035) 1px, transparent 1px) 0 0 / 34px 34px,
    var(--bg);
  color: var(--ink);
  font-family: "Courier Prime", "Courier New", ui-monospace, monospace;
}

body::before {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  content: "";
  background: radial-gradient(circle, rgba(52, 51, 48, 0.08) 0 1px, transparent 1px) 0 0 / 7px 7px;
  opacity: 0.28;
}

button,
input {
  font: inherit;
}

.shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 42px 0;
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(300px, 430px);
  align-items: center;
  gap: 34px;
  padding: 18px 0 34px;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  max-width: 760px;
  margin-bottom: 0;
  color: var(--ink);
  font-family: Impact, Haettenschweiler, "Arial Narrow Bold", sans-serif;
  font-size: clamp(40px, 4vw, 54px);
  font-weight: 900;
  line-height: 0.9;
  letter-spacing: 0;
  text-transform: uppercase;
  text-shadow: 4px 4px 0 #d8d7d2;
  white-space: nowrap;
}

.intro {
  max-width: 620px;
  margin: 16px 0 0;
  color: var(--muted);
  font-size: clamp(14px, 1.35vw, 17px);
  font-weight: 700;
  line-height: 1.25;
}

.language-switch {
  display: inline-grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0;
  margin-top: 18px;
  border: 3px solid var(--line);
  background: var(--paper);
  box-shadow: 4px 4px 0 var(--line);
}

.language-switch button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-width: 54px;
  min-height: 34px;
  border: 0;
  border-right: 3px solid var(--line);
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  padding: 0 12px;
  font-size: 12px;
  font-weight: 700;
}

.language-flag {
  width: 22px;
  height: 16px;
  border: 1px solid var(--line);
  display: block;
  flex: 0 0 auto;
}

.language-switch button:last-child {
  border-right: 0;
}

.language-switch button[aria-pressed="true"] {
  background: var(--ink);
  color: var(--paper);
}

h2 {
  margin-bottom: 0;
  border-bottom: 4px solid var(--ink);
  color: var(--ink);
  font-family: "Germania One", Georgia, serif;
  font-size: 34px;
  font-weight: 400;
  line-height: 0.95;
  letter-spacing: 0;
  text-transform: uppercase;
}

h3 {
  margin-bottom: 16px;
  color: var(--ink);
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

.deck-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(86px, 1fr));
  gap: 12px;
}

.deck-summary span {
  position: relative;
  display: grid;
  min-height: 118px;
  align-content: center;
  justify-items: center;
  border: 7px solid var(--line);
  border-radius: 6px;
  background: var(--paper);
  color: var(--ink);
  padding: 16px 10px 14px;
  text-align: center;
  overflow: hidden;
  font-size: clamp(10px, 0.95vw, 12px);
  font-weight: 700;
  line-height: 1.05;
  text-transform: uppercase;
  overflow-wrap: anywhere;
  box-shadow: inset 0 0 0 4px var(--paper), inset 0 0 0 6px var(--line-soft);
}

.deck-summary span::after {
  position: absolute;
  inset: 12px;
  border: 2px solid var(--line);
  border-radius: 2px;
  content: "";
}

.deck-summary .liberal-ticket {
  background: linear-gradient(180deg, var(--paper), var(--liberal-soft));
}

.deck-summary .fascist-ticket {
  background: linear-gradient(180deg, var(--paper), var(--fascist-soft));
}

.deck-summary strong {
  display: block;
  color: var(--ink);
  font-family: "Germania One", Georgia, serif;
  font-size: clamp(34px, 3.5vw, 44px);
  font-weight: 400;
  line-height: 1;
}

.grid {
  display: grid;
  grid-template-columns: minmax(320px, 420px) 1fr;
  gap: 20px;
}

.panel {
  position: relative;
  border: 2px solid var(--line-soft);
  border-radius: 0;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.panel::before {
  position: absolute;
  inset: 14px;
  border: 3px solid var(--line);
  pointer-events: none;
  content: "";
}

.panel::after {
  position: absolute;
  inset: 22px;
  border: 2px dotted var(--line);
  pointer-events: none;
  content: "";
  opacity: 0.8;
}

.controls,
.results {
  padding: 36px;
}

.panel-heading,
.section-title {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 24px;
}

.ghost {
  min-height: 38px;
  border: 3px solid var(--line);
  border-radius: 0;
  background: var(--paper);
  color: var(--ink);
  cursor: pointer;
  padding: 0 14px;
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  box-shadow: 4px 4px 0 var(--line);
}

.ghost:hover {
  transform: translate(-1px, -1px);
  box-shadow: 5px 5px 0 var(--line);
}

.control-group {
  position: relative;
  z-index: 1;
  border-top: 3px dotted var(--line);
  padding: 22px 0;
}

.optional-card {
  border: 3px solid var(--line);
  background: repeating-linear-gradient(
    -45deg,
    #fff,
    #fff 9px,
    #f3f3f1 9px,
    #f3f3f1 18px
  );
  margin: 8px 0 0;
  padding: 18px;
}

.optional-card h3 {
  margin-bottom: 14px;
}

.optional-card .counter-row:last-of-type {
  margin-bottom: 14px;
}

.counter-row {
  display: grid;
  grid-template-columns: 1fr 96px;
  align-items: center;
  gap: 14px;
  margin-bottom: 12px;
}

label {
  color: var(--ink);
  font-weight: 700;
}

input[type="number"] {
  width: 100%;
  min-height: 42px;
  border: 3px solid var(--line);
  border-radius: 0;
  background: var(--paper);
  padding: 0 10px;
  color: var(--ink);
  font-weight: 700;
  box-shadow: inset 3px 3px 0 #ededeb;
}

input[type="number"]:focus {
  outline: 3px solid #cfcfca;
}

input:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 42px;
  margin-bottom: 14px;
}

.toggle-row input {
  width: 48px;
  height: 26px;
  margin: 0;
  accent-color: var(--line);
}

.hint {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

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

.policy-count {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
}

.policy-hand {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 6px;
  border: 2px solid var(--line);
  background: var(--paper);
  white-space: nowrap;
  vertical-align: middle;
}

.policy-number {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.policy-icon {
  display: inline-grid;
  place-items: center;
  width: 1.42em;
  height: 1.72em;
  border: 2px solid var(--line);
  border-radius: 2px;
  color: var(--ink);
  background: var(--paper);
  font-family: "Germania One", Georgia, serif;
  font-size: 0.86em;
  font-weight: 400;
  line-height: 1;
}

.policy-icon.liberal {
  border-color: var(--liberal);
  background: var(--liberal);
  color: var(--paper);
}

.policy-icon.fascist {
  border-color: var(--fascist);
  background: var(--fascist);
  color: var(--paper);
}

.policy-divider {
  color: var(--muted);
}

.status {
  border: 3px solid var(--line);
  border-radius: 0;
  padding: 7px 10px;
  background: var(--paper);
  color: var(--ink);
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
}

.status.invalid {
  border-color: var(--fascist);
  background: var(--fascist-soft);
  color: var(--ink);
}

.primary-result {
  position: relative;
  z-index: 1;
  display: grid;
  gap: 16px;
  border: 7px solid var(--line);
  border-radius: 6px;
  background: var(--paper);
  color: var(--ink);
  padding: 24px;
  margin-bottom: 22px;
  box-shadow: inset 0 0 0 4px var(--paper), inset 0 0 0 6px var(--line-soft);
}

.primary-result p {
  margin-bottom: 0;
  color: var(--ink);
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
}

.majority-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.majority-grid div {
  border: 3px solid var(--line);
  background: var(--paper);
  padding: 16px;
}

.majority-grid div:first-child {
  background: linear-gradient(180deg, #fff, var(--liberal-soft));
}

.majority-grid div:last-child {
  background: linear-gradient(180deg, #fff, var(--fascist-soft));
}

.majority-grid span {
  display: block;
  margin-bottom: 8px;
  color: var(--ink);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.majority-grid strong {
  display: block;
  font-family: "Germania One", Georgia, serif;
  font-size: clamp(36px, 5vw, 62px);
  font-weight: 400;
  line-height: 1;
}

.pie-panel {
  position: relative;
  z-index: 1;
  border: 3px solid var(--line);
  background: var(--paper);
  padding: 16px;
  margin-bottom: 24px;
}

.pie-layout {
  display: grid;
  grid-template-columns: 170px minmax(260px, 1fr);
  align-items: center;
  gap: 24px;
}

.pie-chart {
  width: 170px;
  aspect-ratio: 1;
  border: 6px solid var(--line);
  border-radius: 50%;
  background: #ededeb;
  box-shadow: inset 0 0 0 12px #fff;
}

.pie-legend {
  display: grid;
  gap: 8px;
}

.legend-row {
  display: grid;
  grid-template-columns: 14px minmax(76px, max-content) minmax(98px, 1fr) minmax(76px, auto);
  align-items: center;
  gap: 10px;
  min-height: 38px;
  border-bottom: 2px dotted var(--line);
  color: var(--muted);
  font-size: 13px;
}

.legend-row.likely {
  color: var(--ink);
}

.legend-row strong {
  justify-self: end;
  color: var(--ink);
  font-size: 16px;
  line-height: 1;
}

.likely-label {
  justify-self: start;
  border: 2px solid var(--line);
  background: var(--paper);
  color: var(--ink);
  padding: 2px 7px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
}

.legend-swatch {
  width: 14px;
  height: 14px;
  border: 2px solid var(--line);
  border-radius: 50%;
}

.distribution {
  position: relative;
  z-index: 1;
  border-top: 3px dotted var(--line);
  padding-top: 20px;
}

.section-title {
  margin-bottom: 12px;
}

.section-title h3 {
  margin-bottom: 0;
}

.section-title > span {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 13px;
}

.bar-row {
  display: grid;
  grid-template-columns: minmax(104px, max-content) 1fr 68px;
  align-items: center;
  gap: 12px;
  min-height: 34px;
  color: var(--muted);
  font-size: 13px;
}

.bar-row > span {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.bar-track {
  height: 12px;
  overflow: hidden;
  border: 2px solid var(--line);
  border-radius: 0;
  background: repeating-linear-gradient(90deg, #fff, #fff 5px, #ededeb 5px, #ededeb 10px);
}

.bar-fill {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--liberal), #c9962c 52%, var(--fascist));
}

@media (max-width: 860px) {
  .hero,
  .grid {
    grid-template-columns: 1fr;
  }

  h1 {
    white-space: normal;
  }

  .deck-summary {
    min-width: 0;
  }

  .pie-layout {
    grid-template-columns: 150px minmax(220px, 1fr);
  }

  .pie-chart {
    width: 150px;
  }
}

@media (max-width: 520px) {
  .shell {
    width: min(100% - 20px, 1180px);
    padding: 22px 0;
  }

  h1 {
    font-size: clamp(38px, 12vw, 52px);
    text-shadow: 3px 3px 0 #d8d7d2;
  }

  .deck-summary {
    grid-template-columns: 1fr;
  }

  .controls,
  .results {
    padding: 28px 24px;
  }

  .panel::before {
    inset: 10px;
  }

  .panel::after {
    inset: 17px;
  }

  .counter-row {
    grid-template-columns: 1fr 78px;
  }

  .panel-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .majority-grid {
    grid-template-columns: 1fr;
  }

  .pie-layout {
    grid-template-columns: 1fr;
  }

  .legend-row {
    grid-template-columns: 14px minmax(72px, max-content) 1fr;
  }

  .legend-row strong {
    grid-column: 3;
  }

  .likely-label {
    display: none;
  }

  .section-title {
    align-items: flex-start;
    flex-direction: column;
  }

  .pie-chart {
    width: min(220px, 100%);
    justify-self: center;
  }

  .bar-row {
    grid-template-columns: 1fr 64px;
  }

  .bar-track {
    grid-column: 1 / -1;
    grid-row: 2;
  }
}
