/* DnD HUB — character sheet. Presentation only; calculations live in class modules. */
#characterView {
  --sheet-gold: #e6c77d;
  --sheet-ink: #f4edde;
  --sheet-muted: #b8b6a4;
  --sheet-line: #a58a4b44;
  --sheet-surface: #0a2019;
  color: var(--sheet-ink);
}
#characterView > .card {
  padding: 26px;
  margin-bottom: 22px;
  border-color: #a58a4b66;
  border-radius: 18px;
  background: linear-gradient(125deg, #102b22fa, #091d17fc 70%);
  box-shadow: inset 0 1px 0 #ebd7a30a, 0 12px 36px #0003;
}
#characterView .section-title { gap: 14px; flex-wrap: wrap; }
#characterView h2 { color: var(--sheet-gold); font-size: 27px; line-height: 1.2; }
#characterView #charTitle {
  margin: 0;
  color: #f1d596;
  font-size: clamp(28px, 3vw, 40px);
  line-height: 1.15;
  overflow-wrap: anywhere;
}
#characterView #charSubtitle { font-size: 16px; line-height: 1.6; color: #d0cab8; }
#characterView #templateStatus { margin-top: 4px; font-size: 12px; color: #aaa997; }
#characterView button { min-height: 42px; border-radius: 8px; }
#characterView button:focus-visible, #charDialog :is(button, input, select):focus-visible {
  outline: 2px solid #f1d596;
  outline-offset: 3px;
}
#characterView .summary-heading { margin: 20px 0 14px; padding-top: 18px; border-color: var(--sheet-line); }
#characterView .summary-heading h2 { font-size: 21px; }
#characterView #kpis.summary-kpis { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
#characterView .summary-kpi {
  gap: 12px;
  padding: 15px 13px;
  border-color: #c2b78329;
  border-radius: 10px;
  background: #06191180;
  box-shadow: none;
}
#characterView .summary-kpi-icon { border: 0; background: none; box-shadow: none; width: 32px; flex-basis: 32px; }
#characterView .summary-kpi-icon svg { width: 29px; height: 29px; }
#characterView .summary-kpi-label { font-size: 12px; line-height: 1.35; color: #bbbba9; text-transform: none; letter-spacing: 0; }
#characterView .summary-kpi-value { margin-top: 5px; font-size: 29px; color: #f3ebd6; text-shadow: none; }
#characterView .summary-attacks { margin-top: 14px; border-color: var(--sheet-line); border-radius: 10px; background: #071a1480; box-shadow: none; }
#characterView .summary-attacks-title { padding: 12px 16px; background: #ffffff03; color: var(--sheet-gold); border-color: var(--sheet-line); font-size: 19px; }
#characterView .summary-attack-card { grid-template-columns: minmax(200px, 1.5fr) repeat(3, minmax(100px, .7fr)); }
#characterView .summary-attack-name { font-size: 20px; color: #ede0bc; overflow-wrap: anywhere; }
#characterView .summary-attack-icon { border: 0; background: none; box-shadow: none; width: 32px; flex-basis: 32px; }
#characterView .summary-attack-metric-label { font-size: 11px; letter-spacing: .025em; color: var(--sheet-muted); }
#characterView .summary-attack-metric-value { font-size: 21px; }

/* Original club artwork for the summary and attack columns. */
#characterView .summary-kpi-icon {
  width: 40px;
  height: 40px;
  flex-basis: 40px;
  flex-shrink: 0;
  overflow: hidden;
  border-radius: 0;
}
#characterView .summary-image-icon {
  display: block;
  width: 100%;
  height: 100%;
  max-width: none;
  object-fit: cover;
  filter: none;
}
/* White UI glyphs requested for combat/spell metrics.
   Original WEBP files stay untouched for instant rollback. */
#characterView :is(
  .summary-image-spell-attack,
  .summary-image-spell-dc,
  .summary-image-damage
) {
  filter: brightness(0) invert(1);
}
#characterView .summary-image-armor { transform: translateY(3px) scale(1.55); }
#characterView :is(.summary-image-initiative, .summary-image-proficiency, .summary-image-speed) { transform: translateY(2px) scale(1.58); }
#characterView .summary-image-health { transform: scale(1.08); filter: brightness(1.45) saturate(1.25); }
#characterView :is(.summary-image-spell-attack, .summary-image-spell-dc) {
  transform: scale(1.18);
}
#characterView .summary-image-damage { transform: scale(1.08); }
#characterView .summary-attack-metric-label { display: flex; align-items: center; justify-content: center; gap: 7px; min-height: 28px; }
#characterView .summary-metric-icon { display: block; width: 28px; height: 28px; flex: 0 0 28px; overflow: hidden; }

/* A quiet frame, clear labels, and the club's six original ability emblems. */
#characterView #statsCard2 { position: relative; overflow: hidden; padding: 28px 26px; }
#statsCard2 .stats-head2 { display: flex; align-items: baseline; justify-content: space-between; flex-wrap: wrap; gap: 8px 20px; margin-bottom: 22px; }
#statsCard2 .stats-head2 h2 { margin: 0; }
#statsCard2 .stats-caption2 { color: var(--sheet-muted); font-size: 13px; line-height: 1.5; }
#statsGrid2 { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 12px; margin-bottom: 30px; }
#statsCard2 .ability-str { --ability-color: #ee9992; --ability-wash: #e3766610; }
#statsCard2 .ability-dex { --ability-color: #99d9a5; --ability-wash: #68c47c10; }
#statsCard2 .ability-con { --ability-color: #d8b38a; --ability-wash: #c28b5010; }
#statsCard2 .ability-int { --ability-color: #95c9f3; --ability-wash: #4b9be310; }
#statsCard2 .ability-wis { --ability-color: #cbb1ed; --ability-wash: #a171d610; }
#statsCard2 .ability-cha { --ability-color: #eccc88; --ability-wash: #e7b14610; }
#statsCard2 .stat-box2 {
  min-width: 0;
  overflow: hidden;
  border: 1px solid #c2b78338;
  border-radius: 12px;
  background: radial-gradient(ellipse at 50% 0%, var(--ability-wash), transparent 80%), #071911b3;
  box-shadow: inset 0 1px 0 #ffffff05;
}
#statsCard2 .stat-box2 .name {
  padding: 15px 4px 0;
  color: var(--ability-color);
  font: 600 14px/1.3 Arial, sans-serif;
  text-align: center;
}
#statsCard2 .stat-main2 { display: flex; align-items: center; justify-content: center; gap: 13px; min-height: 82px; padding: 10px 8px 14px; }
#statsCard2 .stat-main2 strong { font: 700 44px/1 Georgia, serif; font-variant-numeric: tabular-nums; color: #f6edd7; letter-spacing: -.04em; }
#statsCard2 .stat-icon2 { display: grid; place-items: center; width: 44px; height: 44px; flex: 0 0 44px; overflow: hidden; }
#statsCard2 .stat-icon2 img { display: block; width: 44px; height: 44px; max-width: none; object-fit: contain; }
/* Large originals have generous transparent margins; match their visible size in CSS. */
#statsCard2 :is(.ability-wis, .ability-cha) .stat-icon2 img { transform: scale(1.57); }
#statsCard2 .ability-con .stat-icon2 img { transform: scale(1.45); }
#statsCard2 .stat-save2 {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 7px;
  padding: 11px 5px;
  border-top: 1px solid #c2b78326;
  color: #b9bba9;
  background: #ffffff05;
  font-size: 11px;
  line-height: 1.2;
  white-space: nowrap;
}
#statsCard2 .stat-save2 b { color: #e9e2ce; font-size: 16px; font-variant-numeric: tabular-nums; }
#statsCard2 .stat-save2.is-prof b, #statsCard2 .stat-proficiency2 { color: #eed08a; }
#statsCard2 .stat-proficiency2 { width: 9px; font-size: 10px; }

/* Skills read like a character sheet: full names, a steady value column, no nested boxes. */
#statsCard2 .skills-head2 {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px 20px;
  padding-top: 23px;
  margin-bottom: 15px;
  border-top: 1px solid var(--sheet-line);
}
#statsCard2 .skills-heading2 { display: flex; align-items: baseline; flex-wrap: wrap; gap: 8px 16px; }
#statsCard2 .skills-heading2 h3 { margin: 0; font: 700 24px/1.2 Georgia, serif; color: var(--sheet-gold); }
#statsCard2 .hint2 { color: var(--sheet-muted); font-size: 13px; }
#statsCard2 .stats-legend2 { display: flex; flex-wrap: wrap; gap: 14px; color: #c9c6b5; font-size: 12px; }
#statsCard2 .stats-legend2 > span { white-space: nowrap; }
#statsCard2 .stats-legend2 i { font-style: normal; color: #ecd08a; margin-right: 4px; letter-spacing: -1px; }
#skillsGrid2 { display: grid; grid-template-rows: repeat(6, minmax(49px, auto)); grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); column-gap: 26px; }
#statsCard2 .skill-row2 {
  min-width: 0;
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr) 29px 37px;
  gap: 8px;
  align-items: center;
  padding: 10px 7px;
  border: 0;
  border-bottom: 1px solid #b9c5ad18;
  background: transparent;
  border-radius: 0;
}
#statsCard2 .skill-row2.is-prof { background: linear-gradient(90deg, #d9be7021, #d9be7004); }
#statsCard2 .skill-row2.is-expert { background: linear-gradient(90deg, #d9be7030, #d9be7008); }
#statsCard2 .skill-prof2 { color: #9ba291; font-size: 18px; line-height: 1; text-align: center; letter-spacing: -2px; white-space: nowrap; }
#statsCard2 .skill-row2.is-prof .skill-prof2 { color: #eed08a; font-size: 13px; }
#statsCard2 .skill-name2 { color: #d3d5c7; font-size: 15px; line-height: 1.45; white-space: normal; overflow: visible; overflow-wrap: anywhere; }
#statsCard2 .skill-row2.is-prof .skill-name2 { color: #f2ead4; font-weight: 600; }
#statsCard2 .skill-stat2 { color: var(--ability-color); font: 600 10px/1.2 Arial, sans-serif; letter-spacing: .025em; text-align: right; }
#statsCard2 .skill-val2 { color: #d7ddce; font: 700 23px/1 Georgia, serif; font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
#statsCard2 .skill-row2.is-prof .skill-val2 { color: #f1d591; }

/* Give the prose abilities the same hierarchy and breathing room. */
#characterView #raceAbilities2[hidden] { display: none !important; }
#characterView #raceAbilities2:not([hidden]) { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-top: 16px; }
#characterView #raceAbilities2 > .locked { min-width: 0; margin: 0; padding: 15px 18px; border: 1px solid #a58a4b38; border-radius: 10px; background: #071a1273; font-size: 15px; line-height: 1.7; color: #d8dccc; }
#characterView #raceAbilities2 .race-skill-selection { grid-column: 1 / -1; }
#characterView #opened { margin-top: 14px; }
#characterView #opened .ability-group2 + .ability-group2 { margin-top: 26px; padding-top: 22px; border-color: var(--sheet-line); }
#characterView #opened .ability-group-title2 { margin-bottom: 16px; font-size: 20px; color: #d1c9b0; }
#characterView #opened .ability-group-active2 .ability-group-title2 { color: #ebcf87; }
#characterView #opened .ability-group-count2 { font-size: 12px; padding: 3px 9px; color: #c2c2ad; border-color: #a58a4b55; }
#characterView #opened .ability-row2 {
  display: grid;
  grid-template-columns: 54px minmax(160px, .65fr) minmax(0, 2fr);
  align-items: start;
  gap: 14px;
  margin: 0;
  padding: 18px 12px;
  border: 0;
  border-top: 1px solid #b9c5ad1f;
  line-height: 1.65;
}
#characterView #opened .ability-level2 { justify-self: start; margin-top: 3px; padding: 3px 6px; border-color: #a58a4b44; border-radius: 5px; background: #071a1273; color: #c9bb91; font-size: 11px; }
#characterView #opened .ability-name2 { min-width: 0; font: 700 18px/1.5 Georgia, serif; color: #eddfbc; overflow-wrap: anywhere; }
#characterView #opened .ability-text2 { color: #d6d9cc; font-size: 15px; }
#characterView #locked .locked { padding: 12px 15px; margin: 10px 0; border-left-width: 2px; color: #b7bdad; font-size: 14px; line-height: 1.65; }
#characterView .artifact-gold { font-size: 17px; }
#characterView .artifact-gold strong { font-size: 26px; }


/* Shapeshifter combat forms: calculated from the current character. */
#characterView #shapeshifterFormsCard { overflow: hidden; }
#characterView .shapeshifter-forms-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 12px;
}
#characterView .shapeshifter-forms-head h2 { margin: 0 0 7px; }
#characterView .shapeshifter-forms-head p {
  margin: 0;
  max-width: 760px;
  color: #bfc2b4;
  font-size: 14px;
  line-height: 1.55;
}
#characterView .shapeshifter-form-resource,
#characterView .shapeshifter-form-gear {
  color: #d8c58f;
  font-size: 13px;
  line-height: 1.45;
}
#characterView .shapeshifter-form-resource {
  flex: 0 0 auto;
  padding: 7px 10px;
  border: 1px solid #9d824a55;
  border-radius: 999px;
  background: #071b1480;
  white-space: nowrap;
}
#characterView .shapeshifter-form-gear { margin: 0 0 15px; }
#characterView .shapeshifter-forms-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}
#characterView .shapeshifter-form {
  min-width: 0;
  border: 1px solid #a58a4b4a;
  border-radius: 13px;
  overflow: hidden;
  background: #071a1488;
}
#characterView .shapeshifter-form > header {
  padding: 14px 15px 12px;
  border-bottom: 1px solid #a58a4b38;
  background: #ffffff03;
}
#characterView .shapeshifter-form > header h3 {
  margin: 0 0 4px;
  color: #ead39a;
  font: 700 21px/1.15 Georgia, serif;
}
#characterView .shapeshifter-form > header span {
  color: #aaa997;
  font-size: 12px;
}
#characterView .shapeshifter-form-stats {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  border-bottom: 1px solid #a58a4b38;
}
#characterView .shapeshifter-form-stats > div {
  min-width: 0;
  padding: 11px 5px 10px;
  text-align: center;
  border-right: 1px solid #a58a4b24;
}
#characterView .shapeshifter-form-stats > div:last-child { border-right: 0; }
#characterView .shapeshifter-form-stats small {
  display: block;
  margin-bottom: 3px;
  color: #9fa397;
  font-size: 9px;
  line-height: 1.2;
  text-transform: uppercase;
  letter-spacing: .055em;
}
#characterView .shapeshifter-form-stats strong {
  display: block;
  color: #f1e8d2;
  font-size: 17px;
  line-height: 1.2;
  overflow-wrap: anywhere;
}
#characterView .shapeshifter-form-abilities { padding: 5px 14px 10px; }
#characterView .shapeshifter-form-ability {
  padding: 11px 0;
  border-bottom: 1px solid #a58a4b24;
}
#characterView .shapeshifter-form-ability:last-child { border-bottom: 0; }
#characterView .shapeshifter-form-ability > div {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 4px;
}
#characterView .shapeshifter-form-ability b {
  color: #eee0ba;
  font-size: 15px;
}
#characterView .shapeshifter-form-ability span {
  color: #b69a5c;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .04em;
}
#characterView .shapeshifter-form-ability p {
  margin: 0;
  color: #cfd2c5;
  font-size: 13px;
  line-height: 1.55;
}

@media (min-width: 1200px) {
  #characterView #kpis.summary-kpis { grid-template-columns: repeat(7, minmax(0, 1fr)); }
  #characterView .summary-kpi { padding: 14px 10px; gap: 8px; }
}
@media (max-width: 1050px) {
  #statsGrid2 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  #skillsGrid2 { grid-template-rows: repeat(9, minmax(49px, auto)); column-gap: 22px; }
  #characterView #opened .ability-row2 { grid-template-columns: 54px minmax(0, 1fr); gap: 8px 12px; }
  #characterView #opened .ability-text2 { grid-column: 2; }
}
@media (max-width: 700px) {
  #characterView > .card { padding: 20px 16px; margin-bottom: 16px; border-radius: 13px; }
  #characterView #statsCard2 { padding: 22px 16px; }
  #characterView h2 { font-size: 25px; }
  #characterView > .card:first-child > .section-title { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  #characterView > .card:first-child > .section-title > .spacer { display: none; }
  #characterView #backToSquadBtn { grid-column: 1 / -1; grid-row: 1; justify-self: start; min-height: 36px; padding: 6px 10px; font-size: 13px; }
  #characterView #charTitle { grid-column: 1 / -1; grid-row: 2; font-size: 32px; }
  #characterView > .card:first-child > .section-title > button:not(#backToSquadBtn) { min-width: 0; padding: 10px 7px; font-size: 13px; }
  #characterView #charSubtitle { font-size: 14px; }
  #characterView #kpis.summary-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  #characterView .summary-kpi { padding: 12px 10px; gap: 10px; }
  #characterView .summary-kpi-value { font-size: 27px; }
  #characterView .summary-kpi-label { font-size: 12px; }
  #characterView .summary-attack-card { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  #characterView .summary-attack-weapon { grid-column: 1 / -1; padding: 13px 12px; }
  #characterView .summary-attack-name { font-size: 18px; }
  #characterView .summary-attack-metric { padding: 12px 4px; }
  #characterView .summary-attack-metric-value { font-size: 18px; }
  #statsCard2 .stats-head2 { margin-bottom: 18px; }
  #statsGrid2 { gap: 9px; margin-bottom: 22px; }
  #statsCard2 .stat-box2 .name { font-size: 13px; }
  #statsCard2 .stat-main2 { min-height: 77px; gap: 10px; }
  #statsCard2 .stat-main2 strong { font-size: 39px; }
  #statsCard2 .stat-icon2 { width: 38px; height: 38px; flex-basis: 38px; }
  #statsCard2 .stat-icon2 img { width: 38px; height: 38px; }
  #statsCard2 .skills-head2 { padding-top: 20px; margin-bottom: 12px; }
  #statsCard2 .skills-heading2 h3 { font-size: 23px; }
  #statsCard2 .stats-legend2 { font-size: 12px; }
  #characterView .shapeshifter-forms-head { flex-direction: column; gap: 10px; }
  #characterView .shapeshifter-form-resource { white-space: normal; }
  #characterView .shapeshifter-forms-grid { grid-template-columns: minmax(0, 1fr); }
  #characterView .shapeshifter-form-stats { grid-template-columns: repeat(5, minmax(0, 1fr)); }
  #characterView .shapeshifter-form > header h3 { font-size: 20px; }
  #characterView .shapeshifter-form-ability p { font-size: 14px; }
  #characterView #raceAbilities2 { grid-template-columns: minmax(0, 1fr); }
  #characterView #opened .ability-row2 { padding: 16px 0; }
  #characterView #opened .ability-name2 { font-size: 18px; }
  #characterView #opened .ability-text2 { grid-column: 1 / -1; font-size: 15px; }
}
@media (max-width: 620px) {
  #skillsGrid2 { grid-template-rows: none; grid-auto-flow: row; grid-template-columns: minmax(0, 1fr); }
  #statsCard2 .skill-row2 { min-height: 51px; padding: 11px 9px; grid-template-columns: 22px minmax(0, 1fr) 30px 38px; gap: 10px; }
  #statsCard2 .skill-name2 { font-size: 16px; }
}
@media (max-width: 480px) {
  #statsGrid2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  #statsCard2 .stats-head2 { align-items: flex-start; flex-direction: column; }
  #statsCard2 .stat-box2 .name { font-size: 14px; }
  #statsCard2 .stat-save2 { gap: 6px; }
}
@media (prefers-reduced-motion: reduce) {
  #characterView *, #charDialog * { scroll-behavior: auto; transition: none !important; }
}
