:root {
  --ink: #1d211f;
  --muted: #6c756f;
  --paper: #f6f1e8;
  --panel: #fffaf0;
  --line: #d8cdb8;
  --accent: #1f6f5b;
  --accent-2: #c46a2b;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 15% 10%, rgba(31, 111, 91, 0.12), transparent 28rem),
    radial-gradient(circle at 90% 20%, rgba(196, 106, 43, 0.12), transparent 24rem),
    var(--paper);
  font-family: Avenir Next, Charter, Georgia, sans-serif;
}

header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.4rem;
  background: rgba(246, 241, 232, 0.92);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(10px);
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: 1.2rem;
  letter-spacing: 0.02em;
}

#status,
.instruction,
.meta,
.count-labels,
table {
  color: var(--muted);
  font-size: 0.92rem;
}

.tabs,
.voter-form {
  display: flex;
  align-items: center;
  gap: 0.55rem;
}

.tab {
  color: var(--accent);
  background: transparent;
  border: 1px solid var(--line);
}

.tab.active {
  color: white;
  background: var(--accent);
}

input {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.55rem 0.8rem;
  background: white;
  color: var(--ink);
}

input[readonly] {
  background: #f0eadf;
  color: var(--muted);
}

dialog {
  width: min(520px, 92vw);
  border: 1px solid var(--line);
  border-radius: 24px;
  padding: 0;
  background: var(--panel);
  box-shadow: 0 30px 100px rgba(31, 41, 35, 0.28);
}

dialog::backdrop {
  background: rgba(29, 33, 31, 0.42);
  backdrop-filter: blur(4px);
}

.voter-dialog form,
.results-dialog form {
  display: grid;
  gap: 0.75rem;
  padding: 1.4rem;
}

.voter-dialog input,
.results-dialog input {
  width: 100%;
  border-radius: 14px;
}

.voter-dialog menu,
.results-dialog menu {
  display: flex;
  gap: 0.55rem;
  justify-content: flex-end;
  margin: 0.3rem 0 0;
  padding: 0;
}

.error-text {
  color: #a73526;
  font-weight: 800;
}

main {
  width: min(1700px, 96vw);
  margin: 1rem auto 3rem;
}

.prompt-card,
.intro-card,
.leaderboard {
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 1rem;
  background: rgba(255, 250, 240, 0.86);
  box-shadow: 0 16px 50px rgba(78, 55, 30, 0.08);
}

.intro-card {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: end;
  gap: 1rem;
  margin-bottom: 1rem;
}

.eyebrow {
  margin-bottom: 0.25rem;
  color: var(--accent-2);
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.hidden {
  display: none !important;
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

.meta {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 0.35rem;
  font-weight: 700;
  color: var(--accent);
}

#prompt {
  margin-bottom: 0.4rem;
  font-size: clamp(1.05rem, 1.5vw, 1.5rem);
}

.arena {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin: 1rem 0;
}

.candidate {
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 0.8rem;
  background: white;
  box-shadow: 0 20px 60px rgba(31, 41, 35, 0.1);
}

.candidate-head,
.section-head,
.controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.8rem;
}

.candidate h3 {
  font-size: 1rem;
  color: var(--accent);
}

.candidate img {
  display: block;
  width: 100%;
  max-height: 70vh;
  object-fit: contain;
  margin: 0.8rem 0;
  border-radius: 16px;
  background: #ece7dc;
}

button {
  border: 0;
  border-radius: 999px;
  padding: 0.7rem 1rem;
  color: white;
  background: var(--accent);
  font-weight: 800;
  cursor: pointer;
}

button:hover {
  filter: brightness(1.08);
}

.secondary {
  color: var(--ink);
  background: #e7ddcc;
}

.link-button {
  color: var(--accent);
  background: transparent;
  border: 1px solid var(--line);
  padding: 0.5rem 0.75rem;
}

#voteRight {
  background: var(--accent-2);
}

#tie,
#skip {
  background: #3d4540;
}

.count-labels {
  display: flex;
  flex-wrap: wrap;
  gap: 0.7rem;
  align-items: center;
}

.controls {
  justify-content: flex-start;
  margin-bottom: 1rem;
}

#notes {
  min-width: min(520px, 60vw);
  border-radius: 12px;
}

.leaderboard {
  overflow-x: auto;
}

.section-head {
  margin-bottom: 0.7rem;
}

.section-head a {
  color: var(--accent);
  font-weight: 800;
  margin-left: 0.8rem;
}

table {
  width: 100%;
  border-collapse: collapse;
  background: white;
  border-radius: 14px;
  overflow: hidden;
}

th,
td {
  text-align: left;
  border-bottom: 1px solid #ece4d7;
  padding: 0.55rem;
}

th {
  color: var(--ink);
  background: #efe6d5;
}

@media (max-width: 900px) {
  header,
  .arena,
  .candidate-head,
  .controls,
  .intro-card,
  .voter-form {
    display: block;
  }

  .candidate,
  .prompt-card,
  .leaderboard {
    margin-bottom: 1rem;
  }

  button {
    margin-top: 0.5rem;
    width: 100%;
  }

  .tabs {
    display: grid;
    grid-template-columns: 1fr 1fr;
    width: 100%;
  }
}
