.legend-intro h1 { font-size: clamp(36px, 4.4vw, 65px); }
.legend-intro .dataset-stats { flex-basis: min(37.5%, 476px); }
.legend-controls { margin-bottom: 20px; min-width: 0; }
.legend-controls-heading { padding: 12px 16px 0; }
.legend-controls-heading h2 { font-size: 16px; }
.legend-controls-main { display: grid; grid-template-columns: minmax(307px, 1.5fr) minmax(71px, .52fr) minmax(170px, 1fr) minmax(106px, .68fr) minmax(125px, .62fr); align-items: end; gap: 12px; padding: 16px 16px; }
.legend-help { display: flex; flex-wrap: wrap; gap: 4px 16px; padding: 0 16px 12px; }
.legend-choice { border: 0; min-width: 0; padding: 0; margin: 0; }
.legend-choice legend, .legend-field { color: #d0cbd0; font-size: 12px; font-weight: 650; }
.legend-choice legend { padding: 0; margin-bottom: 6px; }
.legend-field { display: flex; flex-direction: column; justify-content: end; gap: 6px; min-width: 0; }
.legend-field input, .legend-field .select { padding: 8px 8px; min-height: 36px; min-width: 0; width: 100%; border: 1px solid var(--line); border-radius: 7px; color: var(--ink); background: var(--input); font-size: 13px; font-weight: 560; }
.legend-segments { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 4px; padding: 4px; background: var(--input); border: 1px solid var(--line); border-radius: 8px; }
.legend-segments label { position: relative; min-width: 0; }
.legend-segments input { position: absolute; inset: 0; width: 100%; margin: 0; opacity: 0; cursor: pointer; }
.legend-segments span { display: block; padding: 6px 4px; border-radius: 6px; border: 1px solid transparent; text-align: center; font-size: 12px; font-weight: 670; color: var(--muted); pointer-events: none; white-space: nowrap; }
.legend-segments input:hover + span { color: var(--ink); }
.legend-segments input:checked + span { background: var(--accent-soft); border-color: #603d35; color: #ffad97; }
.legend-segments input:focus-visible + span { outline: 2px solid var(--accent); }
.legend-run { min-height: 36px; padding: 6px 10px; border: 1px solid #ec9a85; border-radius: 7px; background: #eb927b; color: #261713; font-size: 13px; font-weight: 740; }
.legend-run:hover:not(:disabled) { background: #f6a38f; }
.legend-run:disabled { opacity: .56; }
.legend-advanced { border-top: 1px solid var(--line-soft); }
.legend-advanced summary { display: flex; justify-content: space-between; align-items: center; padding: 10px 16px; list-style: none; cursor: pointer; color: var(--muted); font-size: 13px; font-weight: 610; }
.legend-advanced summary:hover { color: var(--ink); }
.legend-advanced summary::-webkit-details-marker { display: none; }
.legend-advanced summary span { color: var(--accent); font-size: 16px; }
.legend-advanced[open] summary span { transform: rotate(45deg); }
.legend-advanced-fields { padding: 4px 16px 14px; display: grid; grid-template-columns: repeat(auto-fit, minmax(135px, 1fr)); gap: 10px; }

.legend-results-head { display: flex; gap: 14px; align-items: flex-end; justify-content: space-between; margin: 0 0 12px; }
.legend-results-head h2 { font-size: 24px; font-weight: 690; letter-spacing: -.035em; }
.legend-results-head p { margin-top: 4px; }
.legend-tabs { gap: 4px; justify-content: flex-end; }
.legend-tabs .role-tab { padding-inline: 10px; }
.legend-status { color: #edc1b2; margin: -2px 0 10px; font-size: 13px; }
.legend-status:empty { display: none; }
.legend-scope-note { margin-bottom: 12px; }
.legend-results { display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; }
.legend-results > .surface { min-width: 0; }
.legend-mobile-label { display: none; }
.legend-related { display: flex; flex-wrap: wrap; gap: 4px 12px; }
.legend-results[aria-busy="true"] > .surface { opacity: .73; }
.legend-empty { display: grid; min-height: 105px; justify-items: center; align-content: center; gap: 4px; padding: 14px; text-align: center; color: var(--muted); font-size: 13px; }
.legend-empty strong { color: var(--ink); }
.legend-inner-empty { min-height: 75px; border-top: 1px solid var(--line-soft); }
.legend-band .section-heading { align-items: flex-start; }
.legend-band .section-heading h3 { font-size: 19px; letter-spacing: -.03em; }
.legend-band h4 { font-size: 14px; margin: 0; }
.legend-band-title { color: #ecc292; white-space: nowrap; font-variant-numeric: tabular-nums; }
.legend-band .item-only-summary { margin: 0; line-height: 1.45; }
.legend-band .item-only-summary + .scroll-table { margin-top: 8px; }
.legend-band .legend-empty + details { border-top: 1px solid var(--line-soft); }

.legend-overview th, .legend-overview td, .legend-table th, .legend-table td { padding: 10px 12px; border-top: 1px solid var(--line-soft); }
.legend-overview th:first-child, .legend-overview td:first-child, .legend-table th:first-child, .legend-table td:first-child { padding-left: 16px; }
.legend-overview th:last-child, .legend-overview td:last-child, .legend-table th:last-child, .legend-table td:last-child { padding-right: 16px; }
.legend-overview td { vertical-align: top; min-width: 178px; }
.legend-overview .legend-role-cell { min-width: 112px; width: 125px; vertical-align: middle; white-space: normal; }
.legend-role-cell .plain-button { padding: 0; color: var(--ink); min-height: auto; font-size: 13px; }
.legend-role-cell .plain-button:hover { color: #ffbca8; background: transparent; }
.legend-overview tbody tr:hover, .legend-table tbody tr:hover { background: #202128; }
.leader-name, .legend-hero-name, .legend-items { display: flex; align-items: center; gap: 8px; }
.leader-name { font-size: 14px; font-weight: 680; }
.legend-items { flex-wrap: wrap; gap: 4px; font-size: 12px; }
.legend-items > span { display: inline-flex; align-items: center; gap: 4px; }
.legend-items .item-icon { width: 24px; height: 18px; }
.leader-items { margin-top: 4px; }
.leader-output { display: flex; gap: 6px 10px; flex-wrap: wrap; align-items: baseline; margin-top: 6px; font-size: 11px; color: var(--muted); }
.leader-output strong { color: var(--positive); font-size: 13px; }
.legend-hero-name a, .leader-name a { color: var(--ink); text-decoration: none; }
.legend-hero-name a:hover, .leader-name a:hover { color: #ffbca8; text-decoration: underline; text-underline-offset: 3px; }
.legend-role-subtitle { display: block; margin-top: 2px; }
.legend-hero-name { font-weight: 650; white-space: nowrap; }
.legend-hero-name .portrait, .leader-name .portrait { width: 42px; height: 24px; }
.legend-spell { display: block; margin-top: 4px; color: var(--muted); white-space: normal; line-height: 1.45; }
.legend-gold { color: #e3be89; white-space: nowrap; }
.legend-value { font-weight: 690; white-space: nowrap; }
.legend-value-unit { color: var(--muted); font-size: 10px; font-weight: 550; }
.legend-table th { white-space: normal; vertical-align: top; }
.legend-hero-cell { color: var(--ink); letter-spacing: inherit; text-transform: none; }
.legend-coverage-cell { color: var(--muted); white-space: nowrap; }
.legend-picks { white-space: nowrap; }
.legend-coverage-cell.is-partial { color: #e1b594; }
.legend-method { margin-top: 16px; }
.legend-ability-context {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 12px;
  padding: 12px 14px;
  border: 1px solid #533b34;
  border-radius: 9px;
  background: var(--surface);
  color: #e8c8ba;
  font-size: 13px;
  line-height: 1.48;
}
.legend-ability-context > div { display: grid; gap: 4px; flex: 1 1 390px; }
.legend-ability-context strong { color: var(--ink); }
.legend-ability-context .role-tab { color: #ffad97; background: var(--accent-soft); border-color: #603d35; }
.legend-ability-context .role-tab:hover { background: #523028; }
.legend-ability-links { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; }
.legend-ability-links a { color: #ffad97; text-underline-offset: 3px; }
.legend-ability-table td, .legend-ability-table th { vertical-align: middle; }
.legend-cast-hits { min-width: 73px; }
.legend-cast-speed { min-width: 128px; }
.legend-cast-note { display: block; color: var(--muted); margin-top: 2px; font-size: 11px; line-height: 1.35; }
.legend-cast-note strong { color: var(--positive); }
.legend-cast-value { white-space: nowrap; font-weight: 650; }
.legend-hero-name > span:last-child, .leader-name > span:last-child { color: var(--ink); }
.legend-interactions { margin-top: 16px; min-width: 0; }
.legend-interaction { border-top: 1px solid var(--line-soft); }
.legend-interaction > summary { list-style: none; cursor: pointer; display: grid; grid-template-columns: minmax(150px, 1fr) minmax(160px, 1.4fr) auto; gap: 10px; align-items: center; padding: 10px 14px; }
.legend-interaction > summary:hover { background: #1c1e24; }
.legend-interaction > summary::-webkit-details-marker { display: none; }
.interaction-title strong { display: block; overflow-wrap: anywhere; font-size: 13px; }
.interaction-title small, .interaction-example { color: var(--muted); font-size: 12px; }
.interaction-example { overflow-wrap: anywhere; }
.interaction-status { color: #e7b9a2; border: 1px solid #63463d; border-radius: 20px; padding: 4px 8px; white-space: nowrap; font-size: 11px; }
.interaction-status.is-scored { color: var(--positive); border-color: #43695a; }
.interaction-detail { padding: 2px 14px 12px; display: grid; gap: 6px; color: var(--muted); font-size: 12px; line-height: 1.5; }
.interaction-detail ul { margin: 0; padding-left: 20px; }
.interaction-detail a { color: var(--accent); text-underline-offset: 2px; }

@media (max-width: 1000px) {
  .legend-results-head { align-items: start; flex-direction: column; }
  .legend-tabs { justify-content: start; }
  .legend-table th, .legend-table td { padding-inline: 8px; }
}

@media (max-width: 920px) {
  .legend-controls-main { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .legend-choice { grid-column: 1 / -1; }
  .legend-advanced-fields { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .legend-overview, .legend-table { min-width: 590px; }
  .legend-results-head { gap: 6px; }
}

@media (max-width: 550px) {
  .legend-intro { gap: 12px; }
  .legend-intro .dataset-stats { flex-basis: auto; padding-top: 4px; }
  .legend-intro .dataset-stats dt { font-size: 11px; }
  .legend-intro h1 { font-size: clamp(36px, 11vw, 51px); }
  .legend-controls-main { gap: 8px; padding: 12px; }
  .legend-controls-heading, .legend-help { padding-inline: 12px; }
  .legend-controls .legend-advanced summary { padding-inline: 12px; }
  .legend-advanced-fields { padding-inline: 12px; }
  .legend-tabs .role-tab { padding-inline: 8px; }
  .legend-interaction > summary { grid-template-columns: minmax(0, 1fr) auto; gap: 4px 8px; }
  .interaction-example { grid-column: 1 / -1; grid-row: 2; }
  .legend-segments span { font-size: 11px; }
  .legend-table-region { overflow: visible; }
  .legend-overview, .legend-table, .legend-overview tbody, .legend-table tbody { display: block; min-width: 0; }
  .legend-overview thead, .legend-table thead {
    position: absolute;
    width: 1px;
    height: 1px;
    clip-path: inset(50%);
    overflow: hidden;
    white-space: nowrap;
  }
  .legend-mobile-label { display: block; color: var(--muted); font-size: 11px; font-weight: 500; margin-bottom: 2px; }
  .legend-overview tbody tr { display: grid; grid-template-columns: minmax(0, 1fr); }
  .legend-overview .legend-role-cell { width: auto; background: var(--layer); }
  .legend-table tbody tr {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    border-top: 1px solid var(--line);
    padding: 12px 16px;
    gap: 8px 12px;
  }
  .legend-table .legend-hero-cell, .legend-table .legend-build-cell { grid-column: 1 / -1; }
  .legend-overview td, .legend-table th, .legend-table td { min-width: 0; }
  .legend-overview td { padding-inline: 16px; }
  .legend-overview td .legend-mobile-label { color: #ecc292; }
  .legend-table :is(th, td):is(:first-child, :last-child), .legend-table th, .legend-table td { padding: 0; border: 0; }
  .legend-table .legend-coverage-cell { white-space: normal; }
  .legend-table .legend-cast-hits, .legend-table .legend-cast-speed { min-width: 0; }
}
