:root {
  --void: #070908;
  --surface: #0e110f;
  --surface-raised: #151916;
  --stone: #232923;
  --border: #343c35;
  --ink: #edf1e9;
  --muted: #919b92;
  --green: #9bd35a;
  --green-dim: #5e8b39;
  --amber: #e0ad4f;
  --cyan: #62c7c0;
  --red: #d56d62;
  --font: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
}

* { box-sizing: border-box; }

html { background: var(--void); }

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background: var(--void);
  color: var(--ink);
  font-family: var(--font);
  font-size: 14px;
  letter-spacing: 0;
}

button { font: inherit; letter-spacing: 0; }

.dungeon-header {
  min-height: 228px;
  border-bottom: 1px solid var(--border);
  background-color: #090b0a;
  background-image: url("/assets/dungeon-header.webp");
  background-position: center;
  background-size: cover;
}

.header-inner {
  width: min(1180px, calc(100% - 40px));
  min-height: 228px;
  margin: 0 auto;
  padding: 38px 0 24px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
}

.glyph {
  margin: 0 0 4px;
  color: var(--green);
  font-size: 22px;
  font-weight: 800;
  line-height: 1;
  text-shadow: 0 0 12px #315b20;
}

h1 {
  margin: 0;
  color: #ffffff;
  font-size: 60px;
  line-height: 1;
  letter-spacing: 0;
  text-transform: uppercase;
  text-shadow: 0 2px 0 #000000, 0 0 18px #000000;
}

.tagline {
  margin: 9px 0 20px;
  color: #d9ded7;
  font-size: 15px;
  text-shadow: 0 1px 8px #000000;
}

.live-status {
  display: inline-flex;
  gap: 8px;
  align-items: center;
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.status-light {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 8px var(--green-dim);
}

.live-status.offline .status-light { background: var(--red); box-shadow: none; }

.start-link {
  min-height: 38px;
  margin-top: 16px;
  padding: 10px 14px;
  border: 1px solid var(--green-dim);
  border-radius: 4px;
  background: rgba(7, 9, 8, 0.86);
  color: var(--green);
  font-weight: 700;
  text-decoration: none;
}

.start-link:hover { border-color: var(--green); color: var(--ink); }

.agent-entry {
  border-bottom: 1px solid var(--border);
  background: var(--surface-raised);
}

.agent-entry-inner {
  width: min(1180px, calc(100% - 40px));
  min-height: 136px;
  margin: 0 auto;
  padding: 28px 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 36px;
  align-items: center;
}

.agent-entry-kicker {
  margin: 0 0 7px;
  color: var(--green);
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
}

.agent-entry h2 { margin: 0; font-size: 21px; }

.agent-entry p:last-child {
  max-width: 760px;
  margin: 9px 0 0;
  color: var(--muted);
  line-height: 1.55;
}

.agent-protocol-link {
  min-width: 150px;
  min-height: 42px;
  padding: 12px 15px;
  border: 1px solid var(--green-dim);
  border-radius: 4px;
  color: var(--green);
  font-weight: 700;
  text-align: center;
  text-decoration: none;
}

.agent-protocol-link:hover { border-color: var(--green); color: var(--ink); }

.score-strip {
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.score-strip-inner {
  width: min(1180px, calc(100% - 40px));
  margin: 0 auto;
  display: grid;
  grid-template-columns: repeat(5, minmax(116px, 1fr)) minmax(180px, 1.35fr);
}

.score-stat {
  min-height: 83px;
  padding: 17px 22px;
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.score-stat:last-child { border-right: 1px solid var(--border); }

.score-stat span {
  overflow-wrap: anywhere;
  color: var(--amber);
  font-size: 23px;
  font-weight: 700;
  line-height: 1.15;
}

.score-stat small {
  margin-top: 5px;
  color: var(--muted);
  font-size: 10px;
  text-transform: uppercase;
}

.baseline-stat span { color: var(--cyan); font-size: 16px; }

main {
  width: min(1180px, calc(100% - 40px));
  min-height: 360px;
  margin: 0 auto;
  padding: 30px 0 56px;
}

.board-head {
  height: 47px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
}

.tabs { min-width: 0; height: 47px; display: flex; flex: 1; gap: 28px; overflow-x: auto; }

.tab {
  height: 47px;
  padding: 0;
  border: 0;
  border-bottom: 2px solid transparent;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-weight: 700;
  text-transform: uppercase;
}

.tab:hover { color: var(--ink); }
.tab:focus-visible, .refresh:focus-visible, .close:focus-visible, .recent-row:focus-visible {
  outline: 2px solid var(--cyan);
  outline-offset: 3px;
}

.tab.active { border-bottom-color: var(--green); color: var(--green); }

.refresh, .close {
  width: 36px;
  height: 36px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface-raised);
  color: var(--ink);
  cursor: pointer;
  font-size: 20px;
  line-height: 1;
}

.board-head > .refresh { flex: 0 0 auto; margin-left: 12px; }

.refresh:hover, .close:hover { border-color: var(--green); color: var(--green); }
.refresh.loading { animation: spin 0.8s linear infinite; }

@keyframes spin { to { transform: rotate(360deg); } }

.table-scroll { width: 100%; overflow-x: auto; }

.leaderboard {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

.leaderboard th {
  height: 48px;
  padding: 0 12px;
  border-bottom: 1px solid var(--border);
  color: var(--muted);
  font-size: 10px;
  text-align: left;
  text-transform: uppercase;
}

.leaderboard td {
  height: 72px;
  padding: 12px;
  border-bottom: 1px solid var(--stone);
  overflow: hidden;
  color: #cbd1ca;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.leaderboard tbody tr { cursor: pointer; }
.leaderboard tbody tr:hover { background: var(--surface); }
.leaderboard a, .detail-grid a { color: inherit; text-decoration-color: var(--green-dim); text-underline-offset: 3px; }
.leaderboard a:hover, .detail-grid a:hover { color: var(--green); }
.leaderboard .rank-col { width: 66px; }
.leaderboard th:nth-child(2) { width: 19%; }
.leaderboard th:nth-child(3) { width: 15%; }
.leaderboard th:nth-child(8) { width: 17%; }
.leaderboard th:nth-child(9) { width: 112px; }
.leaderboard .number { text-align: right; }
.leaderboard td.number { color: var(--ink); font-variant-numeric: tabular-nums; text-align: right; }
.rank { color: var(--muted); font-size: 16px; font-weight: 700; }
.rank.top { color: var(--amber); }
.agent-name { display: block; overflow: hidden; color: var(--ink); font-weight: 700; text-overflow: ellipsis; }
.agent-digest { display: block; margin-top: 4px; color: var(--muted); font-size: 10px; }
.hacker { color: var(--green); }
.compute { color: var(--cyan); font-size: 12px; }
.verified-time { color: var(--muted); font-size: 11px; }
.reported-number { color: var(--amber) !important; }
.reputation { color: var(--cyan) !important; }
.repository { color: var(--cyan); font-size: 11px; }

.trust-legend {
  min-height: 48px;
  padding: 0 12px;
  border-bottom: 1px solid var(--border);
  display: flex;
  gap: 26px;
  align-items: center;
  color: var(--muted);
  font-size: 10px;
  text-transform: uppercase;
}

.trust-legend span { display: inline-flex; gap: 8px; align-items: center; }
.legend-mark { width: 8px; height: 8px; display: inline-block; }
.verified-mark { background: var(--green); }
.provisional-mark { background: var(--amber); }
.pool-table th:nth-child(1) { width: 190px; }
.pool-table th:nth-child(2) { width: 18%; }
.pool-table th:nth-child(3) { width: 13%; }
.pool-table th:nth-child(6) { width: 18%; }
.pool-table th:nth-child(7) { width: 100px; }
.evidence { font-size: 10px; font-weight: 700; }
.evidence.verified { color: var(--green); }
.evidence.provisional { color: var(--amber); }

.condition-bar {
  min-height: 48px;
  padding: 0 12px;
  border-bottom: 1px solid var(--border);
  display: flex;
  gap: 28px;
  align-items: center;
  justify-content: space-between;
  color: var(--muted);
  font-size: 10px;
  text-transform: uppercase;
}

.condition-section-head {
  min-height: 70px;
  padding: 16px 12px 14px;
  border-bottom: 1px solid var(--stone);
}

.condition-section-head h2 { margin: 0; font-size: 14px; }
.condition-section-head p { margin: 6px 0 0; color: var(--muted); font-size: 11px; line-height: 1.45; }
.condition-section-head.evidence-head { border-top: 1px solid var(--border); }

.condition-catalog-scroll {
  width: 100%;
  max-height: 474px;
  overflow: auto;
}

.condition-catalog {
  width: 100%;
  min-width: 720px;
  border-collapse: collapse;
  table-layout: fixed;
}

.condition-catalog th,
.condition-catalog td {
  height: 42px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--stone);
  color: #cbd1ca;
  text-align: left;
}

.condition-catalog thead th {
  position: sticky;
  z-index: 1;
  top: 0;
  background: var(--void);
  color: var(--muted);
  font-size: 10px;
  text-transform: uppercase;
}

.condition-catalog th:first-child { width: 190px; }
.condition-catalog th:nth-child(2) { width: 160px; }
.condition-catalog th:last-child { width: 104px; }
.condition-catalog .number { text-align: right; }
.condition-catalog .identity-code { color: var(--green); font-weight: 700; }
.condition-catalog .natural-draw { color: var(--cyan); font-variant-numeric: tabular-nums; }

.condition-scroll { width: 100%; overflow-x: auto; }

.condition-matrix {
  width: max(100%, 760px);
  border-collapse: collapse;
  table-layout: fixed;
}

.condition-matrix th,
.condition-matrix td {
  height: 58px;
  border-right: 1px solid var(--stone);
  border-bottom: 1px solid var(--stone);
}

.condition-matrix thead th {
  height: 54px;
  padding: 8px 10px;
  overflow: hidden;
  color: var(--muted);
  font-size: 10px;
  text-align: center;
  text-overflow: ellipsis;
  text-transform: uppercase;
  white-space: nowrap;
}

.condition-matrix th:first-child {
  width: 142px;
  padding: 8px 12px;
  background: var(--void);
  text-align: left;
}

.condition-matrix tbody th strong,
.condition-matrix tbody th span { display: block; }
.condition-matrix tbody th strong { color: var(--green); font-size: 12px; }
.condition-matrix tbody th span { margin-top: 3px; color: var(--muted); font-size: 10px; }
.condition-matrix td { padding: 5px; text-align: center; }

.heat-cell {
  width: 100%;
  height: 46px;
  padding: 0 6px;
  border: 1px solid rgb(155 211 90 / calc(18% + var(--heat) * 62%));
  border-radius: 3px;
  background: rgb(155 211 90 / calc(5% + var(--heat) * 52%));
  color: var(--ink);
  cursor: pointer;
  font-variant-numeric: tabular-nums;
  font-weight: 700;
}

.heat-cell:hover { border-color: var(--green); color: #ffffff; }
.heat-cell:focus-visible { outline: 2px solid var(--cyan); outline-offset: 2px; }
.condition-missing { color: var(--muted); }

.condition-note {
  min-height: 54px;
  padding: 18px 12px;
  border-top: 1px solid var(--stone);
  color: var(--muted);
  font-size: 11px;
}

.empty-state {
  min-height: 280px;
  padding: 70px 20px;
  color: var(--muted);
  text-align: center;
}

.empty-state pre { display: inline-block; margin: 0 0 18px; color: var(--green-dim); text-align: left; }

.recent-list { display: flex; flex-direction: column; }

.recent-row {
  width: 100%;
  min-height: 72px;
  padding: 11px 12px;
  border: 0;
  border-bottom: 1px solid var(--stone);
  background: transparent;
  color: var(--ink);
  display: grid;
  grid-template-columns: 34px minmax(180px, 1fr) 120px 94px 128px;
  gap: 14px;
  align-items: center;
  text-align: left;
  cursor: pointer;
}

.recent-row:hover { background: var(--surface); }
.recent-mark { color: var(--green-dim); font-size: 20px; }
.recent-main { min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.recent-main strong, .recent-main small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.recent-main small, .recent-row time { color: var(--muted); font-size: 11px; }
.recent-score { color: var(--amber); text-align: right; }

.status-tag {
  justify-self: center;
  padding: 4px 6px;
  border: 1px solid var(--border);
  border-radius: 2px;
  color: var(--muted);
  font-size: 10px;
  text-transform: uppercase;
}

.status-tag.verified { border-color: var(--green-dim); color: var(--green); }
.status-tag.running { border-color: #8e733d; color: var(--amber); }
.status-tag.failed { border-color: #814640; color: var(--red); }
.status-tag.unhosted { border-color: #555b55; color: var(--muted); }

footer {
  width: min(1180px, calc(100% - 40px));
  min-height: 74px;
  margin: 0 auto;
  padding: 22px 0;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  font-size: 11px;
}

.verified-copy { color: var(--green); }
.reported-copy { color: var(--amber); }

dialog {
  width: min(650px, calc(100% - 28px));
  max-height: min(720px, calc(100vh - 28px));
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 24px 80px #000000;
}

dialog::backdrop { background: rgb(0 0 0 / 78%); }

.dialog-head {
  padding: 22px 24px 18px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  gap: 20px;
}

.dialog-kicker { margin: 0 0 5px; color: var(--green); font-size: 10px; text-transform: uppercase; }
dialog h2 { margin: 0; overflow-wrap: anywhere; font-size: 21px; }
.dialog-description { margin: 0; padding: 20px 24px; border-bottom: 1px solid var(--stone); color: #cbd1ca; line-height: 1.6; }
.detail-grid { margin: 0; padding: 18px 24px; display: grid; grid-template-columns: 1fr 1fr; gap: 16px 28px; }
.detail-grid div { min-width: 0; }
.detail-grid dt { margin: 0 0 4px; color: var(--muted); font-size: 10px; text-transform: uppercase; }
.detail-grid dd { margin: 0; overflow-wrap: anywhere; color: var(--ink); }
.digest-block { padding: 17px 24px 22px; border-top: 1px solid var(--stone); }
.digest-block span { display: block; margin-bottom: 7px; color: var(--muted); font-size: 10px; text-transform: uppercase; }
.digest-block code { display: block; overflow-wrap: anywhere; color: var(--cyan); font-size: 11px; }

@media (max-width: 850px) {
  .score-strip-inner { grid-template-columns: repeat(3, 1fr); }
  .score-stat:nth-child(n + 4) { border-top: 1px solid var(--border); }
  .recent-row { grid-template-columns: 28px minmax(150px, 1fr) 94px; }
  .recent-score, .recent-row time { display: none; }
}

@media (max-width: 700px) {
  .dungeon-header, .header-inner { min-height: 184px; }
  .header-inner { width: min(100% - 28px, 1180px); padding: 28px 0 19px; }
  h1 { font-size: 44px; }
  .tagline { margin-bottom: 13px; }
  .score-strip-inner, main, footer { width: calc(100% - 28px); }
  .agent-entry-inner {
    width: calc(100% - 28px);
    grid-template-columns: 1fr;
    gap: 18px;
  }
  .agent-protocol-link { justify-self: start; }
  .score-stat { min-height: 72px; padding: 13px 14px; }
  .score-stat span { font-size: 19px; }
  main { padding-top: 20px; }
  .table-scroll { overflow: visible; }
  .leaderboard, .leaderboard tbody { display: block; }
  .leaderboard thead { display: none; }
  .leaderboard tbody { padding-top: 8px; }
  .leaderboard tbody tr {
    margin: 9px 0;
    padding: 13px 12px;
    border: 1px solid var(--stone);
    border-radius: 5px;
    display: grid;
    grid-template-columns: 44px minmax(0, 1fr) minmax(88px, auto);
    gap: 8px 10px;
    background: var(--surface);
  }
  .leaderboard td { height: auto; padding: 0; border: 0; }
  .leaderboard td:nth-child(1) { grid-row: 1 / span 2; }
  .leaderboard td:nth-child(2) { grid-column: 2; }
  .leaderboard td:nth-child(3) { grid-column: 2; }
  .leaderboard td:nth-child(4) { grid-column: 3; grid-row: 1; }
  .leaderboard td:nth-child(5),
  .leaderboard td:nth-child(6),
  .leaderboard td:nth-child(7),
  .leaderboard td:nth-child(9) { display: none; }
  .leaderboard td:nth-child(8) { grid-column: 3; grid-row: 2; text-align: right; }
  .leaderboard.pool-table tbody tr {
    grid-template-columns: 92px minmax(0, 1fr) minmax(62px, auto);
  }
  .leaderboard.pool-table td:nth-child(1) {
    grid-column: 1;
    grid-row: 1 / span 2;
    overflow: visible;
    white-space: normal;
  }
  .leaderboard.pool-table td:nth-child(2) { grid-column: 2; grid-row: 1; }
  .leaderboard.pool-table td:nth-child(3) { grid-column: 2; grid-row: 2; }
  .leaderboard.pool-table td:nth-child(4) { grid-column: 3; grid-row: 1; }
  .leaderboard.pool-table td:nth-child(5) { grid-column: 3; grid-row: 2; display: block; }
  .leaderboard.pool-table td:nth-child(6),
  .leaderboard.pool-table td:nth-child(7) { display: none; }
  .rank { font-size: 22px; }
  footer { flex-direction: column; gap: 8px; }
}

@media (max-width: 430px) {
  h1 { font-size: 36px; }
  .score-strip-inner { width: 100%; grid-template-columns: repeat(2, 1fr); }
  .baseline-stat { grid-column: 1 / -1; }
  .score-stat { border-left: 0; }
  .score-stat:nth-child(odd) { border-left: 1px solid var(--border); }
  .score-stat:nth-child(even) { border-right: 1px solid var(--border); }
  .tabs { gap: 8px; }
  .tab { font-size: 10px; white-space: nowrap; }
  .trust-legend { padding-inline: 4px; gap: 12px; align-items: flex-start; flex-direction: column; justify-content: center; }
  .recent-row { padding-inline: 4px; grid-template-columns: 23px minmax(120px, 1fr) 80px; gap: 8px; }
  .detail-grid { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  .refresh.loading { animation: none; }
}
