:root {
  --paper: #e4e9e0;
  --ink: #141414;
  --line: #161616;
  --pen: #1f3fa0;
  --stamp: #3a3fae;
  --red: #c8102e;
  --guilloche: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18'%3E%3Cg fill='none' stroke='%237f9a86' stroke-width='.55' opacity='.5'%3E%3Ccircle cx='9' cy='9' r='6.5'/%3E%3Ccircle cx='0' cy='0' r='6.5'/%3E%3Ccircle cx='18' cy='0' r='6.5'/%3E%3Ccircle cx='0' cy='18' r='6.5'/%3E%3Ccircle cx='18' cy='18' r='6.5'/%3E%3C/g%3E%3C/svg%3E");
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  padding: 0 16px 80px;
  color: var(--ink);
  font-family: 'PT Serif', 'Times New Roman', serif;
  background: #5e625f radial-gradient(ellipse at 50% 0%, #8b908c 0%, #5e625f 55%, #3f4341 100%) fixed;
  overflow-x: hidden;
}

button, input, textarea { font: inherit; color: inherit; }

.sr { position: absolute; opacity: 0; width: 1px; height: 1px; pointer-events: none; }

/* top bar */
.bar {
  max-width: 880px;
  margin: 0 auto;
  padding: 14px 0 18px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.bar a {
  color: #f4f4ef;
  font-weight: 700;
  text-decoration: none;
  border-bottom: 2px dashed rgba(255, 255, 255, .5);
}
.langs { display: flex; gap: 6px; }
.langs button {
  border: 0;
  cursor: pointer;
  padding: 5px 9px 4px;
  font-weight: 700;
  font-size: 13px;
  letter-spacing: .06em;
  background: #d7dcd3;
  box-shadow: 0 2px 0 #2c2f2d;
  transform: rotate(var(--r, 0deg));
  transition: transform .15s;
}
.langs button:nth-child(odd) { --r: -2deg; }
.langs button:nth-child(even) { --r: 2deg; }
.langs button:hover { transform: rotate(0) translateY(-2px); }
.langs button[aria-pressed='true'] { background: var(--stamp); color: #fff; }

/* paper */
.stack { position: relative; max-width: 880px; margin: 0 auto 48px; }
.stack::before, .stack::after {
  content: '';
  position: absolute;
  inset: 0;
  background: #f1f2ec;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .35);
}
.stack::before { transform: rotate(1.6deg) translate(10px, 6px); }
.stack::after { transform: rotate(-1deg) translate(-6px, 10px); background: #e9ebe4; }

.sheet {
  position: relative;
  z-index: 1;
  background: var(--paper) var(--guilloche);
  padding: 20px 26px 28px;
  box-shadow: 0 1px 0 #fff inset, 0 22px 40px rgba(0, 0, 0, .45);
  transform: rotate(-.35deg);
  transition: transform .9s cubic-bezier(.6, -0.2, .7, 1), opacity .9s;
  transform-origin: 50% 0;
}
.sheet.fold { transform: perspective(900px) rotateX(75deg) translateY(60vh) scale(.25) rotate(8deg); opacity: 0; }
.sheet.shake { animation: shake .45s; }
@keyframes shake {
  20%, 60% { transform: rotate(-.35deg) translateX(-10px); }
  40%, 80% { transform: rotate(-.35deg) translateX(10px); }
}

/* header */
.head {
  display: grid;
  grid-template-columns: 1fr 280px;
  gap: 10px;
  border-bottom: 3px solid var(--line);
  padding-bottom: 12px;
}
.head h1 {
  margin: 8px 0 12px;
  text-align: center;
  font-size: 27px;
  letter-spacing: .05em;
}
.sub {
  margin: 0;
  text-align: center;
  font-size: 19px;
  font-weight: 700;
  line-height: 1.25;
  white-space: pre-line;
}
.seal { position: relative; min-height: 180px; }
.seal .place { position: absolute; right: 0; top: -4px; font-size: 11px; color: #333; }
.stamp {
  position: absolute;
  left: 0;
  top: 2px;
  width: 168px;
  color: var(--stamp);
  transform: rotate(-9deg);
  mix-blend-mode: multiply;
  opacity: .9;
}
.holo {
  position: absolute;
  right: 4px;
  top: 22px;
  width: 124px;
  height: 86px;
  display: flex;
  border-radius: 3px;
  overflow: hidden;
  background: linear-gradient(135deg, #6e1f46, #3c0e29);
  box-shadow: 0 1px 3px rgba(0, 0, 0, .45);
  transform: rotate(1.5deg);
  color: #fff;
  font: 700 11px/1.08 Arial, sans-serif;
}
.holo .foil {
  width: 40px;
  display: grid;
  place-items: center;
  background: conic-gradient(from 30deg, #ddd, #c9f, #9df, #fe9, #f9c, #ddd);
}
.holo .foil svg { width: 26px; }
.holo .txt { padding: 7px 6px; display: flex; flex-direction: column; justify-content: space-between; }
.holo .ok {
  align-self: flex-end;
  width: 17px;
  height: 17px;
  display: grid;
  place-items: center;
  background: #fff;
  color: #1c9b3c;
  font-size: 14px;
}
.holo::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(115deg, transparent 30%, rgba(255, 0, 200, .35) 42%, rgba(0, 255, 220, .35) 50%, rgba(255, 255, 0, .3) 58%, transparent 70%);
  background-size: 260% 100%;
  mix-blend-mode: screen;
  animation: shine 4.5s linear infinite;
}
@keyframes shine { from { background-position: 130% 0; } to { background-position: -130% 0; } }
.sign { position: absolute; right: 0; bottom: 0; width: 190px; transform: rotate(-4deg); }

/* explanation */
.explain { border-bottom: 3px solid var(--line); padding: 8px 4px 10px; }
.explain h2 {
  margin: 2px 0 8px;
  font-size: 15px;
  font-style: italic;
  text-transform: uppercase;
  letter-spacing: .02em;
}
.explain h2::before { content: '•'; margin: 0 14px 0 8px; font-style: normal; }
.explain p {
  margin: 0 0 6px;
  font-size: 13.5px;
  font-style: italic;
  line-height: 1.3;
  text-align: justify;
  text-indent: 2.2em;
  hyphens: auto;
}

/* candidates */
.cand {
  display: grid;
  grid-template-columns: 210px 1fr 74px;
  grid-template-areas: 'name bio box';
  gap: 18px;
  align-items: center;
  min-height: 170px;
  padding: 18px 6px;
  border-bottom: 3px solid var(--line);
  cursor: pointer;
  transition: background .2s;
}
.cand:hover { background: rgba(255, 255, 255, .28); }
.name { grid-area: name; line-height: 1.2; overflow-wrap: anywhere; }
.name b { display: block; font-size: 22px; text-transform: uppercase; }
.name span { display: block; font-size: 19px; font-weight: 700; }
.bio { grid-area: bio; margin: 0; font-size: 16.5px; line-height: 1.3; text-align: justify; text-indent: 3em; hyphens: auto; overflow-wrap: anywhere; }
.box {
  grid-area: box;
  justify-self: center;
  position: relative;
  width: 46px;
  height: 46px;
  border: 3px solid var(--line);
  background: rgba(255, 255, 255, .45);
}
.cand:has(input:focus-visible) .box { outline: 3px solid var(--stamp); outline-offset: 4px; }
.box svg { position: absolute; left: -14px; top: -16px; width: 76px; height: 76px; overflow: visible; pointer-events: none; }
.box path {
  fill: none;
  stroke: var(--pen);
  stroke-width: 4.5;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 1;
  stroke-dashoffset: 1;
  animation: draw .35s ease-out forwards;
}
.box path + path { animation-delay: .25s; }
@keyframes draw { to { stroke-dashoffset: 0; } }
.empty { padding: 50px 10px; text-align: center; font-style: italic; font-size: 18px; border-bottom: 3px solid var(--line); }

/* footer of ballot */
.foot { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; flex-wrap: wrap; padding-top: 22px; }
.field { display: flex; align-items: baseline; gap: 10px; flex: 1 1 260px; }
.field > span { font-size: 13px; font-style: italic; white-space: nowrap; }
.hand {
  flex: 1;
  min-width: 0;
  border: 0;
  border-bottom: 2px dotted #333;
  background: transparent;
  padding: 0 4px;
  font-family: 'Caveat', cursive;
  font-size: 27px;
  color: var(--pen);
  outline: none;
}
.hand::placeholder { color: rgba(31, 63, 160, .35); }
.hand:focus { border-bottom-color: var(--pen); }
textarea.hand { resize: vertical; line-height: 1.15; min-height: 64px; }

.btn {
  border: 3px solid var(--line);
  background: var(--line);
  color: var(--paper);
  padding: 13px 22px 12px;
  font-weight: 700;
  font-size: 17px;
  letter-spacing: .06em;
  text-transform: uppercase;
  cursor: pointer;
  box-shadow: 4px 4px 0 rgba(0, 0, 0, .3);
  transition: transform .12s, box-shadow .12s;
}
.btn:hover { transform: translate(-1px, -2px) rotate(-1deg); box-shadow: 6px 7px 0 rgba(0, 0, 0, .3); }
.btn:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 rgba(0, 0, 0, .3); }
.btn:disabled { opacity: .6; cursor: wait; }
.btn.ghost { background: transparent; color: var(--line); }
.err { width: 100%; margin: 6px 0 0; color: var(--red); font-weight: 700; min-height: 1.3em; }

/* nomination form */
.form .title { text-align: center; margin: 4px 0 2px; font-size: 26px; letter-spacing: .3em; }
.form .title + p { text-align: center; margin: 0 0 18px; font-weight: 700; font-size: 17px; }
.form .grid { display: grid; grid-template-columns: 1fr 140px; gap: 16px 22px; }
.form .wide { grid-column: 1 / -1; }
.form .field { flex-direction: column; align-items: stretch; gap: 0; }
.form .field > span { font-size: 12px; order: 2; text-align: center; color: #333; }
.form .foot { justify-content: flex-end; }

/* overlay after cast */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(30, 32, 31, .78);
  backdrop-filter: blur(3px);
  animation: fade .4s;
}
@keyframes fade { from { opacity: 0; } }
.done { text-align: center; color: #f4f4ef; max-width: 440px; }
.done svg { width: 220px; display: block; margin: 0 auto; }
.done .drop { animation: drop 1.1s .2s cubic-bezier(.5, 0, .9, .5) both; }
@keyframes drop { from { transform: translateY(-120px) rotate(-6deg); } to { transform: translateY(70px) rotate(0); } }
.done .pile-new { animation: fade .3s 1.2s both; }
.done .big {
  display: inline-block;
  margin: 18px 0 6px;
  padding: 6px 16px;
  border: 4px double var(--red);
  color: var(--red);
  background: rgba(255, 255, 255, .92);
  font-size: 26px;
  font-weight: 700;
  text-transform: uppercase;
  transform: rotate(-4deg);
  animation: slam .35s 1.3s cubic-bezier(.3, 1.6, .5, 1) both;
}
@keyframes slam { from { transform: scale(2.6) rotate(-14deg); opacity: 0; } }
.done .fine { font-size: 13px; opacity: .7; margin: 0 0 6px; font-style: italic; }
.done p { font-size: 18px; margin: 8px 0 22px; }
.done .btn { background: #f4f4ef; color: var(--line); border-color: #f4f4ef; }

/* registered stamp */
.reg {
  position: absolute;
  z-index: 2;
  left: 50%;
  top: 45%;
  padding: 8px 20px;
  border: 5px double var(--stamp);
  color: var(--stamp);
  font-size: 34px;
  font-weight: 700;
  letter-spacing: .1em;
  mix-blend-mode: multiply;
  pointer-events: none;
  transform: translate(-50%, -50%) rotate(-12deg);
  animation: slam .35s cubic-bezier(.3, 1.6, .5, 1) both, fade .6s 1.8s reverse forwards;
}

/* protocol */
.proto .head { grid-template-columns: 1fr 200px; }
.proto .stamp { width: 160px; }
.prow {
  display: grid;
  grid-template-columns: 36px 1fr auto;
  gap: 8px 14px;
  align-items: center;
  padding: 10px 4px;
  border-bottom: 1px solid #333;
}
.prow .n { font-weight: 700; }
.prow .t { font-weight: 700; text-transform: uppercase; overflow-wrap: anywhere; }
.prow .v { font-weight: 700; text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.prow .v small { font-weight: 400; display: block; font-size: 13px; }
.prow .meter { grid-column: 2 / -1; height: 16px; border: 2px solid var(--line); background: rgba(255, 255, 255, .5); position: relative; }
.prow .meter i {
  position: absolute;
  inset: 0 auto 0 0;
  background: repeating-linear-gradient(-45deg, var(--pen) 0 3px, transparent 3px 7px);
  transition: width .8s cubic-bezier(.3, 1.3, .5, 1);
}
.prow.lead { position: relative; background: rgba(255, 255, 255, .3); }
.prow.lead .win {
  position: absolute;
  right: 120px;
  top: 2px;
  padding: 2px 10px;
  border: 3px solid var(--red);
  color: var(--red);
  font-weight: 700;
  font-size: 15px;
  letter-spacing: .12em;
  transform: rotate(-6deg);
  mix-blend-mode: multiply;
}
.stats { margin: 12px 0 14px; }
.stats .prow { grid-template-columns: 36px 1fr auto; border-bottom: 1px dotted #555; padding: 6px 4px; font-size: 15px; }
.stats .hot { color: var(--red); }
.section-t { margin: 22px 0 6px; font-size: 16px; text-transform: uppercase; letter-spacing: .08em; border-bottom: 3px solid var(--line); padding-bottom: 6px; }
.live { margin: 16px 0 0; font-size: 12px; font-style: italic; text-align: right; color: #444; }
.live::before { content: ''; display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--red); margin-right: 6px; animation: blink 1.4s infinite; }
@keyframes blink { 50% { opacity: .2; } }

/* admin */
.modes { display: flex; margin: 16px 0 4px; border: 3px solid var(--line); width: fit-content; max-width: 100%; }
.modes button { border: 0; background: transparent; padding: 8px 14px; font-weight: 700; cursor: pointer; }
.modes button[aria-pressed='true'] { background: var(--line); color: var(--paper); }
.voter { border-bottom: 1px solid #333; }
.voter summary { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; padding: 8px 4px; cursor: pointer; list-style: none; }
.voter summary::-webkit-details-marker { display: none; }
.voter summary b { font-family: 'Caveat', cursive; font-size: 24px; color: var(--pen); font-weight: 700; }
.chip { font-size: 12px; padding: 1px 6px; border: 1px solid #555; font-family: ui-monospace, monospace; }
.badge { font-size: 12px; font-weight: 700; padding: 2px 7px; border: 2px solid var(--red); color: var(--red); transform: rotate(-3deg); letter-spacing: .08em; }
.voter ol { margin: 0 0 10px; padding-left: 26px; font-size: 14px; }
.voter li { margin: 3px 0; }
.voter li.void { text-decoration: line-through; opacity: .55; }
.voter li time { font-family: ui-monospace, monospace; font-size: 12px; margin-right: 6px; }
.crow { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 6px 4px; border-bottom: 1px dotted #555; }
.crow small { color: #444; }
.crow button { border: 2px solid var(--red); color: var(--red); background: transparent; cursor: pointer; font-weight: 700; padding: 2px 8px; flex: none; }

@media (max-width: 680px) {
  .sheet { padding: 14px 14px 22px; transform: none; }
  .head, .proto .head { grid-template-columns: 1fr; }
  .head h1 { font-size: 21px; }
  .sub { font-size: 16px; }
  .seal { min-height: 150px; order: -1; }
  .stamp { width: 140px; left: 6px; }
  .proto .stamp { width: 130px; }
  .sign { width: 150px; right: auto; left: 150px; bottom: 6px; }
  .cand {
    grid-template-columns: 1fr 60px;
    grid-template-areas: 'name box' 'bio bio';
    gap: 10px 12px;
    min-height: 0;
    padding: 16px 2px;
  }
  .name b { font-size: 19px; }
  .name span { font-size: 16px; }
  .bio { font-size: 15px; text-indent: 2em; }
  .explain p { font-size: 12.5px; }
  .form .grid { grid-template-columns: 1fr; }
  .btn { width: 100%; }
  .prow.lead .win { right: 70px; }
}

.sealed { position: relative; margin: 26px 0 8px; padding: 40px 16px 30px; text-align: center; border: 3px dashed var(--line); background: rgba(255, 255, 255, .35); overflow: hidden; }
.sealed .tape {
  display: inline-block;
  margin-bottom: 18px;
  padding: 8px 26px;
  border: 5px double var(--red);
  color: var(--red);
  font-size: 30px;
  font-weight: 700;
  letter-spacing: .12em;
  transform: rotate(-5deg);
  mix-blend-mode: multiply;
}
.sealed p { margin: 0 0 10px; font-size: 18px; }
.sealed .clock { margin-top: 18px; font: 700 44px/1 'PT Serif', serif; font-variant-numeric: tabular-nums; }
.sealed .clock small { display: block; margin-bottom: 8px; font-size: 13px; font-weight: 400; font-style: italic; }
@media (max-width: 680px) { .sealed .tape { font-size: 21px; } .sealed .clock { font-size: 32px; } }
