/* V1.28Beta-character-codex-fullart-fourup1: opened character codex uses full, uncropped paintings. */
html body:not(.maintenance-mode) #characterCodexDialog#characterCodexDialog.character-codex-dialog .character-codex-box.character-codex-box {
  width: min(1720px, calc(100vw - 28px)) !important;
  max-height: min(92dvh, 980px) !important;
  padding: clamp(16px, 1.45vw, 28px) !important;
}

html body:not(.maintenance-mode) #characterCodexDialog#characterCodexDialog.character-codex-dialog .character-codex-grid.character-codex-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
  gap: clamp(18px, 1.55vw, 28px) !important;
  align-items: stretch !important;
}

html body:not(.maintenance-mode) #characterCodexDialog#characterCodexDialog.character-codex-dialog .character-codex-card.character-codex-card {
  grid-column: auto !important;
  grid-template-rows: auto minmax(190px, 1fr) !important;
  border-radius: 10px !important;
  border-width: 1px !important;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.94),
    inset 0 0 0 1px rgba(255, 255, 255, 0.5),
    0 18px 38px rgba(15, 43, 72, 0.2) !important;
}

html body:not(.maintenance-mode) #characterCodexDialog#characterCodexDialog.character-codex-dialog .character-codex-card.character-codex-card::before {
  border-radius: 10px !important;
}

html body:not(.maintenance-mode) #characterCodexDialog#characterCodexDialog.character-codex-dialog .character-codex-card.character-codex-card .character-codex-art.character-codex-art {
  width: 100% !important;
  aspect-ratio: 2 / 3 !important;
  border-bottom: 1px solid rgba(186, 155, 84, 0.3) !important;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.03) 0 62%, rgba(255, 255, 255, 0.28) 100%),
    var(--character-art, none) center center / contain no-repeat,
    radial-gradient(circle at 50% 18%, rgba(255, 239, 184, 0.25), transparent 44%),
    linear-gradient(180deg, #f8fcff 0%, #deedf6 100%) !important;
  background-position: center center, center center, center center, center center !important;
  background-size: auto, contain, auto, auto !important;
  background-repeat: no-repeat, no-repeat, no-repeat, no-repeat !important;
  box-shadow:
    inset 0 -20px 30px rgba(255, 255, 255, 0.28),
    inset 0 0 0 1px rgba(255, 255, 255, 0.58) !important;
}

html body:not(.maintenance-mode) #characterCodexDialog#characterCodexDialog.character-codex-dialog .character-codex-copy.character-codex-copy {
  gap: clamp(9px, 0.75vw, 13px) !important;
  padding: clamp(13px, 1vw, 18px) !important;
}

html body:not(.maintenance-mode) #characterCodexDialog#characterCodexDialog.character-codex-dialog .character-codex-copy.character-codex-copy em {
  padding: 3px 9px !important;
  border-left-width: 4px !important;
  border-radius: 6px !important;
  font-size: clamp(12px, 0.72vw, 14px) !important;
  line-height: 1.18 !important;
}

html body:not(.maintenance-mode) #characterCodexDialog#characterCodexDialog.character-codex-dialog .character-codex-copy.character-codex-copy strong {
  font-size: clamp(21px, 1.42vw, 28px) !important;
  line-height: 1.05 !important;
}

html body:not(.maintenance-mode) #characterCodexDialog#characterCodexDialog.character-codex-dialog .character-codex-skill.character-codex-skill,
html body:not(.maintenance-mode) #characterCodexDialog#characterCodexDialog.character-codex-dialog .character-codex-skill.character-codex-skill.passive-skill-label {
  min-height: clamp(36px, 2.35vw, 44px) !important;
  padding: 7px 10px !important;
  gap: 8px !important;
  border-left-width: 4px !important;
  border-radius: 8px !important;
  font-size: clamp(13px, 0.8vw, 16px) !important;
}

html body:not(.maintenance-mode) #characterCodexDialog#characterCodexDialog.character-codex-dialog .character-codex-skill.character-codex-skill .skill-inline-icon,
html body:not(.maintenance-mode) #characterCodexDialog#characterCodexDialog.character-codex-dialog .character-codex-skill.character-codex-skill .skill-inline-icon.passive-skill-icon {
  flex: 0 0 clamp(26px, 1.65vw, 30px) !important;
  width: clamp(26px, 1.65vw, 30px) !important;
  min-width: clamp(26px, 1.65vw, 30px) !important;
  max-width: clamp(26px, 1.65vw, 30px) !important;
  height: clamp(26px, 1.65vw, 30px) !important;
  min-height: clamp(26px, 1.65vw, 30px) !important;
  max-height: clamp(26px, 1.65vw, 30px) !important;
  padding: 3px !important;
}

html body:not(.maintenance-mode) #characterCodexDialog#characterCodexDialog.character-codex-dialog .character-codex-skill.character-codex-skill .skill-inline-text {
  font-size: clamp(13px, 0.8vw, 16px) !important;
  line-height: 1.06 !important;
}

html body:not(.maintenance-mode) #characterCodexDialog#characterCodexDialog.character-codex-dialog .character-codex-copy.character-codex-copy small {
  font-size: clamp(13px, 0.76vw, 15px) !important;
  line-height: 1.5 !important;
  -webkit-line-clamp: 5 !important;
}

@media (max-width: 899px) {
  html body:not(.maintenance-mode) #characterCodexDialog#characterCodexDialog.character-codex-dialog .character-codex-box.character-codex-box {
    width: min(720px, calc(100vw - 18px)) !important;
    max-height: calc(100dvh - 18px) !important;
    padding: 12px !important;
  }

  html body:not(.maintenance-mode) #characterCodexDialog#characterCodexDialog.character-codex-dialog .character-codex-grid.character-codex-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 12px !important;
  }

  html body:not(.maintenance-mode) #characterCodexDialog#characterCodexDialog.character-codex-dialog .character-codex-copy.character-codex-copy {
    gap: 7px !important;
    padding: 9px !important;
  }

  html body:not(.maintenance-mode) #characterCodexDialog#characterCodexDialog.character-codex-dialog .character-codex-copy.character-codex-copy strong {
    font-size: clamp(17px, 4.5vw, 21px) !important;
  }

  html body:not(.maintenance-mode) #characterCodexDialog#characterCodexDialog.character-codex-dialog .character-codex-copy.character-codex-copy small {
    -webkit-line-clamp: 4 !important;
  }
}

@media (max-width: 520px) {
  html body:not(.maintenance-mode) #characterCodexDialog#characterCodexDialog.character-codex-dialog .character-codex-grid.character-codex-grid {
    grid-template-columns: 1fr !important;
  }
}

/* V1.28Beta-character-codex-fourup-scale2:
   Desktop character codex rule: exactly four large character cards per row.
   The card, portrait panel, skill strip, and copy scale together instead of shrinking into a dense grid. */
@media (min-width: 900px) {
  html body:not(.maintenance-mode) #characterCodexDialog#characterCodexDialog#characterCodexDialog.character-codex-dialog .character-codex-box.character-codex-box.character-codex-box {
    width: min(1880px, calc(100vw - 24px)) !important;
    max-width: calc(100vw - 24px) !important;
    max-height: min(94dvh, 1080px) !important;
    padding: clamp(18px, 1.55vw, 30px) !important;
    overflow-y: auto !important;
  }

  html body:not(.maintenance-mode) #characterCodexDialog#characterCodexDialog#characterCodexDialog.character-codex-dialog .character-codex-grid.character-codex-grid.character-codex-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
    grid-auto-flow: row !important;
    grid-auto-rows: auto !important;
    gap: clamp(22px, 1.65vw, 34px) !important;
    align-items: stretch !important;
    justify-items: stretch !important;
  }

  html body:not(.maintenance-mode) #characterCodexDialog#characterCodexDialog#characterCodexDialog.character-codex-dialog .character-codex-card.character-codex-card.character-codex-card {
    width: 100% !important;
    min-width: 0 !important;
    grid-column: auto !important;
    grid-template-rows: auto minmax(190px, 1fr) !important;
    border-radius: 12px !important;
    overflow: hidden !important;
  }

  html body:not(.maintenance-mode) #characterCodexDialog#characterCodexDialog#characterCodexDialog.character-codex-dialog .character-codex-card.character-codex-card.character-codex-card .character-codex-art.character-codex-art.character-codex-art {
    width: 100% !important;
    aspect-ratio: 2 / 3 !important;
    min-height: clamp(420px, 31vw, 660px) !important;
    background-position: center center, center center, center center, center center !important;
    background-size: auto, contain, auto, auto !important;
  }

  html body:not(.maintenance-mode) #characterCodexDialog#characterCodexDialog#characterCodexDialog.character-codex-dialog .character-codex-copy.character-codex-copy.character-codex-copy {
    gap: clamp(10px, 0.78vw, 14px) !important;
    padding: clamp(15px, 1.08vw, 20px) !important;
  }

  html body:not(.maintenance-mode) #characterCodexDialog#characterCodexDialog#characterCodexDialog.character-codex-dialog .character-codex-copy.character-codex-copy.character-codex-copy strong {
    font-size: clamp(24px, 1.46vw, 31px) !important;
  }

  html body:not(.maintenance-mode) #characterCodexDialog#characterCodexDialog#characterCodexDialog.character-codex-dialog .character-codex-skill.character-codex-skill.character-codex-skill,
  html body:not(.maintenance-mode) #characterCodexDialog#characterCodexDialog#characterCodexDialog.character-codex-dialog .character-codex-skill.character-codex-skill.character-codex-skill.passive-skill-label {
    min-height: clamp(40px, 2.45vw, 50px) !important;
    font-size: clamp(14px, 0.86vw, 17px) !important;
  }
}

/* V1.28Beta-character-codex-portrait-lower1:
   Character codex uses full character art, but these paintings keep too much visual weight high in the frame.
   Move only the codex presentation down; do not affect character-select small/big cards or battle crops. */
html body:not(.maintenance-mode) #characterCodexDialog#characterCodexDialog.character-codex-dialog
  .character-codex-card.character-codex-card[data-character="Guming"]
  .character-codex-art.character-codex-art,
html body:not(.maintenance-mode) #characterCodexDialog#characterCodexDialog.character-codex-dialog
  .character-codex-card.character-codex-card[data-character="Lollipopz"]
  .character-codex-art.character-codex-art {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.03) 0 62%, rgba(255, 255, 255, 0.28) 100%),
    var(--character-art, none) center 67% / auto 108% no-repeat,
    radial-gradient(circle at 50% 18%, rgba(255, 239, 184, 0.25), transparent 44%),
    linear-gradient(180deg, #f8fcff 0%, #deedf6 100%) !important;
}

html body:not(.maintenance-mode) #characterCodexDialog#characterCodexDialog.character-codex-dialog
  .character-codex-card.character-codex-card[data-character="Lollipopz-magic-assassin"]
  .character-codex-art.character-codex-art {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.03) 0 62%, rgba(255, 255, 255, 0.28) 100%),
    var(--character-art, none) center 64% / auto 102% no-repeat,
    radial-gradient(circle at 50% 18%, rgba(255, 239, 184, 0.25), transparent 44%),
    linear-gradient(180deg, #f8fcff 0%, #deedf6 100%) !important;
}

/* V1.28Beta-character-codex-portrait-lower3:
   Final codex-only portrait crops. The desktop four-up rule above forces
   contain/center with higher specificity, so these selectors intentionally match
   that weight. Smaller Y values move oversized portrait art down in the frame. */
html body:not(.maintenance-mode) #characterCodexDialog#characterCodexDialog#characterCodexDialog.character-codex-dialog
  .character-codex-card.character-codex-card.character-codex-card[data-character="Jisoo"]
  .character-codex-art.character-codex-art.character-codex-art {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.03) 0 62%, rgba(255, 255, 255, 0.28) 100%),
    var(--character-art, none) center 28% / auto 106% no-repeat,
    radial-gradient(circle at 50% 18%, rgba(255, 239, 184, 0.25), transparent 44%),
    linear-gradient(180deg, #f8fcff 0%, #deedf6 100%) !important;
  background-position: center center, center 28%, center center, center center !important;
  background-size: auto, auto 106%, auto, auto !important;
}

html body:not(.maintenance-mode) #characterCodexDialog#characterCodexDialog#characterCodexDialog.character-codex-dialog
  .character-codex-card.character-codex-card.character-codex-card[data-character="Guming"]
  .character-codex-art.character-codex-art.character-codex-art {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.03) 0 62%, rgba(255, 255, 255, 0.28) 100%),
    var(--character-art, none) center 38% / auto 108% no-repeat,
    radial-gradient(circle at 50% 18%, rgba(255, 239, 184, 0.25), transparent 44%),
    linear-gradient(180deg, #f8fcff 0%, #deedf6 100%) !important;
  background-position: center center, center 38%, center center, center center !important;
  background-size: auto, auto 108%, auto, auto !important;
}

/* V1.28Beta-lollipopz-near-crop2: normal Lollipopz stays close, slightly smaller, and shifted left in frame. */
html body:not(.maintenance-mode) #characterCodexDialog#characterCodexDialog#characterCodexDialog.character-codex-dialog
  .character-codex-card.character-codex-card.character-codex-card[data-character="Lollipopz"]
  .character-codex-art.character-codex-art.character-codex-art {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.03) 0 62%, rgba(255, 255, 255, 0.28) 100%),
    var(--character-art, none) 54% 42% / auto 124% no-repeat,
    radial-gradient(circle at 50% 18%, rgba(255, 239, 184, 0.25), transparent 44%),
    linear-gradient(180deg, #f8fcff 0%, #deedf6 100%) !important;
  background-position: center center, 54% 42%, center center, center center !important;
  background-size: auto, auto 124%, auto, auto !important;
}

html body:not(.maintenance-mode) #characterCodexDialog#characterCodexDialog#characterCodexDialog.character-codex-dialog
  .character-codex-card.character-codex-card.character-codex-card[data-character="Lollipopz-magic-assassin"]
  .character-codex-art.character-codex-art.character-codex-art {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.03) 0 62%, rgba(255, 255, 255, 0.28) 100%),
    var(--character-art, none) center 36% / auto 102% no-repeat,
    radial-gradient(circle at 50% 18%, rgba(255, 239, 184, 0.25), transparent 44%),
    linear-gradient(180deg, #f8fcff 0%, #deedf6 100%) !important;
  background-position: center center, center 36%, center center, center center !important;
  background-size: auto, auto 102%, auto, auto !important;
}

/* V1.28Beta-codex-faction-tabs1: character codex uses the same three-faction grouping as character select. */
html body:not(.maintenance-mode)
  #characterCodexDialog#characterCodexDialog.character-codex-dialog
  .character-codex-faction-tabs.character-codex-faction-tabs {
  display: grid !important;
  grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
  align-items: stretch !important;
  width: min(560px, 100%) !important;
  height: clamp(34px, 3.5vw, 40px) !important;
  margin: 0 auto clamp(14px, 1.1vw, 20px) !important;
  padding: 4px !important;
  gap: 5px !important;
  box-sizing: border-box !important;
  border: 1px solid rgba(187, 208, 224, 0.68) !important;
  border-radius: 999px !important;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.86), rgba(223, 239, 249, 0.68)),
    linear-gradient(90deg, rgba(170, 217, 247, 0.24), rgba(255, 255, 255, 0.26)) !important;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.88),
    0 10px 22px rgba(24, 55, 84, 0.14) !important;
}

html body:not(.maintenance-mode)
  #characterCodexDialog#characterCodexDialog.character-codex-dialog
  .character-codex-faction-tabs.character-codex-faction-tabs
  > button[data-character-codex-faction-tab] {
  appearance: none !important;
  -webkit-appearance: none !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  width: 100% !important;
  height: 100% !important;
  min-width: 0 !important;
  min-height: 0 !important;
  margin: 0 !important;
  padding: 0 10px !important;
  box-sizing: border-box !important;
  border: 0 !important;
  border-radius: 999px !important;
  background: transparent !important;
  color: rgba(32, 58, 82, 0.76) !important;
  -webkit-text-fill-color: currentColor !important;
  font-size: clamp(12px, 0.78vw, 14px) !important;
  font-weight: 900 !important;
  line-height: 1 !important;
  letter-spacing: 0 !important;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.62) !important;
  cursor: pointer !important;
}

html body:not(.maintenance-mode)
  #characterCodexDialog#characterCodexDialog.character-codex-dialog
  .character-codex-faction-tabs.character-codex-faction-tabs
  > button[data-character-codex-faction-tab="luminary"].selected {
  background:
    radial-gradient(circle at 18% 0%, rgba(255, 255, 255, 0.96), transparent 46%),
    linear-gradient(102deg, #fafdff 0%, #dff6ff 48%, #9fdcff 100%) !important;
  box-shadow:
    inset 0 0 0 1px rgba(141, 220, 255, 0.9),
    inset 0 1px 0 rgba(255, 255, 255, 0.94),
    0 4px 12px rgba(99, 184, 232, 0.24) !important;
  color: #11445f !important;
  -webkit-text-fill-color: #11445f !important;
}

html body:not(.maintenance-mode)
  #characterCodexDialog#characterCodexDialog.character-codex-dialog
  .character-codex-faction-tabs.character-codex-faction-tabs
  > button[data-character-codex-faction-tab="neutral"].selected {
  background:
    radial-gradient(circle at 18% 0%, rgba(255, 255, 255, 0.98), transparent 46%),
    linear-gradient(102deg, #ffffff 0%, #faeef8 48%, #dfe3ea 100%) !important;
  box-shadow:
    inset 0 0 0 1px rgba(226, 196, 220, 0.9),
    inset 0 1px 0 rgba(255, 255, 255, 0.94),
    0 4px 12px rgba(173, 129, 169, 0.18) !important;
  color: #60415d !important;
  -webkit-text-fill-color: #60415d !important;
}

html body:not(.maintenance-mode)
  #characterCodexDialog#characterCodexDialog.character-codex-dialog
  .character-codex-faction-tabs.character-codex-faction-tabs
  > button[data-character-codex-faction-tab="villain"].selected {
  background:
    radial-gradient(circle at 18% 0%, rgba(255, 100, 120, 0.48), transparent 46%),
    linear-gradient(102deg, #2b0710 0%, #7b1021 55%, #13050a 100%) !important;
  box-shadow:
    inset 0 0 0 1px rgba(247, 83, 100, 0.82),
    inset 0 1px 0 rgba(255, 155, 164, 0.34),
    0 4px 13px rgba(102, 12, 28, 0.28) !important;
  color: #fff0f3 !important;
  -webkit-text-fill-color: #fff0f3 !important;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5) !important;
}

html body:not(.maintenance-mode)
  #characterCodexDialog#characterCodexDialog.character-codex-dialog
  .character-codex-faction-tabs.character-codex-faction-tabs
  > button.empty:not(.selected) {
  opacity: 0.48 !important;
}

@media (max-width: 640px) {
  html body:not(.maintenance-mode)
    #characterCodexDialog#characterCodexDialog.character-codex-dialog
    .character-codex-faction-tabs.character-codex-faction-tabs {
    width: min(330px, 100%) !important;
    height: 34px !important;
    margin-bottom: 12px !important;
    gap: 4px !important;
  }

  html body:not(.maintenance-mode)
    #characterCodexDialog#characterCodexDialog.character-codex-dialog
    .character-codex-faction-tabs.character-codex-faction-tabs
    > button[data-character-codex-faction-tab] {
    padding: 0 4px !important;
    font-size: 11px !important;
  }
}
