:root {
  --navy-950: #091024;
  --navy-900: #0c1630;
  --navy-800: #14234a;
  --navy-700: #1f3566;
  --paper: #f7f1e3;
  --paper-bright: #fffdf6;
  --rule: #cdbf9f;
  --ink: #1b1f2a;
  --ink-soft: #4b5164;
  --cream: #f3ecda;
  --cream-soft: #b9c0d6;
  --red: #b4232c;
  --red-tint: #fbecec;
  --blue: #1f3d7a;
  --blue-tint: #eaf0fa;
  --green: #1d6b46;
  --green-tint: #eaf5ee;
  --gold: #d6b04a;

  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --type: "American Typewriter", "Courier Prime", "Courier New", Courier, monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --stamp: Impact, Haettenschweiler, "Franklin Gothic Bold", "Arial Narrow Bold", "Arial Black", sans-serif;

  --page: 760px;
}

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

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

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.5;
  color: var(--cream);
  background-color: var(--navy-900);
  background-image:
    radial-gradient(1100px 520px at 50% -140px, rgba(92, 128, 204, 0.38), rgba(92, 128, 204, 0) 70%),
    linear-gradient(180deg, var(--navy-800) 0%, var(--navy-900) 55%, var(--navy-950) 100%);
  background-attachment: fixed;
}

body::before {
  content: "";
  display: block;
  height: 6px;
  flex: none;
  background: linear-gradient(90deg, var(--red) 0 33.33%, #f4f4f4 33.33% 66.66%, #2c53a3 66.66% 100%);
}

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

.skip {
  position: absolute;
  left: 12px;
  top: -60px;
  z-index: 10;
  padding: 10px 14px;
  border-radius: 8px;
  background: var(--paper);
  color: var(--ink);
  font-weight: 700;
}

.skip:focus {
  top: 14px;
}

a {
  color: inherit;
}

:focus-visible {
  outline: 3px solid var(--gold);
  outline-offset: 3px;
  border-radius: 4px;
}

/* Masthead */

.masthead {
  width: 100%;
  max-width: var(--page);
  margin: 0 auto;
  padding: 14px 16px 6px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  text-decoration: none;
  color: var(--cream);
}

.emblem {
  width: 38px;
  height: 38px;
  flex: none;
}

.brand-text {
  font-family: var(--serif);
  font-size: 1rem;
  line-height: 1.2;
  letter-spacing: 0.01em;
}

.brand-text strong {
  color: var(--gold);
  font-weight: 700;
}

.link-button {
  flex: none;
  padding: 8px 4px;
  border: 0;
  background: none;
  color: var(--cream-soft);
  font: inherit;
  font-size: 0.9rem;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}

.link-button:hover {
  color: var(--cream);
}

/* Layout */

main {
  flex: 1;
  width: 100%;
  max-width: var(--page);
  margin: 0 auto;
  padding: 10px 16px 32px;
}

main:focus,
[tabindex="-1"]:focus {
  outline: none;
}

/* The entrance moves the view but never hides it, so the page is readable
   even where animations do not run. */
.view {
  animation: rise 0.3s ease-out;
}

@keyframes rise {
  from {
    transform: translateY(10px);
  }
  to {
    transform: none;
  }
}

.footer {
  width: 100%;
  max-width: var(--page);
  margin: 0 auto;
  padding: 0 16px 28px;
  color: var(--cream-soft);
  font-size: 0.8rem;
  text-align: center;
}

.footer p {
  margin: 0;
}

.footer p + p {
  margin-top: 6px;
}

.footer a {
  color: var(--cream);
  text-underline-offset: 3px;
}

.footer a:hover {
  color: var(--gold);
}

/* Ads. A position with no unit id is never rendered, so these rules only apply to a real unit. */

.ad {
  max-width: var(--page);
  margin: 28px auto 0;
  text-align: center;
}

.ad-label {
  margin: 0 0 6px;
  font-size: 0.7rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--cream-soft);
}

.noscript {
  max-width: var(--page);
  margin: 24px auto;
  padding: 16px;
  border-radius: 8px;
  background: var(--paper);
  color: var(--ink);
  text-align: center;
}

/* Buttons */

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  padding: 12px 24px;
  border: 0;
  border-radius: 10px;
  background: var(--red);
  color: #fff;
  font-family: var(--sans);
  font-size: 1.02rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  cursor: pointer;
  box-shadow: 0 4px 0 #7d151c;
  transition: transform 0.1s ease, box-shadow 0.1s ease, background-color 0.1s ease;
}

.button:hover {
  background: #c62a34;
}

.button:active {
  transform: translateY(3px);
  box-shadow: 0 1px 0 #7d151c;
}

.button.secondary {
  background: var(--paper-bright);
  color: var(--ink);
  box-shadow: 0 4px 0 var(--rule);
  border: 1.5px solid var(--rule);
}

.button.secondary:hover {
  background: #fff;
}

.button.secondary:active {
  box-shadow: 0 1px 0 var(--rule);
}

.button.on-dark {
  background: transparent;
  color: var(--cream);
  border: 1.5px solid rgba(243, 236, 218, 0.5);
  box-shadow: none;
}

.button.on-dark:hover {
  background: rgba(243, 236, 218, 0.1);
}

kbd {
  display: inline-block;
  min-width: 1.5em;
  padding: 1px 6px;
  border: 1px solid currentColor;
  border-radius: 5px;
  font-family: var(--type);
  font-size: 0.85em;
  text-align: center;
  opacity: 0.85;
}

/* Start screen */

.start {
  padding: clamp(18px, 6vh, 56px) 0 8px;
  text-align: center;
}

.start-kicker {
  margin: 0 0 14px;
  font-family: var(--type);
  font-size: 0.82rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--gold);
}

.start h1 {
  margin: 0 auto;
  max-width: 13em;
  font-family: var(--serif);
  font-size: clamp(2.1rem, 8.4vw, 4rem);
  font-weight: 700;
  line-height: 1.04;
  letter-spacing: -0.012em;
  text-wrap: balance;
}

.start h1 em {
  font-style: normal;
  color: var(--gold);
}

.start-deck {
  max-width: 34em;
  margin: 22px auto 0;
  font-family: var(--serif);
  font-size: clamp(1.05rem, 2.9vw, 1.24rem);
  line-height: 1.5;
  color: #dfe4f2;
  text-wrap: pretty;
}

.start-actions {
  margin-top: 30px;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 14px;
}

.start-actions .button {
  min-width: 220px;
  font-size: 1.12rem;
}

.rules {
  max-width: 560px;
  margin: 40px auto 0;
  padding: 20px 22px;
  border-radius: 8px;
  background: var(--paper);
  color: var(--ink);
  text-align: left;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.4);
  transform: rotate(-0.6deg);
}

.rules h2 {
  margin: 0 0 8px;
  font-family: var(--type);
  font-weight: 400;
  font-size: 0.8rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--red);
}

.rules p {
  margin: 0;
  font-family: var(--serif);
  font-size: 1.04rem;
  line-height: 1.55;
}

.rules p + p {
  margin-top: 10px;
}

.rules .legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px dashed var(--rule);
  font-family: var(--sans);
  font-size: 0.86rem;
  color: var(--ink-soft);
}

.legend span {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.best {
  margin: 22px 0 0;
  font-size: 0.92rem;
  color: var(--cream-soft);
}

/* Tracker */

.tracker {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin: 6px 0 14px;
}

.pips {
  display: flex;
  gap: 5px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.pip {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 5px;
  border: 1.5px solid rgba(243, 236, 218, 0.35);
  color: #fff;
  font-size: 0.72rem;
  font-weight: 800;
  line-height: 1;
}

.pip.is-current {
  border-color: var(--gold);
  box-shadow: 0 0 0 2px rgba(214, 176, 74, 0.35);
}

.pip.is-majority {
  background: #2a8a5c;
  border-color: #2a8a5c;
}

.pip.is-trump {
  background: #cf3540;
  border-color: #cf3540;
}

.pip.is-other {
  background: #5f6b8a;
  border-color: #5f6b8a;
}

.tally {
  margin: 0;
  font-size: 0.9rem;
  color: var(--cream-soft);
  white-space: nowrap;
}

.tally strong {
  color: var(--cream);
  font-size: 1.05rem;
}

/* Memo */

.memo {
  position: relative;
  padding: clamp(26px, 5vw, 44px) clamp(18px, 4.6vw, 44px) clamp(22px, 4.6vw, 40px);
  border-radius: 6px;
  color: var(--ink);
  background-color: var(--paper);
  background-image:
    linear-gradient(180deg, rgba(255, 255, 255, 0.6), rgba(255, 255, 255, 0) 140px),
    repeating-linear-gradient(0deg, rgba(120, 98, 50, 0.035) 0 1px, rgba(120, 98, 50, 0) 1px 3px);
  box-shadow: 0 22px 48px rgba(0, 0, 0, 0.45), 0 2px 6px rgba(0, 0, 0, 0.3);
}

.memo::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 8px;
  border-radius: 6px 6px 0 0;
  background: linear-gradient(90deg, var(--red) 0 33.33%, #fff 33.33% 66.66%, var(--blue) 66.66% 100%);
}

.memo-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin: 0;
  font-family: var(--type);
  font-size: 0.82rem;
  font-weight: 400;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--red);
}

.memo-head .count {
  color: var(--ink-soft);
  letter-spacing: 0.1em;
  white-space: nowrap;
}

.memo-meta {
  margin: 12px 0 0;
  padding: 10px 0;
  border-top: 1.5px solid var(--ink);
  border-bottom: 1px dashed var(--rule);
  font-family: var(--type);
  font-size: 0.9rem;
  color: var(--ink);
}

.memo-meta div {
  display: flex;
  gap: 10px;
}

.memo-meta dt {
  flex: none;
  width: 3.4em;
  color: var(--ink-soft);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.memo-meta dd {
  margin: 0;
}

.prompt {
  margin: 20px 0 0;
  font-family: var(--serif);
  font-size: clamp(1.16rem, 3.5vw, 1.42rem);
  line-height: 1.42;
  text-wrap: pretty;
}

.ask {
  margin: 20px 0 10px;
  font-family: var(--type);
  font-size: 0.86rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.options {
  display: grid;
  gap: 10px;
}

.option {
  display: grid;
  grid-template-columns: 34px 1fr;
  gap: 12px;
  align-items: start;
  width: 100%;
  padding: 13px 14px;
  border: 1.5px solid var(--rule);
  border-radius: 10px;
  background: var(--paper-bright);
  color: var(--ink);
  font-family: var(--serif);
  font-size: clamp(1rem, 2.9vw, 1.09rem);
  line-height: 1.4;
  text-align: left;
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.12s ease, border-color 0.12s ease, background-color 0.12s ease, opacity 0.2s ease;
}

.option .letter {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--navy-800);
  color: var(--paper);
  font-family: var(--type);
  font-size: 0.95rem;
  font-weight: 700;
}

.option .body {
  padding-top: 4px;
  min-width: 0;
}

.option:not(:disabled):hover {
  border-color: var(--blue);
  background: #fff;
  transform: translateY(-1px);
  box-shadow: 0 4px 0 rgba(31, 61, 122, 0.2);
}

.option:not(:disabled):active {
  transform: translateY(1px);
  box-shadow: none;
}

.option:disabled {
  cursor: default;
  color: var(--ink);
}

.option.is-dim {
  opacity: 0.55;
}

.option.is-majority {
  border-color: var(--green);
  background: var(--green-tint);
  box-shadow: inset 5px 0 0 var(--green);
}

.option.is-majority .letter {
  background: var(--green);
}

.option.is-trump {
  border-color: var(--red);
  background: var(--red-tint);
  box-shadow: inset 5px 0 0 var(--red);
}

.option.is-trump .letter {
  background: var(--red);
}

.option.is-picked {
  outline: 3px solid var(--ink);
  outline-offset: 2px;
}

.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.tag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: 999px;
  font-family: var(--sans);
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: #fff;
}

.tag-majority {
  background: var(--green);
}

.tag-trump {
  background: var(--red);
}

.tag-you {
  background: var(--ink);
}

.hint {
  margin: 14px 0 0;
  font-size: 0.82rem;
  color: var(--ink-soft);
}

@media (hover: none) {
  .hint {
    display: none;
  }
}

/* Reveal */

.reveal {
  margin-top: 26px;
  padding-top: 22px;
  border-top: 1.5px solid var(--ink);
  scroll-margin-top: 14px;
}

.reveal:focus {
  outline: none;
}

.stamp {
  display: inline-block;
  padding: 7px 16px 4px;
  border: 4px double currentColor;
  border-radius: 8px;
  font-family: var(--stamp);
  font-size: clamp(1.45rem, 6vw, 2.15rem);
  font-weight: 400;
  line-height: 1.1;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  transform: rotate(-3deg);
  transform-origin: left center;
  opacity: 0.92;
  animation: thump 0.38s cubic-bezier(0.2, 0.9, 0.3, 1.2) both;
}

.stamp.majority {
  color: var(--green);
}

.stamp.trump {
  color: var(--red);
}

.stamp.other {
  color: var(--blue);
}

@keyframes thump {
  0% {
    opacity: 0;
    transform: rotate(-3deg) scale(2.1);
  }
  100% {
    opacity: 0.92;
    transform: rotate(-3deg) scale(1);
  }
}

.verdict {
  margin: 16px 0 0;
  font-family: var(--serif);
  font-size: 1.12rem;
  font-weight: 700;
}

.fact {
  margin-top: 18px;
  padding: 14px 16px;
  border-radius: 8px;
  border-left: 5px solid var(--ink-soft);
  background: rgba(255, 255, 255, 0.6);
}

.fact.fact-trump {
  border-left-color: var(--red);
}

.fact.fact-majority {
  border-left-color: var(--green);
}

.fact h2 {
  margin: 0 0 6px;
  font-family: var(--type);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.fact-trump h2 {
  color: var(--red);
}

.fact-majority h2 {
  color: var(--green);
}

.fact p {
  margin: 0;
  font-family: var(--serif);
  font-size: 1.04rem;
  line-height: 1.5;
}

.sources {
  margin: 14px 0 0;
  font-size: 0.84rem;
  color: var(--ink-soft);
}

.sources a {
  color: var(--blue);
  text-underline-offset: 2px;
}

.sources a:hover {
  color: var(--red);
}

.next-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 14px;
  margin-top: 22px;
}

/* Results */

.results .memo-head {
  margin-bottom: 4px;
}

.score-line {
  margin: 18px 0 0;
  font-family: var(--serif);
  font-size: clamp(1.3rem, 4.6vw, 1.9rem);
  font-weight: 700;
  line-height: 1.2;
  text-wrap: balance;
}

.score-line .lead {
  color: var(--green);
}

.score-line.is-twin .lead {
  color: var(--red);
}

.score-tally {
  margin: 12px 0 0;
  font-family: var(--serif);
  font-size: 1.14rem;
  line-height: 1.45;
}

.score-note {
  margin: 10px 0 0;
  font-family: var(--serif);
  font-size: 1.08rem;
  line-height: 1.5;
}

.bars {
  display: grid;
  gap: 12px;
  margin: 22px 0 0;
  padding: 16px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.6);
}

.bar-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 4px 12px;
  align-items: baseline;
}

.bar-label {
  font-weight: 700;
  font-size: 0.95rem;
}

.bar-value {
  font-family: var(--type);
  font-size: 0.95rem;
  white-space: nowrap;
}

.bar-track {
  grid-column: 1 / -1;
  height: 16px;
  border-radius: 999px;
  background: #e2d8bf;
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  min-width: 0;
  border-radius: 999px;
  background: var(--green);
  transition: width 0.9s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.bar-fill.him {
  background: var(--red);
}

.bars-caption {
  margin: 0;
  font-size: 0.84rem;
  color: var(--ink-soft);
}

.recap-title {
  margin: 26px 0 8px;
  font-family: var(--type);
  font-weight: 400;
  font-size: 0.8rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.recap {
  margin: 0;
  padding: 0;
  list-style: none;
  border-top: 1px dashed var(--rule);
}

.recap li {
  border-bottom: 1px dashed var(--rule);
}

.recap summary {
  display: grid;
  grid-template-columns: 24px 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 10px 2px;
  cursor: pointer;
  list-style: none;
  font-family: var(--serif);
  font-size: 1.02rem;
}

.recap summary::-webkit-details-marker {
  display: none;
}

.recap summary::after {
  content: "+";
  display: inline-block;
  font-family: var(--type);
  font-size: 1.1rem;
  color: var(--ink-soft);
  transition: transform 0.15s ease;
}

.recap details[open] summary::after {
  transform: rotate(45deg);
}

.recap .pip {
  border-color: transparent;
}

.recap-body {
  padding: 0 2px 14px 34px;
  font-family: var(--serif);
  font-size: 0.98rem;
  line-height: 1.5;
}

.recap-body p {
  margin: 0 0 8px;
}

.recap-body .label {
  margin-right: 4px;
  font-family: var(--sans);
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.recap-body .label.trump {
  color: var(--red);
}

.recap-body .label.majority {
  color: var(--green);
}

.recap-body .label.you {
  color: var(--ink-soft);
}

.results-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  margin-top: 26px;
}

.share-status {
  margin: 12px 0 0;
  min-height: 1.3em;
  font-size: 0.9rem;
  color: var(--ink-soft);
}

.share-text {
  width: 100%;
  margin-top: 10px;
  padding: 10px 12px;
  border: 1.5px solid var(--rule);
  border-radius: 8px;
  background: var(--paper-bright);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 0.92rem;
  line-height: 1.45;
  resize: vertical;
}

/* About dialog */

.about {
  width: min(92vw, 540px);
  padding: 26px 26px 22px;
  border: 0;
  border-radius: 8px;
  background: var(--paper);
  color: var(--ink);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.6);
}

.about::backdrop {
  background: rgba(6, 10, 24, 0.72);
}

.about h2 {
  margin: 0 0 10px;
  font-family: var(--serif);
  font-size: 1.5rem;
}

.about p {
  margin: 0 0 12px;
  font-family: var(--serif);
  font-size: 1.04rem;
  line-height: 1.55;
}

.about form {
  margin-top: 18px;
}

/* Small screens */

@media (max-width: 520px) {
  .brand-text {
    font-size: 0.9rem;
  }

  .tracker {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }

  .pip {
    width: 24px;
    height: 24px;
  }

  .start-actions .button,
  .results-actions .button,
  .next-row .button {
    width: 100%;
  }

  .recap-body {
    padding-left: 2px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}
