#match-judge-dialog {
  --judge-ink: #17171e;
  --judge-panel: #23222b;
  --judge-line: #413d4a;
  --judge-text: #f5f0fa;
  --judge-muted: #c4bdce;
  --judge-accent: #e3c5ff;
  width: min(630px, calc(100% - 24px));
  max-height: calc(100dvh - 24px);
  box-sizing: border-box;
  margin: auto;
  padding: 0;
  overflow: auto;
  overscroll-behavior: contain;
  border: 1px solid var(--judge-line);
  border-radius: 12px;
  color: var(--judge-text);
  background: var(--judge-ink);
  box-shadow: 0 24px 80px #000a;
  scrollbar-color: var(--judge-line) var(--judge-ink);
}

#match-judge-dialog::backdrop { background: #0a0911ba; }

.match-judge-header {
  position: sticky;
  z-index: 1;
  top: 0;
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 12px;
  padding: 14px clamp(12px, 3vw, 23px);
  border-bottom: 1px solid var(--judge-line);
  background: var(--judge-panel);
}

.match-judge-heading { min-width: 0; }
#match-judge-heading {
  margin: 0 0 4px;
  color: var(--judge-accent);
  font-size: .78rem;
  font-weight: 700;
}

#match-judge-title { margin: 0; overflow-wrap: anywhere; font-size: clamp(1.15rem, 4.5vw, 1.55rem); line-height: 1.2; }
#match-judge-title:focus { outline: none; }

#match-judge-dialog .match-judge-close {
  width: 42px;
  height: 42px;
  padding: 0;
  border: 1px solid var(--judge-line);
  border-radius: 7px;
  color: var(--judge-text);
  background: var(--judge-ink);
  font-size: 1.35rem;
}

#match-judge-dialog .match-judge-close:hover { border-color: var(--judge-accent); }
#match-judge-dialog :is(a, button):focus-visible { outline: 2px solid var(--judge-accent); outline-offset: 3px; }

.match-judge-body {
  display: grid;
  gap: 17px;
  padding: 15px clamp(12px, 3vw, 23px) 20px;
  font-size: .875rem;
  line-height: 1.48;
  overflow-wrap: anywhere;
}

.match-judge-body :is(h3, h4, dl, dd, p, ul, ol) { margin: 0; }
.match-judge-body h3 { margin-bottom: 8px; font-size: .96rem; }
.match-judge-body h4 { font-size: .875rem; }

.match-judge-status {
  justify-self: start;
  padding: 3px 9px;
  border-radius: 5px;
  color: var(--judge-accent);
  background: #332941;
  font-weight: 700;
}

.match-judge-facts {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px 14px;
  padding: 10px 12px;
  border: 1px solid var(--judge-line);
  border-radius: 7px;
  background: var(--judge-panel);
}

.match-judge-facts dt { color: var(--judge-muted); font-size: .77rem; }
.match-judge-facts dd { font-weight: 600; white-space: pre-line; }
.match-judge-fact-wide { grid-column: 1 / -1; }

.match-judge-timeline {
  display: grid;
  gap: 4px;
  padding-inline-start: 2em;
  list-style: decimal;
}

.match-judge-timeline li { padding: 6px 9px; border-inline-start: 2px solid var(--judge-line); }
.match-judge-timeline li::marker { color: var(--judge-muted); font-variant-numeric: tabular-nums; }
.match-judge-timeline li[aria-current] { border-inline-start-color: var(--judge-accent); background: #2a2234; }
.match-judge-timeline li[aria-current]::marker { color: var(--judge-accent); }
.match-judge-timeline p { margin-top: 2px; color: var(--judge-muted); }

.match-judge-rules { padding-top: 12px; border-top: 1px solid var(--judge-line); }
#match-judge-topics { display: grid; gap: 12px; padding: 0; list-style: none; }
#match-judge-topics p { margin-top: 2px; color: var(--judge-muted); }
#match-judge-topics small { display: block; margin-top: 4px; color: var(--judge-accent); font-size: .77rem; }
#match-judge-topics a { color: inherit; text-underline-offset: 3px; }
#match-judge-source-status { color: var(--judge-muted); }
#match-judge-source { display: inline-block; margin-top: 10px; color: var(--judge-accent); text-underline-offset: 3px; }

.match-judge-open {
  min-height: 23px;
  padding: 1px 5px;
  border: 1px solid #a89dbb64;
  border-radius: 4px;
  color: #f0d8ff;
  background: #332941;
  font: 700 10px/1.15 system-ui, sans-serif;
  cursor: pointer;
}
.match-judge-open:hover { background: #51405f; }
.match-judge-open:focus-visible { outline: 2px solid #e3c5ff; outline-offset: 2px; }
.match-judge-chain-controls { display: flex; flex-wrap: wrap; gap: 3px 5px; align-items: center; }
:is(#log, #table-feed-entries) .match-judge-open { margin-inline-start: 5px; }
#log li:has(> .match-judge-open) { grid-template-columns: minmax(0, 1fr) auto; align-items: center; }
#log li:has(> .match-judge-open) > small { grid-column: 1 / -1; }

@media (pointer: coarse) {
  .match-judge-open { min-height: 30px; padding-inline: 8px; }
}

@media (max-width: 420px) {
  .match-judge-facts { grid-template-columns: minmax(0, 1fr); }
}
