:root {
  --parchment: #efe5cd;
  --parchment-deep: #e5d8b8;
  --parchment-bright: #f6efdb;
  --ink: #1a1410;
  --ink-soft: #5b4a3b;
  --ink-faint: #8a7a64;
  --rule: #c4b288;
  --gold: #a67d24;
  --gold-bright: #cc9a30;
  --gold-deep: #6f5215;
  --oxblood: #7a1d22;
  --oxblood-deep: #4a0e12;
  --oxblood-soft: rgba(122, 29, 34, 0.10);
  --ok: #2d5b3a;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--parchment);
  color: var(--ink);
  font-family: 'Inter', -apple-system, system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.55;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* Paper grain — warmer, more textured than before */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 1;
  background-image:
    radial-gradient(circle at 18% 25%, rgba(80, 50, 20, 0.04) 0 1px, transparent 1.5px),
    radial-gradient(circle at 72% 65%, rgba(80, 50, 20, 0.035) 0 1px, transparent 1.5px),
    radial-gradient(circle at 45% 85%, rgba(80, 50, 20, 0.025) 0 1px, transparent 1.5px),
    radial-gradient(ellipse at 50% 0%, rgba(0,0,0,0.04), transparent 60%),
    radial-gradient(ellipse at 50% 100%, rgba(0,0,0,0.04), transparent 60%);
  background-size: 9px 9px, 13px 13px, 17px 17px, 100% 100%, 100% 100%;
  mix-blend-mode: multiply;
}

/* Damask diamond background — very faint */
.damask {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  color: var(--gold);
  opacity: 0.06;
  z-index: 0;
  pointer-events: none;
}

.frame {
  position: relative;
  z-index: 2;
  max-width: 780px;
  margin: 0 auto;
  padding: 40px 32px 64px;
}

/* MASTHEAD */
.masthead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 56px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--ink);
  position: relative;
}
.masthead::after {
  content: "";
  position: absolute;
  bottom: -4px;
  left: 0;
  right: 0;
  height: 1px;
  background: var(--ink);
  opacity: 0.4;
}

.brand {
  display: flex;
  align-items: baseline;
  gap: 12px;
}

.crown-mark {
  font-size: 22px;
  color: var(--gold);
  line-height: 1;
}

.wordmark {
  font-family: 'Cormorant Garamond', serif;
  font-weight: 700;
  font-size: 30px;
  letter-spacing: 0.04em;
  color: var(--ink);
}

.brand .rule {
  width: 1px;
  height: 22px;
  background: var(--ink-faint);
  display: inline-block;
}

.subbrand {
  font-family: 'Cormorant Garamond', serif;
  font-style: italic;
  font-size: 17px;
  color: var(--ink-soft);
}

.masthead-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
}

.reign-number {
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  color: var(--ink-soft);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.reign-number span { color: var(--oxblood); font-weight: 500; }

.x-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: 'Cormorant Garamond', serif;
  font-style: italic;
  font-size: 14px;
  color: var(--ink-soft);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  padding-bottom: 1px;
  transition: color 0.15s, border-color 0.15s;
}
.x-link:hover {
  color: var(--oxblood);
  border-bottom-color: var(--gold);
}
.x-link svg {
  color: var(--ink-soft);
  transition: color 0.15s;
}
.x-link:hover svg { color: var(--oxblood); }

/* LEDE */
.lede { margin-bottom: 52px; }

.lede h1 {
  font-family: 'Cormorant Garamond', serif;
  font-weight: 500;
  font-size: clamp(26px, 4vw, 36px);
  line-height: 1.25;
  letter-spacing: -0.005em;
  margin: 0;
  color: var(--ink);
  max-width: 680px;
}

.lede h1 em {
  font-style: italic;
  font-weight: 600;
  color: var(--oxblood);
}

/* VOTE */
.vote { margin-bottom: 64px; }

.vote label {
  display: block;
  font-family: 'Cormorant Garamond', serif;
  font-style: italic;
  font-size: 16px;
  color: var(--ink-soft);
  margin-bottom: 10px;
  letter-spacing: 0.02em;
}

.vote-row {
  display: flex;
  gap: 0;
  border: 1px solid var(--ink);
  background: var(--parchment-bright);
  box-shadow: 2px 2px 0 var(--ink);
  transition: box-shadow 0.15s, transform 0.15s;
}

.vote-row:focus-within {
  box-shadow: 3px 3px 0 var(--oxblood);
  transform: translate(-1px, -1px);
}

#ca {
  flex: 1;
  min-width: 0;
  padding: 16px 18px;
  background: transparent;
  border: none;
  font-family: 'JetBrains Mono', monospace;
  font-size: 14px;
  color: var(--ink);
  outline: none;
}
#ca::placeholder {
  color: var(--ink-faint);
  font-style: italic;
  font-family: 'Cormorant Garamond', serif;
  font-size: 15px;
}

#vote-btn {
  padding: 16px 26px;
  background: var(--ink);
  color: var(--parchment-bright);
  border: none;
  border-left: 1px solid var(--ink);
  font-family: 'Cormorant Garamond', serif;
  font-size: 16px;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s;
}
#vote-btn:hover:not(:disabled) {
  background: var(--oxblood);
}
#vote-btn:disabled {
  background: var(--ink-faint);
  cursor: not-allowed;
}

.message {
  min-height: 22px;
  margin-top: 14px;
  font-size: 14px;
  font-family: 'Cormorant Garamond', serif;
  font-style: italic;
  font-size: 15px;
}
.message.ok { color: var(--ok); }
.message.err { color: var(--oxblood); }
.message.ok::before { content: "✓  "; font-style: normal; }
.message.err::before { content: "—  "; font-style: normal; }

/* THRONE */
.throne-section { margin-bottom: 64px; }

.throne-rail {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin-bottom: 18px;
}
.throne-rail::before, .throne-rail::after {
  content: "";
  flex: 1;
  max-width: 140px;
  height: 1px;
  background: linear-gradient(to right, transparent, var(--gold), transparent);
}
.throne-rail::before { background: linear-gradient(to right, transparent, var(--gold)); }
.throne-rail::after { background: linear-gradient(to left, transparent, var(--gold)); }

.rail-glyph {
  color: var(--gold);
  font-size: 14px;
}

.rail-label {
  font-family: 'Cormorant Garamond', serif;
  font-style: italic;
  font-weight: 600;
  font-size: 22px;
  color: var(--ink);
  letter-spacing: 0.05em;
}

.throne-frame {
  padding: 6px;
  border: 1px solid var(--gold);
  background: linear-gradient(135deg, var(--oxblood) 0%, var(--oxblood-deep) 100%);
  box-shadow:
    0 0 0 1px var(--gold-deep) inset,
    4px 4px 0 var(--ink);
  position: relative;
}
.throne-frame::before,
.throne-frame::after {
  content: "";
  position: absolute;
  width: 16px;
  height: 16px;
  border: 1px solid var(--gold);
}
.throne-frame::before { top: -4px; left: -4px; border-right: none; border-bottom: none; }
.throne-frame::after  { bottom: -4px; right: -4px; border-left: none; border-top: none; }

.throne-card {
  padding: 36px 26px 30px;
  text-align: center;
  border: 1px solid var(--gold-deep);
  background: linear-gradient(180deg, rgba(0,0,0,0) 0%, rgba(0,0,0,0.18) 100%);
}

.throne-crown {
  font-size: 56px;
  color: var(--gold-bright);
  line-height: 1;
  margin-bottom: 18px;
  text-shadow:
    0 0 30px rgba(204, 154, 48, 0.5),
    0 2px 0 var(--gold-deep);
}

.throne-status {
  font-family: 'Cormorant Garamond', serif;
  font-style: italic;
  font-size: 18px;
  color: var(--parchment);
  opacity: 0.7;
}

.throne-image {
  display: block;
  width: 110px;
  height: 110px;
  margin: 0 auto 18px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--gold);
  box-shadow:
    0 0 0 1px var(--gold-deep) inset,
    0 0 24px rgba(204, 154, 48, 0.32),
    0 6px 18px rgba(0, 0, 0, 0.35);
  background: var(--oxblood-deep);
}
.throne-image[hidden] { display: none; }

.throne-identity {
  margin-bottom: 14px;
}
.throne-identity[hidden] { display: none; }

.throne-name {
  display: block;
  font-family: 'Cormorant Garamond', serif;
  font-weight: 600;
  font-size: 30px;
  color: var(--parchment-bright);
  line-height: 1.15;
  letter-spacing: -0.005em;
  margin-bottom: 4px;
}

.throne-symbol {
  display: block;
  font-family: 'JetBrains Mono', monospace;
  font-size: 13px;
  color: var(--gold-bright);
  letter-spacing: 0.14em;
}

.throne-ca-wrap {
  margin-bottom: 16px;
}
.throne-ca-wrap[hidden] { display: none; }

.throne-ca {
  font-family: 'JetBrains Mono', monospace;
  font-size: 15px;
  color: var(--parchment-bright);
  background: rgba(0,0,0,0.25);
  padding: 8px 14px;
  border: 1px solid var(--gold-deep);
  display: inline-block;
  max-width: 100%;
  overflow-x: auto;
  white-space: nowrap;
  letter-spacing: 0.02em;
}

.throne-stats {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  font-family: 'Cormorant Garamond', serif;
  color: var(--parchment);
}
.throne-stats[hidden] { display: none; }

.throne-stat {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.throne-stat-label {
  font-style: italic;
  font-size: 12px;
  color: var(--gold-bright);
  opacity: 0.8;
  letter-spacing: 0.1em;
  text-transform: lowercase;
}

.throne-stat-value {
  font-weight: 600;
  font-size: 24px;
  color: var(--parchment-bright);
  font-variant-numeric: tabular-nums;
}

.throne-divider {
  color: var(--gold);
  opacity: 0.4;
  font-size: 18px;
  margin-top: 14px;
}

.round-status {
  margin-top: 14px;
  font-family: 'Cormorant Garamond', serif;
  font-style: italic;
  font-size: 14px;
  color: var(--gold-deep);
  min-height: 18px;
  text-align: center;
}

/* SECTION RULES */
.section-rule {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--ink);
  position: relative;
}
.section-rule::after {
  content: "";
  position: absolute;
  left: 0; right: 0;
  bottom: -3px;
  height: 1px;
  background: var(--gold);
  opacity: 0.6;
}

.kicker {
  font-family: 'Cormorant Garamond', serif;
  font-style: italic;
  font-weight: 600;
  font-size: 24px;
  color: var(--ink);
}
.kicker::first-letter {
  font-size: 32px;
  color: var(--oxblood);
}

.kicker-meta {
  font-family: 'Cormorant Garamond', serif;
  font-style: italic;
  font-size: 13px;
  color: var(--ink-faint);
}

/* COURT (BOARD) */
.board { margin-bottom: 64px; }

.leaderboard {
  list-style: none;
  margin: 0;
  padding: 0;
}

.leaderboard li {
  display: grid;
  grid-template-columns: 36px 1fr auto;
  align-items: center;
  gap: 16px;
  padding: 14px 4px;
  border-bottom: 1px dotted var(--rule);
  transition: background 0.15s;
}
.leaderboard li:hover { background: var(--oxblood-soft); }
.leaderboard li:last-child { border-bottom: 1px solid var(--ink); }

.rank {
  font-family: 'Cormorant Garamond', serif;
  font-style: italic;
  font-size: 18px;
  color: var(--gold-deep);
  text-align: right;
}

.ca {
  font-family: 'JetBrains Mono', monospace;
  font-size: 13px;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.count {
  font-family: 'Cormorant Garamond', serif;
  font-weight: 600;
  font-size: 22px;
  color: var(--ink);
  text-align: right;
  min-width: 40px;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

/* PURSE */
.purse { margin-bottom: 64px; }

.purse-card {
  padding: 22px;
  background: var(--parchment-bright);
  border: 1px solid var(--ink);
  position: relative;
}
.purse-card::before {
  content: "";
  position: absolute;
  top: -1px; left: -1px;
  width: 48px; height: 4px;
  background: var(--gold);
}

.purse-line {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.purse-ticker {
  font-family: 'Cormorant Garamond', serif;
  font-weight: 700;
  font-size: 24px;
  color: var(--oxblood);
  letter-spacing: 0.02em;
}

.purse-ca {
  font-family: 'JetBrains Mono', monospace;
  font-size: 13px;
  color: var(--ink);
  padding: 6px 10px;
  background: var(--parchment-deep);
  border: 1px solid var(--rule);
  overflow-x: auto;
  white-space: nowrap;
  flex: 1;
  min-width: 0;
}

.purse-actions {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

#koth-copy, .link-btn {
  font-family: 'Cormorant Garamond', serif;
  font-size: 14px;
  font-weight: 500;
  padding: 8px 16px;
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--ink);
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s, color 0.15s;
  letter-spacing: 0.04em;
}
#koth-copy:hover, .link-btn:hover {
  background: var(--ink);
  color: var(--parchment-bright);
}

.purse-blurb {
  font-family: 'Cormorant Garamond', serif;
  font-style: italic;
  font-size: 15px;
  color: var(--ink-soft);
  margin: 0;
  line-height: 1.5;
}

/* LINEAGE (HISTORY) */
.archive { margin-bottom: 48px; }

.history {
  list-style: none;
  margin: 0;
  padding: 0;
}

.history li {
  padding: 20px 0;
  border-bottom: 1px solid var(--rule);
  position: relative;
}
.history li:last-child { border-bottom: 1px solid var(--ink); }

.history-top {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

.history-image {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  object-fit: cover;
  border: 1px solid var(--gold);
  background: var(--parchment-deep);
  flex-shrink: 0;
}

.history-identity {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
  flex: 1;
}
.history-name {
  font-family: 'Cormorant Garamond', serif;
  font-weight: 600;
  font-size: 17px;
  color: var(--ink);
  line-height: 1.1;
}
.history-symbol {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  color: var(--gold-deep);
  letter-spacing: 0.1em;
}

.history-crown {
  color: var(--gold);
  font-size: 16px;
  line-height: 1;
}

.history-id {
  font-family: 'Cormorant Garamond', serif;
  font-style: italic;
  font-weight: 600;
  font-size: 16px;
  color: var(--oxblood);
  letter-spacing: 0.02em;
}

.history-ca {
  font-family: 'JetBrains Mono', monospace;
  font-size: 14px;
  color: var(--ink);
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-votes {
  font-family: 'Cormorant Garamond', serif;
  font-weight: 600;
  font-size: 18px;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}
.history-votes::after {
  content: " votes";
  font-family: 'Cormorant Garamond', serif;
  font-style: italic;
  font-weight: 400;
  font-size: 13px;
  color: var(--ink-faint);
  margin-left: 3px;
}

.history-when {
  font-family: 'Cormorant Garamond', serif;
  font-style: italic;
  font-size: 13px;
  color: var(--ink-faint);
}

.badge {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  padding: 3px 8px;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  border: 1px solid;
}
.badge.pending { color: var(--gold-deep); border-color: var(--gold-deep); background: rgba(166, 125, 36, 0.08); }
.badge.completed { color: var(--ok); border-color: var(--ok); background: rgba(45, 91, 58, 0.06); }
.badge.no_funds { color: var(--ink-soft); border-color: var(--ink-soft); }
.badge.partial { color: var(--gold-deep); border-color: var(--gold-deep); }
.badge.failed { color: var(--oxblood); border-color: var(--oxblood); background: var(--oxblood-soft); }

.history-stats {
  font-family: 'Cormorant Garamond', serif;
  font-style: italic;
  font-size: 14px;
  color: var(--ink-soft);
  margin-top: 6px;
  margin-bottom: 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 4px 18px;
}
.history-stats .stat-label {
  font-style: normal;
  color: var(--ink-faint);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-size: 10px;
  margin-right: 4px;
  font-family: 'JetBrains Mono', monospace;
}

.history-links {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 16px;
  font-size: 14px;
  margin-top: 6px;
  font-family: 'Cormorant Garamond', serif;
}

.history-links a {
  color: var(--ink);
  text-decoration: none;
  border-bottom: 1px solid var(--gold);
  padding-bottom: 1px;
  transition: color 0.15s, border-color 0.15s;
}
.history-links a:hover {
  color: var(--oxblood);
  border-bottom-color: var(--oxblood);
}

.history-error {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  color: var(--oxblood);
  margin-top: 8px;
  padding: 6px 10px;
  background: var(--oxblood-soft);
  border-left: 2px solid var(--oxblood);
  word-break: break-word;
}

.empty-state {
  font-family: 'Cormorant Garamond', serif;
  font-style: italic;
  color: var(--ink-faint);
  text-align: center;
  padding: 28px 0;
  font-size: 16px;
}
.empty-state.hidden { display: none; }

.foot {
  text-align: center;
  padding-top: 32px;
  color: var(--ink-faint);
  font-size: 13px;
  font-family: 'Cormorant Garamond', serif;
  font-style: italic;
  letter-spacing: 0.02em;
}
.foot .dot {
  margin: 0 8px;
  color: var(--gold);
  font-style: normal;
  font-size: 9px;
  vertical-align: 2px;
}

@keyframes bump {
  0% { transform: translateX(0); background: transparent; }
  30% { transform: translateX(2px); background: var(--oxblood-soft); }
  100% { transform: translateX(0); background: transparent; }
}
.bump { animation: bump 0.45s ease; }

@keyframes ascend {
  0% { transform: translateY(8px); opacity: 0; }
  100% { transform: translateY(0); opacity: 1; }
}
.throne-card > * { animation: ascend 0.35s ease both; }
.throne-card > *:nth-child(2) { animation-delay: 0.05s; }
.throne-card > *:nth-child(3) { animation-delay: 0.1s; }
.throne-card > *:nth-child(4) { animation-delay: 0.15s; }

@media (max-width: 600px) {
  .frame { padding: 24px 18px 48px; }
  .masthead { margin-bottom: 36px; }
  .wordmark { font-size: 24px; }
  .crown-mark { font-size: 18px; }
  .subbrand { font-size: 14px; display: none; }
  .brand .rule { display: none; }
  .lede { margin-bottom: 40px; }
  .lede h1 { font-size: 22px; }
  .vote { margin-bottom: 48px; }
  .vote-row { flex-direction: column; box-shadow: 2px 2px 0 var(--ink); }
  #vote-btn { border-left: none; border-top: 1px solid var(--ink); width: 100%; }
  .throne-section { margin-bottom: 48px; }
  .throne-card { padding: 28px 18px 24px; }
  .throne-crown { font-size: 44px; margin-bottom: 14px; }
  .throne-ca { font-size: 12px; padding: 6px 10px; }
  .throne-stat-value { font-size: 20px; }
  .board { margin-bottom: 48px; }
  .purse { margin-bottom: 48px; }
  .purse-card { padding: 18px; }
  .purse-ca { font-size: 11px; }
  .history-top { gap: 10px; }
  .history-ca { font-size: 12px; flex-basis: 100%; }
  .section-rule { flex-direction: column; align-items: flex-start; gap: 4px; }
}
