:root {
  --bg-page: #f3efe6;
  --bg-paper: #fbf9f4;
  --bg-card: #ffffff;
  --ink-primary: #1a1917;
  --ink-secondary: #524f49;
  --ink-muted: #7b766d;
  --border-ink: #2c2a26;
  --border-subtle: #d8d1c2;
  --accent-navy: #1d3557;
  --accent-crimson: #9e2a2b;
  --accent-gold: #c98a27;
  --accent-emerald: #1f6f50;
  --censor-bg: #22201d;
  --censor-text: #f7f3e8;
  --shadow-paper: 0 4px 16px rgba(26, 25, 23, 0.08);
  --font-serif: "Georgia", "Times New Roman", serif;
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
}

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

html,
body {
  background-color: var(--bg-page);
  color: var(--ink-primary);
  font-family: var(--font-sans);
  line-height: 1.5;
  min-height: 100vh;
  max-width: 100%;
  overflow-x: hidden;
}

/* Masthead */
.masthead {
  background-color: var(--bg-paper);
  border-bottom: 3px double var(--border-ink);
  padding: 0.75rem 1.25rem 0;
}

.masthead-inner {
  max-width: 1680px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding-bottom: 0.65rem;
  flex-wrap: wrap;
}

.masthead-left,
.masthead-right {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.edition-tag {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 0.25rem 0.55rem;
  border: 1px solid var(--border-ink);
  background: var(--bg-page);
}

.mode-switch {
  display: inline-flex;
  border: 1px solid var(--border-ink);
  border-radius: 4px;
  overflow: hidden;
}

.mode-btn {
  background: transparent;
  border: none;
  padding: 0.3rem 0.65rem;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  color: var(--ink-secondary);
}

.mode-btn.active {
  background: var(--accent-navy);
  color: #fff;
}

.masthead-title-group {
  text-align: center;
}

.masthead-title {
  font-family: var(--font-serif);
  font-size: 1.95rem;
  font-weight: 900;
  letter-spacing: 0.06em;
  line-height: 1.1;
}

.masthead-subtitle {
  font-size: 0.8rem;
  color: var(--ink-secondary);
  margin-top: 0.15rem;
}

.score-pill {
  display: flex;
  align-items: baseline;
  gap: 0.35rem;
  background: var(--ink-primary);
  color: #fff;
  padding: 0.35rem 0.8rem;
  border-radius: 4px;
  font-family: var(--font-mono);
}

.score-label {
  font-size: 0.7rem;
  letter-spacing: 0.08em;
  color: #c9c3b8;
}

.score-value {
  font-size: 1.15rem;
  font-weight: 700;
  color: #ffd166;
}

.score-max {
  font-size: 0.75rem;
  color: #b5afa4;
}

.icon-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1.5px solid var(--border-ink);
  background: var(--bg-page);
  font-weight: 700;
  cursor: pointer;
  font-size: 0.95rem;
}

.icon-btn:hover {
  background: var(--border-ink);
  color: #fff;
}

/* Progress strip */
.progress-strip {
  border-top: 1px solid var(--border-subtle);
  max-width: 1680px;
  margin: 0 auto;
  padding: 0.45rem 0;
}

.round-steps {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.5rem;
}

.round-step-pill {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.3rem 0.65rem;
  border: 1px solid var(--border-subtle);
  background: var(--bg-page);
  border-radius: 4px;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--ink-secondary);
}

.round-step-pill.active {
  border-color: var(--accent-navy);
  background: #e8eef5;
  color: var(--accent-navy);
}

.round-step-pill.completed {
  border-color: var(--accent-emerald);
  background: #eaf4ef;
  color: var(--accent-emerald);
}

/* Main Workspace */
.workspace {
  max-width: 1680px;
  margin: 1.25rem auto 2.5rem;
  padding: 0 1.25rem;
  display: grid;
  grid-template-columns: minmax(0, 0.95fr) minmax(0, 1.05fr);
  gap: 1.5rem;
  align-items: start;
}

@media (max-width: 1024px) {
  .workspace {
    grid-template-columns: minmax(0, 1fr);
  }
  .control-panel {
    position: static;
  }
}

/* Official Ballot Sheet */
.ballot-sheet {
  background: var(--bg-paper);
  border: 2px solid var(--border-ink);
  box-shadow: var(--shadow-paper);
  padding: 1.5rem;
  position: relative;
  min-width: 0;
}

.ballot-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  border-bottom: 2px solid var(--border-ink);
  padding-bottom: 1rem;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
}

.ballot-seal {
  width: 46px;
  height: 46px;
  border: 2px solid var(--border-ink);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.35rem;
  background: var(--bg-page);
  flex-shrink: 0;
}

.ballot-header-text {
  flex: 1;
}

.ballot-kicker {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.12em;
  color: var(--ink-secondary);
  font-weight: 700;
}

.ballot-jurisdiction {
  font-family: var(--font-serif);
  font-size: 1.25rem;
  margin-top: 0.15rem;
}

.ballot-round-badge {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  font-weight: 700;
  padding: 0.3rem 0.65rem;
  background: var(--accent-navy);
  color: #fff;
  border-radius: 3px;
  white-space: nowrap;
}

/* Redacted / Censor Styling */
.censor-inline {
  display: inline-block;
  background: var(--censor-bg);
  color: var(--censor-text);
  font-family: var(--font-mono);
  font-size: 0.78em;
  font-weight: 700;
  padding: 0.05rem 0.42rem;
  border-radius: 3px;
  letter-spacing: 0.05em;
  vertical-align: baseline;
  margin: 0 0.08rem;
}

/* Measures List */
.measures-list {
  display: flex;
  flex-direction: column;
  gap: 1.1rem;
}

.measure-card {
  background: var(--bg-card);
  border: 1.5px solid var(--border-ink);
  padding: 1.15rem 1.25rem;
  position: relative;
}

.measure-top-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.45rem;
  flex-wrap: wrap;
}

.measure-code {
  font-family: var(--font-mono);
  font-weight: 800;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--accent-navy);
  background: #e9eff6;
  padding: 0.18rem 0.55rem;
  border: 1px solid #b8cbe0;
  border-radius: 3px;
}

.measure-category {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--ink-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.measure-title {
  font-family: var(--font-serif);
  font-size: 1.12rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
  color: var(--ink-primary);
}

.measure-desc {
  font-size: 0.94rem;
  color: var(--ink-secondary);
  line-height: 1.6;
}

/* Official Ballot Voting Options (YES / NO) */
.ballot-choices {
  margin-top: 0.85rem;
  border-top: 1px solid var(--border-subtle);
  padding-top: 0.7rem;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.ballot-choice-row {
  display: flex;
  align-items: baseline;
  gap: 0.65rem;
  padding: 0.4rem 0.65rem;
  background: var(--bg-paper);
  border: 1px solid var(--border-subtle);
  border-radius: 3px;
  font-size: 0.86rem;
}

.ballot-choice-row.choice-winner-yes {
  background: #e8f5ee;
  border-color: #9ad3b7;
}

.ballot-choice-row.choice-winner-no {
  background: #fdf0f0;
  border-color: #e5a9a9;
}

.ballot-box {
  font-family: var(--font-mono);
  font-weight: 800;
  font-size: 0.82rem;
  color: var(--ink-primary);
  white-space: nowrap;
  min-width: 68px;
}

.box-mark {
  font-size: 1rem;
  margin-right: 0.15rem;
}

.ballot-choice-text {
  color: var(--ink-secondary);
  line-height: 1.4;
}

/* Measure Outcome Footer (Shown on Reveal) */
.measure-outcome {
  margin-top: 0.85rem;
  padding-top: 0.7rem;
  border-top: 1px dashed var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.outcome-badge {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  font-weight: 700;
  padding: 0.22rem 0.6rem;
  border-radius: 3px;
}

.outcome-passed {
  background: #e4f4ec;
  color: var(--accent-emerald);
  border: 1px solid #9ad3b7;
}

.outcome-failed {
  background: #fbe9e9;
  color: var(--accent-crimson);
  border: 1px solid #e5a9a9;
}

.vote-bar-wrap {
  flex: 1;
  min-width: 160px;
  max-width: 260px;
  height: 10px;
  background: #e9e4d8;
  border-radius: 5px;
  overflow: hidden;
  border: 1px solid var(--border-subtle);
}

.vote-bar-fill {
  height: 100%;
}

.vote-bar-fill.passed {
  background: var(--accent-emerald);
}

.vote-bar-fill.failed {
  background: var(--accent-crimson);
}

/* Reveal Banner */
.reveal-banner {
  background: #eef4f0;
  border: 2px solid var(--accent-emerald);
  padding: 1.1rem 1.25rem;
  margin-bottom: 1.25rem;
  border-radius: 4px;
}

.reveal-banner-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  border-bottom: 1px solid #c5ddd0;
  padding-bottom: 0.65rem;
  margin-bottom: 0.8rem;
}

.reveal-answer-headline {
  font-family: var(--font-serif);
  font-size: 1.45rem;
  font-weight: 800;
  color: var(--ink-primary);
}

.reveal-round-score {
  font-family: var(--font-mono);
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--accent-emerald);
  background: #fff;
  padding: 0.25rem 0.7rem;
  border: 1.5px solid var(--accent-emerald);
  border-radius: 4px;
}

.reveal-breakdown-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  margin-bottom: 0.8rem;
}

.breakdown-card {
  background: #fff;
  border: 1px solid #cbdcd2;
  padding: 0.65rem 0.85rem;
  border-radius: 4px;
}

.breakdown-title {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--ink-muted);
  letter-spacing: 0.06em;
}

.breakdown-main {
  font-weight: 700;
  font-size: 0.98rem;
  margin-top: 0.1rem;
}

.breakdown-sub {
  font-size: 0.82rem;
  color: var(--ink-secondary);
  margin-top: 0.1rem;
}

.reveal-context-note {
  font-size: 0.88rem;
  color: var(--ink-secondary);
  background: rgba(255, 255, 255, 0.7);
  padding: 0.6rem 0.8rem;
  border-left: 3px solid var(--accent-navy);
}

/* Right Column: Control Panel */
.control-panel {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  position: sticky;
  top: 1rem;
  min-width: 0;
}

.panel-card {
  background: var(--bg-paper);
  border: 2px solid var(--border-ink);
  padding: 1.15rem;
  box-shadow: var(--shadow-paper);
}

.panel-section-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.85rem;
}

.step-num {
  width: 28px;
  height: 28px;
  background: var(--accent-navy);
  color: #fff;
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 0.85rem;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.panel-section-header h3 {
  font-family: var(--font-serif);
  font-size: 1.05rem;
}

.panel-hint {
  font-size: 0.78rem;
  color: var(--ink-muted);
}

.state-select-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.65rem;
  margin-bottom: 0.75rem;
  flex-wrap: wrap;
}

.state-dropdown {
  flex: 1;
  min-width: 0;
  width: 100%;
  padding: 0.65rem 0.8rem;
  font-size: 1.02rem;
  border: 2px solid var(--border-ink);
  background: #fff;
  border-radius: 4px;
  font-weight: 700;
}

.selected-state-pill {
  font-family: var(--font-mono);
  font-size: 0.88rem;
  font-weight: 700;
  padding: 0.5rem 0.8rem;
  background: #e8eef5;
  color: var(--accent-navy);
  border: 1.5px solid #b8cbe0;
  border-radius: 4px;
  white-space: nowrap;
}

/* Interactive US Map */
.map-wrapper {
  background: #fff;
  border: 1.5px solid var(--border-subtle);
  border-radius: 4px;
  padding: 0.35rem;
}

#usMapSvg {
  width: 100%;
  height: auto;
  display: block;
  user-select: none;
}

.state-tile {
  cursor: pointer;
  transition: transform 0.1s ease, fill 0.12s ease;
}

.state-tile rect {
  fill: #e7e2d5;
  stroke: #2c2a26;
  stroke-width: 1.75px;
  rx: 5px;
}

.state-tile .tile-code {
  font-family: var(--font-mono);
  font-size: 17px;
  font-weight: 800;
  fill: #1a1917;
  pointer-events: none;
}

.state-tile .tile-name {
  font-family: var(--font-sans);
  font-size: 9.5px;
  font-weight: 600;
  fill: #524f49;
  pointer-events: none;
}

.state-tile:hover rect {
  fill: #cddbe9;
}

.state-tile.selected rect {
  fill: var(--accent-navy);
}

.state-tile.selected text {
  fill: #ffffff;
}

.state-tile.actual rect {
  fill: var(--accent-emerald);
}

.state-tile.actual text {
  fill: #ffffff;
}

.state-tile.wrong-guess rect {
  fill: var(--accent-gold);
}

.state-tile.wrong-guess text {
  fill: #ffffff;
}

.map-legend {
  display: flex;
  gap: 1rem;
  justify-content: center;
  font-size: 0.76rem;
  color: var(--ink-secondary);
  margin-top: 0.35rem;
}

.dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 2px;
  margin-right: 4px;
  vertical-align: middle;
}

.dot-selected {
  background: var(--accent-navy);
}

.dot-actual {
  background: var(--accent-emerald);
}

/* Year Selector Controls */
.year-control-box {
  background: #fff;
  border: 1px solid var(--border-subtle);
  padding: 0.85rem;
  border-radius: 4px;
}

.year-display-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  margin-bottom: 0.75rem;
  flex-wrap: wrap;
}

.year-number-input {
  width: 96px;
  text-align: center;
  font-family: var(--font-mono);
  font-size: 1.4rem;
  font-weight: 800;
  padding: 0.25rem;
  border: 2px solid var(--border-ink);
  border-radius: 4px;
  color: var(--accent-navy);
  background: var(--bg-paper);
}

.year-step-btn {
  padding: 0.35rem 0.55rem;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  font-weight: 700;
  border: 1px solid var(--border-ink);
  background: var(--bg-page);
  border-radius: 3px;
  cursor: pointer;
}

.year-step-btn:hover {
  background: var(--accent-navy);
  color: #fff;
}

.year-slider {
  width: 100%;
  accent-color: var(--accent-navy);
  cursor: pointer;
}

.year-ticks {
  display: flex;
  justify-content: space-between;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--ink-muted);
  margin-top: 0.25rem;
}

/* Action Buttons */
.action-bar {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.primary-action-btn {
  width: 100%;
  padding: 0.95rem 1.25rem;
  font-family: var(--font-serif);
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  background: var(--accent-navy);
  color: #fff;
  border: 2px solid var(--border-ink);
  border-radius: 4px;
  cursor: pointer;
  box-shadow: 0 3px 0 var(--border-ink);
  transition: transform 0.08s ease, background 0.15s ease;
}

.primary-action-btn:hover:not(:disabled) {
  background: #142742;
}

.primary-action-btn:active:not(:disabled) {
  transform: translateY(2px);
  box-shadow: 0 1px 0 var(--border-ink);
}

.primary-action-btn:disabled {
  background: #b7b1a5;
  color: #f3efe6;
  cursor: not-allowed;
  box-shadow: none;
}

.next-btn {
  background: var(--accent-emerald);
}

.next-btn:hover:not(:disabled) {
  background: #17563d;
}

.secondary-action-btn {
  width: 100%;
  padding: 0.75rem 1rem;
  font-weight: 700;
  background: var(--bg-page);
  color: var(--ink-primary);
  border: 1.5px solid var(--border-ink);
  border-radius: 4px;
  cursor: pointer;
}

/* Modals */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(26, 25, 23, 0.65);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  z-index: 100;
}

.modal-card {
  background: var(--bg-paper);
  border: 2px solid var(--border-ink);
  max-width: 580px;
  width: 100%;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.25);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  border-bottom: 2px solid var(--border-ink);
  background: var(--bg-page);
}

.modal-header h2 {
  font-family: var(--font-serif);
  font-size: 1.2rem;
}

.modal-close-btn {
  background: none;
  border: none;
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
}

.modal-body {
  padding: 1.25rem;
}

.final-score-banner {
  text-align: center;
  background: var(--ink-primary);
  color: #fff;
  padding: 1.25rem;
  border-radius: 4px;
  margin-bottom: 1rem;
}

.final-score-label {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  letter-spacing: 0.1em;
  color: #c9c3b8;
}

.final-score-big {
  font-family: var(--font-mono);
  font-size: 2.1rem;
  font-weight: 800;
  color: #ffd166;
  margin: 0.2rem 0;
}

.final-rank-badge {
  display: inline-block;
  font-size: 0.82rem;
  font-weight: 700;
  padding: 0.2rem 0.65rem;
  background: rgba(255, 255, 255, 0.14);
  border-radius: 99px;
}

.summary-rounds-table {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 1.1rem;
}

.summary-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #fff;
  border: 1px solid var(--border-subtle);
  padding: 0.6rem 0.85rem;
  border-radius: 4px;
  font-size: 0.88rem;
}

.summary-row-score {
  font-family: var(--font-mono);
  font-weight: 700;
  color: var(--accent-emerald);
}

.next-daily-countdown {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-page);
  border: 1px solid var(--border-ink);
  padding: 0.65rem 0.9rem;
  border-radius: 4px;
  margin-bottom: 1rem;
  font-family: var(--font-mono);
}

.countdown-label {
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--ink-secondary);
}

.countdown-timer {
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--accent-navy);
}

.modal-actions {
  display: flex;
  gap: 0.75rem;
}

.share-feedback {
  text-align: center;
  font-family: var(--font-mono);
  font-size: 0.82rem;
  color: var(--accent-emerald);
  margin-top: 0.6rem;
  font-weight: 700;
}

.help-body p {
  margin-bottom: 0.75rem;
}

.help-list {
  padding-left: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  font-size: 0.92rem;
}

.help-list ul {
  padding-left: 1.25rem;
  margin-top: 0.35rem;
}

.hidden {
  display: none !important;
}

/* Mobile Responsive Adjustments */
@media (max-width: 680px) {
  .masthead {
    padding: 0.6rem 0.75rem 0;
  }

  .masthead-inner {
    justify-content: center;
    gap: 0.5rem;
  }

  .masthead-title {
    font-size: 1.45rem;
  }

  .round-steps {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.35rem;
  }

  .round-step-pill {
    font-size: 0.72rem;
    padding: 0.25rem 0.45rem;
  }

  .workspace {
    margin: 0.75rem auto 1.75rem;
    padding: 0 0.65rem;
    gap: 1rem;
  }

  .ballot-sheet,
  .panel-card {
    padding: 0.9rem;
  }

  .ballot-seal {
    width: 36px;
    height: 36px;
    font-size: 1.1rem;
  }

  .ballot-jurisdiction {
    font-size: 1.05rem;
  }

  .ballot-round-badge {
    width: 100%;
    text-align: center;
  }

  .measure-card {
    padding: 0.85rem;
  }

  .reveal-banner-top {
    flex-direction: column;
    align-items: flex-start;
  }

  .reveal-breakdown-grid {
    grid-template-columns: 1fr;
  }

  .state-select-row {
    flex-direction: column;
    align-items: stretch;
  }

  .selected-state-pill {
    text-align: center;
  }

  .year-number-input {
    width: 78px;
    font-size: 1.2rem;
  }

  .year-step-btn {
    padding: 0.3rem 0.42rem;
    font-size: 0.74rem;
  }
}
