#dialog:has(.league-profile) {
  width: min(456px, calc(100% - 24px));
}

#dialog:has(.league-profile) .modal-content {
  padding: 0;
}

#dialog:has(.league-profile) .modal-head {
  margin: 0;
  padding: 18px 22px;
  background: #22241e;
  color: #fff;
}

#dialog:has(.league-profile) .modal-close {
  color: #f5f4e9;
  background: #3a3c34;
}

.lp-identity {
  display: flex;
  align-items: center;
  min-width: 0;
  gap: 12px;
}

.lp-identity > div {
  min-width: 0;
}

.lp-identity [hidden] {
  display: none;
}

.lp-avatar {
  width: 50px;
  height: 50px;
  flex: none;
  object-fit: cover;
  border: 1px solid #e7b23d;
  border-radius: 12px;
  background: #f8e5af;
}

.lp-game {
  display: block;
  color: #ffd36b;
  font-size: 11px;
  font-weight: 680;
  line-height: 1.4;
}

.lp-identity h2 {
  margin: 0;
  font-size: clamp(22px, 4vw, 27px);
  line-height: 1.15;
}

.league-profile {
  padding: 18px 22px 21px;
}

.league-profile [hidden] {
  display: none;
}

.league-profile h3, .lp-form legend {
  margin: 17px 0 7px;
  color: var(--ink);
  font-size: 15px;
  font-weight: 730;
  line-height: 1.3;
}

.lp-id, .lp-ranks, .lp-champions {
  margin: 0;
}

.lp-id {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 3px 12px;
}

.lp-id dt, .lp-ranks dt {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.lp-id dd, .lp-ranks dd {
  min-width: 0;
  margin: 0;
  font-size: 16px;
  font-weight: 710;
  overflow-wrap: anywhere;
}

.lp-id.lp-server {
  margin-top: 3px;
}

.lp-server dd {
  color: var(--muted);
  font-size: 13px;
  font-weight: 550;
}

.lp-ranks, .lp-selects {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.lp-ranks > div {
  display: grid;
  align-content: center;
  gap: 4px;
  border: 1px solid #dadbd0;
  border-radius: 9px;
  padding: 9px 12px;
  background: #f6f6f1;
}

.lp-champions {
  padding: 0;
  list-style: none;
}

.lp-champion-link {
  display: flex;
  width: 100%;
  align-items: center;
  gap: 12px;
  min-height: 44px;
  border: 0;
  border-radius: 8px;
  padding: 5px 6px 5px 0;
  background: transparent;
  text-align: left;
  font-size: 15px;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.lp-champion-link:disabled {
  opacity: 1;
}

.lp-champion-link:not(:disabled):hover, .lp-champion-link:focus-visible {
  background: var(--pale);
}

.lp-champion-chevron {
  width: 15px;
  height: 15px;
  margin-left: auto;
  color: var(--muted);
  transform: rotate(-90deg);
}

.lp-champion-link:disabled .lp-champion-chevron {
  display: none;
}

.lp-champions li + li {
  border-top: 1px solid #eeefe8;
}

.lp-place {
  display: grid;
  width: 22px;
  height: 22px;
  flex: none;
  place-items: center;
  border-radius: 50%;
  background: #efefe8;
  color: #505347;
  font-variant-numeric: tabular-nums;
  font-size: 12px;
  font-weight: 730;
}

.lp-champions li:first-child .lp-place {
  background: #f6ce6c;
  color: #423214;
}

.lp-portrait {
  flex: none;
  width: 48px;
  height: 48px;
  border-radius: 9px;
  background-repeat: no-repeat;
  box-shadow: inset 0 0 0 1px #0002;
}

.league-profile .lp-missing {
  color: var(--muted);
  font-size: 13px;
  font-weight: 480;
}

.lp-source, .lp-hint, .lp-error, .lp-feedback {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.lp-source {
  margin-top: 12px;
}

.lp-key-note, .lp-feedback:not(:empty) {
  margin-top: 10px;
}

.lp-no-mastery {
  padding: 5px 0;
}

.lp-hint-key, .lp-key-note {
  padding: 8px 10px;
  background: #fff5dc;
  color: #755414;
  border-radius: 7px;
}

.lp-form h3 {
  margin: 0;
}

.lp-credits {
  border-top: 1px solid var(--line);
  margin-top: 14px;
  padding-top: 6px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.45;
}

.lp-credits summary {
  cursor: pointer;
  padding: 6px 0;
}

.lp-credits p {
  margin: 4px 0 0;
}

.lp-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.lp-actions button:disabled {
  cursor: default;
  opacity: .6;
}

.lp-view .lp-actions {
  margin-top: 15px;
}

.lp-secondary {
  padding: 10px 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  font-size: 13px;
  font-weight: 640;
}

.lp-secondary:hover {
  background: var(--paper);
}

.lp-form {
  display: grid;
  gap: 13px;
}

.lp-form fieldset {
  display: grid;
  min-width: 0;
  gap: 6px;
  padding: 0;
  margin: 0;
  border: 0;
}

.lp-form legend {
  padding: 0;
  margin: 0 0 8px;
}

.lp-entry {
  display: flex;
  align-items: center;
  gap: 8px;
}

.lp-form .field select, .lp-entry input {
  width: 100%;
  min-width: 0;
  height: 42px;
  border: 1px solid #d3d4c9;
  border-radius: 8px;
  padding: 0 8px;
  background: #fafaf7;
  color: var(--ink);
  font: 450 14px/1.35 Bricolage, "Segoe UI", sans-serif;
}

.lp-form select:focus-visible {
  outline: 3px solid #ac7500;
  outline-offset: 2px;
}

.lp-error:not(:empty) {
  color: #8a3e1b;
}

.lp-error:empty {
  display: none;
}

#dialog:has(.lp-champion-sheet) {
  width: min(768px, calc(100% - 24px));
}

#dialog:has(.lp-champion-sheet) .modal-head {
  position: sticky;
  z-index: 1;
  top: 0;
}

.lp-heading-portrait {
  box-shadow: inset 0 0 0 1px #ffd36b99;
}

.lp-champion-back {
  display: flex;
  align-items: center;
  gap: 5px;
  min-height: 28px;
  max-width: 100%;
  padding: 0 4px 0 0;
  border: 0;
  border-radius: 3px;
  background: none;
  color: #ffd36b;
  font-size: 12px;
  font-weight: 650;
  text-align: left;
  overflow-wrap: anywhere;
}

.lp-champion-back:hover span {
  text-decoration: underline;
}

.lp-champion-back svg {
  width: 15px;
  height: 15px;
}

.lp-champion-sheet {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 216px;
  align-items: start;
  gap: 26px;
}

.lp-champion-sheet h3 {
  margin: 0 0 12px;
  font-size: 18px;
}

.lp-performance {
  grid-column: 1 / -1;
  border-bottom: 1px solid var(--line);
  padding-bottom: 16px;
}

.lp-performance-heading {
  display: flex;
  gap: 5px 12px;
  flex-wrap: wrap;
  align-items: baseline;
}

.lp-performance-heading h3 {
  margin: 0;
  overflow-wrap: anywhere;
}

.lp-example, .lp-performance-status, .lp-sample-window {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.lp-performance-status { margin: 5px 0 0; }
.lp-performance-status:empty { margin: 0; }
.lp-performance-retry { margin-top: 8px; }

.lp-performance-data {
  display: grid;
  grid-template-columns: minmax(142px, .75fr) minmax(0, 2fr);
  gap: 20px;
  align-items: start;
  margin-top: 10px;
}

.lp-mastery-total {
  display: grid;
  gap: 3px;
  padding: 13px 15px;
  margin: 0;
  border-radius: 9px;
  background: #fff1c9;
  color: #4a3715;
}

.lp-mastery-total dt, .lp-results caption {
  font-size: 13px;
  font-weight: 690;
}

.lp-mastery-total dd {
  margin: 0;
  font-size: clamp(21px, 3vw, 28px);
  font-variant-numeric: tabular-nums;
  font-weight: 740;
  line-height: 1.15;
}

.lp-results {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  line-height: 1.35;
}

.lp-results caption { text-align: left; padding-bottom: 4px; }
.lp-results > :is(thead, tbody) > tr > :is(th, td) { padding: 5px 4px; text-align: right; }
.lp-results > :is(thead, tbody) > tr > th:first-child { text-align: left; padding-left: 0; }
.lp-results > :is(thead, tbody) > tr > :last-child { padding-right: 0; }
.lp-results > thead th { color: var(--muted); font-size: 12px; font-weight: 550; }
.lp-results > tbody > tr[data-queue] { border-top: 1px solid var(--line); cursor: pointer; }
.lp-results > tbody > tr[data-queue]:is(:hover, :focus-within) { background: #fff7e2; }
.lp-results > tbody > tr:has(.lp-queue-toggle[aria-expanded="true"]) { background: #fff1c9; }
.lp-results > tbody > tr[data-queue] > th:first-child { padding: 0; }
.lp-results > tbody > tr[data-queue] > td:last-child { font-weight: 720; }
.lp-queue-toggle {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 36px;
  border: 0;
  border-radius: 4px;
  background: transparent;
  padding: 5px 3px;
  color: inherit;
  font: inherit;
  font-weight: 660;
  text-align: left;
}
.lp-queue-toggle svg { width: 14px; height: 14px; flex: none; transform: rotate(-90deg); }
.lp-queue-toggle[aria-expanded="true"] svg { transform: none; }
.lp-results > tbody > .lp-queue-details > td { padding: 0 0 6px; text-align: left; }
.lp-match-history {
  padding: 9px 12px;
  border-left: 3px solid #d5a63c;
  border-radius: 0 0 7px 0;
  background: #faf8f1;
  color: var(--ink);
  font-size: 12px;
}
.lp-matches { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.lp-matches th, .lp-matches td { padding: 5px 3px; text-align: left; }
.lp-matches thead th { color: var(--muted); font-weight: 570; }
.lp-matches th:first-child, .lp-matches td:first-child { padding-left: 0; }
.lp-matches th:last-child, .lp-matches td:last-child { text-align: right; padding-right: 0; }
.lp-matches tbody tr { border-top: 1px solid var(--line); }
.lp-matches time span { margin-left: 3px; color: var(--muted); font-size: 11px; }
.lp-match-result, .lp-match-kda { font-weight: 650; white-space: nowrap; }
.lp-match-result[data-win="true"] { color: #775300; }
.lp-kda-key { margin: 5px 0 0; color: var(--muted); font-size: 11px; font-weight: 500; }
.lp-sample-window { margin: 5px 0 0; }

.lp-abilities, .lp-champion-stats {
  padding: 0;
  margin: 0;
  list-style: none;
}

.lp-ability {
  display: flex;
  align-items: start;
  gap: 12px;
  padding: 12px 0;
}

.lp-ability:first-child {
  padding-top: 0;
}

.lp-ability + .lp-ability, .lp-champion-stats > div + div {
  border-top: 1px solid var(--line);
}

.lp-ability-icon {
  width: 48px;
  height: 48px;
  flex: none;
  border-radius: 9px;
  background: #24251f url("assets/lol-abilities.jpg") no-repeat;
  box-shadow: inset 0 0 0 1px #0002;
}

.lp-ability-title {
  display: flex;
  align-items: baseline;
  gap: 6px;
}

.lp-ability-key {
  display: inline-grid;
  flex: none;
  min-width: 21px;
  min-height: 19px;
  padding: 0 5px;
  place-items: center;
  border-radius: 4px;
  color: #674600;
  background: #ffecb8;
  font-size: 11px;
  font-weight: 720;
}

.lp-ability-title h4 {
  margin: 0;
  font-size: 15px;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.lp-ability p {
  margin: 4px 0 0;
  color: #52534d;
  font-size: 13px;
  line-height: 1.5;
  white-space: pre-line;
  overflow-wrap: anywhere;
}

.lp-stat-block {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 13px;
  background: var(--paper);
}

.lp-stat-block h3 {
  margin-bottom: 2px;
  font-size: 16px;
}

.lp-level {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 12px;
}

.lp-champion-stats > div {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  padding: 7px 0;
}

.lp-champion-stats dt {
  color: var(--muted);
  font-size: 12px;
}

.lp-champion-stats dd {
  flex: none;
  margin: 0;
  font-size: 13px;
  font-weight: 730;
  font-variant-numeric: tabular-nums;
}

@media (max-width: 640px) {
  .lp-performance-data { grid-template-columns: minmax(0, 1fr); gap: 11px; }
  .lp-queue-toggle { min-height: 44px; }
  .lp-mastery-total {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 11px;
  }
  .lp-champion-sheet {
    grid-template-columns: minmax(0, 1fr);
    gap: 14px;
  }

  .lp-champion-stats {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0 14px;
  }

  .lp-champion-stats > div {
    flex-direction: column;
    gap: 2px;
    border-top: 1px solid var(--line);
  }

  .lp-champion-back {
    min-height: 34px;
  }
}

@media (max-width: 420px) {
  .lp-matches time span { display: block; margin-left: 0; }
  #dialog:has(.league-profile) .modal-head {
    padding: 14px 16px;
  }
  .league-profile {
    padding: 15px 16px;
  }
  .lp-ranks > div {
    padding: 8px 10px;
  }
}
