:root {
  --navy: #0b1a3a;
  --navy-2: #12275a;
  --red: #e02535;
  --red-2: #ff3b4a;
  --gold: #ffcf33;
  --cream: #fff8ec;
  --ink: #0a1020;
  --muted: #6b7793;
  --card: #ffffff;
  --shadow: 0 18px 50px rgba(11, 26, 58, 0.18);
  --font: "Segoe UI", system-ui, -apple-system, Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(1200px 500px at 80% -10%, rgba(255,207,51,0.20), transparent 60%),
    radial-gradient(900px 500px at -10% 10%, rgba(224,37,53,0.18), transparent 55%),
    linear-gradient(180deg, var(--cream), #ffffff 40%);
  min-height: 100vh;
}

/* ---------- top bar ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px clamp(16px, 5vw, 48px);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 900; }
.brand-mark {
  color: var(--gold); font-size: 26px;
  filter: drop-shadow(0 2px 0 rgba(224,37,53,0.5));
}
.brand-name { font-size: 22px; letter-spacing: -0.5px; color: var(--navy); }
.donate {
  display: inline-flex; align-items: center; gap: 8px;
  background: linear-gradient(180deg, var(--red-2), var(--red));
  color: #fff; text-decoration: none; font-weight: 800;
  padding: 11px 20px; border-radius: 999px;
  box-shadow: 0 8px 20px rgba(224,37,53,0.35);
  transition: transform .12s ease, box-shadow .12s ease;
}
.donate:hover { transform: translateY(-2px); box-shadow: 0 12px 26px rgba(224,37,53,0.45); }
.donate-heart { font-size: 15px; }

/* ---------- hero ---------- */
main { max-width: 1280px; margin: 0 auto; padding: 8px clamp(16px, 5vw, 32px) 60px; }
.hero { text-align: center; padding: 28px 0 24px; }
.kicker {
  display: inline-block; text-transform: uppercase; letter-spacing: 2px;
  font-size: 12px; font-weight: 800; color: var(--red);
  background: rgba(224,37,53,0.10); padding: 6px 14px; border-radius: 999px; margin: 0 0 14px;
}
.portrait {
  display: block; margin: 0 auto 20px;
  width: clamp(220px, 62vw, 360px); height: auto;
  border-radius: 18px; border: 6px solid #fff;
  box-shadow: 0 18px 44px rgba(11,26,58,0.32);
}
.hero h1 {
  font-size: clamp(40px, 9vw, 76px); line-height: 0.95; margin: 0;
  color: var(--navy); letter-spacing: -2px; font-weight: 900;
}
.subtitle { font-size: clamp(16px, 3vw, 20px); color: var(--muted); margin: 14px 0 0; font-weight: 600; }

/* ---------- cards ---------- */
.card {
  background: var(--card); border-radius: 22px; box-shadow: var(--shadow);
  padding: clamp(22px, 4vw, 36px); margin-top: 22px;
  border: 1px solid rgba(11,26,58,0.06);
}
.card-title { margin: 0 0 20px; font-size: clamp(20px, 4vw, 26px); color: var(--navy); text-align: center; font-weight: 800; }

/* ---------- candidate list ---------- */
.list-head { text-align: center; margin: 46px 0 6px; }
.list-head h2 { font-size: clamp(26px, 6vw, 38px); color: var(--navy); margin: 0; font-weight: 900; letter-spacing: -1px; }
.list-head p { color: var(--muted); font-weight: 600; margin: 8px 0 0; }

#candidateList { display: grid; gap: 22px; margin-top: 18px; }

/* card + right-side tally panel */
.cand-row {
  display: flex; gap: 16px; align-items: stretch;
  /* skip layout/paint for rows that aren't on screen — keeps a 29-card page
     smooth. `auto` lets the browser remember each row's real height. */
  content-visibility: auto;
  contain-intrinsic-size: auto 640px;
}
.cand-row .card { flex: 1 1 0; min-width: 0; margin-top: 0; }
#featured { margin-top: 22px; }
/* poll panel is an equal half, always present; it shows an empty placeholder
   until this candidate is voted on, then fills with the results */
.tally {
  flex: 1 1 0; min-width: 0; align-self: stretch;
  display: flex; flex-direction: column;
  background: var(--card); border-radius: 18px; box-shadow: var(--shadow);
  border: 1px solid rgba(11, 26, 58, 0.06); padding: 18px 16px;
}
.tally-dim { color: #c3cad8 !important; }
.tally-hint { margin-top: auto; padding-top: 14px; text-align: center; color: var(--muted); font-weight: 700; font-size: 13px; }
.tally-avg { display: flex; align-items: baseline; justify-content: center; gap: 6px; }
.tally-big { font-size: 46px; font-weight: 900; color: var(--navy); line-height: 1; letter-spacing: -1px; }
.tally-outof { color: var(--muted); font-weight: 800; font-size: 12px; text-transform: uppercase; }
.tally-total { text-align: center; color: var(--red); font-weight: 800; margin: 4px 0 14px; }
.tally .dist { margin: 0; }
.your-vote { text-align: center; color: var(--navy); font-weight: 700; margin: 8px 0 2px; }

@media (max-width: 640px) {
  .cand-row { flex-direction: column; }
  .tally { flex-basis: auto; width: 100%; align-self: stretch; }
  .tally:not(.filled) { display: none; } /* don't reserve empty space when stacked */
}

.cand-head { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 12px; margin-bottom: 18px; }
.cand-photo { width: 132px; height: 132px; border-radius: 18px; object-fit: cover; border: 4px solid #fff; box-shadow: 0 10px 24px rgba(11,26,58,0.22); }
.cand-name { margin: 0 0 8px; color: var(--navy); font-size: clamp(20px, 4vw, 26px); font-weight: 800; }
.cand-tags { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: center; }
.tag { font-size: 12px; font-weight: 800; color: #fff; padding: 3px 10px; border-radius: 999px; text-transform: uppercase; letter-spacing: .5px; }
.p-r { background: #d8283b; }
.p-d { background: #2456c8; }
.p-i { background: #6b7793; }
.p-l { background: #f0a500; }
.p-g { background: #1f9e57; }
.tag-note { font-size: 12px; color: var(--muted); font-weight: 700; }

/* featured card gets the big treatment */
.featured { border: 2px solid var(--gold); }
.featured .cand-photo { width: clamp(120px, 40vw, 200px); height: auto; border-radius: 16px; }
.featured .cand-head { flex-direction: column; text-align: center; gap: 14px; }
.featured .cand-name { font-size: clamp(30px, 7vw, 48px); letter-spacing: -1px; }
.featured .cand-tags { justify-content: center; }

/* ---------- stars ---------- */
.stars { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; }
.star {
  width: 46px; height: 46px; border: none; background: transparent; cursor: pointer;
  font-size: 38px; line-height: 1; color: #d7ddea; padding: 0;
  transition: transform .08s ease, color .08s ease;
}
.star:hover { transform: scale(1.15); }
.star.on { color: var(--gold); filter: drop-shadow(0 2px 4px rgba(255,207,51,0.6)); }
.star.on { animation: starpop .3s ease; }
@keyframes starpop { 0% { transform: scale(1.5); } 60% { transform: scale(0.9); } 100% { transform: scale(1); } }

/* ---------- animated rating reaction ---------- */
.reaction {
  height: 150px; display: flex; align-items: center; justify-content: center;
  text-align: center; margin: 10px 0 6px;
}
.react-empty { color: var(--muted); font-weight: 700; }
.react-pop { animation: pop .35s cubic-bezier(.2, 1.5, .4, 1); }
@keyframes pop { 0% { transform: scale(.3); opacity: 0; } 100% { transform: scale(1); opacity: 1; } }
.react-emoji { font-size: 56px; line-height: 1; display: inline-block; }

/* per-score emote animations */
.em-wobble { animation: em-wobble 1.1s ease-in-out infinite; }
@keyframes em-wobble { 0%, 100% { transform: rotate(-7deg) scale(1); } 50% { transform: rotate(7deg) scale(1.06); } }
.em-thumbdown { animation: em-thumbdown 1s ease-in-out infinite; }
@keyframes em-thumbdown { 0%, 100% { transform: translateY(0) rotate(0); } 50% { transform: translateY(7px) rotate(-10deg); } }
.em-sway { animation: em-sway 1.8s ease-in-out infinite; }
@keyframes em-sway { 0%, 100% { transform: rotate(-5deg); } 50% { transform: rotate(5deg); } }
.em-shake { animation: em-shake .5s ease-in-out infinite; }
@keyframes em-shake { 0%, 100% { transform: translateX(-2.5px); } 50% { transform: translateX(2.5px); } }
.em-bob { animation: em-bob 1.5s ease-in-out infinite; }
@keyframes em-bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-7px); } }
.em-thumbup { animation: em-thumbup 1s ease-in-out infinite; }
@keyframes em-thumbup { 0%, 100% { transform: translateY(0) rotate(0); } 50% { transform: translateY(-7px) rotate(10deg); } }
.em-bounce { animation: em-bounce .8s cubic-bezier(.3, 1.4, .5, 1) infinite; }
@keyframes em-bounce { 0%, 100% { transform: translateY(0); } 40% { transform: translateY(-13px); } 65% { transform: translateY(-5px); } }
.em-pulse { animation: em-pulse .9s ease-in-out infinite; }
@keyframes em-pulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.2); } }
.react-label { font-weight: 900; color: var(--navy); margin-top: 6px; font-size: 19px; }
.react-num { color: var(--muted); font-weight: 800; font-size: 13px; margin-top: 3px; }

/* score 1: green dumpster fire (image) */
.dumpster-wrap { display: inline-block; animation: dump-shake .5s infinite; transform-origin: 50% 85%; }
.dumpster-img { width: 118px; height: auto; display: block; }
.fire-label { color: var(--red); }
@keyframes dump-shake { 0%, 100% { transform: rotate(-3deg); } 50% { transform: rotate(3deg); } }
@keyframes flame-flick {
  from { transform: scaleY(.82) scaleX(1.06); opacity: .82; }
  to { transform: scaleY(1.15) scaleX(.92); opacity: 1; }
}

/* score 10: gold star, "WELL DONE" in the middle */
/* the whole group (star + text) moves together */
.goldstar {
  position: relative; display: inline-flex; align-items: center; justify-content: center;
  animation: gold-spin 2.2s ease-in-out infinite;
}
.gs-star { font-size: 110px; line-height: 1; color: var(--gold); animation: gold-glow 2.2s ease-in-out infinite; }
.gs-text {
  position: absolute; font-size: 13px; font-weight: 900; color: #7a5500;
  text-align: center; line-height: 1.05; letter-spacing: .5px;
  transform: translateY(9px);
}
@keyframes gold-spin {
  0%, 100% { transform: rotate(-9deg) scale(1); }
  50% { transform: rotate(9deg) scale(1.08); }
}
@keyframes gold-glow {
  0%, 100% { filter: drop-shadow(0 0 8px rgba(255, 207, 51, .7)); }
  50% { filter: drop-shadow(0 0 20px rgba(255, 207, 51, 1)); }
}

/* ---------- comment ---------- */
.comment-label { display: block; margin: 18px 0 8px; font-weight: 700; color: var(--navy); }
textarea {
  width: 100%; border: 2px solid #e6e9f2; border-radius: 14px; padding: 14px;
  font-family: var(--font); font-size: 15px; resize: vertical; color: var(--ink);
}
textarea:focus { outline: none; border-color: var(--navy-2); }
.comment-foot { display: flex; justify-content: space-between; margin-top: 6px; min-height: 18px; }
.char { color: var(--muted); font-size: 13px; }
.char.over { color: var(--red); font-weight: 800; }
.warn { color: var(--red); font-size: 13px; font-weight: 700; text-align: right; }

/* ---------- vote button ---------- */
.vote-btn {
  width: 100%; margin-top: 20px; border: none; cursor: pointer;
  background: linear-gradient(180deg, var(--navy-2), var(--navy));
  color: #fff; font-size: 19px; font-weight: 800; padding: 16px; border-radius: 14px;
  box-shadow: 0 10px 26px rgba(11,26,58,0.30); transition: transform .12s ease, opacity .12s ease;
}
.vote-btn:hover:not(:disabled) { transform: translateY(-2px); }
.vote-btn:disabled { opacity: 0.45; cursor: not-allowed; }
.fineprint { text-align: center; color: var(--muted); font-size: 13px; margin: 12px 0 0; }

/* ---------- results ---------- */
.voted-banner {
  background: rgba(31,168,92,0.12); color: #1c8a4e; font-weight: 800;
  text-align: center; padding: 12px; border-radius: 12px; margin-bottom: 20px;
}
.banner-info { background: rgba(11,26,58,0.07); color: var(--navy); }
.note-muted { color: var(--muted); font-weight: 700; }
.score-block { display: flex; align-items: center; justify-content: center; gap: 18px; margin-bottom: 8px; }
.score-big {
  font-size: clamp(64px, 16vw, 104px); font-weight: 900; line-height: 1; color: var(--navy);
  letter-spacing: -3px;
}
.score-side { text-align: left; }
.score-outof { color: var(--muted); font-weight: 700; text-transform: uppercase; letter-spacing: 1px; font-size: 13px; }
.score-total { font-size: 20px; font-weight: 800; color: var(--red); margin-top: 4px; }

.dist { margin: 24px 0 8px; display: grid; gap: 7px; }
.dist-row { display: grid; grid-template-columns: 34px 1fr 42px; align-items: center; gap: 10px; }
.dist-num { font-weight: 800; color: var(--navy); text-align: right; }
.dist-bar-wrap { background: #eef1f7; border-radius: 999px; height: 16px; overflow: hidden; }
.dist-bar { height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--gold), var(--red)); width: 0; transition: width .8s cubic-bezier(.15, .85, .25, 1); }

/* headline score bar — each star = 10% of the bar */
.scorebar { position: relative; height: 24px; border-radius: 999px; background: #eef1f7; overflow: hidden; margin: 8px 0 10px; }
.scorebar-fill {
  height: 100%; width: 0; border-radius: 999px;
  background: var(--red); /* colour set from the score in JS: red = bad, gold = good */
  transition: width 1.1s cubic-bezier(.15, .85, .25, 1), background-color .6s ease;
}
.scorebar-ticks {
  position: absolute; inset: 0; pointer-events: none;
  background-image: repeating-linear-gradient(90deg,
    transparent 0, transparent calc(10% - 1.5px),
    rgba(255, 255, 255, .7) calc(10% - 1.5px), rgba(255, 255, 255, .7) 10%);
}
.dist-count { color: var(--muted); font-size: 13px; font-weight: 700; }

.comments-head { color: var(--navy); margin: 26px 0 12px; }
.comments { display: grid; gap: 12px; }
.comment-item {
  background: #f7f8fc; border-radius: 14px; padding: 14px 16px; border-left: 5px solid var(--gold);
}
.comment-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.comment-score { font-weight: 900; color: var(--navy); }
.comment-score small { color: var(--muted); font-weight: 700; }
.comment-date { color: var(--muted); font-size: 12px; }
.comment-text { color: var(--ink); line-height: 1.5; overflow-wrap: anywhere; }
.comments-empty { color: var(--muted); text-align: center; padding: 10px; }

/* ---------- disclaimer / footer ---------- */
.disclaimer {
  margin-top: 26px; color: var(--muted); font-size: 13px; line-height: 1.6; text-align: center;
  border-top: 1px dashed #d7ddea; padding-top: 20px;
}
.disclaimer strong { color: var(--navy); }
.foot { color: var(--muted); font-size: 13px; padding: 30px clamp(16px, 5vw, 40px) 40px; }
.vote-rule { text-align: center; color: var(--navy); font-weight: 800; font-size: 15px; margin: 0 0 20px; }
.legal { max-width: 760px; margin: 0 auto; border-top: 1px solid #d7ddea; padding-top: 22px; }
.legal p { line-height: 1.6; margin: 0 0 12px; text-align: center; }
.legal strong { color: var(--navy); }
.foot-line { text-align: center; margin-top: 14px; font-weight: 600; }

@media (max-width: 480px) {
  .star { width: 38px; height: 38px; font-size: 31px; }
}
