/* ── Design tokens ──────────────────────────────────────────────────────── */
:root {
  --tisza: #3b82f6;
  --tisza-lean: #93bbfd;
  --tisza-glow: rgba(59, 130, 246, 0.35);
  --fidesz: #f59e0b;
  --fidesz-lean: #fcd078;
  --fidesz-glow: rgba(245, 158, 11, 0.35);
  --mihazank: #22c55e;
  --dk: #afafaf;
  --mkkp: #afafaf;
  --uncalled: rgba(148, 163, 184, 0.25);
  --uncalled-stroke: rgba(148, 163, 184, 0.4);

  --other: #6b7280;
  --other-lean: #9ca3af;
  --other-glow: rgba(107, 114, 128, 0.4);

  --bg: #05050a;
  --bg-elevated: rgba(255, 255, 255, 0.05);
  --bg-glass: rgba(255, 255, 255, 0.07);
  --bg-glass-hover: rgba(255, 255, 255, 0.12);
  --border-glass: rgba(255, 255, 255, 0.12);
  --border-glass-strong: rgba(255, 255, 255, 0.2);

  --text-primary: #ffffff;
  --text-secondary: rgba(255, 255, 255, 0.6);
  --text-muted: rgba(255, 255, 255, 0.35);

  --radius-sm: 12px;
  --radius-md: 18px;
  --radius-lg: 26px;
  --radius-xl: 32px;

  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-top: env(safe-area-inset-top, 0px);

  --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-med: 250ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: 450ms cubic-bezier(0.16, 1, 0.3, 1);
}

/* ── Typography & Global ────────────────────────────────────────────────── */
body {
  font-family: 'Outfit', -apple-system, BlinkMacSystemFont, sans-serif;
  letter-spacing: -0.01em;
}

h1,
h2,
h3,
.app-title {
  letter-spacing: -0.03em;
}

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

html {
  height: 100%;
}

body {
  min-height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, 'Inter', 'SF Pro Display', 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text-primary);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

body.modal-open {
  overflow: hidden;
}

/* ── App layout ─────────────────────────────────────────────────────────── */
#app {
  min-height: 100vh;
  min-height: 100dvh;
}

/* ── Header ─────────────────────────────────────────────────────────────── */
.app-header {
  position: sticky;
  top: 0;
  z-index: 100;
  padding: calc(var(--safe-top) + 12px) 20px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(5, 5, 10, 0.75);
  backdrop-filter: blur(24px) saturate(1.8);
  -webkit-backdrop-filter: blur(24px) saturate(1.8);
  border-bottom: 1px solid var(--border-glass);
}

.app-logo {
  color: var(--tisza);
  filter: drop-shadow(0 0 10px var(--tisza-glow));
  flex-shrink: 0;
}

.app-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
}

.app-title span {
  background: linear-gradient(135deg, #fff 0%, rgba(255, 255, 255, 0.7) 100%);
  background-clip: text;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.header-actions {
  display: flex;
  gap: 8px;
}

.btn-icon {
  width: 38px;
  height: 38px;
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-sm);
  background: var(--bg-glass);
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.btn-icon:hover {
  background: var(--bg-glass-hover);
  color: var(--text-primary);
}

.btn-icon:active {
  transform: scale(0.92);
}

.btn-icon.copied {
  border-color: var(--tisza);
  color: var(--tisza);
}

/* ── Main content ──────────────────────────────────────────────────────── */
.main-content {
  /* Normal flow - page scrolls naturally */
}

/* ── Hero section ──────────────────────────────────────────────────────── */
/* ── Mesh Gradient ──────────────────────────────────────────────────────── */
.mesh-gradient {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: -1;
  background: var(--bg);
  overflow: hidden;
}

.mesh-gradient::before,
.mesh-gradient::after {
  content: '';
  position: absolute;
  width: 150%;
  height: 150%;
  top: -25%;
  left: -25%;
  opacity: 0.12;
}

.mesh-gradient::before {
  background: radial-gradient(circle at 20% 30%, var(--tisza) 0%, transparent 40%),
    radial-gradient(circle at 80% 70%, var(--fidesz) 0%, transparent 40%);
  animation: mesh-anim 25s infinite alternate ease-in-out;
}

@keyframes mesh-anim {
  0% {
    transform: translate(0, 0) rotate(0deg);
  }

  100% {
    transform: translate(-5%, -10%) rotate(5deg);
  }
}

/* ── Hero section ──────────────────────────────────────────────────────── */
.hero-section {
  padding: 48px 24px 32px;
  text-align: center;
  position: relative;
  z-index: 10;
}

.hero-title {
  font-size: 46px;
  font-weight: 900;
  margin-bottom: 12px;
  letter-spacing: -0.05em;
  line-height: 1;
  background: linear-gradient(to bottom, #fff 0%, rgba(255, 255, 255, 0.6) 100%);
  background-clip: text;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.hero-title span {
  font-size: 18px;
  font-weight: 800;
  background: var(--tisza);
  color: #fff;
  padding: 3px 12px;
  border-radius: 99px;
  -webkit-text-fill-color: #fff;
  margin-top: 6px;
  box-shadow: 0 4px 20px var(--tisza-glow);
  text-transform: uppercase;
  letter-spacing: 0.15em;
}

.hero-subtitle {
  font-size: 17px;
  font-weight: 500;
  color: var(--text-secondary);
  max-width: 500px;
  margin: 0 auto;
  line-height: 1.5;
}

/* ── Animations & Transitions ───────────────────────────────────────────── */
.pulse-in {
  animation: pulse-in 0.8s cubic-bezier(0.16, 1, 0.3, 1) both;
}

@keyframes pulse-in {
  from {
    transform: scale(0.96);
    opacity: 0;
  }

  to {
    transform: scale(1);
    opacity: 1;
  }
}

button,
.district-item,
.small-district-item,
.preset-btn {
  transition: all var(--transition-med);
}

button:active {
  transform: scale(0.96);
}

.preset-btn:hover {
  background: var(--bg-glass-hover);
  border-color: var(--border-glass-strong);
  transform: translateY(-2px);
  box-shadow: 0 5px 10px rgba(0, 0, 0, 0.4);
}

.preset-btn.active {
  background: var(--tisza);
  color: #fff;
  border-color: var(--tisza);
  box-shadow: 0 5px 10px var(--tisza-glow);
}

/* ── Presets ────────────────────────────────────────────────────────────── */
.presets-section {
  display: flex;
  gap: 8px;
  padding: 12px 16px;
  overflow-x: auto;
  justify-content: center;
  flex-wrap: wrap;
}

.preset-btn {
  padding: 7px 16px;
  border-radius: 20px;
  border: 1px solid var(--border-glass-strong);
  background: var(--bg-glass);
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
}

.preset-btn:hover {
  background: var(--bg-glass-hover);
  color: var(--text-primary);
}

.preset-btn.active {
  background: rgba(59, 130, 246, 0.15);
  border-color: var(--tisza);
  color: var(--tisza);
}

/* ── Map wrap ──────────────────────────────────────────────────────────── */
.map-wrap {
  position: relative;
}

#mapRoot {
  position: relative;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  overflow: hidden;
  padding: 8px 4px 12px;
}

.map-svg {
  width: 100%;
  display: block;
}

/* ── District paths (5 states) ─────────────────────────────────────────── */
.district-path {
  stroke: rgba(255, 255, 255, 0.45);
  stroke-width: 0.8;
  stroke-linejoin: round;
  transition: fill var(--transition-fast);
  cursor: pointer;
  outline: none;
}

.district-uncalled {
  fill: var(--uncalled);
}

.district-tisza-lean {
  fill: var(--tisza-lean);
}

.district-tisza-sure {
  fill: var(--tisza);
  filter: drop-shadow(0 0 4px var(--tisza-glow));
}

.district-fidesz-lean {
  fill: var(--fidesz-lean);
}

.district-fidesz-sure {
  fill: var(--fidesz);
  filter: drop-shadow(0 0 4px var(--fidesz-glow));
}

.district-other-lean {
  fill: var(--other-lean);
}

.district-other-sure {
  fill: var(--other);
  filter: drop-shadow(0 0 4px var(--other-glow));
}

.district-noninteractive {
  opacity: 0.6;
  pointer-events: auto;
  /* Allow hovering so user knows it's clickable in the Pest/Bp case */
}

.district-hit {
  cursor: pointer;
}

.district-hit:focus {
  outline: none;
}

.district-hit:focus-visible {
  stroke: var(--text-primary);
  stroke-width: 3;
}

/* ── County borders ────────────────────────────────────────────────────── */
.county-borders-layer .county-border {
  fill: none;
  stroke: rgba(255, 255, 255, 0.4);
  stroke-width: 3;
  stroke-linejoin: round;
  pointer-events: none;
}

/* ── Underlay layer ────────────────────────────────────────────────────── */
.underlay-layer {
  pointer-events: none;
}

.underlay-river {
  fill: none;
  stroke: rgba(59, 130, 246, 0.2);
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ── City labels ───────────────────────────────────────────────────────── */
.cities-layer {
  pointer-events: none;
}

.city-dot {
  fill: rgba(255, 255, 255, 0.5);
  stroke: rgba(0, 0, 0, 0.3);
  stroke-width: 0.5;
}

.city-name {
  fill: rgba(255, 255, 255, 0.5);
  font-family: -apple-system, BlinkMacSystemFont, 'Inter', monospace;
  font-weight: 700;
  paint-order: stroke;
  stroke: rgba(0, 0, 0, 0.65);
  stroke-width: 3px;
  stroke-linejoin: round;
  letter-spacing: 1px;
}

.city-name.tier-3 {
  font-size: 12px;
  fill: rgba(255, 255, 255, 0.7);
  font-weight: 600;
}

.city-name.tier-2 {
  font-size: 12px;
  fill: rgba(255, 255, 255, 0.7);
}

.city-name.tier-1 {
  font-size: 12px;
  fill: rgba(255, 255, 255, 0.7);
}

/* ── District labels ───────────────────────────────────────────────────── */
.labels-layer {
  pointer-events: none;
}

.district-label {
  fill: rgba(255, 255, 255, 0.40);
  font-family: -apple-system, BlinkMacSystemFont, 'Inter', sans-serif;
  font-weight: 500;
}

.label-national {
  font-size: 9px;
}

.label-submap {
  font-size: 12px;
  stroke-width: 4px;
}

/* ── Tap pulse animation ────────────────────────────────────────────────── */
.tap-pulse {
  fill: rgba(255, 255, 255, 0.5);
  pointer-events: none;
  animation: tapPulse 400ms ease-out forwards;
}

@keyframes tapPulse {
  0% {
    r: 4;
    opacity: 0.7;
  }

  100% {
    r: 20;
    opacity: 0;
  }
}

/* ── Region overlay buttons ─────────────────────────────────────────────── */
#overlayButtons {
  position: absolute;
  bottom: 0px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 10px;
  z-index: 5;
}

.region-btn {
  padding: 10px 20px;
  border-radius: var(--radius-lg);
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(30, 30, 45, 0.85);
  backdrop-filter: blur(24px) saturate(1.5);
  -webkit-backdrop-filter: blur(24px) saturate(1.5);
  color: var(--text-primary);
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -0.01em;
  cursor: pointer;
  transition: all var(--transition-med);
  white-space: nowrap;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.region-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.25);
  transform: translateY(-1px);
}

.region-btn:active {
  transform: scale(0.96);
}

/* ── Small district panel ──────────────────────────────────────────────── */
.small-district-panel {
  padding: 32px 16px 32px;
}

.small-district-header {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
  margin-bottom: 8px;
  text-align: center;
}

.small-district-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: center;
}

.small-district-item {
  padding: 7px 14px;
  border-radius: 6px;
  border: 1px solid var(--border-glass);
  background: var(--bg-glass);
  color: var(--text-secondary);
  font-size: 16px;
  font-weight: 700;
  font-family: 'SF Mono', 'Fira Code', monospace;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.small-district-item:hover {
  border-color: var(--text-secondary);
}

.small-label-uncalled {
  background: rgba(148, 163, 184, 0.35);
  border-color: rgba(148, 163, 184, 0.5);
  color: var(--text-secondary);
}

.small-label-tisza-lean {
  background: rgba(147, 187, 253, 0.4);
  border-color: var(--tisza-lean);
  color: var(--tisza-lean);
}

.small-label-tisza-sure {
  background: rgba(59, 130, 246, 0.45);
  border-color: var(--tisza);
  color: var(--tisza);
}

.small-label-fidesz-lean {
  background: rgba(252, 208, 120, 0.4);
  border-color: var(--fidesz-lean);
  color: var(--fidesz-lean);
}

.small-label-fidesz-sure {
  background: rgba(245, 158, 11, 0.45);
  border-color: var(--fidesz);
  color: var(--fidesz);
}

.small-label-other-lean {
  background: rgba(156, 163, 175, 0.4);
  border-color: var(--other-lean);
  color: #d1d5db;
}

.small-label-other-sure {
  background: rgba(107, 114, 128, 0.45);
  border-color: var(--other);
  color: #f3f4f6;
}

/* ── Results panel (bottom sheet) ──────────────────────────────────────── */
.results-panel {
  background: rgba(18, 18, 28, 0.95);
  backdrop-filter: blur(40px) saturate(1.6);
  -webkit-backdrop-filter: blur(40px) saturate(1.6);
  border-top: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  max-height: 80vh;
  overflow-y: auto;
  overscroll-behavior: contain;
  box-shadow: 0 -8px 40px rgba(0, 0, 0, 0.5);
}

.sheet-handle {
  display: flex;
  justify-content: center;
  padding: 10px 0 6px;
  cursor: pointer;
}

.sheet-handle::after {
  content: '';
  width: 36px;
  height: 4px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 2px;
}

/* ── Collapsed summary ──────────────────────────────────────────────────── */
.sheet-collapsed {
  padding: 4px 20px 14px;
}

.seat-summary {
  display: flex;
  align-items: center;
  gap: 16px;
  justify-content: center;
}

.seat-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
}

.seat-num {
  font-size: 18px;
  font-weight: 700;
}

.tisza-badge .seat-num {
  color: var(--tisza);
}

.fidesz-badge .seat-num {
  color: var(--fidesz);
}

.uncalled-badge .seat-num {
  color: var(--text-secondary);
}

.other-badge .seat-num {
  color: var(--other);
}

.seat-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.seat-dot.tisza {
  background: var(--tisza);
  box-shadow: 0 0 8px var(--tisza-glow);
}

.seat-dot.fidesz {
  background: var(--fidesz);
  box-shadow: 0 0 8px var(--fidesz-glow);
}

.seat-dot.uncalled {
  background: rgba(148, 163, 184, 0.4);
}

/* ── Expanded content ───────────────────────────────────────────────────── */
.sheet-expanded {
  padding: 0 20px 20px;
  display: none;
}

.results-panel.expanded .sheet-expanded {
  display: block;
}

/* ── Party colors ──────────────────────────────────────────────────────── */
.fidesz-color {
  color: var(--fidesz);
}

.tisza-color {
  color: var(--tisza);
}

.mihazank-color {
  color: var(--mihazank);
}

.dk-color {
  color: var(--dk);
}

.mkkp-color {
  color: var(--mkkp);
}

/* ── Seat bar ───────────────────────────────────────────────────────────── */
.seat-bar-section {
  margin: 16px 0;
}

.seat-bar-wrap {
  position: relative;
  height: 32px;
  background: rgba(255, 255, 255, 0.04);
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--border-glass);
}

.seat-bar-fill {
  position: absolute;
  top: 0;
  height: 100%;
  transition: width var(--transition-med), opacity var(--transition-med);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  color: rgba(0, 0, 0, 0.7);
  overflow: hidden;
}

.seat-bar-fill.tisza {
  left: 0;
  background: var(--tisza);
  border-radius: var(--radius-sm) 0 0 var(--radius-sm);
}

.seat-bar-fill.other {
  left: 0;
  /* Will be translated dynamically by JS */
  background: var(--other);
}

.seat-bar-fill.fidesz {
  right: 0;
  background: var(--fidesz);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

.seat-bar-markers {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  pointer-events: none;
}

.seat-bar-marker {
  position: absolute;
  top: -2px;
  bottom: -2px;
  width: 2px;
  background: var(--text-primary);
  opacity: 0.4;
}

.seat-bar-marker-label {
  position: absolute;
  top: -18px;
  font-size: 10px;
  color: var(--text-muted);
  transform: translateX(-50%);
  white-space: nowrap;
  font-weight: 500;
}

/* ── Party slider rows ─────────────────────────────────────────────────── */
.slider-section {
  margin: 16px 0;
}

.party-slider-row {
  display: grid;
  grid-template-columns: 80px 1fr 44px;
  align-items: center;
  gap: 10px;
  margin: 6px 0;
}

.party-slider-label {
  font-size: 13px;
  font-weight: 600;
  text-align: right;
}

.party-slider-val {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.party-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 5px;
  border-radius: 3px;
  outline: none;
  background: rgba(255, 255, 255, 0.1);
}

.party-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--text-primary);
  border: 2px solid var(--bg);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
  cursor: pointer;
}

.party-slider::-moz-range-thumb {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--text-primary);
  border: 2px solid var(--bg);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
  cursor: pointer;
}

/* Slider track colors */
.slider-fidesz {
  accent-color: var(--fidesz);
}

.slider-tisza {
  accent-color: var(--tisza);
}

.slider-mihazank {
  accent-color: var(--mihazank);
}

.slider-dk {
  accent-color: var(--dk);
}

.slider-mkkp {
  accent-color: var(--mkkp);
}

.threshold-note {
  font-size: 11px;
  color: var(--text-muted);
  text-align: center;
  margin-top: 8px;
  font-style: italic;
}

/* ── List seats grid ───────────────────────────────────────────────────── */
.list-seats-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
  margin: 12px 0;
}

.list-seat-cell {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 8px 4px;
  background: var(--bg-glass);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-sm);
}

.list-seat-num {
  font-size: 22px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

.list-seat-party {
  font-size: 9px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 600;
  text-align: center;
}

/* ── Section labels ─────────────────────────────────────────────────────── */
.section-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 4px;
  margin-top: 16px;
}

.section-label {
  font-size: 12px;
  color: var(--text-secondary);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* ── District seat numbers ──────────────────────────────────────────────── */
.district-seats-row {
  display: flex;
  gap: 12px;
  align-items: center;
  margin: 12px 0;
  justify-content: space-around;
}

.district-seat-cell {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.district-seat-cell:first-child {
  align-items: flex-start;
}

.district-seat-cell:last-child {}

.district-seat-num {
  font-size: 28px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

.district-seat-num.tisza {
  color: var(--tisza);
}

.district-seat-num.fidesz {
  color: var(--fidesz);
}

.district-seat-party {
  font-size: 11px;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 600;
}

/* ── Action buttons ─────────────────────────────────────────────────────── */
.sheet-actions {
  display: flex;
  gap: 10px;
  margin-top: 20px;
}

.btn {
  flex: 1;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-glass-strong);
  background: var(--bg-glass);
  color: var(--text-primary);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
  text-align: center;
}

.btn:hover {
  background: var(--bg-glass-hover);
}

.btn:active {
  transform: scale(0.97);
}

.btn-primary {
  background: var(--tisza);
  border-color: var(--tisza);
  color: #fff;
}

.btn-primary:hover {
  background: #2563eb;
}

/* ── Export row ─────────────────────────────────────────────────────────── */
.export-row {
  margin-top: 10px;
}

.export-select {
  padding: 10px 12px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-glass-strong);
  background: var(--bg-glass);
  color: var(--text-primary);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  min-width: 72px;
  text-align: center;
}

.btn-export {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ── Watermark ──────────────────────────────────────────────────────────── */
.watermark-text {
  fill: rgb(120, 120, 120);
  font-family: -apple-system, BlinkMacSystemFont, 'Inter', sans-serif;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.06em;
  pointer-events: none;
}

/* ── Modal ──────────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  animation: fadeIn 250ms ease;
}

.modal-content {
  position: absolute;
  inset: 0;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  animation: slideUp 350ms cubic-bezier(0.16, 1, 0.3, 1);
}

.modal-header {
  display: flex;
  align-items: center;
  padding: calc(var(--safe-top) + 12px) 16px 12px;
  gap: 12px;
  border-bottom: 1px solid var(--border-glass);
  background: var(--bg-glass);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}

.modal-title {
  flex: 1;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.modal-back {
  width: 40px;
  height: 40px;
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-sm);
  background: var(--bg-glass);
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.modal-back:hover {
  background: var(--bg-glass-hover);
  color: var(--text-primary);
}

.modal-map-container {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  overflow: hidden;
}

.modal-map-container .map-svg {
  max-height: 100%;
}

.modal-map-container .district-path {
  stroke-width: 1.2;
}

/* ── Explainer section ─────────────────────────────────────────────────── */
.explainer-section {
  padding: 40px 20px;
  border-top: 1px solid var(--border-glass);
}

.explainer-title {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.02em;
  text-align: center;
  margin-bottom: 24px;
}

.explainer-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
  max-width: 700px;
  margin: 0 auto;
}

.explainer-card {
  background: var(--bg-glass);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-md);
  padding: 20px;
}

.explainer-icon {
  font-size: 28px;
  margin-bottom: 8px;
}

.explainer-card h3 {
  font-size: 15px;
  font-weight: 700;
  margin-bottom: 6px;
}

.explainer-card p {
  font-size: 13px;
  line-height: 1.6;
  color: var(--text-secondary);
}

/* ── Legend ─────────────────────────────────────────────────────────────── */
.legend-section {
  margin-top: 32px;
  text-align: center;
}

.legend-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 12px;
}

.legend-items {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: center;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-secondary);
}

.legend-swatch {
  width: 16px;
  height: 16px;
  border-radius: 4px;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.swatch-uncalled {
  background: var(--uncalled);
}

.swatch-tisza-lean {
  background: var(--tisza-lean);
}

.swatch-tisza-sure {
  background: var(--tisza);
}

.swatch-fidesz-lean {
  background: var(--fidesz-lean);
}

.swatch-fidesz-sure {
  background: var(--fidesz);
}

.swatch-other-lean {
  background: var(--other-lean);
}

.swatch-other-sure {
  background: var(--other);
}

/* ── Footer ────────────────────────────────────────────────────────────── */
.app-footer {
  padding: 24px 20px 40px;
  text-align: center;
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.5;
  border-top: 1px solid var(--border-glass);
}

/* ── Animations ─────────────────────────────────────────────────────────── */
@keyframes fadeIn {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

@keyframes slideUp {
  from {
    transform: translateY(100%);
  }

  to {
    transform: translateY(0);
  }
}

/* ── Copy toast ─────────────────────────────────────────────────────────── */
.copy-toast {
  position: fixed;
  top: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(-60px);
  background: rgba(16, 16, 24, 0.85);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border-glass-strong);
  color: var(--text-primary);
  padding: 10px 20px;
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 600;
  z-index: 200;
  opacity: 0;
  transition: all 300ms cubic-bezier(0.16, 1, 0.3, 1);
  pointer-events: none;
}

.copy-toast.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ── Responsive ─────────────────────────────────────────────────────────── */
@media (min-width: 768px) {
  .hero-title {}

  .hero-subtitle {
    font-size: 16px;
  }

  #mapRoot {
    padding: 12px 24px 16px;
  }

  .map-svg {
    max-width: 900px;
  }

  .explainer-grid {
    grid-template-columns: repeat(3, 1fr);
  }

  .results-panel {
    max-width: 540px;
    margin: 0 auto;
    border-radius: var(--radius-xl);
    border: 1px solid var(--border-glass);
    margin-bottom: 24px;
  }

  .modal-content {
    inset: 24px;
    border-radius: var(--radius-xl);
    overflow: hidden;
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.6);
  }
}

@media (min-width: 1024px) {
  .map-svg {
    max-width: 1100px;
  }
}

/* ── Scrollbar styling ──────────────────────────────────────────────────── */
.results-panel::-webkit-scrollbar {
  width: 4px;
}

.results-panel::-webkit-scrollbar-track {
  background: transparent;
}

.results-panel::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 2px;
}

.main-content::-webkit-scrollbar {
  width: 6px;
}

.main-content::-webkit-scrollbar-track {
  background: transparent;
}

.main-content::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.08);
  border-radius: 3px;
}