.ms-match-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
}
#app .ms-match-list .ms-match {
  min-width: 0;
  display: grid;
  align-content: start;
  gap: 8px;
  text-align: left;
  color: white;
  background:
    linear-gradient(var(--match-light-angle), var(--match-shade), var(--match-tint)),
    var(--match-texture) var(--match-crop) / var(--match-scale) no-repeat #102032;
  border: 1px solid #b8d4ed80;
  box-shadow: inset 0 2px 1px #ffffff55, 0 6px 16px -12px #14365c99;
}
/* A different fold catches the light on each card; colour still carries the result. */
.ms-match-list > .ms-match:nth-child(3n + 1) { --match-texture: url("/textures/tidal-silver.webp?v=c1cde224a2e4b9cfa97cd3ab"); --match-crop: 10% 70%; --match-scale: 145% auto; --match-light-angle: 112deg; }
.ms-match-list > .ms-match:nth-child(3n + 2) { --match-texture: url("/textures/satin-wave.webp?v=8a9b612b5bcf5adc6ff9b9c6"); --match-crop: 88% 22%; --match-scale: 164% auto; --match-light-angle: 73deg; }
.ms-match-list > .ms-match:nth-child(3n) { --match-texture: url("/textures/smoked-pearl.webp?v=faa887906e7a72511d285861"); --match-crop: 52% 96%; --match-scale: 130% auto; --match-light-angle: 138deg; }
#app .ms-match-neutral { --match-shade: #182536e0; --match-tint: #303f50ac; }
#app .ms-match-upcoming { --match-shade: #123468e5; --match-tint: #245faec9; --match-accent: #9ccfff; }
#app .ms-match-win { --match-shade: #074135e5; --match-tint: #147b50c9; --match-accent: #a2edbd; }
#app .ms-match-loss { --match-shade: #511b2be5; --match-tint: #9b3546c9; --match-accent: #ffb3bf; }
.ms-match-top, .ms-match-heading, .ms-match-sets { display: flex; align-items: center; gap: 8px; }
.ms-match-top, .ms-match-heading { justify-content: space-between; }
.ms-match-top { flex-wrap: wrap; font-size: 14px; font-weight: 700; }
.ms-match-heading { font: 700 26px/1.1 "Fira Sans Extra Condensed", sans-serif; text-transform: uppercase; }
.ms-match-top > :first-child { display: inline-flex; align-items: center; gap: 6px; }
.ms-match-top > :first-child::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--match-accent, #bdcadd); }
.ms-match-heading strong { min-width: 0; overflow-wrap: anywhere; }
.ms-match-heading b { font-size: 34px; white-space: nowrap; }
.ms-match time, .ms-match-sets { font-variant-numeric: tabular-nums; }
.ms-match-sets { flex-wrap: wrap; }
.ms-match-sets span:not(:first-child) { padding: 3px 7px; background: #ffffff20; border-radius: 7px; font-weight: 650; }
.ms-match small { color: #e6edf4; line-height: 1.4; }
.ms-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 16px;
  margin-bottom: 20px;
}
.ms-header > div {
  flex: 1;
  min-width: 200px;
}
.ms-header h2 {
  margin: 0;
}
.ms-header p {
  margin: 8px 0 0;
  font-size: 14px;
}
.ms-header > small {
  width: 100%;
  color: var(--muted);
  font-size: 12px;
}
.ms-editor {
  display: grid;
  gap: 20px;
}
.ms-editor h2 {
  margin-top: 0;
}
.ms-roster {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 2px 18px;
  max-height: 340px;
  overflow: auto;
}
.ms-table-scroll {
  overflow: auto;
  max-width: 100%;
  overscroll-behavior-x: contain;
  border: 1px solid var(--line);
  border-radius: 14px;
}
.ms-table-scroll table {
  border-collapse: separate;
  border-spacing: 0;
  width: 100%;
  font-size: 13px;
  text-align: center;
}
.ms-table-scroll th,
.ms-table-scroll td {
  padding: 12px 8px;
  border-bottom: 1px solid var(--line);
  border-right: 1px solid var(--line);
  min-width: 82px;
}
.ms-table-scroll thead th {
  background: #e9f0ff;
  vertical-align: middle;
  font-weight: 600;
}
.ms-table-scroll tbody th {
  position: sticky;
  left: 0;
  z-index: 1;
  min-width: 170px;
  max-width: 200px;
  text-align: left;
  background: #fff;
  box-shadow: 2px 0 5px #102d4907;
}
.ms-table-scroll tbody th small {
  display: block;
  font-weight: 400;
  margin-top: 6px;
  color: var(--muted);
}
.ms-input-table input {
  width: 68px;
  min-width: 0;
  min-height: 44px;
  padding: 8px;
  text-align: center;
  font-size: 16px;
}
.ms-roster-table td {
  min-width: 75px;
}
.ms-roster-table input {
  vertical-align: middle;
}
.ms-set-tabs {
  margin: 18px 0;
  overflow: auto;
  display: flex;
}
.ms-set-tabs button {
  white-space: nowrap;
  flex: none;
}
.ms-save {
  background: #ffffffed;
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  padding: 14px;
  border-radius: 18px;
  box-shadow: 0 5px 30px #0a1a3f14;
}
.ms-save button {
  min-width: 140px;
}
.ms-error {
  color: var(--red);
  font-size: 14px;
}
.ms-error:empty {
  display: none;
}
.ms-formulas {
  padding: 18px;
  margin-top: 18px;
  border: 1px solid var(--line);
  border-radius: 16px;
  font-size: 13px;
  background: white;
  line-height: 1.6;
}
.ms-formulas summary {
  cursor: pointer;
  font-weight: 600;
}
.ms-total {
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
  margin: 16px 0 24px;
}
.ms-total > div {
  flex: 1;
  min-width: 100px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.ms-total strong {
  font:
    700 34px "Fira Sans Extra Condensed",
    sans-serif;
}
.ms-total span {
  font-size: 12px;
  color: var(--muted);
}
.ms-mobile {
  display: none;
}
.ms-player-entry,
.ms-player-report {
  border: 1px solid var(--line);
  border-radius: 16px;
  margin-top: 12px;
  background: white;
}
.ms-player-entry summary,
.ms-player-report summary {
  padding: 16px;
  cursor: pointer;
  font-weight: 600;
  font-size: 14px;
}
.ms-player-entry summary::marker,
.ms-player-report summary::marker {
  color: var(--blue);
}
.ms-player-entry h3 {
  padding: 0 16px;
  font-size: 19px;
  margin: 14px 0 10px;
}
.ms-input-grid {
  padding: 0 16px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
.ms-input-grid label {
  font-size: 11px;
  line-height: 1.4;
}
.ms-input-grid input {
  width: 100%;
  margin-top: 6px;
  font-size: 18px !important;
  min-height: 48px;
}
.ms-player-live {
  font-size: 12px;
  padding: 0 16px 14px;
  color: var(--blue);
}
.ms-player-report dl {
  padding: 0 16px 12px;
  margin: 0;
}
.ms-player-report dl > div {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  padding: 10px 0;
  border-top: 1px solid var(--line);
  font-size: 13px;
}
.ms-player-report dt {
  color: var(--muted);
}
.ms-player-report dd {
  margin: 0;
  font-weight: 600;
  white-space: nowrap;
}
.ms-player-report summary strong {
  float: right;
  color: var(--blue);
}
@media (max-width: 767px) {
  .ms-desktop {
    display: none;
  }
  .ms-mobile {
    display: block;
  }
  .ms-match-list {
    grid-template-columns: 1fr;
  }
  .ms-header > button {
    width: 100%;
  }
  .ms-header h2 {
    font-size: 27px;
  }
  .ms-editor > .card {
    padding: 16px;
  }
  .ms-roster {
    display: block;
  }
  .ms-roster .check-row {
    font-size: 13px;
  }
  .ms-roster-table tbody th {
    min-width: 130px;
    max-width: 150px;
    font-size: 12px;
  }
  .ms-save {
    padding: 10px;
    gap: 8px;
  }
  .ms-save button {
    min-width: 0;
    flex: 1;
    font-size: 13px;
    padding: 10px;
  }
  .ms-total {
    gap: 8px;
  }
  .ms-total strong {
    font-size: 30px;
  }
  .ms-total span {
    font-size: 11px;
  }
  .ms-total > div {
    min-width: 85px;
  }
  .ms-formulas {
    padding: 14px;
    font-size: 12px;
  }
  .ms-set-tabs button {
    font-size: 12px;
    padding: 8px 12px;
  }
}
.ms-player-live {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 16px 0;
}
.ms-player-live span {
  font-size: 12px;
}
.ms-player-live output,
.ms-input-table output {
  font-weight: 700;
  color: var(--blue);
}
.ms-scroll-control {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 4px 0;
  clear: both;
}
.ms-scroll-control[hidden] {
  display: none !important;
}
.ms-scroll-control > span {
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
  white-space: nowrap;
}
.ms-scroll-control input[type="range"] {
  flex: 1;
  min-width: 80px;
  width: 100%;
  height: 28px;
  margin: 0;
  accent-color: var(--blue);
  cursor: ew-resize;
}
.ms-table-scroll {
  scrollbar-width: auto;
  scrollbar-color: #8daaff #e9f0ff;
}
.ms-table-scroll::-webkit-scrollbar {
  height: 12px;
  display: block;
}
.ms-table-scroll::-webkit-scrollbar-track {
  background: #e9f0ff;
  border-radius: 10px;
}
.ms-table-scroll::-webkit-scrollbar-thumb {
  background: #8daaff;
  border: 3px solid #e9f0ff;
  border-radius: 10px;
}
.ms-input-table th,
.ms-input-table td {
  min-width: 74px;
  padding: 9px 6px;
}
.ms-input-table input {
  width: 60px;
  min-height: 42px;
}
.ms-table-scroll .ms-input-table tbody th {
  min-width: 145px;
  max-width: 170px;
}
@media (max-width: 767px) {
  .ms-scroll-control.ms-desktop {
    display: none;
  }
  .ms-scroll-control {
    flex-wrap: wrap;
    gap: 4px;
  }
  .ms-scroll-control input[type="range"] {
    flex-basis: 100%;
  }
}
/* Analytics surfaces share the application's palette and typography. */
#match-statistics-workspace,
[data-ms-dashboard-content] {
  display: grid;
  gap: 18px;
  min-width: 0;
}
.ms-nav,
.ms-category-tabs,
.ms-header-actions,
.ms-entry-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.ms-nav {
  position: sticky;
  top: 0;
  background: var(--bg, #f3f6fb);
  border-radius: 20px;
  padding: 8px;
  z-index: 3;
}
.ms-nav button,
.ms-category-tabs button {
  min-height: 42px;
  font-size: 13px;
}
.ms-filter-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-top: 14px;
}
.ms-filter-grid label {
  display: grid;
  gap: 6px;
  font-size: 13px;
  min-width: 0;
}
.ms-filter-grid input,
.ms-filter-grid select {
  width: 100%;
  min-width: 0;
}
.ms-cards {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin: 18px 0;
}
.ms-kpi {
  background: var(--pale, #edf2ff);
  padding: 16px;
  border-radius: 18px;
  display: grid;
  gap: 8px;
  min-width: 0;
}
.ms-kpi > span {
  font-size: 13px;
  color: var(--muted, #6c7a93);
}
.ms-kpi > strong {
  font-size: 30px;
  color: var(--ink, #102047);
  line-height: 1.1;
}
.ms-kpi > small {
  font-size: 11px;
  line-height: 1.5;
  color: var(--muted, #6c7a93);
}
.ms-player-heading {
  display: flex;
  align-items: center;
  gap: 16px;
  margin: 22px 0;
}
.ms-player-heading .avatar {
  width: 76px;
  height: 76px;
  flex: none;
  border-radius: 50%;
  overflow: hidden;
}
.ms-player-heading img {
  width: 76px;
  height: 76px;
  border-radius: 50%;
  object-fit: cover;
}
.ms-player-heading h2 {
  margin: 0;
}
.ms-player-heading p {
  margin: 6px 0;
}
[data-ms-pdf-player] {
  margin-bottom: 14px;
}
.ms-coverage {
  display: grid;
  gap: 8px;
  padding: 16px;
  background: var(--pale, #eef3ff);
  border-radius: 16px;
  font-size: 13px;
}
.ms-coverage progress {
  width: 100%;
  height: 8px;
  accent-color: var(--blue, #2456ff);
}
.ms-coverage-list {
  display: grid;
  gap: 10px;
  margin: 16px 0;
}
.ms-coverage-list > div {
  display: grid;
  grid-template-columns: 1fr 2fr;
  gap: 4px;
  padding-bottom: 10px;
  border-bottom: 1px solid #e7edf6;
}
.ms-coverage-list small {
  grid-column: 2;
  color: var(--muted);
}
.ms-metric-list {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 22px;
}
.ms-metric-list > div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid #e7edf6;
  padding: 12px 0;
  font-size: 13px;
}
.ms-metric-list strong {
  white-space: nowrap;
}
.ms-status {
  font-size: 11px;
  display: inline-block;
  border-radius: 20px;
  padding: 6px 10px;
  background: #edf1f8;
  color: #53627a;
}
.ms-status-filled,
.ms-status-complete {
  background: #e5f6ed;
  color: #19784c;
}
.ms-status-partially_filled,
.ms-status-partial,
.ms-status-draft,
.ms-status-legacy {
  background: #fff1d7;
  color: #8a5b08;
}
.ms-status-not_applicable {
  background: #f1f0f6;
  color: #756e83;
}
.ms-history {
  display: flex;
  width: 100%;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 15px 0;
  text-align: left;
  border-bottom: 1px solid #e7edf6;
}
.ms-history small {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  font-size: 12px;
}
.ms-history span {
  min-width: 0;
}
.ms-history > strong {
  white-space: nowrap;
}
.ms-compare-row {
  display: grid;
  grid-template-columns: 1.1fr 1fr 1fr;
  gap: 12px;
  border-bottom: 1px solid #e7edf6;
  padding: 12px 0;
  font-size: 13px;
}
.ms-compare-row small {
  display: block;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.4;
  margin-top: 4px;
}
.ms-award {
  padding: 12px 0;
  border-bottom: 1px solid #e7edf6;
}
.ms-award h3 {
  font-size: 18px;
}
.ms-award p {
  font-size: 13px;
}
.ms-stepper {
  display: flex;
  align-items: center;
  gap: 4px;
}
.ms-stepper input {
  width: 76px;
  min-width: 0;
  text-align: center;
  padding: 10px 4px;
}
.ms-stepper button {
  width: 32px;
  min-width: 32px;
  min-height: 38px;
  padding: 0;
}
.ms-stepper input::placeholder {
  font-size: 10px;
}
.ms-player-entry select {
  margin: 10px 0;
}
.ms-category-tabs {
  margin: 14px 0;
}
.ms-entry-actions {
  margin-top: 16px;
}
.ms-entry-actions button {
  font-size: 12px;
}
.ms-save-status {
  font-size: 12px;
  color: var(--muted);
}
.ms-save {
  flex-wrap: wrap;
}
.ms-data-entry .ms-input-table {
  min-width: 920px;
}
.ms-data-entry .ms-input-table td {
  min-width: 170px;
}
.ms-data-entry .ms-input-table td select {
  min-width: 140px;
}
.ms-data-entry .ms-input-table th {
  min-width: 150px;
}
.ms-roster-table input {
  width: 20px;
  height: 20px;
}
.ms-formulas p {
  font-size: 13px;
  line-height: 1.7;
}
@media (max-width: 767px) {
  .ms-filter-grid {
    grid-template-columns: 1fr 1fr;
    gap: 10px;
  }
  .ms-filters {
    padding: 16px;
  }
  .ms-nav {
    flex-wrap: nowrap;
    overflow-x: auto;
    padding: 8px;
    position: relative;
  }
  .ms-nav button {
    flex: none;
    font-size: 12px;
    padding: 10px 13px;
  }
  .ms-cards {
    grid-template-columns: 1fr 1fr;
    gap: 9px;
  }
  .ms-kpi {
    padding: 13px;
    border-radius: 14px;
  }
  .ms-kpi > strong {
    font-size: 27px;
  }
  .ms-player-heading {
    align-items: flex-start;
  }
  .ms-player-heading h2 {
    font-size: 25px;
  }
  .ms-metric-list {
    grid-template-columns: 1fr;
  }
  .ms-coverage-list > div {
    grid-template-columns: 1fr;
  }
  .ms-coverage-list small {
    grid-column: 1;
  }
  .ms-coverage-list strong {
    font-size: 12px;
  }
  .ms-history {
    font-size: 13px;
  }
  .ms-compare-row {
    gap: 8px;
    font-size: 12px;
  }
  .ms-input-grid {
    grid-template-columns: 1fr !important;
  }
  .ms-input-grid label {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    font-size: 13px;
  }
  .ms-stepper button {
    width: 42px;
    min-width: 42px;
    min-height: 46px;
  }
  .ms-stepper input {
    width: 66px;
    min-height: 46px;
  }
  .ms-stepper {
    flex: none;
  }
  .ms-save {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }
  .ms-save [type="submit"] {
    grid-column: 1/-1;
  }
  .ms-header-actions {
    display: grid;
    grid-template-columns: 1fr;
    width: 100%;
  }
  .ms-player-report summary {
    gap: 10px;
  }
  .ms-player-report summary strong {
    white-space: nowrap;
  }
  .ms-coverage {
    font-size: 12px;
  }
}

.ms-date-range {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 180px), 1fr));
  gap: 12px;
}
.ms-filters summary,
.ms-chart-filters summary {
  overflow-wrap: anywhere;
}
.ms-chart-filters form {
  margin-top: 14px;
}
.ms-summary-category {
  display: grid;
  gap: 6px;
}
.ms-filter-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-block: 12px;
}
.ms-filter-error {
  margin: 8px 0;
  color: var(--danger, #ad243e);
}
.ms-filter-error:empty {
  display: none;
}
.ms-metric-groups {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr));
  align-items: start;
  gap: 8px;
}
.ms-metric-groups details {
  min-width: 0;
  padding: 10px 12px;
  border-radius: 12px;
  background: var(--pale, #edf2ff);
}
.ms-metric-groups summary span {
  font-size: 12px;
  font-weight: normal;
}
.ms-metric-groups .check-row {
  gap: 8px;
  min-height: 36px;
  margin: 2px 0;
}
.ms-metric-groups input {
  flex-shrink: 0;
}
.ms-metric-groups input:indeterminate {
  border-color: #1686e8;
  background: #1686e8;
}
.ms-metric-groups input:indeterminate::after {
  content: "";
  width: 9px;
  border-bottom: 2px solid #fff;
}

.ms-filter-menu > summary {
  overflow-wrap: anywhere;
}
.ms-filter-menu > summary small {
  margin-inline-start: 8px;
  font-weight: normal;
}
.ms-filter-menu > details {
  padding: 12px 0 0;
  margin-top: 12px;
  border-top: 1px solid #d9e6ef;
}

.ms-opponent-grid {
  padding: 0;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 140px), 1fr));
}
#ms-editor .ms-opponent-grid .ms-stepper :is(button, input) {
  height: 44px;
  min-height: 44px;
  margin: 0;
  padding-block: 0;
}
#ms-editor .ms-opponent-grid .ms-stepper button {
  width: 44px;
  min-width: 44px;
}
.ms-opponent-grid .ms-stepper input { width: 58px; }
#ms-editor .ms-stepper input.ms-counter-linked {
  color: #124b80;
  background: #d7edff;
  border-color: #397ac2;
  box-shadow: 0 0 0 2px #397ac234;
  transition: none;
}
.ms-visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}
@media (min-width: 768px) {
  .ms-category-tabs.ms-mobile { display: none; }
  .ms-entry-modes,
  .ms-rally-navigation {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
  }
  .ms-entry-modes { margin: 12px 0; }
  #ms-editor .ms-entry-modes button { min-height: 44px; padding-block: 8px; }
  .ms-rally-controls {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 180px), 1fr));
    align-items: end;
    gap: 12px;
    margin: 12px 0 16px;
  }
  .ms-rally-controls > label {
    display: grid;
    grid-template-rows: auto 44px;
    gap: 6px;
    margin: 0;
  }
  #ms-editor .ms-rally-controls .field-select,
  #ms-editor .ms-rally-controls .ms-stepper :is(button, input),
  #ms-editor .ms-rally-navigation button {
    height: 44px;
    min-height: 44px;
    margin: 0;
    padding-block: 0;
  }
  .ms-rally-opponent .ms-stepper input { width: 56px; }
  .ms-rally-navigation { justify-content: flex-end; height: 44px; }
  .ms-rally-navigation button { min-width: 40px; padding-inline: 10px; }
  .ms-rally-navigation span { min-width: 46px; text-align: center; font-size: 13px; }
  .ms-rally-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 246px), 1fr));
    gap: 12px;
  }
  .ms-rally-group {
    display: grid;
    grid-template-rows: 1fr auto;
    gap: 8px;
    min-width: 0;
    margin: 0;
    padding: 8px 12px 12px;
    border: 1px solid #cedef0;
    border-radius: 15px;
    background: #f7fbff;
  }
  .ms-rally-group legend {
    padding: 0 5px;
    font-weight: 700;
  }
  #ms-editor .ms-rally-group > .custom-select .field-select {
    height: 42px;
    min-height: 42px;
    padding-block: 0;
  }
  .ms-rally-fields {
    display: grid;
    align-content: start;
    gap: 6px;
  }
  .ms-rally-fields label {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 6px;
    min-height: 40px;
    margin: 0;
    font-size: 12px;
  }
  #ms-editor .ms-rally-fields .ms-stepper :is(button, input) {
    height: 40px;
    min-height: 40px;
    padding-block: 0;
  }
  .ms-rally-fields .ms-stepper input { width: 46px; }
  .ms-rally-editor .ms-player-live { padding: 12px 0 0; }
}

@media (min-width: 768px) {
  .ms-matrix-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 8px 16px;
    margin: 10px 0 12px;
  }
  .ms-matrix-bar .hint { flex: 1 1 440px; margin: 0; }
  .ms-matrix-bar label { margin: 0; }
  .ms-matrix-bar input { width: 56px; }
  .ms-matrix-table {
    width: 100%;
    min-width: 820px;
    table-layout: auto;
  }
  .ms-matrix-table th:first-child { min-width: 118px; width: 130px; }
  .ms-matrix-table th,
  .ms-matrix-table td {
    padding: 6px;
    border-color: #344d7512;
  }
  .ms-matrix-table thead th {
    background: #eaf1fa;
    color: #34445a;
  }
  .ms-matrix-table td { min-width: 92px; vertical-align: top; }
  .ms-matrix-table tbody th {
    position: sticky;
    inset-inline-start: 0;
    z-index: 1;
    background: #f3f7fc;
    overflow-wrap: anywhere;
  }
  .ms-matrix-cell {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 5px;
  }
  #ms-editor .ms-matrix-action {
    --counter-top: #79a5f021;
    --counter-bottom: #6e9be23c;
    --counter-edge: #6189c426;
    --counter-ink: #203f67;
    display: grid;
    grid-template-rows: minmax(14px, auto) 18px;
    justify-items: center;
    align-content: center;
    gap: 2px;
    min-width: 0;
    min-height: 42px;
    padding: 4px;
    border: 1px solid var(--counter-edge);
    border-radius: 11px;
    background:
      linear-gradient(172deg, var(--counter-top), var(--counter-bottom));
    color: var(--counter-ink);
    box-shadow: inset 0 1px 0 #ffffff85;
    text-align: center;
    font-size: 11px;
    line-height: 1.15;
    overflow-wrap: anywhere;
  }
  #ms-editor .ms-matrix-action[data-tone="success"] {
    --counter-top: #58aaa521;
    --counter-bottom: #49989136;
    --counter-edge: #548f8726;
    --counter-ink: #24504d;
  }
  #ms-editor .ms-matrix-action[data-tone="error"] {
    --counter-top: #d18b9821;
    --counter-bottom: #bb748833;
    --counter-edge: #9d657c24;
    --counter-ink: #66374b;
  }
  #ms-editor .ms-matrix-action:is([data-ms-matrix-total], :only-child) { grid-column: 1 / -1; }
  #ms-editor .ms-matrix-action strong {
    color: inherit;
    font-size: 16px;
    font-weight: 700;
    line-height: 18px;
    font-variant-numeric: tabular-nums;
  }
  #ms-editor .ms-matrix-action:hover {
    border-color: var(--counter-ink);
    box-shadow: inset 0 1px 0 #ffffffb3;
  }
  #ms-editor .ms-matrix-action:focus-visible {
    outline: 2px solid #325d8d;
    outline-offset: 2px;
  }
  #ms-editor .ms-matrix-action.ms-counter-linked {
    box-shadow: inset 0 0 0 2px #527cba;
    transition: none;
  }
}

#ms-editor :is(.ms-stepper, .ms-matrix-action)[data-ms-counter-change] {
  position: relative;
}
#ms-editor :is(.ms-stepper, .ms-matrix-action)[data-ms-counter-change]::after {
  content: attr(data-ms-counter-change);
  position: absolute;
  inset: 2px 3px auto auto;
  z-index: 1;
  padding: 1px 3px;
  border-radius: 4px;
  background: #214ba1;
  color: #fff;
  font: 700 10px/1.2 sans-serif;
  pointer-events: none;
}
#ms-editor .ms-matrix-action[data-ms-counter-change]::after {
  inset-block-start: -5px;
}
#ms-editor .ms-stepper[data-ms-counter-change]::after {
  inset-inline-end: 50%;
  translate: 100%;
}
#ms-editor :is(.ms-stepper, .ms-matrix-action)[data-ms-counter-change="−1"]::after {
  background: #8d3446;
}
#ms-editor .ms-matrix-action[data-ms-counter-change="−1"] {
  box-shadow: inset 0 0 0 2px #a04859;
}
#ms-editor .ms-stepper[data-ms-counter-change="−1"] input.ms-counter-linked {
  background: #fae9ec;
  border-color: #a04859;
  box-shadow: 0 0 0 2px #a0485934;
}

@media (forced-colors: active) {
  #ms-editor .ms-matrix-action[data-tone] {
    background: ButtonFace;
    border-color: ButtonText;
    color: ButtonText;
    box-shadow: none;
  }
  #ms-editor .ms-matrix-action[data-ms-counter-change] {
    outline: 2px solid Highlight;
  }
}

.ms-entry-heading {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 8px 16px;
}
.ms-entry-heading h2 { margin: 0; }
@media (min-width: 768px) {
  .ms-matrix-table { min-width: 960px; }
  .ms-matrix-table td:nth-child(6) { min-width: 156px; }
  body:has(.ms-entry-wide) { overflow: hidden; }
  body:has(.ms-entry-wide) #toast { z-index: 9001; bottom: 20px; }
  #app #ms-editor .ms-entry-wide {
    position: fixed;
    inset: 0;
    z-index: 9000;
    overflow: auto;
    overscroll-behavior: contain;
    margin: 0;
    padding: 16px clamp(16px, 2vw, 38px);
    border-radius: 0;
    background: #f5f8fd;
  }
  .ms-entry-wide .ms-table-scroll { width: 100%; }
}
@media (min-width: 1920px) {
  .ms-entry-wide .ms-matrix-cell {
    grid-template-columns: none;
    grid-auto-flow: column;
    grid-auto-columns: minmax(0, 1fr);
  }
  #ms-editor .ms-entry-wide .ms-matrix-action:is([data-ms-matrix-total], :only-child) {
    grid-column: auto;
  }
}

/* A bounded table viewport keeps column headings visible in both editor sizes. */
.ms-data-entry .ms-table-scroll { max-height: 60vh; max-height: 60dvh; }
.ms-data-entry .ms-table-scroll thead th { position: sticky; top: 0; z-index: 3; }
.ms-data-entry .ms-table-scroll thead th:first-child { left: 0; z-index: 4; }
.ms-entry-wide .ms-entry-heading { position: sticky; top: -16px; z-index: 5; background: #f5f8fd; padding: 12px 0; }
.ms-entry-wide .ms-table-scroll { max-height: 55vh; max-height: 55dvh; }
.ms-action-history { margin-top: 20px; border-top: 1px solid var(--line); padding-top: 12px; }
.ms-action-history h3 { margin: 0 0 8px; }
.ms-action-history ol { margin: 0; padding-left: 24px; font-size: 13px; }
.ms-action-history li { padding: 4px 0; }

.ms-entry-heading .ms-set-tabs { margin: 0; flex: 1; }
.ms-entry-toolbar { align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.ms-entry-toolbar .ms-entry-modes { margin: 0; }
.ms-toolbar-opponent { display: flex; align-items: center; gap: 8px; margin: 0; }
.ms-toolbar-opponent input { width: 52px; }
.ms-input-help { position: relative; }
.ms-input-help summary, .ms-action-history summary { cursor: pointer; padding: 10px; font-size: 13px; }
.ms-input-help p { position: absolute; right: 0; top: 100%; z-index: 7; width: min(340px, 85vw); padding: 16px; background: #f5f8fd; border: 1px solid var(--line); border-radius: 12px; }
.ms-entry-footer { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; }
.ms-entry-footer .ms-action-history { margin: 0; padding: 0; border: 0; }
.ms-action-history [data-ms-history] { padding: 8px; }
@media (min-width: 768px) {
  .ms-entry-toolbar { display: flex; margin-block: 8px; }
  #app #ms-editor .ms-entry-wide { display: flex; flex-direction: column; height: 100dvh; padding: 8px 12px; overflow: hidden; gap: 6px; }
  .ms-entry-wide .ms-entry-heading { position: static; padding: 0; flex: 0 0 auto; gap: 8px; }
  .ms-entry-wide .ms-entry-heading h2 { font-size: 20px; }
  .ms-entry-wide .ms-entry-toolbar { margin: 0; flex: 0 0 auto; }
  #ms-editor .ms-entry-wide .ms-entry-modes button, #ms-editor .ms-entry-wide .ms-set-tabs button { min-height: 36px; padding: 6px 10px; }
  .ms-entry-wide > .hint { display: none; }
  .ms-entry-wide .ms-rally-matrix { display: flex; flex-direction: column; flex: 1 1 auto; min-height: 0; }
  .ms-entry-wide .ms-table-scroll { flex: 1 1 auto; min-height: 0; max-height: none; width: 100%; }
  .ms-entry-wide .ms-scroll-control { display: flex; flex: 0 0 auto; align-items: center; gap: 8px; padding: 0; margin: 0; }
  .ms-entry-wide .ms-rally-editor { min-height: 0; overflow: auto; flex: 1 1 auto; }
  .ms-entry-wide .ms-entry-footer { flex: 0 0 auto; position: relative; }
  .ms-entry-wide .ms-action-history[open] [data-ms-history] { position: absolute; bottom: 100%; right: 0; width: min(800px, 100%); max-height: min(240px, 40vh); overflow: auto; z-index: 6; background: #f5f8fd; border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 8px 24px #102d4920; }
  .ms-entry-wide .ms-matrix-table { min-width: 1280px; }
  .ms-entry-wide .ms-matrix-table th, .ms-entry-wide .ms-matrix-table td { padding: 3px; }
  .ms-entry-wide .ms-matrix-table th:first-child { width: 110px; min-width: 110px; max-width: 110px; }
  .ms-entry-wide .ms-matrix-table td { min-width: 0; }
  .ms-entry-wide .ms-matrix-table td:nth-child(6) { min-width: 250px; }
  .ms-entry-wide .ms-matrix-cell { grid-template-columns: none; grid-auto-flow: column; grid-auto-columns: minmax(max-content, 1fr); gap: 3px; }
  #ms-editor .ms-entry-wide .ms-matrix-action:is([data-ms-matrix-total], :only-child) { grid-column: auto; }
  #ms-editor .ms-entry-wide .ms-matrix-action { min-height: 42px; padding: 3px 2px; font-size: 10px; }
  #ms-editor .ms-entry-wide .ms-matrix-action span { white-space: nowrap; }
}
/* Use the available height for readable rows and generous click targets. */
@media (min-width: 768px) {
  .ms-entry-wide .ms-matrix-table { height: calc(100% - 4px); min-width: 1520px; }
  .ms-entry-wide .ms-matrix-table thead { height: 36px; }
  .ms-entry-wide .ms-matrix-table thead th { padding: 7px 8px; font-size: 13px; border-bottom: 2px solid #9aaec8; }
  .ms-entry-wide .ms-matrix-table th, .ms-entry-wide .ms-matrix-table td { border-right: 4px solid #748ba9; }
  .ms-entry-wide .ms-matrix-table th:last-child, .ms-entry-wide .ms-matrix-table td:last-child { border-right: 0; }
  .ms-entry-wide .ms-matrix-table tbody th, .ms-entry-wide .ms-matrix-table tbody td { height: 1px; padding: 2px 8px; vertical-align: middle; border-bottom: 1px solid #b8c7d9; }
  .ms-entry-wide .ms-matrix-table tbody tr:nth-child(even) > :is(th, td) { background-color: #eaf0f8; }
  .ms-entry-wide .ms-matrix-table tbody th { font-size: 14px; padding-inline: 10px; }
  .ms-entry-wide .ms-matrix-table th:first-child { min-width: 150px; width: 150px; max-width: 180px; }
  .ms-entry-wide .ms-matrix-cell { height: 100%; gap: 5px; }
  #ms-editor .ms-entry-wide .ms-matrix-action { height: 100%; min-height: 44px; grid-template-rows: auto auto; padding: 2px; font-size: clamp(12px, .8vw, 16px); gap: 3px; border-radius: 8px; }
  #ms-editor .ms-entry-wide .ms-matrix-action strong { font-size: clamp(18px, 1.2vw, 28px); line-height: 1.15; }
  .ms-entry-wide .ms-matrix-table tbody tr:hover > :is(th, td),
  .ms-entry-wide .ms-matrix-table tbody tr:focus-within > :is(th, td) { background-color: #dce9fa; }
  #ms-editor .ms-entry-wide .ms-matrix-action:hover { outline: 2px solid #6d87aa; outline-offset: -2px; }
}

@media (min-width: 768px) {
  .ms-entry-wide .ms-scroll-control { min-height: 32px; padding-inline: 8px; border: 1px solid #a5b7cd; border-radius: 8px; background: #eaf1fa; }
  #ms-editor .ms-entry-wide .ms-scroll-control input[type="range"] { min-height: 28px; height: 28px; padding: 0; }
  .ms-entry-wide .ms-matrix-table thead th { background: #dce6f3; color: #172c49; }
}

.ms-contribution-help {
  margin: 16px 0;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 0 16px;
}
.ms-contribution-help summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 44px;
  padding: 10px 0;
  cursor: pointer;
  list-style: none;
  font-weight: 600;
}
.ms-contribution-help summary::-webkit-details-marker { display: none; }
.ms-contribution-help summary::marker { content: ""; }
.ms-contribution-help summary::after { content: "+"; flex: none; }
.ms-contribution-help[open] > summary::after,
.ms-contribution-help details[open] > summary::after { content: "−"; }
.ms-contribution-help summary:focus-visible {
  outline: 2px solid currentColor;
  outline-offset: 3px;
  border-radius: 4px;
}
.ms-contribution-help summary:hover { text-decoration: underline; }
.ms-contribution-explanation {
  font-size: 14px;
  line-height: 1.65;
  overflow-wrap: anywhere;
  padding-bottom: 12px;
}
.ms-contribution-explanation h3 { margin: 22px 0 8px; }
.ms-contribution-explanation h4 { margin: 0 0 4px; }
.ms-contribution-explanation p { margin: 8px 0 14px; }
.ms-contribution-explanation ul { padding-inline-start: 22px; }
.ms-contribution-explanation li { margin: 8px 0; }
.ms-contribution-explanation details {
  border-block: 1px solid var(--line);
  margin: 16px 0;
}
.ms-contribution-roles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 240px), 1fr));
  gap: 16px;
}
.ms-contribution-roles > div { border-left: 2px solid var(--line); padding-left: 12px; }
