:root {
  --profit-page: #070913;
  --profit-panel: #10081e;
  --profit-panel-alt: #170c27;
  --profit-line: rgba(125, 85, 184, 0.34);
  --profit-cyan: #55f5e8;
  --profit-pink: #ff5ddd;
  --profit-purple: #9b72ff;
  --profit-green: #53f3a7;
  --profit-gold: #ffcc57;
  --profit-red: #ff7087;
  --profit-text: #f7f4ff;
  --profit-muted: #9ea7bd;
}

body[data-page="winning-strat-per-th"] { background: var(--profit-page); }

.profit-page { min-width: 0; padding: clamp(18px, 2.3vw, 34px); }

.profit-board {
  position: relative;
  overflow: hidden;
  border: 1px solid rgba(255, 93, 221, 0.44);
  border-radius: 20px;
  background:
    radial-gradient(circle at 83% 0%, rgba(85, 245, 232, 0.09), transparent 28%),
    linear-gradient(135deg, rgba(255, 93, 221, 0.07), transparent 25%),
    var(--profit-panel);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.38), inset 0 1px 0 rgba(255,255,255,0.04);
}

.profit-board::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--profit-pink), var(--profit-cyan), transparent);
}

.profit-board-header {
  display: flex;
  justify-content: space-between;
  gap: 22px;
  align-items: end;
  padding: 22px 24px 16px;
  border-bottom: 1px solid var(--profit-line);
}

.profit-overline {
  color: var(--profit-pink);
  font: 900 0.64rem/1.2 ui-monospace, SFMono-Regular, Consolas, monospace;
  letter-spacing: 0.17em;
}

.profit-board-header h1 {
  margin: 6px 0 2px;
  color: var(--profit-text);
  font-size: clamp(1.45rem, 2.4vw, 2.3rem);
  letter-spacing: -0.035em;
}

.profit-board-header p,
.leaderboard-caption p { margin: 0; color: var(--profit-muted); font-size: 0.78rem; line-height: 1.5; }

.profit-summary { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 7px; }
.profit-summary span {
  padding: 6px 9px;
  border: 1px solid rgba(255, 93, 221, 0.34);
  border-radius: 999px;
  background: rgba(7, 9, 19, 0.72);
  color: #cbd4e8;
  font-size: 0.68rem;
}
.profit-summary b { color: var(--profit-cyan); }

.profit-controls {
  display: grid;
  grid-template-columns: minmax(140px, 0.9fr) auto minmax(170px, 1fr) auto auto;
  gap: 9px;
  align-items: end;
  margin: 14px 20px;
  padding: 12px;
  border: 1px solid rgba(85, 245, 232, 0.18);
  border-radius: 13px;
  background: linear-gradient(110deg, rgba(18, 11, 33, 0.95), rgba(9, 22, 37, 0.94));
}

.profit-field { display: grid; gap: 5px; min-width: 0; }
.profit-field > span { color: var(--profit-muted); font: 800 0.6rem/1.2 ui-monospace, SFMono-Regular, Consolas, monospace; letter-spacing: 0.1em; text-transform: uppercase; }
.profit-field input,
.profit-field select {
  width: 100%;
  min-height: 40px;
  padding: 8px 11px;
  border: 1px solid #35405a;
  border-radius: 9px;
  outline: 0;
  background: #080e1a;
  color: var(--profit-text);
}
.profit-field input:focus,
.profit-field select:focus { border-color: var(--profit-cyan); box-shadow: 0 0 0 2px rgba(85, 245, 232, 0.14); }

.profit-button,
.profit-cycle-controls button {
  min-height: 40px;
  padding: 8px 12px;
  border: 1px solid #4b3566;
  border-radius: 9px;
  background: #17112a;
  color: var(--profit-text);
  font-weight: 850;
  cursor: pointer;
}
.profit-button:hover,
.profit-cycle-controls button:hover:not(:disabled) { border-color: var(--profit-cyan); }
.profit-button.primary { border-color: rgba(85, 245, 232, 0.45); background: linear-gradient(110deg, #11324b, #382059); }
.profit-button.profile { color: var(--profit-cyan); }
.profit-button:disabled,
.profit-cycle-controls button:disabled { cursor: not-allowed; opacity: 0.4; }

.profit-cycle-controls { display: flex; gap: 6px; align-items: stretch; }
.profit-cycle-controls button { min-width: 40px; padding-inline: 10px; }
.profit-cycle-controls > span {
  display: grid;
  min-width: 66px;
  place-content: center;
  border: 1px solid #35405a;
  border-radius: 9px;
  background: #080e1a;
  text-align: center;
}
.profit-cycle-controls small { color: var(--profit-muted); font: 700 0.52rem ui-monospace, monospace; letter-spacing: 0.1em; text-transform: uppercase; }
.profit-cycle-controls b { color: var(--profit-cyan); font: 900 0.88rem ui-monospace, monospace; }
.profit-cycle-controls .cycle-current { color: var(--profit-pink); }
.profile-status { grid-column: 1 / -1; min-height: 15px; margin: 0; color: var(--profit-green); font-size: 0.68rem; }
.profile-status.error { color: var(--profit-red); }

.leaderboard-caption {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 18px;
  padding: 4px 22px 10px;
}
.leaderboard-caption span { color: var(--profit-cyan); font: 900 0.58rem ui-monospace, monospace; letter-spacing: 0.14em; }
.leaderboard-caption h2 { margin: 4px 0 0; color: var(--profit-text); font-size: 1.15rem; }
.leaderboard-caption p { max-width: 650px; text-align: right; }

.profit-view-toolbar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  padding: 0 20px 10px;
}
.profit-view-toolbar > span {
  color: var(--profit-muted);
  font: 850 0.56rem/1 ui-monospace, monospace;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}
.profit-view-switcher {
  display: inline-flex;
  gap: 4px;
  padding: 4px;
  border: 1px solid rgba(85, 245, 232, 0.2);
  border-radius: 10px;
  background: rgba(5, 12, 24, 0.8);
}
.profit-view-switcher button {
  min-height: 32px;
  padding: 6px 11px;
  border: 1px solid transparent;
  border-radius: 7px;
  background: transparent;
  color: var(--profit-muted);
  font-size: 0.65rem;
  font-weight: 850;
  cursor: pointer;
}
.profit-view-switcher button:hover { color: var(--profit-text); }
.profit-view-switcher button[aria-pressed="true"] {
  border-color: rgba(85, 245, 232, 0.42);
  background: linear-gradient(110deg, rgba(85, 245, 232, 0.2), rgba(155, 114, 255, 0.32));
  color: var(--profit-text);
  box-shadow: 0 0 18px rgba(85, 245, 232, 0.12);
}
.profit-view-panel[hidden] { display: none !important; }

.profit-table-shell {
  margin: 0 20px;
  overflow-x: hidden;
  border: 1px solid rgba(255, 93, 221, 0.36);
  border-radius: 11px;
  scrollbar-color: auto;
}

.profit-table {
  width: 100%;
  min-width: 0;
  border-collapse: separate;
  border-spacing: 0;
  table-layout: fixed;
  color: var(--profit-text);
  font-variant-numeric: tabular-nums;
}

.profit-table th,
.profit-table td { min-width: 0; padding: 8px 6px; overflow-wrap: anywhere; border-right: 1px solid #31163f; border-bottom: 1px solid #31163f; text-align: left; vertical-align: middle; }
.profit-table tr > :last-child { border-right: 0; }
.profit-table tbody tr:last-child > * { border-bottom: 0; }
.profit-table thead th { background: #27113b; color: #dfe6f6; font: 900 0.57rem/1.25 ui-monospace, monospace; letter-spacing: 0.035em; }
.profit-table tbody td { height: 58px; background: #130a21; font-size: 0.68rem; }
.profit-table tbody tr:nth-child(even) td { background: var(--profit-panel-alt); }
.profit-table tbody tr:hover td { background: #201136; }
.profit-table tbody tr:first-child td { box-shadow: inset 0 2px var(--profit-green); }
.profit-table th:nth-child(1) { width: 4%; text-align: center; }
.profit-table th:nth-child(2) { width: 17%; }
.profit-table th:nth-child(3) { width: 8%; }
.profit-table th:nth-child(4) { width: 10%; }
.profit-table th:nth-child(5) { width: 7%; }
.profit-table th:nth-child(6) { width: 9%; }
.profit-table th:nth-child(7) { width: 9%; }
.profit-table th:nth-child(8) { width: 27%; }
.profit-table th:nth-child(9) { width: 9%; }
.profit-table td:nth-child(9) { white-space: nowrap; }

.profit-rank { display: grid; place-items: center; width: 26px; height: 26px; margin: auto; border-radius: 8px; background: #28143a; color: var(--profit-cyan); font: 900 0.65rem ui-monospace, monospace; }
.profit-user { display: grid; grid-template-columns: 28px minmax(0, 1fr); gap: 7px; align-items: center; min-width: 0; }
.profit-avatar { display: grid; place-items: center; width: 28px; height: 28px; border: 1px solid #663a82; border-radius: 8px; background: linear-gradient(135deg, #25334e, #3a1b4d); font-size: 0.58rem; font-weight: 900; }
.profit-user strong,
.profit-user small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.profit-user strong { font-size: 0.69rem; }
.profit-user small { margin-top: 3px; color: var(--profit-muted); font-size: 0.58rem; }
.profit-league { color: var(--profit-cyan); font: 850 0.65rem ui-monospace, monospace; }
.profit-number { font: 850 0.67rem ui-monospace, monospace; }
.profit-gross { color: var(--profit-cyan); }
.profit-cost { color: var(--profit-gold); }
.profit-net { color: var(--profit-green); font: 900 0.72rem ui-monospace, monospace; }
.profit-net.negative { color: var(--profit-red); }
.th-match { display: block; margin-top: 3px; color: var(--profit-muted); font-size: 0.54rem; }

.boost-pattern { display: flex; flex-wrap: wrap; gap: 4px; }
.boost-pill { display: inline-flex; align-items: center; gap: 4px; padding: 3px 6px; border: 1px solid #33415e; border-radius: 999px; background: #0a1220; color: #cbd7ed; font: 800 0.56rem ui-monospace, monospace; }
.boost-pill i { width: 6px; height: 6px; flex: 0 0 6px; border-radius: 50%; background: var(--boost-color, var(--profit-purple)); box-shadow: 0 0 8px var(--boost-color, var(--profit-purple)); }
.boost-empty { color: var(--profit-muted); font-size: 0.65rem; }

.strategy-boost-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  min-width: 0;
}
.strategy-boost-tag {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  min-height: 20px;
  padding: 2px 6px;
  border: 1px solid color-mix(in srgb, var(--ability-color, #9b72ff) 52%, transparent);
  border-radius: 999px;
  background: color-mix(in srgb, var(--ability-color, #9b72ff) 10%, #07101d);
  color: #dce7f7;
  white-space: nowrap;
  font: 800 0.51rem/1 "Segoe UI Emoji", "Apple Color Emoji", ui-monospace, monospace;
}
.strategy-boost-round {
  padding-right: 4px;
  border-right: 1px solid rgba(203, 215, 237, 0.22);
  color: var(--profit-pink);
  font: 900 0.47rem/1 ui-monospace, monospace;
}
.strategy-boost-tag b { color: var(--ability-color, var(--profit-cyan)); font-size: 0.5rem; }
.strategy-boost-tag small {
  padding-left: 4px;
  border-left: 1px solid rgba(203, 215, 237, 0.22);
  color: #dce7f7;
  font-size: 0.48rem;
}
.strategy-boost-more,
.strategy-boost-empty {
  align-self: center;
  color: var(--profit-muted);
  font: 750 0.52rem ui-monospace, monospace;
}
.strategy-boost-more {
  padding: 3px 6px;
  border: 1px solid #33415e;
  border-radius: 999px;
}

.profit-tier-board {
  display: grid;
  gap: 9px;
  margin: 0 20px;
  padding: 12px;
  border: 1px solid rgba(255, 93, 221, 0.34);
  border-radius: 12px;
  background: rgba(7, 9, 19, 0.62);
}
.profit-tier-lane {
  display: grid;
  grid-template-columns: 112px minmax(0, 1fr);
  gap: 9px;
  --tier-accent: var(--profit-green);
}
.profit-tier-lane.tone-strong { --tier-accent: var(--profit-cyan); }
.profit-tier-lane.tone-positive { --tier-accent: var(--profit-purple); }
.profit-tier-label {
  display: grid;
  place-content: center;
  gap: 7px;
  min-height: 92px;
  padding: 10px;
  border-left: 3px solid var(--tier-accent);
  background: #151a2a;
  text-align: center;
  text-transform: uppercase;
}
.profit-tier-label strong { color: var(--profit-text); font-size: 0.7rem; }
.profit-tier-label span { color: var(--profit-muted); font-size: 0.54rem; text-transform: none; }
.profit-tier-cards {
  display: grid;
  grid-template-columns: repeat(4, minmax(155px, 1fr));
  gap: 6px;
}
.profit-tier-card {
  min-width: 0;
  min-height: 92px;
  padding: 10px;
  border-bottom: 2px solid var(--tier-accent);
  background: #151a2a;
}
.profit-tier-card-heading {
  display: flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
}
.profit-tier-card-heading span { color: var(--profit-muted); font: 800 0.55rem ui-monospace, monospace; }
.profit-tier-card-heading strong {
  overflow: hidden;
  color: var(--profit-text);
  font-size: 0.65rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.profit-tier-net { display: block; margin: 5px 0 2px; color: var(--profit-green); font: 900 0.72rem ui-monospace, monospace; }
.profit-tier-net.negative { color: var(--profit-red); }
.profit-tier-meta { margin-bottom: 6px; color: var(--profit-muted); font-size: 0.5rem; }

.profit-bar-board {
  display: grid;
  gap: 7px;
  margin: 0 20px;
  padding: 12px;
  border: 1px solid rgba(255, 93, 221, 0.34);
  border-radius: 12px;
  background: rgba(7, 9, 19, 0.62);
}
.profit-bar-row {
  display: grid;
  grid-template-columns: minmax(190px, 250px) minmax(160px, 1fr) minmax(170px, 210px);
  gap: 12px;
  align-items: center;
  min-height: 74px;
  padding: 10px;
  border: 1px solid rgba(49, 22, 63, 0.5);
  border-radius: 8px;
  background: #0b0713;
}
.profit-bar-identity {
  display: grid;
  grid-template-columns: 28px 34px minmax(0, 1fr);
  gap: 7px;
  align-items: center;
  min-width: 0;
}
.profit-bar-rank {
  display: grid;
  width: 28px;
  height: 28px;
  place-items: center;
  border-radius: 8px;
  background: #28143a;
  color: var(--profit-cyan);
  font: 900 0.58rem ui-monospace, monospace;
}
.profit-bar-avatar {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border: 1px solid #663a82;
  border-radius: 9px;
  background: linear-gradient(135deg, #25334e, #3a1b4d);
  font-size: 0.58rem;
  font-weight: 900;
}
.profit-bar-identity strong,
.profit-bar-identity small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.profit-bar-identity strong { color: var(--profit-text); font-size: 0.68rem; }
.profit-bar-identity small { margin-top: 3px; color: var(--profit-muted); font-size: 0.52rem; }
.profit-bar-rail {
  position: relative;
  height: 32px;
  overflow: hidden;
  border-radius: 5px;
  background: #151224;
}
.profit-bar-rail::after {
  content: "";
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(90deg, transparent 0, transparent calc(25% - 1px), rgba(255,255,255,0.07) 25%);
  pointer-events: none;
}
.profit-bar-rail span {
  display: block;
  height: 100%;
  min-width: 7%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--profit-pink), #7c65f4 55%, var(--profit-green));
  box-shadow: 0 0 20px rgba(85, 245, 232, 0.16);
}
.profit-bar-row.negative .profit-bar-rail span { background: linear-gradient(90deg, #7d263e, var(--profit-red)); }
.profit-bar-result { min-width: 0; }
.profit-bar-result > b { display: block; color: var(--profit-green); font: 900 0.85rem ui-monospace, monospace; }
.profit-bar-row.negative .profit-bar-result > b { color: var(--profit-red); }
.profit-bar-result > small { display: block; margin: 2px 0 5px; color: var(--profit-muted); font-size: 0.52rem; }
.profit-alternative-empty {
  display: grid;
  min-height: 180px;
  place-items: center;
  color: var(--profit-muted);
  text-align: center;
}

.multiplier-boosts { display: grid; gap: 4px; }
.multiplier-boost-row {
  display: grid;
  grid-template-columns: 54px minmax(0, 1fr);
  gap: 4px;
  align-items: center;
  min-width: 0;
  padding: 3px 5px;
  border-left: 2px solid var(--boost-color, var(--profit-purple));
  border-radius: 4px;
  background: rgba(6, 12, 24, 0.56);
  color: #cbd7ed;
  font: 750 0.54rem/1.35 ui-monospace, monospace;
}
.multiplier-boost-row > b { color: var(--profit-pink); font-size: 0.53rem; }
.multiplier-boost-abilities { display: flex; flex-wrap: wrap; gap: 4px; min-width: 0; }
.multiplier-boost-ability {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  min-width: 0;
  padding: 2px 5px;
  border: 1px solid color-mix(in srgb, var(--ability-color, #9b72ff) 48%, transparent);
  border-radius: 999px;
  background: color-mix(in srgb, var(--ability-color, #9b72ff) 12%, #07101d);
  color: #dce7f7;
  white-space: nowrap;
}
.boost-ability-icon {
  display: inline-grid;
  place-items: center;
  width: 16px;
  min-width: 16px;
  height: 16px;
  font: 400 0.76rem/1 "Segoe UI Emoji", "Apple Color Emoji", sans-serif;
}
.boost-ability-label {
  max-width: 54px;
  overflow: hidden;
  color: #dce7f7;
  text-overflow: ellipsis;
}
.boost-ability-strength {
  color: var(--ability-color, var(--profit-cyan));
  font: 950 0.55rem ui-monospace, monospace;
}
.multiplier-boost-ability .boost-ability-count {
  padding-left: 4px;
  border-left: 1px solid rgba(203, 215, 237, 0.22);
  color: #dce7f7;
  font: 850 0.5rem ui-monospace, monospace;
}

.profit-status { margin: 12px 20px 0; padding: 10px 12px; border: 1px solid rgba(85, 245, 232, 0.18); border-radius: 9px; background: rgba(5, 12, 24, 0.78); color: var(--profit-cyan); font-size: 0.7rem; }
.profit-status.ready { color: var(--profit-green); }
.profit-status.warning { color: var(--profit-gold); }
.profit-status.error { color: var(--profit-red); border-color: rgba(255, 112, 135, 0.34); }
.profit-empty-row td { height: 180px !important; color: var(--profit-muted); text-align: center !important; }
.profit-notes { display: flex; flex-wrap: wrap; gap: 8px 18px; padding: 14px 22px 20px; color: var(--profit-muted); font-size: 0.62rem; }
.profit-notes span:first-child { color: var(--profit-cyan); }

@media (max-width: 1120px) {
  .profit-controls { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .profit-cycle-controls { grid-column: 1 / -1; }
  .profit-tier-cards { grid-template-columns: repeat(2, minmax(155px, 1fr)); }
  .profit-bar-row { grid-template-columns: minmax(180px, 220px) minmax(140px, 1fr) minmax(155px, 190px); }
}

@media (max-width: 960px) {
  .profit-table-shell { overflow-x: auto; }
  .profit-table { min-width: 960px; }
}

@media (max-width: 760px) {
  .profit-page { padding: 12px 9px 20px; }
  .profit-board { border-radius: 14px; }
  .profit-board-header,
  .leaderboard-caption { align-items: flex-start; flex-direction: column; }
  .profit-board-header { padding: 18px 14px 12px; }
  .profit-summary { justify-content: flex-start; }
  .profit-controls { grid-template-columns: 1fr 1fr; margin: 10px; padding: 10px; }
  .profit-field { grid-column: 1 / -1; }
  .profit-button { width: 100%; }
  .profit-cycle-controls { overflow-x: auto; }
  .leaderboard-caption { padding: 4px 12px 9px; }
  .leaderboard-caption p { text-align: left; }
  .profit-view-toolbar { align-items: flex-start; flex-direction: column; padding-inline: 10px; }
  .profit-view-switcher { display: grid; width: 100%; grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .profit-view-switcher button { padding-inline: 5px; }
  .profit-table-shell { margin-inline: 10px; }
  .profit-tier-board,
  .profit-bar-board { margin-inline: 10px; padding: 8px; }
  .profit-tier-lane { grid-template-columns: 1fr; }
  .profit-tier-label {
    grid-template-columns: auto auto;
    justify-content: space-between;
    min-height: 0;
    place-content: initial;
    padding: 9px 11px;
    text-align: left;
  }
  .profit-tier-cards { grid-template-columns: 1fr; }
  .profit-tier-card { min-height: 0; }
  .profit-bar-row { grid-template-columns: 1fr; gap: 8px; }
  .profit-bar-result { display: grid; grid-template-columns: auto auto; align-items: center; gap: 3px 10px; }
  .profit-bar-result .strategy-boost-tags { grid-column: 1 / -1; }
  .profit-status { margin-inline: 10px; }
  .profit-notes { padding-inline: 12px; }
}
