:root {
  color-scheme: dark;
  --bg: #0d1117;
  --bg-soft: #11161d;
  --panel: #161b22;
  --panel-raised: #1b2230;
  --border: #30363d;
  --border-soft: #232a33;
  --text: #e6edf3;
  --muted: #9198a1;
  --accent: #58a6ff;
  --accent-soft: rgba(88, 166, 255, 0.14);
  --green: #3fb950;
  --green-soft: rgba(63, 185, 80, 0.16);
  --red: #f85149;
  --red-soft: rgba(248, 81, 73, 0.14);
  --amber: #d29922;
  --amber-soft: rgba(210, 153, 34, 0.16);
  --radius: 12px;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

.col-hidden {
  display: none !important;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

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

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(1100px 520px at 18% -12%, rgba(88, 166, 255, 0.11), transparent 60%),
    radial-gradient(900px 480px at 95% 0%, rgba(63, 185, 80, 0.07), transparent 55%),
    var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 15px;
  line-height: 1.5;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

code {
  font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
  font-size: 0.92em;
  background: var(--bg-soft);
  border: 1px solid var(--border-soft);
  border-radius: 5px;
  padding: 0.08em 0.34em;
}

.page {
  width: min(1500px, 100%);
  margin: 0 auto;
  padding: 28px 24px 40px;
}

.site-header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px 40px;
  padding-bottom: 22px;
  border-bottom: 1px solid var(--border-soft);
}

.eyebrow {
  margin: 0 0 4px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--accent);
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 6px;
  font-size: clamp(1.7rem, 3vw, 2.5rem);
  line-height: 1.1;
  letter-spacing: -0.02em;
}

.subline {
  margin-bottom: 3px;
  color: var(--muted);
  font-size: 0.9rem;
}

.header-meta {
  max-width: 620px;
  color: var(--muted);
  font-size: 0.86rem;
  text-align: right;
}

.header-meta p {
  margin-bottom: 4px;
}

.counts {
  color: var(--text);
  font-size: 0.95rem;
  font-weight: 600;
}

.credit {
  color: var(--muted);
}

.player-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
  margin-bottom: 10px;
}

.data-source {
  color: var(--green);
  font-size: 0.8rem;
}

.data-source.is-error {
  color: var(--red);
}

.data-source.is-loading {
  color: var(--accent);
  animation: tagstats-pulse 1.6s ease-in-out infinite;
}

.kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  margin: 22px 0 18px;
}

.kpi {
  background: linear-gradient(180deg, var(--panel-raised), var(--panel));
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 14px 16px;
}

.kpi-label {
  margin-bottom: 6px;
  overflow: hidden;
  color: var(--muted);
  font-size: 0.73rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-overflow: ellipsis;
  text-transform: uppercase;
  white-space: nowrap;
}

.kpi-value {
  margin: 0;
  font-size: clamp(1.35rem, 2.2vw, 1.8rem);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
}

.kpi-sub {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 0.76rem;
  font-variant-numeric: tabular-nums;
}

.controls {
  display: grid;
  grid-template-columns: minmax(190px, 1.1fr) auto minmax(160px, 1fr) 84px minmax(170px, 1fr) auto;
  align-items: start;
  gap: 14px 22px;
  padding: 16px 18px;
  background: var(--panel);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
}

.control {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}

.control-label {
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.07em;
  line-height: 1;
  text-transform: uppercase;
}

.control-row {
  display: flex;
  align-items: center;
  min-width: 0;
  min-height: 36px;
}

.switch {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
  font-size: 0.88rem;
  font-weight: 400;
  letter-spacing: 0;
  line-height: 1.3;
  text-transform: none;
  cursor: pointer;
}

.control-row .switch {
  min-height: 36px;
}

.switch input {
  flex: none;
  width: 16px;
  height: 16px;
  margin: 0;
  accent-color: var(--accent);
}

.columns-control {
  align-items: flex-start;
  margin-left: auto;
}

.columns-button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 36px;
  padding: 0 12px;
}

.columns-count {
  min-width: 1.5em;
  padding: 0 5px;
  color: var(--accent);
  background: var(--accent-soft);
  border: 1px solid rgba(88, 166, 255, 0.35);
  border-radius: 999px;
  font-size: 0.66rem;
  font-variant-numeric: tabular-nums;
  line-height: 1.6;
  text-align: center;
}

.columns-popover {
  position: fixed;
  z-index: 200;
  width: 348px;
  max-width: calc(100vw - 16px);
  padding: 14px;
  overflow-y: auto;
  color: var(--text);
  background: var(--panel-raised);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.55);
  font-size: 0.82rem;
}

.columns-note {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 0.76rem;
  line-height: 1.4;
}

.columns-group {
  margin: 0 0 10px;
  padding: 0;
  border: 0;
}

.columns-group legend {
  margin-bottom: 6px;
  padding: 0;
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

.columns-options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 3px 12px;
}

.columns-options label {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 0.82rem;
  white-space: nowrap;
  cursor: pointer;
}

.columns-options input {
  width: 14px;
  height: 14px;
  margin: 0;
  accent-color: var(--accent);
}

.columns-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 2px;
  padding-top: 10px;
  border-top: 1px solid var(--border-soft);
}

input[type="search"],
input[type="number"] {
  width: 150px;
  padding: 7px 10px;
  color: var(--text);
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 7px;
  font: inherit;
  font-size: 0.88rem;
}

input[type="search"] {
  width: 210px;
}

input[type="number"] {
  width: 84px;
}

.control input[type="search"],
.control input[type="number"] {
  height: 36px;
}

.control input[type="search"] {
  width: 100%;
  min-width: 0;
}

.control input[type="number"] {
  width: 84px;
}

input:focus-visible,
button:focus-visible,
a:focus-visible,
.has-tip:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  min-height: 36px;
  gap: 6px;
}

.chip {
  padding: 5px 11px;
  color: var(--muted);
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 999px;
  font: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
}

.chip:hover:not(.is-disabled) {
  border-color: var(--accent);
  color: var(--text);
}

.chip.active {
  color: var(--accent);
  background: var(--accent-soft);
  border-color: rgba(88, 166, 255, 0.55);
}

.chip.is-disabled {
  opacity: 0.38;
  cursor: help;
}

.reading-note {
  margin-top: 18px;
  color: var(--muted);
  background: rgba(88, 166, 255, 0.05);
  border: 1px solid var(--border-soft);
  border-left: 3px solid var(--accent);
  border-radius: 8px;
  font-size: 0.85rem;
}

.reading-note > summary {
  padding: 10px 16px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
}

.reading-note > summary:hover {
  color: var(--text);
}

.reading-note[open] > summary {
  color: var(--text);
  border-bottom: 1px solid var(--border-soft);
}

.reading-note-body {
  padding: 12px 16px;
}

.reading-note strong {
  color: var(--text);
}

.panel {
  margin-top: 20px;
  background: var(--panel);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  overflow: hidden;
}

.panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 18px 12px;
  border-bottom: 1px solid var(--border-soft);
}

.panel-head h2 {
  margin-bottom: 2px;
  font-size: 1.08rem;
  letter-spacing: -0.01em;
}

.panel-sub {
  margin: 0;
  color: var(--muted);
  font-size: 0.8rem;
}

.panel-action {
  flex: none;
  padding: 5px 10px;
  color: var(--muted);
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 7px;
  font: inherit;
  font-size: 0.78rem;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
}

.panel-action:hover {
  color: var(--text);
  border-color: var(--accent);
}

.tabs {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  flex-wrap: nowrap;
  gap: 4px;
  margin-top: 18px;
  padding: 8px;
  overflow-x: auto;
  background: rgba(13, 17, 23, 0.92);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  scrollbar-width: thin;
}

.tab {
  display: inline-flex;
  flex: none;
  align-items: center;
  gap: 8px;
  padding: 7px 13px;
  color: var(--muted);
  background: transparent;
  border: 1px solid transparent;
  border-radius: 8px;
  font: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
}

.tab:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.04);
}

.tab[aria-selected="true"] {
  color: var(--text);
  background: var(--panel-raised);
  border-color: var(--border);
  box-shadow: inset 0 0 0 1px rgba(88, 166, 255, 0.15);
}

.tab-count {
  flex: none;
  min-width: 1.7em;
  padding: 0 6px;
  color: var(--muted);
  background: var(--bg-soft);
  border: 1px solid var(--border-soft);
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  line-height: 1.7;
  text-align: center;
}

.tab[aria-selected="true"] .tab-count {
  color: var(--accent);
  background: var(--accent-soft);
  border-color: rgba(88, 166, 255, 0.35);
}

[role="tabpanel"][hidden] {
  display: none !important;
}

[role="tabpanel"] {
  margin-top: 12px;
}

[role="tabpanel"]:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.panel-actions {
  display: flex;
  flex: none;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.runs-page-size {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 30px;
  color: var(--muted);
  font-size: 0.76rem;
}

.runs-page-size label {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 600;
  white-space: nowrap;
}

select.panel-action {
  height: 30px;
  padding: 0 8px;
  color: var(--muted);
  cursor: pointer;
}

select.panel-action:hover {
  color: var(--text);
  border-color: var(--accent);
}

.section-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  padding: 0;
  color: var(--muted);
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 7px;
  font: inherit;
  font-size: 0.78rem;
  line-height: 1;
  cursor: pointer;
}

.section-toggle:hover {
  color: var(--text);
  border-color: var(--accent);
}

.section-chevron {
  display: inline-block;
  flex: none;
  transition: transform 0.12s ease;
}

.section-toggle[aria-expanded="true"] .section-chevron {
  transform: rotate(90deg);
}

.section.is-collapsed .panel-head {
  border-bottom: 0;
}

.section.is-collapsed .section-body {
  display: none;
}

.section-body.kpis {
  margin: 0;
  padding: 16px 18px 18px;
}

.section-body.controls {
  border: 0;
  border-radius: 0;
}

.override-notes {
  display: grid;
  gap: 4px;
  padding: 12px 18px 0;
}

.override-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 12px 20px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border-soft);
}

.override-search {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.override-search label {
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

.override-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-left: auto;
}

.override-warning {
  margin: 0;
  padding: 10px 18px;
  color: #ffd28a;
  background: var(--amber-soft);
  border-bottom: 1px solid rgba(210, 153, 34, 0.4);
  font-size: 0.82rem;
}

.override-status {
  margin: 0;
  padding: 10px 18px 0;
  font-size: 0.78rem;
}

.override-status:empty {
  display: none;
}

.override-empty {
  margin: 0;
  padding: 18px;
  font-size: 0.82rem;
}

.override-row {
  padding: 14px 18px;
  border-top: 1px solid var(--border-soft);
}

.override-list > .override-row:first-child {
  border-top: 0;
}

.override-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 8px;
}

.override-name {
  font-weight: 600;
}

.override-source {
  margin: 4px 0 8px;
  color: var(--muted);
  font-size: 0.78rem;
}

.override-effective {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
  margin-bottom: 8px;
  font-size: 0.8rem;
}

.override-effective-label {
  margin-right: 4px;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.tag-editable {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding-right: 3px;
}

.tag-remove {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  padding: 0;
  color: var(--muted);
  background: none;
  border: 0;
  border-radius: 50%;
  font: inherit;
  font-size: 0.85rem;
  line-height: 1;
  cursor: pointer;
}

.tag-remove:hover {
  color: var(--red);
  background: var(--red-soft);
}

.tag-remove svg {
  display: block;
  flex: none;
}

.override-add-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

input[type="text"].override-add-input {
  width: 170px;
  padding: 6px 9px;
  color: var(--text);
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 7px;
  font: inherit;
  font-size: 0.84rem;
}

.override-reset {
  margin-left: auto;
}

.override-move-note {
  margin: 8px 0 0;
  color: var(--amber);
  font-size: 0.74rem;
}

.detail-note {
  margin: 0 0 10px;
}

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

/*
 * By tag, Tag combos and Tag pairs share one fixed column grid, so switching
 * tabs never moves a column. The widths are declared once here and apply to
 * every .metric-table, including rows added by app.js.
 */
.metric-table {
  table-layout: fixed;
  width: 100%;
  min-width: 1080px;
}

.metric-table > thead > tr > th {
  vertical-align: bottom;
}

.metric-table > thead > tr > th:nth-child(1) {
  width: 22%;
}

.metric-table > thead > tr > th:nth-child(2),
.metric-table > thead > tr > th:nth-child(3),
.metric-table > thead > tr > th:nth-child(4),
.metric-table > thead > tr > th:nth-child(5),
.metric-table > thead > tr > th:nth-child(6) {
  width: 5%;
}

.metric-table > thead > tr > th:nth-child(7),
.metric-table > thead > tr > th:nth-child(8) {
  width: 7%;
}

.metric-table > thead > tr > th:nth-child(9),
.metric-table > thead > tr > th:nth-child(10),
.metric-table > thead > tr > th:nth-child(11),
.metric-table > thead > tr > th:nth-child(12) {
  width: 8%;
}

.metric-table > thead > tr > th:nth-child(13) {
  width: 7%;
}

.metric-table > thead > tr > th,
.metric-table > thead > tr > th button.sort {
  white-space: normal;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

/*
 * Narrow numeric columns cannot afford the global 12 px inset at the 1080 px
 * minimum width, so the metric tables use one shared 8 px inset for header
 * and body. This keeps header labels whole and keeps header/body right edges
 * aligned.
 *
 * Only the outer table's rows are targeted: an expanded row contains its own
 * .detail-table, which must keep the normal table styles.
 */
.metric-table > thead > tr > th button.sort {
  padding-left: 8px;
  padding-right: 8px;
}

.metric-table > tbody > tr:not(.detail-row):not(.empty-row) > td {
  padding-left: 8px;
  padding-right: 8px;
}

.metric-table > tbody > tr.empty-row > td {
  padding: 22px 18px;
}

.metric-table > tbody > tr.detail-row > td.detail-cell {
  padding: 0;
}

.metric-table > tbody > tr > td.label-cell {
  max-width: none;
  overflow: visible;
  white-space: normal;
  text-overflow: clip;
}

.metric-table > tbody > tr > td.label-cell .expand-toggle {
  align-items: center;
}

.metric-table > tbody > tr > td.label-cell .expand-label {
  overflow: visible;
  white-space: normal;
  text-overflow: clip;
  overflow-wrap: anywhere;
}

.runs-wrap {
  max-height: 74vh;
  overflow-y: auto;
}

.runs-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 16px;
  padding: 10px 18px;
  color: var(--muted);
  border-top: 1px solid var(--border-soft);
  font-size: 0.78rem;
  font-variant-numeric: tabular-nums;
}

.runs-footer p {
  margin: 0;
}

.runs-pager {
  display: flex;
  align-items: center;
  gap: 8px;
}

.runs-pager .panel-action {
  padding: 3px 10px;
}

.runs-pager button:disabled {
  color: var(--muted);
  border-color: var(--border);
  opacity: 0.45;
  cursor: default;
}

.runs-pager button:disabled:hover {
  color: var(--muted);
  border-color: var(--border);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.86rem;
  white-space: nowrap;
}

thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  padding: 0;
  background: var(--panel-raised);
  border-bottom: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-align: left;
  text-transform: uppercase;
}

thead th.num {
  text-align: right;
}

thead th:not(:first-child) {
  text-align: right;
}

/*
 * The All runs table is not a sortable metric table: only the four numeric
 * columns are right-aligned, and every cell needs the same 12 px inset as its
 * body column.
 */
#panel-runs thead th {
  padding: 11px 12px;
  text-align: left;
}

#panel-runs thead th.num {
  text-align: right;
}

button.sort {
  width: 100%;
  padding: 11px 12px;
  color: inherit;
  background: none;
  border: 0;
  font: inherit;
  font-size: inherit;
  font-weight: inherit;
  letter-spacing: inherit;
  text-align: inherit;
  text-transform: inherit;
  cursor: pointer;
}

button.sort:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.03);
}

button.sort.active {
  color: var(--accent);
}

.metric-table > thead > tr > th button.sort[data-dir="1"],
.metric-table > thead > tr > th button.sort[data-dir="-1"] {
  white-space: nowrap;
}

button.sort[data-dir="1"]::after {
  content: "";
  display: inline-block;
  width: 0;
  height: 0;
  margin-left: 3px;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-bottom: 5px solid currentColor;
  vertical-align: middle;
}

button.sort[data-dir="-1"]::after {
  content: "";
  display: inline-block;
  width: 0;
  height: 0;
  margin-left: 3px;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-top: 5px solid currentColor;
  vertical-align: middle;
}

tbody td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--border-soft);
  vertical-align: middle;
}

tbody tr:last-child td {
  border-bottom: 0;
}

tbody tr:hover td {
  background: rgba(255, 255, 255, 0.025);
}

td.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.stat-cell .num-main {
  display: block;
  line-height: 1.25;
}

.num-sub {
  display: block;
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 400;
  line-height: 1.2;
}

.label-cell {
  max-width: 360px;
  overflow: hidden;
  font-weight: 600;
  text-overflow: ellipsis;
  cursor: pointer;
}

.expand-toggle {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  max-width: 100%;
  padding: 0;
  color: inherit;
  background: none;
  border: 0;
  font: inherit;
  font-weight: inherit;
  text-align: left;
  cursor: pointer;
}

.expand-toggle.has-tip {
  cursor: pointer;
}

.expand-chevron {
  display: block;
  flex: none;
  width: 10px;
  height: 10px;
  color: var(--muted);
  transition: transform 0.12s ease;
}

.expand-toggle[aria-expanded="true"] .expand-chevron {
  transform: rotate(90deg);
}

.expand-label {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.untagged-row .label-cell {
  color: var(--muted);
  font-style: italic;
  font-weight: 500;
}

.date-cell {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.map-cell {
  max-width: 360px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.map-cell .tmx-link,
.detail-map .tmx-link,
.override-name .tmx-link {
  margin-left: 7px;
  padding: 1px 5px;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  vertical-align: 1px;
}

.tags-cell {
  white-space: normal;
}

.tag {
  display: inline-block;
  margin: 1px 4px 1px 0;
  padding: 1px 7px;
  color: #b8c7da;
  background: var(--bg-soft);
  border: 1px solid var(--border-soft);
  border-radius: 999px;
  font-size: 0.72rem;
}

.badge {
  display: inline-block;
  padding: 1px 7px;
  border: 1px solid transparent;
  border-radius: 999px;
  font-size: 0.69rem;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.badge + .badge {
  margin-left: 4px;
}

.kind-cotd {
  color: #8cc8ff;
  background: var(--accent-soft);
  border-color: rgba(88, 166, 255, 0.4);
}

.kind-cotn {
  color: #d2a8ff;
  background: rgba(188, 140, 255, 0.14);
  border-color: rgba(188, 140, 255, 0.4);
}

.kind-cotm {
  color: #ffd28a;
  background: var(--amber-soft);
  border-color: rgba(210, 153, 34, 0.45);
}

.badge.rerun {
  color: var(--muted);
  border-color: var(--border);
  font-weight: 600;
}

.badge.manual {
  margin-left: 6px;
  color: #ffd28a;
  background: var(--amber-soft);
  border-color: rgba(210, 153, 34, 0.45);
  font-size: 0.64rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  vertical-align: 1px;
}

.pct-cell {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 7px;
  width: 100%;
}

.bar {
  display: inline-block;
  width: 42px;
  height: 6px;
  overflow: hidden;
  background: #21262d;
  border-radius: 999px;
}

.bar > span {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: var(--accent);
}

.bar.low > span {
  background: var(--green);
}

.bar.mid > span {
  background: var(--amber);
}

.bar.high > span {
  background: var(--red);
}

.pct-label {
  min-width: 43px;
  text-align: right;
}

.delta.good {
  color: var(--green);
  font-weight: 600;
}

.delta.bad {
  color: var(--red);
  font-weight: 600;
}

.delta.neutral {
  color: var(--muted);
}

.muted {
  color: var(--muted);
}

.empty-row td {
  padding: 22px 18px;
  color: var(--muted);
  text-align: center;
}

.detail-row td.detail-cell {
  padding: 0;
  background: var(--bg-soft);
  border-bottom: 1px solid var(--border);
  white-space: normal;
}

tbody tr.detail-row:hover td {
  background: var(--bg-soft);
}

.detail-inner {
  padding: 12px 14px 14px;
}

.detail-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 3px 12px;
  margin-bottom: 10px;
}

.detail-title {
  font-size: 0.86rem;
  font-weight: 600;
}

.detail-head .num-sub {
  display: inline;
  font-size: 0.74rem;
}

.detail-scroll {
  width: min(100%, calc(100vw - 50px));
  max-width: 100%;
  overflow-x: auto;
}

.detail-empty {
  margin: 0;
  font-size: 0.82rem;
}

.detail-table {
  width: 100%;
  min-width: 760px;
  font-size: 0.8rem;
}

.detail-table thead th {
  position: static;
  padding: 5px 9px;
  background: var(--panel-raised);
  border-bottom: 1px solid var(--border-soft);
  letter-spacing: 0.05em;
}

.detail-table thead th:not(:first-child) {
  text-align: left;
}

.detail-table thead th.num {
  text-align: right;
}

.detail-table tbody td {
  padding: 5px 9px;
  border-bottom: 1px solid var(--border-soft);
}

.detail-table tbody tr:last-child td {
  border-bottom: 0;
}

.detail-table .detail-map {
  max-width: 280px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.detail-table .detail-tags {
  white-space: normal;
}

.search-panel {
  display: flex;
  justify-content: center;
  padding: 48px 0 28px;
}

.search-card {
  width: min(720px, 100%);
  padding: 30px 32px 28px;
  background: linear-gradient(180deg, var(--panel-raised), var(--panel));
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.28);
}

.search-card h2 {
  margin-bottom: 8px;
  font-size: clamp(1.45rem, 3vw, 2rem);
  letter-spacing: -0.02em;
}

.search-subline {
  max-width: 60ch;
  margin-bottom: 20px;
  color: var(--muted);
  font-size: 0.9rem;
}

.search-form {
  display: flex;
  align-items: stretch;
  gap: 10px;
  min-width: 0;
}

.search-form input[type="search"] {
  flex: 1 1 auto;
  width: auto;
  min-width: 0;
  height: 44px;
  padding: 9px 12px;
  font-size: 0.95rem;
}

.search-submit {
  flex: none;
  height: 44px;
  padding: 0 18px;
  color: #0d1117;
  background: var(--accent);
  border-color: var(--accent);
  font-size: 0.9rem;
}

.search-submit:hover {
  color: #0d1117;
  background: #79b8ff;
  border-color: #79b8ff;
}

.search-submit:disabled,
.search-form input:disabled {
  cursor: progress;
  opacity: 0.55;
}

.search-status {
  min-height: 1.4em;
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 0.86rem;
  font-variant-numeric: tabular-nums;
}

.search-status.is-loading {
  animation: tagstats-pulse 1.6s ease-in-out infinite;
}

.search-status.is-error {
  color: var(--red);
}

.search-status.is-success {
  color: var(--green);
}

.search-candidates {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--border-soft);
}

.candidate-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.candidate-button,
.recent-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  padding: 9px 12px;
  color: var(--text);
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 7px;
  font: inherit;
  font-size: 0.86rem;
  text-align: left;
  cursor: pointer;
}

.candidate-button {
  justify-content: space-between;
}

.candidate-button:hover,
.recent-chip:hover {
  border-color: var(--accent);
}

.candidate-name,
.recent-name {
  min-width: 0;
  overflow: hidden;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.candidate-id {
  flex: none;
  max-width: 52%;
  overflow: hidden;
  color: var(--muted);
  font-size: 0.74rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.recent-players {
  margin-top: 22px;
  padding-top: 16px;
  border-top: 1px solid var(--border-soft);
}

.recent-players h3 {
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.recent-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.recent-chip {
  gap: 8px;
  padding: 6px 10px;
}

.recent-time {
  color: var(--muted);
  font-size: 0.74rem;
  white-space: nowrap;
}

@keyframes tagstats-pulse {
  0%,
  100% {
    opacity: 0.55;
  }
  50% {
    opacity: 1;
  }
}

.fatal {
  margin-top: 24px;
  padding: 20px 22px;
  background: var(--red-soft);
  border: 1px solid rgba(248, 81, 73, 0.45);
  border-radius: var(--radius);
}

.fatal h2 {
  margin-bottom: 8px;
  font-size: 1.1rem;
}

.fatal pre {
  margin: 12px 0;
  padding: 12px 14px;
  overflow-x: auto;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.fatal pre code {
  padding: 0;
  background: none;
  border: 0;
}

.site-footer {
  margin-top: 30px;
  color: var(--muted);
  font-size: 0.76rem;
  text-align: center;
}

.site-footer p {
  margin: 0;
}

.snapshot {
  font-size: 0.8rem;
}

.has-tip {
  cursor: help;
}

.control.has-tip .control-label,
.kpi.has-tip .kpi-label,
button.sort.has-tip,
.chip.has-tip {
  text-decoration: underline dotted;
  text-decoration-color: rgba(145, 152, 161, 0.55);
  text-underline-offset: 3px;
}

.control.has-tip input[type="search"],
.control.has-tip input[type="number"] {
  cursor: text;
}

button.sort.has-tip {
  cursor: help;
}

.chip.has-tip:not(.is-disabled) {
  cursor: pointer;
}

.tooltip {
  position: fixed;
  z-index: 1000;
  max-width: 320px;
  padding: 8px 10px;
  color: var(--text);
  background: var(--panel-raised);
  border: 1px solid var(--border);
  border-radius: 7px;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.5);
  font-size: 0.78rem;
  line-height: 1.45;
  pointer-events: none;
}

@media (max-width: 1100px) {
  .controls {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 900px) {
  .search-panel {
    padding: 34px 0 22px;
  }

  .search-card {
    padding: 24px;
  }
}

@media (max-width: 760px) {
  .page {
    padding: 20px 14px 32px;
  }

  .tabs {
    gap: 2px;
    padding: 6px;
  }

  .tab {
    padding: 6px 10px;
  }

  .site-header {
    gap: 12px;
  }

  .header-meta {
    text-align: left;
  }

  .panel-head {
    flex-wrap: wrap;
  }

  .panel-actions {
    margin-left: auto;
  }

  .controls {
    gap: 14px;
  }

  input[type="search"] {
    width: 100%;
  }

  .override-actions {
    width: 100%;
    margin-left: 0;
  }

  .override-search {
    flex: 1 1 100%;
  }

  .kpis {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 700px) {
  .controls {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 520px) {
  .controls {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 500px) {
  .search-card {
    padding: 20px 16px;
  }

  .search-form {
    flex-direction: column;
  }

  .search-submit {
    width: 100%;
  }

  .candidate-button {
    flex-direction: column;
    align-items: flex-start;
    gap: 3px;
  }

  .candidate-id {
    max-width: 100%;
  }

  .player-actions {
    justify-content: flex-start;
  }
}

@media (max-width: 460px) {
  .kpis {
    grid-template-columns: 1fr;
  }
}
