:root {
  --bg: #f8fafc;
  --text: #0f172a;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --white: #ffffff;
  --green: #22c55e;
  --green-light: #dcfce7;
  --green-hover: #16a34a;
  --orange: #f97316;
  --orange-light: #ffedd5;
  --orange-hover: #ea580c;
  --red: #ef4444;
  --shadow-sm: 0 1px 2px 0 rgba(0,0,0,0.05);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -2px rgba(0,0,0,0.1);
  --radius: 12px;
  --radius-sm: 8px;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: "Inter", system-ui, -apple-system, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  padding: 72px 16px 24px;
  overflow-x: hidden;
}

/* -- Top Header -- */
.top-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 56px;
  padding: 0 16px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}

.header-left,
.header-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.header-icon {
  width: 28px;
  height: 28px;
  background: var(--text);
  color: var(--white);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 700;
}

.header-logo {
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--text);
}

.live-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #fef2f2;
  color: var(--red);
  border: 1px solid #fee2e2;
  border-radius: 9999px;
  padding: 4px 12px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  position: relative;
}

.live-ping {
  position: absolute;
  left: 8px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--red);
  opacity: 0.5;
  animation: ping 1.5s cubic-bezier(0, 0, 0.2, 1) infinite;
}

.live-ping-core {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--red);
  position: relative;
  z-index: 1;
}

.live-badge-text {
  padding-left: 4px;
}

@keyframes ping {
  0% { transform: scale(1); opacity: 0.6; }
  75%, 100% { transform: scale(2.5); opacity: 0; }
}

/* -- Content -- */
.content {
  max-width: 560px;
  margin: 0 auto;
}

/* -- Hero -- */
.hero {
  text-align: center;
  padding: 32px 0 28px;
}

.hero h1 {
  font-size: clamp(28px, 8vw, 40px);
  font-weight: 800;
  line-height: 1.15;
  letter-spacing: -0.03em;
  color: var(--text);
  margin: 0 0 10px;
}

.hero-sub {
  font-size: 17px;
  font-weight: 500;
  color: var(--text-muted);
  margin: 0;
}

.section-heading {
  text-align: center;
  font-size: clamp(20px, 5vw, 26px);
  font-weight: 700;
  color: var(--text);
  margin: 8px 0 4px;
}

/* -- Vote Grid -- */
.vote-grid {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-bottom: 24px;
}

/* -- Cards -- */
.card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.card:active {
  transform: scale(0.98);
}

.card-accent {
  height: 4px;
  width: 100%;
}

.cjp-accent { background: var(--green); }
.bjp-accent { background: var(--orange); }

.card-body {
  padding: 20px;
}

.card-top {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 12px;
}

.party-logo {
  width: 52px;
  height: 52px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: url("./assets/cjp-logo.png") center/cover no-repeat;
  flex-shrink: 0;
}

#bjp-logo {
  background: url("./assets/bjp-logo.png") center/cover no-repeat;
}

.party-name {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
  margin: 0 0 4px;
  line-height: 1.2;
}

.party-chip {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  padding: 2px 8px;
  border-radius: 4px;
}

.cjp-chip { background: var(--green-light); color: var(--green); }
.bjp-chip { background: var(--orange-light); color: var(--orange); }

.tagline {
  font-size: 14px;
  line-height: 1.6;
  color: var(--text-muted);
  margin: 0 0 18px;
}

/* -- Vote Buttons -- */
.vote-btn {
  width: 100%;
  border: none;
  border-radius: var(--radius-sm);
  padding: 14px;
  font-family: inherit;
  font-size: 15px;
  font-weight: 700;
  color: var(--white);
  cursor: pointer;
  transition: background 0.15s ease;
}

.vote-btn-cjp { background: var(--green); }
.vote-btn-cjp:hover { background: var(--green-hover); }

.vote-btn-bjp { background: var(--orange); }
.vote-btn-bjp:hover { background: var(--orange-hover); }

.vote-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* -- Results -- */
.results {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  padding: 20px;
  margin-bottom: 24px;
}

.results-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 20px;
}

.results h2 {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
  margin: 0;
}

.results-updated {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 500;
}

.progress-block {
  margin-bottom: 18px;
}

.progress-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}

.progress-label {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
}

.progress-count {
  font-size: 13px;
  font-weight: 600;
}

.cjp-track .progress-count { color: var(--green); }
.bjp-track .progress-count { color: var(--orange); }

.progress-track {
  width: 100%;
  height: 10px;
  background: #f1f5f9;
  border-radius: 9999px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  border-radius: 9999px;
  transition: width 0.6s ease;
}

.cjp-fill { background: var(--green); }
.bjp-fill { background: var(--orange); }

.total-votes {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  margin: 16px 0 4px;
  text-align: center;
}

.live-note {
  font-size: 12px;
  color: var(--text-muted);
  text-align: center;
  margin: 0;
}

/* -- Footer -- */
.page-footer {
  text-align: center;
  padding: 16px 8px 32px;
}

.footer-text {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.6;
  margin: 0 0 12px;
}

.footer-links {
  display: flex;
  justify-content: center;
  gap: 16px;
  margin-bottom: 12px;
}

.footer-links a {
  font-size: 12px;
  font-weight: 500;
  color: var(--text);
  text-decoration: none;
}

.footer-links a:hover {
  text-decoration: underline;
}

.footer-copy {
  font-size: 10px;
  color: var(--text-muted);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin: 0;
}

/* -- Noscript -- */
.noscript {
  margin: 16px;
  padding: 12px 16px;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--red);
  text-align: center;
  font-size: 14px;
  font-weight: 600;
}

/* -- Particles -- */
#particles {
  position: fixed;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 10;
}

.particle {
  position: absolute;
  font-size: 22px;
  animation: floatOut 0.8s ease-out forwards;
  transform: translate(-50%, -50%);
}

/* -- Toast -- */
#toast {
  position: fixed;
  left: 50%;
  bottom: 80px;
  transform: translateX(-50%) translateY(150%);
  background: var(--white);
  color: var(--text);
  padding: 12px 18px;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md);
  border: 1px solid var(--border);
  min-width: 280px;
  max-width: 92vw;
  text-align: center;
  font-size: 14px;
  font-weight: 600;
  z-index: 60;
  opacity: 0;
  transition: transform 0.35s ease, opacity 0.35s ease;
}

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

#toast.success { border-left: 4px solid var(--green); }
#toast.error   { border-left: 4px solid var(--red); }
#toast.info    { border-left: 4px solid var(--text-muted); }

/* -- Voted Banner -- */
#voted-banner {
  position: fixed;
  top: 64px;
  right: 12px;
  background: var(--white);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-md);
  color: var(--text);
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  max-width: 340px;
  font-size: 13px;
  font-weight: 600;
  z-index: 45;
}

.hidden { display: none !important; }

/* -- Animations -- */
@keyframes cjpShake {
  0% { transform: rotate(0deg); }
  20% { transform: rotate(-3deg) translateX(-3px); }
  40% { transform: rotate(3deg) translateX(3px); }
  60% { transform: rotate(-2deg) translateX(-2px); }
  80% { transform: rotate(2deg) translateX(2px); }
  100% { transform: rotate(0deg); }
}

@keyframes bjpBloom {
  0% { transform: scale(1); }
  40% { transform: scale(1.03); }
  70% { transform: scale(1.01); }
  100% { transform: scale(1); }
}

.cjp-voted-anim { animation: cjpShake 0.6s ease; }
.bjp-voted-anim { animation: bjpBloom 0.6s ease; }

@keyframes floatOut {
  from { opacity: 1; transform: translate(-50%, -50%) translate(var(--dx, 0), var(--dy, -10px)); }
  to { opacity: 0; transform: translate(-50%, -50%) translate(var(--dx, 0), calc(var(--dy, -10px) - 30px)); }
}

/* -- Responsive -- */
@media (max-width: 640px) {
  body { padding: 64px 12px 20px; }
  .top-header { height: 48px; }
  .hero { padding: 24px 0 20px; }
  .card-body { padding: 16px; }
  .results { padding: 16px; }
  .page-footer { padding: 12px 8px 24px; }
}

@media (min-width: 860px) {
  .vote-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
  }

  .card-top {
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 10px;
  }

  .party-logo {
    width: 128px;
    height: 128px;
  }
}