:root {
  color-scheme: dark;
  --ink: #15141f;
  --ink-soft: #242235;
  --dirt: #5b3b28;
  --dirt-dark: #35241d;
  --timber: #7b5032;
  --timber-light: #ad7548;
  --paper: #e8d8a5;
  --paper-dark: #c4aa70;
  --text: #f5ecd0;
  --dim: #c5b993;
  --gold: #f6c744;
  --silver: #c8d0d9;
  --oil: #8d96ad;
  --green: #64c466;
  --red: #dc4f45;
  --shadow: 5px 5px 0 #0b0a10;
  font-family: ui-monospace, "SF Mono", Menlo, Monaco, Consolas, monospace;
  font-synthesis: none;
}

* { box-sizing: border-box; }
html { min-width: 320px; scroll-behavior: smooth; }
body {
  min-height: 100vh;
  margin: 0;
  overflow-x: hidden;
  background:
    linear-gradient(rgba(255,255,255,.018) 50%, transparent 50%) 0 0 / 100% 4px,
    var(--ink);
  color: var(--text);
  font-size: 14px;
  line-height: 1.45;
}
body[data-busy="true"] { cursor: progress; }
[hidden] { display: none !important; }
a { color: inherit; }
button, input { font: inherit; }
button { cursor: pointer; }
button, .header-links a {
  min-height: 42px;
  border: 3px solid #241b17;
  border-radius: 0;
  padding: 8px 12px;
  background: var(--gold);
  box-shadow: 3px 3px 0 #09080c;
  color: #1b1710;
  font-weight: 900;
  letter-spacing: .02em;
  transition: filter 100ms linear, transform 100ms linear, box-shadow 100ms linear;
}
button:hover:not(:disabled), .header-links a:hover { filter: brightness(1.12); }
button:active:not(:disabled) { transform: translate(3px,3px); box-shadow: none; }
button:disabled { cursor: not-allowed; filter: grayscale(.45); opacity: .48; }
button.ghost { border-color: #4b4560; background: var(--ink-soft); color: var(--text); }
:focus-visible { outline: 3px solid #fff8ca; outline-offset: 3px; }
.skip-link { position: fixed; z-index: 1000; top: 8px; left: 8px; padding: 10px 14px; transform: translateY(-150%); background: var(--gold); color: var(--ink); font-weight: 900; }
.skip-link:focus { transform: none; }

.topbar {
  position: relative;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: 72px;
  padding: 10px clamp(12px,3vw,28px);
  border-bottom: 4px solid #09080c;
  background: #211a18;
}
.brand { display: flex; align-items: center; gap: 10px; min-width: max-content; color: var(--paper); text-decoration: none; }
.brand-mark { display: grid; width: 42px; height: 42px; place-items: center; border: 3px solid #08070a; background: var(--gold); box-shadow: 3px 3px 0 var(--timber); color: #1a1510; font-size: 22px; }
.brand b, .brand small { display: block; }
.brand b { font-size: 18px; line-height: 1; letter-spacing: .08em; }
.brand small { margin-top: 5px; color: var(--timber-light); font-size: 9px; letter-spacing: .14em; }
.header-links { display: flex; flex: 1; align-items: center; justify-content: flex-end; gap: 7px; }
.header-links a { display: inline-flex; align-items: center; border-color: #4b4560; background: var(--ink-soft); color: var(--text); font-size: 10px; text-decoration: none; text-transform: uppercase; }
.wallet-button { min-width: 138px; }

.network-strip { display: flex; justify-content: space-between; gap: 12px; padding: 8px clamp(12px,3vw,28px); border-bottom: 3px solid #09080c; background: #2d211b; color: var(--dim); font-size: 9px; letter-spacing: .06em; text-transform: uppercase; }
.network-strip span { display: inline-flex; align-items: center; gap: 7px; }
.network-strip i { width: 8px; height: 8px; background: var(--green); }
body[data-wallet-state="wrong-chain"] .network-strip i { background: var(--red); animation: blink .8s steps(1) infinite; }

main { width: min(1320px,100%); margin: 0 auto; padding: clamp(16px,2.5vw,30px); }
.vote-heading { display: grid; grid-template-columns: minmax(0,1fr) auto; gap: 24px; align-items: end; margin-bottom: 18px; }
.eyebrow { margin: 0 0 4px; color: var(--gold); font-size: 10px; font-weight: 900; letter-spacing: .16em; text-transform: uppercase; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin: 0; color: var(--paper); font-size: clamp(30px,5vw,58px); line-height: .96; letter-spacing: .035em; text-transform: uppercase; }
.intro { max-width: 760px; margin: 13px 0 0; color: var(--dim); font-size: 12px; }
.headline-stats { display: grid; grid-template-columns: repeat(3,minmax(118px,1fr)); gap: 8px; margin: 0; }
.headline-stats div { min-height: 78px; border: 3px solid #09080c; padding: 10px; background: #29242f; box-shadow: 3px 3px 0 #09080c; }
.headline-stats dt { color: var(--dim); font-size: 8px; letter-spacing: .08em; text-transform: uppercase; }
.headline-stats dd { margin: 6px 0 0; color: var(--gold); font-size: clamp(13px,2vw,20px); font-weight: 900; }

.claim-board, .ballot-shell { border: 4px solid #09080c; background: #211d27; box-shadow: var(--shadow); }
.claim-board { margin-bottom: 20px; }
.board-heading, .ballot-heading { display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 13px 15px; border-bottom: 3px solid #09080c; background: #30261f; }
.board-heading h2, .ballot-heading h2 { margin: 0; color: var(--paper); font-size: clamp(17px,2.5vw,24px); letter-spacing: .07em; text-transform: uppercase; }
.leader-ticket { border: 2px dashed #6e5738; padding: 8px 10px; background: #151318; color: var(--paper); font-size: 9px; font-weight: 900; text-transform: uppercase; }

.commodity-grid { display: grid; grid-template-columns: repeat(3,1fr); }
.commodity-card {
  position: relative;
  display: grid;
  grid-template-columns: auto minmax(0,1fr) auto;
  grid-template-areas: "mark copy tally" "mark route tally" "slate slate slate";
  gap: 5px 12px;
  min-height: 154px;
  padding: 19px;
  border-right: 3px solid #09080c;
  background: #24212b;
  cursor: pointer;
  transition: background 120ms linear, box-shadow 120ms linear;
}
.commodity-card:last-child { border-right: 0; }
.commodity-card:hover { background: #2e2935; }
.commodity-card:has(input:checked) { background: #352e2a; box-shadow: inset 0 -7px 0 var(--choice-color); }
.commodity-card.gold { --choice-color: var(--gold); }
.commodity-card.silver { --choice-color: var(--silver); }
.commodity-card.oil { --choice-color: var(--oil); }
.commodity-card[data-route-state="offline"] { opacity: .48; cursor: not-allowed; filter: grayscale(.5); }
.commodity-card input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.commodity-check { position: absolute; top: 9px; right: 10px; color: #575163; font-size: 11px; }
.commodity-card:has(input:checked) .commodity-check { color: var(--choice-color); }
.ore-mark { grid-area: mark; display: grid; width: 60px; height: 60px; place-items: center; align-self: center; border: 3px solid #09080c; background: var(--choice-color); box-shadow: 4px 4px 0 #09080c; color: #1b1710; font-size: 20px; font-weight: 900; }
.ore-mark.oil-drop { border-radius: 50% 50% 50% 8px; transform: rotate(-8deg); font-size: 14px; }
.commodity-copy { grid-area: copy; align-self: end; }
.commodity-copy b, .commodity-copy small { display: block; }
.commodity-copy b { color: var(--paper); font-size: 19px; text-transform: uppercase; }
.commodity-copy small { color: var(--choice-color); font-size: 9px; font-weight: 900; }
.route-state { grid-area: route; color: var(--dim); font-size: 8px; font-weight: 900; text-transform: uppercase; }
.commodity-card[data-route-state="live"] .route-state { color: var(--green); }
.vote-tally { grid-area: tally; align-self: center; text-align: right; }
.vote-tally b, .vote-tally small { display: block; }
.vote-tally b { color: var(--choice-color); font-size: clamp(20px,3vw,30px); }
.vote-tally small { color: var(--dim); font-size: 7px; text-transform: uppercase; }
.slate-weight { grid-area: slate; min-height: 18px; border-top: 1px solid #4d4135; padding-top: 5px; color: var(--choice-color); font-size: 8px; font-weight: 900; text-align: right; text-transform: uppercase; }

.ballot-shell { margin-bottom: 20px; }
.ballot-heading p:last-child { margin: 5px 0 0; color: var(--dim); font-size: 9px; }
.ballot-controls { display: grid; grid-template-columns: minmax(105px,155px) auto auto; gap: 6px; align-items: end; }
.ballot-controls label { grid-column: 1/-1; color: var(--dim); font-size: 8px; font-weight: 900; letter-spacing: .08em; text-transform: uppercase; }
.ballot-controls input { min-width: 0; min-height: 42px; border: 2px solid #4b4560; border-radius: 0; padding: 8px 10px; background: #151318; color: var(--text); }

.connect-panel { display: grid; grid-template-columns: 180px minmax(0,520px); gap: 24px; justify-content: center; align-items: center; min-height: 330px; padding: 30px; background: radial-gradient(circle at 50% 0,rgba(246,199,68,.07),transparent 48%); }
.connect-panel h2 { margin-bottom: 9px; color: var(--paper); font-size: clamp(22px,4vw,34px); text-transform: uppercase; }
.connect-panel p:not(.eyebrow) { color: var(--dim); font-size: 11px; }
.wanted-poster { position: relative; display: grid; width: 160px; height: 205px; place-items: center; align-content: center; border: 5px double #3c2d1f; padding: 12px; transform: rotate(-2deg); background: var(--paper); box-shadow: 7px 7px 0 #09080c; color: #302419; text-align: center; }
.wanted-poster::before, .wanted-poster::after { content: "✦"; position: absolute; font-size: 12px; }
.wanted-poster::before { top: 8px; left: 10px; }
.wanted-poster::after { right: 10px; bottom: 8px; }
.wanted-poster span { font-size: 26px; font-weight: 900; letter-spacing: .14em; }
.wanted-poster b { font-size: 45px; }
.wanted-poster small { font-weight: 900; letter-spacing: .08em; }

.roster-loading, .empty-panel { display: grid; min-height: 260px; place-items: center; align-content: center; gap: 8px; padding: 24px; color: var(--dim); text-align: center; }
.roster-loading b, .empty-panel b { color: var(--paper); text-transform: uppercase; }
.empty-panel span { font-size: 9px; }
.empty-panel a { margin-top: 8px; color: var(--gold); font-weight: 900; }
.loader { display: flex; align-items: end; gap: 5px; height: 24px; }
.loader i { width: 9px; height: 21px; background: var(--gold); animation: dig-loader .7s steps(2) infinite alternate; }
.loader i:nth-child(2) { animation-delay: .18s; }
.loader i:nth-child(3) { animation-delay: .36s; }

.miner-grid { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 10px; padding: 12px; }
.miner-card { position: relative; display: grid; grid-template-columns: 92px minmax(0,1fr); gap: 11px; min-height: 128px; border: 3px solid #09080c; padding: 10px; background: #29242f; box-shadow: 3px 3px 0 #09080c; cursor: pointer; content-visibility: auto; contain-intrinsic-size: 128px; }
.miner-card:hover { background: #322d39; }
.miner-card.selected { border-color: var(--gold); background: #352e2a; }
.miner-card.ineligible { cursor: default; opacity: .62; }
.miner-card.filtered { display: none; }
.miner-art { width: 92px; height: 92px; border: 3px solid #09080c; background: #151318; image-rendering: pixelated; }
.miner-art svg { display: block; width: 100%; height: 100%; image-rendering: pixelated; }
.miner-card h3 { margin: 0; color: var(--paper); font-size: 15px; }
.miner-card .profession { margin: 3px 0 8px; color: var(--dim); font-size: 8px; text-transform: uppercase; }
.shift-row { display: flex; flex-wrap: wrap; gap: 5px; }
.shift-badge, .vote-badge { border: 2px solid #4d4135; padding: 4px 6px; background: #151318; color: var(--gold); font-size: 8px; font-weight: 900; text-transform: uppercase; }
.vote-badge.ready { border-color: #315f36; color: var(--green); }
.vote-badge.done { border-color: #615934; color: var(--paper-dark); }
.card-weight { margin: 8px 0 0; color: var(--dim); font-size: 8px; }
.card-weight b { color: var(--paper); font-size: 13px; }
.miner-select { position: absolute; top: 8px; right: 8px; display: grid; width: 28px; height: 28px; place-items: center; border: 2px solid #4b4560; background: #151318; color: transparent; font-size: 14px; }
.miner-card.selected .miner-select { border-color: var(--gold); background: var(--gold); color: #211812; }
.miner-select input { position: absolute; opacity: 0; }

.ballot-submit { position: sticky; z-index: 10; bottom: 0; display: flex; align-items: center; justify-content: space-between; gap: 14px; min-height: 74px; border-top: 4px solid #09080c; padding: 11px 14px; background: rgba(45,33,27,.98); box-shadow: 0 -5px 0 rgba(9,8,12,.35); }
.ballot-submit > div { display: flex; flex-wrap: wrap; gap: 8px 18px; color: var(--dim); font-size: 9px; text-transform: uppercase; }
.selection-count b { color: var(--gold); font-size: 18px; }
.ballot-submit button { min-width: min(330px,45vw); }

.rules-strip { display: grid; grid-template-columns: repeat(3,1fr); border: 3px solid #09080c; background: #211a18; box-shadow: var(--shadow); }
.rules-strip article { display: flex; gap: 10px; padding: 14px; border-right: 2px solid #09080c; }
.rules-strip article:last-child { border-right: 0; }
.rules-strip article > span { color: var(--gold); font-size: 20px; font-weight: 900; }
.rules-strip b { color: var(--paper); font-size: 10px; text-transform: uppercase; }
.rules-strip p { margin: 4px 0 0; color: var(--dim); font-size: 8px; }

.review-overlay { position: fixed; z-index: 200; inset: 0; display: grid; place-items: center; padding: 16px; background: rgba(7,6,10,.82); }
.review-dialog { position: relative; width: min(520px,100%); max-height: calc(100vh - 32px); overflow: auto; border: 4px solid #09080c; padding: 20px; background: #211d27; box-shadow: 9px 9px 0 #050407; }
.review-dialog h2 { color: var(--paper); font-size: 25px; text-transform: uppercase; }
.dialog-close { position: absolute; top: 8px; right: 8px; width: 36px; min-height: 36px; padding: 0; background: var(--red); color: white; font-size: 18px; }
.review-choice { border: 3px solid #09080c; padding: 12px; background: var(--paper); color: #271e15; font-size: 17px; font-weight: 900; text-align: center; text-transform: uppercase; }
.review-dialog dl { margin: 12px 0; }
.review-dialog dl div { display: flex; justify-content: space-between; gap: 16px; border-bottom: 1px solid #4d4135; padding: 8px 0; }
.review-dialog dt { color: var(--dim); font-size: 8px; text-transform: uppercase; }
.review-dialog dd { margin: 0; color: var(--paper); font-size: 10px; font-weight: 900; text-align: right; }
.review-note { color: var(--dim); font-size: 9px; }
.review-progress { display: grid; gap: 6px; border: 2px solid #4d4135; padding: 10px; background: #151318; color: var(--paper); font-size: 9px; }
.review-progress progress { width: 100%; accent-color: var(--gold); }
.dialog-actions { display: grid; grid-template-columns: 1fr 1.5fr; gap: 8px; margin-top: 16px; }

.toast-log { position: fixed; z-index: 300; right: 14px; bottom: 14px; display: grid; width: min(380px,calc(100vw - 28px)); gap: 7px; pointer-events: none; }
.toast { border: 3px solid #09080c; padding: 10px 12px; background: var(--paper); box-shadow: 4px 4px 0 #09080c; color: #211812; font-size: 9px; font-weight: 900; }
.toast.error { background: var(--red); color: white; }

footer { display: flex; align-items: end; justify-content: space-between; gap: 20px; margin-top: 30px; border-top: 3px solid #09080c; padding: 24px clamp(14px,3vw,30px); background: #211a18; color: var(--dim); }
footer b { color: var(--paper); }
footer p { margin: 4px 0 0; font-size: 9px; }
footer > div:last-child { display: grid; gap: 4px; font-size: 8px; text-align: right; text-transform: uppercase; }
footer a { color: var(--gold); }
.noscript { padding: 16px; background: var(--red); color: white; text-align: center; }

@keyframes blink { 50% { opacity: .3; } }
@keyframes dig-loader { to { height: 7px; transform: translateY(12px); } }

@media (max-width: 1000px) {
  .vote-heading { grid-template-columns: 1fr; }
  .headline-stats { max-width: 620px; }
  .miner-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
}

@media (max-width: 760px) {
  .topbar { flex-wrap: wrap; }
  .brand { width: 100%; }
  .header-links { justify-content: flex-start; }
  .wallet-button { margin-left: auto; }
  .commodity-grid { grid-template-columns: 1fr; }
  .commodity-card { min-height: 126px; border-right: 0; border-bottom: 3px solid #09080c; }
  .commodity-card:last-child { border-bottom: 0; }
  .board-heading, .ballot-heading { align-items: flex-start; flex-direction: column; }
  .ballot-controls { width: 100%; }
  .connect-panel { grid-template-columns: 130px minmax(0,1fr); }
  .wanted-poster { width: 120px; height: 165px; }
  .wanted-poster span { font-size: 20px; }
  .wanted-poster b { font-size: 34px; }
  .miner-grid { grid-template-columns: 1fr; }
  .rules-strip { grid-template-columns: 1fr; }
  .rules-strip article { border-right: 0; border-bottom: 2px solid #09080c; }
  .rules-strip article:last-child { border-bottom: 0; }
}

@media (max-width: 520px) {
  .header-links { order: 3; width: 100%; display: grid; grid-template-columns: repeat(3,1fr); }
  .header-links a { justify-content: center; padding-inline: 5px; }
  .wallet-button { position: absolute; top: 10px; right: 12px; min-width: 124px; max-width: 145px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .network-strip { align-items: flex-start; flex-direction: column; }
  .headline-stats { grid-template-columns: 1fr; }
  .headline-stats div { min-height: 62px; }
  .claim-board, .ballot-shell { border-width: 3px; }
  .commodity-card { grid-template-columns: 54px minmax(0,1fr) auto; padding: 14px 12px; }
  .ore-mark { width: 50px; height: 50px; font-size: 16px; }
  .vote-tally b { font-size: 21px; }
  .connect-panel { grid-template-columns: 1fr; padding: 23px 16px; text-align: center; }
  .wanted-poster { display: none; }
  .ballot-controls { grid-template-columns: 1fr 1fr; }
  .ballot-controls input { grid-column: 1/-1; }
  .miner-card { grid-template-columns: 82px minmax(0,1fr); }
  .miner-art { width: 82px; height: 82px; }
  .ballot-submit { align-items: stretch; flex-direction: column; }
  .ballot-submit button { width: 100%; min-width: 0; }
  .dialog-actions { grid-template-columns: 1fr; }
  footer { align-items: flex-start; flex-direction: column; }
  footer > div:last-child { text-align: left; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; scroll-behavior: auto !important; }
}
