.ballot {
  --ballot-olive: var(--olive, #354638);
  --ballot-muted: var(--muted, #666b60);
  --ballot-line: var(--line, #e4e3db);
  --ballot-paper: var(--paper, #f8f7f3);
  --ballot-orange: var(--orange, #ae4b36);
  width: min(100%, 850px);
  margin-inline: auto;
}
.ballot :is(h2, p, ol) { margin: 0; }
.ballot button { font: inherit; }
.ballot button { -webkit-tap-highlight-color: transparent; }

.ballot-slots {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: clamp(6px, 1.5vw, 12px);
  padding: 0;
  list-style: none;
}
.ballot-rank--gold { --medal-bg: #ffebac; --medal-ink: #674600; }
.ballot-rank--silver { --medal-bg: #e8eaf0; --medal-ink: #465063; }
.ballot-rank--bronze { --medal-bg: #f8dfcc; --medal-ink: #794633; }
.ballot-rank { position: relative; min-width: 0; }
.ballot-slot {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  height: 100%;
  min-height: 72px;
  padding: 9px;
  color: var(--ballot-olive);
  border: 1px dashed #c8c9bb;
  border-radius: 13px;
  background: #fff;
}
.ballot-slot:has(.ballot-slot-name) { border-style: solid; }
.ballot-rank-number,
.ballot-team-place {
  display: inline-grid;
  place-items: center;
  min-width: 31px;
  min-height: 25px;
  color: var(--medal-ink);
  background: var(--medal-bg);
  border-radius: 999px;
  font-size: .84rem;
  font-weight: 900;
  line-height: 1;
}
.ballot-slot-name {
  overflow-wrap: anywhere;
  color: var(--ballot-olive);
  font-size: .8rem;
  font-weight: 800;
  line-height: 1.2;
}
.ballot-team-art > .art {
  width: 100%;
  height: 100%;
  min-height: 0;
  aspect-ratio: auto;
  border-radius: 0;
}
.ballot-remove {
  position: absolute;
  top: 1px;
  right: 2px;
  display: grid;
  place-items: center;
  width: 30px;
  height: 32px;
  padding: 0;
  color: var(--ballot-olive);
  border: 0;
  border-radius: 50%;
  background: transparent;
  font-size: 1.22rem !important;
  line-height: 1;
}
.ballot-remove:hover { color: var(--ballot-orange); background: #f9eee6; }

.ballot-lineup { margin-top: clamp(18px, 4vw, 27px); }
.ballot-projects {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 148px), 1fr));
  gap: clamp(8px, 1.8vw, 15px);
}
.ballot-project { position: relative; min-width: 0; }
.ballot-team {
  position: relative;
  display: block;
  width: 100%;
  height: 100%;
  padding: 0;
  overflow: hidden;
  color: var(--ballot-olive);
  border: 2px solid #778573;
  border-radius: 14px;
  background: #fff;
  text-align: left;
  transition: border-color 140ms, box-shadow 140ms;
}
.ballot-team:not(:disabled):hover,
.ballot-project.is-ranked .ballot-team {
  border-color: var(--ballot-olive);
  box-shadow: 0 0 0 1px var(--ballot-olive);
}
.ballot-team-art {
  display: block;
  width: 100%;
  aspect-ratio: 1;
  overflow: hidden;
}
.ballot-team-art img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.ballot-team-copy {
  position: relative;
  display: grid;
  gap: 3px;
  min-height: 61px;
  padding: 10px 27px 10px 10px;
  align-content: center;
}
.ballot-team-copy::after {
  position: absolute;
  content: '';
  right: 12px;
  top: calc(50% - 4px);
  width: 7px;
  height: 7px;
  border-right: 2px solid #586951;
  border-top: 2px solid #586951;
  transform: rotate(45deg);
}
.ballot-team-copy strong {
  overflow-wrap: anywhere;
  font-size: .98rem;
  font-weight: 800;
  line-height: 1.2;
}
.ballot-team-copy small {
  color: var(--ballot-muted);
  font-size: .79rem;
  line-height: 1.2;
}
.ballot-team-place {
  position: absolute;
  top: 6px;
  left: 6px;
  width: 32px;
  height: 32px;
  box-shadow: 0 1px 3px #15151224;
}
.ballot-medal-options {
  display: grid;
  gap: 8px;
  margin: 16px 0;
}
.ballot-medal-dialog h2 { padding-right: 0; overflow-wrap: anywhere; }
.ballot-medal-choice {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  min-height: 50px;
  padding: 7px 10px;
  text-align: left;
  color: var(--olive);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 11px;
}
.ballot-medal-choice:hover,
.ballot-medal-choice[aria-pressed="true"] { background: #edf2dc; border-color: #a5af86; }
.ballot-medal-choice small { display: block; color: var(--muted); overflow-wrap: anywhere; }
.ballot-medal-cancel { width: 100%; }

.ballot-footer {
  position: sticky;
  z-index: 2;
  bottom: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 18px;
  padding: 10px 0 max(10px, env(safe-area-inset-bottom));
  border-top: 1px solid var(--ballot-line);
  background: var(--ballot-paper);
}
.ballot-feedback {
  flex: 1 1 auto;
  color: var(--ballot-muted);
  font-size: .88rem;
  line-height: 1.25;
}
.ballot-feedback.is-error {
  color: var(--ballot-orange);
  font-weight: 800;
}
.ballot-submit {
  flex: 0 0 auto;
  min-height: 44px;
  padding: 8px 14px;
  color: #fff;
  border: 0;
  border-radius: 10px;
  background: var(--ballot-olive);
  font-weight: 800 !important;
}
.ballot-submit:disabled {
  color: #576348;
  background: #ecf0e4;
  cursor: default;
}
.ballot-submit:not(:disabled):hover { filter: brightness(.9); }
.ballot-closed {
  color: var(--ballot-olive);
  font-weight: 800;
}
@media (max-width: 560px) {
  .ballot-projects { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .ballot-team-place { top: 5px; left: 5px; }
}
@media (prefers-reduced-motion: reduce) {
  .ballot .ballot-team { transition: none; }
}
