:root {
  color-scheme: light;
  --topbar-height: 92px;
  --nav-sticky-top: var(--topbar-height);
  --content-pad: clamp(16px, 1.45vw, 28px);
  --bg: #f4f7fb;
  --bg-start: #ffffff;
  --bg-end: #e8eef6;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --panel: #ffffff;
  --panel-2: #f1f5f9;
  --panel-3: #e7eef8;
  --control: rgba(15, 23, 42, 0.052);
  --control-hover: rgba(14, 116, 144, 0.1);
  --text: #142033;
  --muted: #5f6f84;
  --line: rgba(100, 116, 139, 0.24);
  --line-strong: rgba(51, 65, 85, 0.38);
  --shadow-panel: 0 12px 32px rgba(15, 23, 42, 0.12);
  --shadow-control: 0 8px 22px rgba(15, 23, 42, 0.12);
  --red: #ef4444;
  --blue: #3b82f6;
  --green: #20c997;
  --yellow: #f59e0b;
  --team-epa-color: #06728e;
  --team-qual-rank-color: #a14f00;
  --accent: #06728e;
  --accent-soft: rgba(6, 114, 142, 0.12);
  --focus-ring: 0 0 0 3px rgba(6, 114, 142, 0.18);
  --toast-bg: #ffffff;
  --toast-success-bg: #ecfdf5;
  --toast-error-bg: #fff1f2;
  --toast-busy-bg: #ecfeff;
  --topbar-bg: rgba(255, 255, 255, 0.92);
  --auth-bg: #eef4fb;
  --input-hover: #eef4fb;
}

body.theme-dark {
  color-scheme: dark;
  --bg: #080b10;
  --bg-start: #0b1017;
  --bg-end: #07090d;
  --surface: #101821;
  --surface-2: #0c1219;
  --panel: #141e29;
  --panel-2: #1b2836;
  --panel-3: #203143;
  --control: rgba(255, 255, 255, 0.055);
  --control-hover: rgba(255, 255, 255, 0.095);
  --text: #f2f6fb;
  --muted: #a6b3c2;
  --line: rgba(143, 166, 192, 0.24);
  --line-strong: rgba(196, 212, 230, 0.42);
  --shadow-panel: 0 14px 34px rgba(0, 0, 0, 0.24);
  --shadow-control: 0 9px 24px rgba(0, 0, 0, 0.24);
  --team-epa-color: #67e8f9;
  --team-qual-rank-color: #fbbf24;
  --accent: #38bdf8;
  --accent-soft: rgba(56, 189, 248, 0.14);
  --focus-ring: 0 0 0 3px rgba(56, 189, 248, 0.24);
  --toast-bg: #08111a;
  --toast-success-bg: #062019;
  --toast-error-bg: #240b0e;
  --toast-busy-bg: #071b29;
  --topbar-bg: rgba(10, 15, 22, 0.94);
  --auth-bg: #0b0f14;
  --input-hover: #0f1721;
}

* {
  box-sizing: border-box;
}

button,
[role="button"],
summary,
.alliance-card,
.match-phase-tab,
.counter-control,
.counter-control button,
.base-options,
.base-options button,
.graphic-scorer,
.graphic-field,
.graphic-score-button,
.graphic-phase-switch,
.graphic-phase-switch button {
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

button,
[role="button"],
.alliance-card,
.match-phase-tab,
.counter-control button,
.base-options button,
.graphic-score-button,
.graphic-phase-switch button {
  -webkit-user-select: none;
  user-select: none;
}

body {
  margin: 0;
  width: 100%;
  max-width: 100%;
  min-height: 100vh;
  overflow-x: hidden;
  background:
    linear-gradient(180deg, var(--bg-start) 0%, var(--bg) 34%, var(--bg-end) 100%);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body.auth-pending .topbar,
body.auth-pending .app-shell,
body.auth-pending .modal-backdrop {
  display: none;
}

body.authenticated .auth-screen {
  display: none;
}

.auth-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 22px;
  background: var(--auth-bg);
}

.auth-card {
  width: min(1240px, calc(100vw - 44px));
  display: grid;
  gap: 22px;
  padding: clamp(44px, 5vw, 72px) clamp(44px, 5vw, 72px) clamp(32px, 4vw, 52px);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.42);
}

.auth-brand {
  display: grid;
  grid-template-columns: minmax(120px, 1fr) auto minmax(120px, 1fr);
  align-items: center;
  gap: clamp(26px, 4.2vw, 72px);
  min-width: 0;
  margin-bottom: clamp(24px, 4vw, 48px);
}

.auth-brand .brand-text {
  justify-self: center;
  font-size: clamp(44px, 4.8vw, 68px);
  line-height: 1;
  white-space: nowrap;
}

.auth-scoutfish {
  justify-self: start;
  width: clamp(142px, 12.5vw, 190px);
  height: clamp(134px, 12vw, 180px);
  object-fit: contain;
}

.auth-brand .decode-lockup {
  --decode-wordmark-height: clamp(78px, 6vw, 96px);
  --decode-icon-height: clamp(176px, 15vw, 250px);
  display: inline-flex;
  justify-self: end;
  min-width: 0;
}

.auth-brand .decode-wordmark {
  display: none;
  width: clamp(250px, 23vw, 310px);
  height: var(--decode-wordmark-height);
  object-fit: cover;
  object-position: top center;
}

.auth-brand .decode-logo {
  width: auto;
  height: var(--decode-icon-height);
  object-fit: contain;
  object-position: center;
}

.auth-mode-tabs {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
}

.auth-mode {
  min-height: 42px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-weight: 900;
  cursor: pointer;
}

.auth-mode.active {
  background: var(--panel-2);
  color: var(--text);
}

.auth-card label {
  color: var(--text);
  font-size: 15px;
  font-weight: 800;
}

.auth-card input {
  min-height: 48px;
  font-size: 18px;
}

.auth-status {
  min-height: 22px;
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  font-weight: 800;
}

.auth-actions {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
}

body.auth-mode-login .auth-name-field {
  display: none;
}

body.auth-mode-register .auth-remember-field {
  display: none;
}

@media (max-width: 760px) {
  .auth-card {
    width: min(100%, calc(100vw - 28px));
    padding: 22px;
    gap: 18px;
  }

  .auth-brand {
    grid-template-columns: auto minmax(0, 1fr) auto;
    gap: 10px;
    margin-bottom: 4px;
  }

  .auth-brand .brand-text {
    font-size: clamp(22px, 5.6vw, 28px);
    text-align: center;
  }

  .auth-scoutfish {
    width: clamp(64px, 18vw, 82px);
    height: clamp(60px, 17vw, 78px);
  }

  .auth-brand .decode-lockup {
    --decode-wordmark-height: clamp(38px, 9vw, 50px);
    --decode-icon-height: clamp(64px, 17vw, 78px);
    gap: 5px;
  }

  .auth-brand .decode-wordmark {
    width: clamp(120px, 32vw, 176px);
    height: var(--decode-wordmark-height);
  }
}

/* Compact match rows use the same separated title/score/team structure. */
.match-archive-compact,
.match-workspace.editing .match-archive-compact,
.match-groups:has(.match-archive[open]) .match-archive-compact {
  min-height: 172px;
}

.match-archive-compact .match-archive-summary,
.match-workspace.editing .match-archive-compact .match-archive-summary,
.match-groups:has(.match-archive[open]) .match-archive-compact .match-archive-summary {
  display: grid !important;
  grid-template-columns: minmax(0, 1fr);
  grid-template-areas:
    "title"
    "score"
    "teams";
  align-items: center;
  justify-items: stretch;
  min-height: 170px;
  padding: 14px 18px;
  gap: 10px;
}

.match-archive-compact .match-summary-title,
.match-workspace.editing .match-archive-compact .match-summary-title,
.match-groups:has(.match-archive[open]) .match-archive-compact .match-summary-title {
  display: contents !important;
  position: static !important;
  min-height: 0;
}

.match-archive-compact .match-summary-title > strong,
.match-archive-compact .match-archive-summary strong,
.match-workspace.editing .match-archive-compact .match-summary-title > strong,
.match-workspace.editing .match-archive-compact .match-archive-summary strong,
.match-groups:has(.match-archive[open]) .match-archive-compact .match-summary-title > strong,
.match-groups:has(.match-archive[open]) .match-archive-compact .match-archive-summary strong {
  position: static !important;
  grid-area: title;
  justify-self: start;
  min-width: 0;
  max-width: 100%;
  font-size: 30px;
  line-height: 1.04;
  white-space: normal;
  overflow-wrap: anywhere;
}

.match-archive-compact .match-score-badge,
.match-workspace.editing .match-archive-compact .match-score-badge,
.match-groups:has(.match-archive[open]) .match-archive-compact .match-score-badge {
  position: static !important;
  grid-area: score !important;
  justify-self: center;
  width: min(100%, 620px) !important;
  max-width: 100% !important;
  margin: 0;
  transform: none !important;
}

.match-archive-compact .match-score-badge:not(.match-score-with-rp),
.match-workspace.editing .match-archive-compact .match-score-badge:not(.match-score-with-rp),
.match-groups:has(.match-archive[open]) .match-archive-compact .match-score-badge:not(.match-score-with-rp) {
  display: grid;
  grid-template-columns: max-content max-content;
  justify-content: center;
  gap: 16px;
  font-size: 30px;
}

.match-archive-compact .match-score-with-rp,
.match-workspace.editing .match-archive-compact .match-score-with-rp,
.match-groups:has(.match-archive[open]) .match-archive-compact .match-score-with-rp {
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  grid-template-areas:
    "redScore blueScore"
    "redRp blueRp";
  gap: 5px 12px;
}

.match-archive-compact .match-archive-right,
.match-workspace.editing .match-archive-compact .match-archive-right,
.match-groups:has(.match-archive[open]) .match-archive-compact .match-archive-right {
  display: contents;
}

.match-archive-compact .match-archive-teams,
.match-workspace.editing .match-archive-compact .match-archive-teams,
.match-groups:has(.match-archive[open]) .match-archive-compact .match-archive-teams {
  grid-area: teams;
  justify-self: center;
}

@media (max-width: 760px) {
  .match-archive-compact,
  .match-workspace.editing .match-archive-compact,
  .match-groups:has(.match-archive[open]) .match-archive-compact {
    min-height: 180px;
  }

  .match-archive-compact .match-archive-summary,
  .match-workspace.editing .match-archive-compact .match-archive-summary,
  .match-groups:has(.match-archive[open]) .match-archive-compact .match-archive-summary {
    min-height: 178px;
    padding: 14px 12px;
  }

  .match-archive-compact .match-summary-title > strong,
  .match-archive-compact .match-archive-summary strong,
  .match-workspace.editing .match-archive-compact .match-summary-title > strong,
  .match-workspace.editing .match-archive-compact .match-archive-summary strong,
  .match-groups:has(.match-archive[open]) .match-archive-compact .match-summary-title > strong,
  .match-groups:has(.match-archive[open]) .match-archive-compact .match-archive-summary strong {
    justify-self: center;
    font-size: 28px;
    text-align: center;
  }

  .match-archive-compact .match-score-badge:not(.match-score-with-rp),
  .match-workspace.editing .match-archive-compact .match-score-badge:not(.match-score-with-rp),
  .match-groups:has(.match-archive[open]) .match-archive-compact .match-score-badge:not(.match-score-with-rp) {
    gap: 10px;
    font-size: 27px;
  }
}

.save-toast {
  position: fixed;
  right: max(12px, env(safe-area-inset-right));
  bottom: max(12px, env(safe-area-inset-bottom));
  z-index: 5000;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  width: min(300px, calc(100vw - 24px));
  min-height: 38px;
  padding: 7px 11px;
  border: 1px solid var(--accent);
  border-radius: 999px;
  background: var(--toast-bg);
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.2);
  color: var(--text);
  opacity: 0.97;
  pointer-events: none;
  transform: translateY(0);
  animation: toast-in 140ms ease-out;
}

.save-toast[hidden] {
  display: none;
}

.save-toast strong {
  font-size: 12px;
  font-weight: 900;
  line-height: 1;
  white-space: nowrap;
}

.save-toast span {
  min-width: 0;
  overflow: hidden;
  font-size: 12px;
  font-weight: 800;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.save-toast.is-success {
  border-color: var(--green);
  background: var(--toast-success-bg);
}

.save-toast.is-error {
  border-color: var(--red);
  background: var(--toast-error-bg);
}

.save-toast.is-busy {
  border-color: var(--accent);
  background: var(--toast-busy-bg);
}

@media (max-width: 560px) {
  .save-toast {
    right: max(8px, env(safe-area-inset-right));
    bottom: max(8px, env(safe-area-inset-bottom));
    left: auto;
    width: min(260px, calc(100vw - 16px));
    min-height: 36px;
    padding: 7px 10px;
  }

  .save-toast strong,
  .save-toast span {
    font-size: 11px;
  }
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 0.97;
    transform: translateY(0);
  }
}

button,
input,
select,
textarea {
  font: inherit;
}

.topbar {
  --text: #f2f6fb;
  --muted: #a6b3c2;
  --line: rgba(143, 166, 192, 0.24);
  --line-strong: rgba(196, 212, 230, 0.42);
  --panel-2: #172231;
  --control: rgba(255, 255, 255, 0.055);
  --control-hover: rgba(255, 255, 255, 0.095);
  --accent: #38bdf8;
  --focus-ring: 0 0 0 3px rgba(56, 189, 248, 0.24);
  display: block;
  min-height: 58px;
  padding: 8px 18px;
  border-bottom: 1px solid var(--line);
  background: #0b1017;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.24);
  backdrop-filter: blur(18px);
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 40;
  transform: translateY(0);
  transition: transform 180ms ease;
  will-change: transform;
}

body.topbar-hidden {
  --nav-sticky-top: 0px;
}

body.topbar-hidden .topbar {
  pointer-events: none;
  transform: translateY(-100%);
}

.brand-block {
  flex: 1 1 auto;
  min-width: 0;
}

.brand-title {
  display: grid;
  grid-template-columns: max-content max-content minmax(280px, min(48vw, 820px)) minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px 12px;
  width: 100%;
  min-width: 0;
}

.brand-text {
  color: var(--text);
  font-size: clamp(18px, 1.65vw, 24px);
  font-weight: 900;
  line-height: 1;
  white-space: nowrap;
}

.brand-season {
  display: none;
  align-self: flex-end;
  color: var(--accent);
  font-size: 13px;
  font-weight: 800;
  line-height: 1;
  padding-bottom: 4px;
  text-transform: uppercase;
  white-space: nowrap;
}

.global-event-button {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  justify-content: flex-start;
  min-width: 0;
  width: 100%;
  min-height: 40px;
  max-width: 820px;
  padding: 6px 14px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--control);
  color: var(--text);
  cursor: pointer;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
  transition: background 160ms ease, border-color 160ms ease, box-shadow 160ms ease;
}

.global-event-button span {
  color: var(--accent);
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
  white-space: nowrap;
}

.global-event-button strong {
  min-width: 0;
  overflow: hidden;
  color: var(--text);
  font-size: clamp(14px, 1.06vw, 18px);
  font-weight: 900;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.global-event-button:hover {
  border-color: rgba(226, 232, 240, 0.68);
  background: var(--control-hover);
  box-shadow: var(--focus-ring);
}

.global-cloud-status {
  grid-column: 4;
  min-width: 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  line-height: 1.2;
  text-align: right;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.global-account {
  grid-column: 5;
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  min-width: 0;
}

.global-refresh {
  flex: 0 0 auto;
  min-height: 40px;
  padding-inline: 12px;
  background: #172231;
  color: var(--text);
}

.global-account-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  flex: 1 1 auto;
  min-width: 0;
  min-height: 40px;
  width: 74px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #172231;
  color: var(--text);
  cursor: pointer;
  transition: background 160ms ease, border-color 160ms ease;
}

.global-account-button:hover {
  border-color: var(--line-strong);
  background: var(--control-hover);
}

.global-account-button span {
  color: var(--accent);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.global-account-button strong {
  display: none;
}

.global-logout {
  flex: 0 0 auto;
  min-height: 40px;
  padding-inline: 12px;
  font-size: 0;
  background: #172231;
  color: var(--text);
}

.theme-toggle {
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  min-width: 40px;
  width: 40px;
  height: 40px;
  min-height: 40px;
  padding: 0;
  overflow: hidden;
  color: var(--text);
  position: relative;
  background: #172231;
  color: var(--text);
}

.theme-toggle::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  display: block;
  width: 22px;
  height: 22px;
  background: currentColor;
  transform: translate(-50%, -50%);
  pointer-events: none;
  -webkit-mask-position: center;
  mask-position: center;
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
  -webkit-mask-size: 22px 22px;
  mask-size: 22px 22px;
}

.theme-toggle[data-theme-icon="sun"]::before {
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Ccircle cx='12' cy='12' r='5'/%3E%3Crect x='11' y='1' width='2' height='4' rx='1'/%3E%3Crect x='11' y='19' width='2' height='4' rx='1'/%3E%3Crect x='19' y='11' width='4' height='2' rx='1'/%3E%3Crect x='1' y='11' width='4' height='2' rx='1'/%3E%3Crect x='17.3' y='3.4' width='2' height='4' rx='1' transform='rotate(45 18.3 5.4)'/%3E%3Crect x='4.7' y='16.6' width='2' height='4' rx='1' transform='rotate(45 5.7 18.6)'/%3E%3Crect x='17.3' y='16.6' width='2' height='4' rx='1' transform='rotate(-45 18.3 18.6)'/%3E%3Crect x='4.7' y='3.4' width='2' height='4' rx='1' transform='rotate(-45 5.7 5.4)'/%3E%3C/svg%3E");
  mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Ccircle cx='12' cy='12' r='5'/%3E%3Crect x='11' y='1' width='2' height='4' rx='1'/%3E%3Crect x='11' y='19' width='2' height='4' rx='1'/%3E%3Crect x='19' y='11' width='4' height='2' rx='1'/%3E%3Crect x='1' y='11' width='4' height='2' rx='1'/%3E%3Crect x='17.3' y='3.4' width='2' height='4' rx='1' transform='rotate(45 18.3 5.4)'/%3E%3Crect x='4.7' y='16.6' width='2' height='4' rx='1' transform='rotate(45 5.7 18.6)'/%3E%3Crect x='17.3' y='16.6' width='2' height='4' rx='1' transform='rotate(-45 18.3 18.6)'/%3E%3Crect x='4.7' y='3.4' width='2' height='4' rx='1' transform='rotate(-45 5.7 5.4)'/%3E%3C/svg%3E");
}

.theme-toggle[data-theme-icon="moon"]::before {
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M21 14.8A8.8 8.8 0 0 1 9.2 3a9.2 9.2 0 1 0 11.8 11.8Z'/%3E%3C/svg%3E");
  mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M21 14.8A8.8 8.8 0 0 1 9.2 3a9.2 9.2 0 1 0 11.8 11.8Z'/%3E%3C/svg%3E");
}

.global-logout::before {
  content: "Exit";
  font-size: 14px;
}

.empty-action-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 12px;
}

.decode-lockup {
  --decode-wordmark-height: clamp(34px, 3.4vw, 44px);
  --decode-icon-height: clamp(28px, 2.8vw, 34px);
  display: inline-flex;
  align-items: center;
  gap: 9px;
}

.decode-wordmark {
  display: block;
  width: clamp(112px, 12vw, 152px);
  height: var(--decode-wordmark-height);
  object-fit: cover;
  object-position: top center;
}

.decode-logo {
  display: block;
  width: var(--decode-icon-height);
  height: var(--decode-icon-height);
  object-fit: cover;
  object-position: top center;
}

.decode-wordmark,
.decode-logo {
  filter: none !important;
  mix-blend-mode: normal;
  opacity: 1;
}

@media (max-width: 1500px) {
  .brand-title {
    grid-template-columns: max-content max-content minmax(240px, min(46vw, 700px)) minmax(0, 1fr) auto;
  }

  .global-account-button {
    width: 70px;
  }
}

@media (max-width: 1180px) {
  .brand-title {
    grid-template-columns: max-content max-content minmax(180px, 1fr) auto;
    gap: 8px 10px;
  }

  .global-account {
    grid-column: auto;
  }

  .brand-text {
    font-size: clamp(18px, 2.1vw, 24px);
  }

  .decode-lockup {
    --decode-wordmark-height: 34px;
    --decode-icon-height: 28px;
    gap: 6px;
  }

  .decode-wordmark {
    width: 112px;
  }

  .global-event-button {
    min-height: 40px;
    padding-inline: 10px;
  }

  .global-event-button strong {
    font-size: 14px;
  }

  .global-account-button {
    flex: 0 0 68px;
    justify-content: center;
    width: 68px;
    max-width: 68px;
  }

  .global-account-button strong {
    display: none;
  }

  .global-logout {
    min-width: 56px;
  }
}

@media (max-width: 820px) {
  .topbar {
    min-height: 58px;
    padding: 8px 12px;
  }

  .brand-title {
    grid-template-columns: max-content max-content minmax(150px, 1fr) auto;
    gap: 8px;
  }

  .brand-text {
    font-size: 20px;
    white-space: nowrap;
  }

  .decode-lockup {
    --decode-wordmark-height: 32px;
    --decode-icon-height: 26px;
    gap: 6px;
  }

  .decode-wordmark {
    width: 108px;
  }

  .global-event-button {
    min-height: 40px;
    padding: 7px 10px;
  }

  .global-event-button strong {
    font-size: 14px;
  }
}

@media (max-width: 620px) {
  .brand-title {
    grid-template-columns: 1fr auto;
  }

  .brand-text {
    font-size: 22px;
  }

  .decode-wordmark {
    width: 118px;
  }

  .decode-logo {
    display: none;
  }

  .global-event-button {
    grid-column: 1 / -1;
    min-height: 42px;
  }

  .global-account {
    grid-column: 1 / -1;
    justify-content: stretch;
  }

  .global-account-button {
    max-width: none;
  }
}

.eyebrow {
  margin: 0 0 3px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
h3 {
  margin: 0;
  line-height: 1.15;
}

h1 {
  font-size: 24px;
}

h2 {
  font-size: 26px;
}

h3 {
  font-size: 16px;
}

.icon-button,
.small-button,
.primary-button,
.secondary-button,
.danger-button {
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  cursor: pointer;
  min-height: 38px;
  background: var(--panel-2);
  font-weight: 850;
  transition: background 150ms ease, border-color 150ms ease, color 150ms ease, box-shadow 150ms ease, transform 150ms ease;
}

.icon-button:hover,
.small-button:hover,
.secondary-button:hover {
  border-color: var(--line-strong);
  background: var(--control-hover);
  box-shadow: var(--shadow-control);
}

.icon-button:active,
.small-button:active,
.primary-button:active,
.secondary-button:active,
.danger-button:active {
  transform: translateY(1px);
}

button:focus-visible,
summary:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: var(--focus-ring);
}

.icon-button {
  width: 48px;
  display: grid;
  place-items: center;
  font-size: 12px;
  font-weight: 800;
}

.file-button input {
  display: none;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-content: start;
  width: 100%;
  min-height: 100vh;
  padding-top: var(--topbar-height);
  transition: padding-top 180ms ease;
}

body.topbar-hidden .app-shell {
  padding-top: 0;
}

.sidebar {
  position: sticky;
  top: var(--nav-sticky-top);
  z-index: 35;
  align-self: start;
  display: flex;
  gap: 8px;
  overflow-x: auto;
  overflow-y: hidden;
  border-bottom: 1px solid var(--line);
  padding: 10px 22px;
  background: rgba(9, 14, 20, 0.96);
  backdrop-filter: blur(18px);
}

.nav-item {
  position: relative;
  display: grid;
  place-items: center;
  flex: 1 0 110px;
  min-height: 42px;
  margin: 0;
  padding: 0 12px;
  border: 0;
  border-radius: 8px;
  color: var(--muted);
  background: transparent;
  text-align: center;
  cursor: pointer;
  font-weight: 760;
  transition: background 160ms ease, color 160ms ease;
}

.nav-item.active,
.nav-item:hover {
  color: var(--text);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.045), rgba(255, 255, 255, 0.015)), var(--panel);
}

.nav-item.active::after {
  content: "";
  position: absolute;
  left: 18px;
  right: 18px;
  bottom: 6px;
  height: 2px;
  border-radius: 999px;
  background: var(--accent);
}

.content {
  width: 100%;
  max-width: 100%;
  padding: var(--content-pad);
  min-width: 0;
  overflow-x: clip;
}

.content:has(#pit.view.active) {
  overflow-x: clip;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.section-head,
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 16px;
}

.section-head {
  padding-block: 2px 4px;
}

.section-head h2 {
  font-size: clamp(26px, 2vw, 34px);
  letter-spacing: 0;
  white-space: nowrap;
}

.panel-head h3 {
  color: var(--text);
  font-size: 17px;
  font-weight: 900;
}

.section-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.pit-progress {
  display: grid;
  grid-template-columns: minmax(110px, auto) minmax(150px, 220px) auto;
  align-items: center;
  gap: 10px;
  min-width: min(480px, 100%);
  padding: 9px 12px;
  border: 1px solid rgba(6, 114, 142, 0.24);
  border-radius: 8px;
  background: var(--accent-soft);
}

.pit-progress-main {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.pit-progress-main span,
.pit-progress-meta {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  line-height: 1.15;
}

.pit-progress-main strong {
  color: var(--text);
  font-size: 21px;
  line-height: 1;
}

.pit-progress-meter {
  height: 9px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(100, 116, 139, 0.18);
  box-shadow: inset 0 0 0 1px rgba(100, 116, 139, 0.16);
}

.pit-progress-meter span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), var(--green));
  transition: width 180ms ease;
}

.pit-progress-meta {
  white-space: nowrap;
}

.heading-context {
  display: inline-flex;
  align-items: center;
  margin-left: 12px;
  padding: 4px 8px;
  border: 1px solid rgba(56, 189, 248, 0.35);
  border-radius: 6px;
  background: rgba(56, 189, 248, 0.08);
  color: var(--accent);
  font-size: 1em;
  font-weight: 800;
  line-height: 1.15;
  vertical-align: baseline;
}

.status-pill {
  padding: 8px 12px;
  color: #c8f7e4;
  background: rgba(32, 201, 151, 0.12);
  border: 1px solid rgba(32, 201, 151, 0.38);
  border-radius: 999px;
  font-size: 13px;
  font-weight: 800;
  line-height: 1.2;
}

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.metric,
.panel,
.team-card,
.pit-card,
.pick-row {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.032), rgba(255, 255, 255, 0.006)), var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow-panel);
}

.metric {
  padding: 16px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.035), rgba(255, 255, 255, 0)),
    var(--panel);
}

.metric span,
.muted {
  color: var(--muted);
  font-size: 13px;
}

.metric strong {
  display: block;
  margin-top: 8px;
  font-size: 28px;
}

.panel,
.pit-card,
.team-card,
.match-archive {
  transition: border-color 160ms ease, background 160ms ease, box-shadow 160ms ease;
}

.pit-card:hover,
.team-card:hover,
.match-archive:not([open]):hover {
  border-color: var(--line-strong);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0.01)), var(--panel);
}

.split-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}

.single-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 16px;
}

.panel {
  padding: 16px;
  margin-bottom: 16px;
}

.auth-panel {
  margin-bottom: 0;
}

.small-button,
.secondary-button,
.danger-button,
.primary-button {
  padding: 0 14px;
}

.primary-button {
  background: linear-gradient(180deg, #5ed4ff, var(--accent));
  border-color: var(--accent);
  color: #061018;
  font-weight: 800;
}

.primary-button:hover {
  border-color: #7ddcff;
  background: #69d2ff;
  box-shadow: 0 10px 26px rgba(56, 189, 248, 0.24);
}

.data-panel {
  margin-bottom: 0;
}

.settings-status-stack {
  align-items: flex-start;
}

.dashboard-settings-panel {
  margin-top: 18px;
  padding: 0;
  scroll-margin-top: 170px;
  min-width: 0;
  border: 0;
  background: transparent;
  box-shadow: none !important;
}

.dashboard-admin-users {
  display: grid;
  gap: 12px;
  margin: 18px 0;
}

.dashboard-settings-head {
  align-items: flex-start;
  margin-bottom: 12px;
  padding: 0 2px;
}

.dashboard-settings-head h2,
.dashboard-admin-users h2 {
  font-size: 24px;
  line-height: 1.15;
}

.settings-bubble-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 0.8fr);
  gap: 14px;
  min-width: 0;
}

.settings-bubble-grid > * {
  min-width: 0;
  max-width: 100%;
}

.settings-block {
  display: grid;
  grid-template-columns: minmax(170px, 0.32fr) minmax(0, 1fr);
  gap: 16px 22px;
  align-items: start;
  margin: 0;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.045), rgba(255, 255, 255, 0.008)),
    var(--panel);
  box-shadow: var(--shadow-panel);
  overflow: hidden;
}

.settings-block:first-child {
  padding-top: 16px;
}

.auth-panel,
#settingsForm {
  grid-column: 1 / -1;
}

.data-panel,
.release-panel {
  min-height: 100%;
}

.settings-block h3 {
  margin: 0;
  font-size: 17px;
  line-height: 1.2;
}

.settings-section-head {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.settings-section-head .muted {
  max-width: 24ch;
  font-size: 13px;
  line-height: 1.45;
}

.settings-section-body {
  display: grid;
  gap: 12px;
  min-width: 0;
}

.settings-form-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  align-items: start;
}

.settings-full-row {
  grid-column: 1 / -1;
}

.settings-cloud-group {
  display: grid;
  gap: 12px;
  min-width: 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
}

.settings-cloud-group h4 {
  margin: 0;
  color: var(--text);
  font-size: 15px;
  line-height: 1.2;
}

.settings-action-row {
  justify-content: flex-end;
}

.settings-block .form-actions {
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.settings-block .form-actions .primary-button,
.settings-block .form-actions .secondary-button,
.settings-block .form-actions .danger-button,
.settings-block .form-actions .data-file-button {
  flex: 0 0 auto;
  min-width: 112px;
  white-space: nowrap;
}

.data-panel .settings-section-body {
  grid-template-columns: minmax(0, 1fr);
  align-items: start;
}

.data-panel .settings-action-row {
  justify-content: flex-start;
  align-self: start;
}

.data-file-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  cursor: pointer;
}

.data-file-button input {
  display: none;
}

.release-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin: 0;
}

.release-list div {
  display: grid;
  gap: 5px;
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
}

.release-list dt,
.release-list dd {
  margin: 0;
}

.release-list dt {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.release-list dd {
  color: var(--text);
  font-size: 20px;
  font-weight: 900;
}

.admin-user-list {
  display: grid;
  gap: 10px;
}

.admin-create-user-form {
  display: grid;
  grid-template-columns: minmax(190px, 1.1fr) minmax(150px, 0.85fr) minmax(180px, 0.9fr) minmax(120px, 0.55fr) minmax(132px, auto);
  gap: 12px;
  align-items: end;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.026);
}

.dashboard-admin-users .admin-create-user-form {
  margin-top: 2px;
}

.admin-create-user-form .primary-button {
  min-height: 40px;
  white-space: nowrap;
}

.admin-user-row {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(180px, auto) minmax(0, 1.25fr) minmax(260px, auto);
  gap: 12px;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.03);
}

.admin-user-row.is-pending-approval {
  border-color: rgba(245, 158, 11, 0.46);
  background: rgba(245, 158, 11, 0.08);
}

.admin-user-identity strong,
.admin-user-identity span,
.admin-user-meta {
  display: block;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.admin-user-identity span,
.admin-user-meta {
  color: var(--muted);
  font-size: 13px;
}

.admin-user-flags,
.admin-user-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.admin-user-actions {
  justify-content: flex-end;
}

.admin-user-actions .secondary-button,
.admin-user-actions .danger-button {
  min-height: 34px;
  padding-inline: 10px;
  font-size: 13px;
  white-space: nowrap;
}

.role-pill {
  min-width: 74px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--text);
  font-size: 12px;
  font-weight: 900;
  text-align: center;
  text-transform: uppercase;
}

.role-pill.is-admin {
  border-color: rgba(56, 189, 248, 0.48);
  color: var(--accent);
}

.role-pill.is-master {
  border-color: rgba(167, 139, 250, 0.58);
  color: #ddd6fe;
}

.role-pill.is-disabled {
  border-color: rgba(248, 113, 113, 0.5);
  color: #fecaca;
}

.role-pill.is-pending {
  border-color: rgba(245, 158, 11, 0.52);
  color: #fde68a;
}

.role-pill.is-email {
  border-color: rgba(14, 165, 233, 0.5);
  color: #bae6fd;
}

.role-pill.is-active {
  border-color: rgba(32, 201, 151, 0.48);
  color: #bbf7d0;
}

@media (max-width: 1180px) {
  .settings-bubble-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .settings-block {
    grid-template-columns: minmax(0, 1fr);
    gap: 12px;
  }

  .auth-panel,
  #settingsForm {
    grid-column: auto;
  }

  .settings-section-head .muted {
    max-width: 62ch;
  }

  .settings-form-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .data-panel .settings-section-body {
    grid-template-columns: minmax(0, 1fr);
  }

  .admin-create-user-form {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .admin-create-user-form .primary-button {
    grid-column: 1 / -1;
  }

  .admin-user-row {
    grid-template-columns: minmax(0, 1fr);
    align-items: stretch;
  }

  .admin-user-actions {
    justify-content: flex-start;
  }
}

@media (max-width: 620px) {
  .dashboard-settings-panel {
    padding: 0;
  }

  .settings-block {
    padding: 14px;
  }

  .settings-form-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .settings-cloud-group {
    padding: 12px;
  }

  .settings-block .form-actions .primary-button,
  .settings-block .form-actions .secondary-button,
  .settings-block .form-actions .danger-button,
  .settings-block .form-actions .data-file-button {
    flex: 1 1 100%;
    min-width: 0;
  }

  .admin-create-user-form {
    grid-template-columns: 1fr;
  }

  .admin-user-actions .secondary-button,
  .admin-user-actions .danger-button {
    flex: 1 1 136px;
    min-width: 0;
  }
}

body:not(.role-admin) .admin-only {
  display: none !important;
}

.danger-button {
  background: rgba(239, 68, 68, 0.14);
  border-color: rgba(239, 68, 68, 0.45);
  color: #fecaca;
}

.danger-button:hover {
  border-color: rgba(248, 113, 113, 0.7);
  background: rgba(239, 68, 68, 0.22);
  box-shadow: 0 10px 26px rgba(127, 29, 29, 0.28);
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.pit-form {
  display: grid;
  grid-template-columns: minmax(300px, 0.9fr) minmax(0, 1.1fr);
  gap: 14px;
  align-items: start;
  min-width: 0;
}

.pit-form[hidden] {
  display: none;
}

.event-panel {
  display: grid;
  gap: 10px;
  padding: 12px;
}

.dashboard-event-panel {
  margin-bottom: 18px;
  padding: 0;
  overflow: hidden;
  scroll-margin-top: 170px;
}

.dashboard-event-summary {
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 14px 20px 18px;
  cursor: pointer;
  list-style: none;
}

.dashboard-event-panel[open] .expand-open {
  display: none;
}

.dashboard-event-panel[open] .expand-close {
  display: inline;
}

.dashboard-event-panel:not([open]) .expand-close {
  display: none;
}

.dashboard-event-summary::-webkit-details-marker {
  display: none;
}

.dashboard-event-summary > div {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.event-summary-label {
  color: var(--accent);
  font-size: 15px;
  font-weight: 900;
  text-transform: uppercase;
}

.dashboard-event-summary strong {
  display: block;
  overflow: hidden;
  padding-bottom: 5px;
  max-width: min(100%, 72vw);
  font-size: clamp(28px, 1.75vw, 34px);
  font-weight: 900;
  line-height: 1.16;
  white-space: normal;
  overflow-wrap: anywhere;
}

.dashboard-event-body {
  display: grid;
  gap: 12px;
  padding: 14px;
  border-top: 1px solid var(--line);
}

.dashboard-event-panel .eyebrow {
  font-size: 15px;
  font-weight: 900;
}

.dashboard-event-panel label {
  font-size: 18px;
  font-weight: 900;
}

.event-modal {
  width: min(860px, 100%);
}

.import-modal-form {
  margin-bottom: 0;
}

.event-strip {
  display: grid;
  grid-template-columns: minmax(170px, auto) minmax(240px, 1fr) minmax(180px, 280px);
  gap: 12px;
  align-items: end;
}

.active-event-label {
  color: var(--accent);
  font-size: 13px;
  text-align: left;
  padding-bottom: 9px;
}

.event-select-field {
  max-width: none;
  min-width: 0;
}

.event-select-field select {
  min-width: 0;
  max-width: 100%;
}

.event-current-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) max-content;
  gap: 10px;
  align-items: end;
}

.event-list-details {
  display: grid;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
  overflow: hidden;
}

.event-list-details[hidden] {
  display: none;
}

.event-list-summary {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr) max-content;
  gap: 10px;
  align-items: center;
  min-height: 46px;
  padding: 8px 12px;
  cursor: pointer;
  list-style: none;
}

.event-list-summary::-webkit-details-marker {
  display: none;
}

.event-list-summary > span:first-child {
  color: var(--text);
  font-size: 16px;
  font-weight: 900;
  white-space: nowrap;
}

.event-list-summary strong {
  min-width: 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 14px;
  font-weight: 850;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.event-list-details[open] .event-list-summary {
  border-bottom: 1px solid var(--line);
}

.event-list-details[open] .expand-open,
.event-list-details:not([open]) .expand-close {
  display: none;
}

.event-delete-list {
  display: grid;
  gap: 8px;
  max-height: min(320px, 45dvh);
  padding: 10px;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
}

.event-delete-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) max-content;
  gap: 8px;
  align-items: center;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
}

.event-delete-row.is-active {
  border-color: var(--accent);
  box-shadow: var(--focus-ring);
}

.event-delete-select {
  min-width: 0;
  overflow: hidden;
  border: 0;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  font: inherit;
  font-weight: 850;
  text-align: left;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.event-delete-button {
  min-height: 34px;
  padding: 0 14px;
}

@media (max-width: 720px) {
  .event-list-summary {
    grid-template-columns: minmax(0, 1fr) max-content;
    gap: 6px 10px;
  }

  .event-list-summary strong {
    grid-column: 1 / -1;
  }

  .event-delete-row {
    grid-template-columns: 1fr;
  }

  .event-delete-button {
    width: 100%;
  }
}

.event-form {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) 120px minmax(150px, 220px) max-content;
  gap: 10px;
  align-items: end;
}

.event-import-form {
  grid-template-columns: minmax(260px, 1fr) 120px max-content;
}

.import-panel {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  gap: 6px 16px;
  align-items: end;
  padding: 12px;
}

.import-copy {
  display: flex;
  align-items: baseline;
  gap: 8px;
  min-width: 0;
  padding-bottom: 8px;
  white-space: nowrap;
}

.import-copy .eyebrow {
  margin: 0;
}

.import-copy h3 {
  font-size: 15px;
}

.import-controls {
  display: grid;
  grid-template-columns: 96px minmax(150px, 210px) max-content max-content;
  gap: 8px;
  align-items: end;
  justify-content: start;
}

.import-status {
  grid-column: 2;
  margin: -2px 0 0;
  font-size: 12px;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
}

.choice-group {
  display: grid;
  gap: 9px;
  margin: 0;
  padding: 0;
  border: 0;
  color: var(--muted);
  font-size: 13px;
}

.choice-group legend {
  display: block;
  padding: 0;
  margin-bottom: 4px;
  color: var(--text);
  font-size: 20px;
  font-weight: 800;
}

.alliance-choice {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 0;
  padding: 0;
  border: 0;
  color: var(--muted);
  font-size: 13px;
}

.alliance-choice legend {
  grid-column: 1 / -1;
  display: block;
  padding: 0;
  margin-bottom: 4px;
  color: var(--text);
  font-size: 20px;
  font-weight: 800;
}

.alliance-card {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 42px;
  border: 2px solid transparent;
  border-radius: 8px;
  color: #fff;
  font-weight: 800;
  cursor: pointer;
  transition: background 150ms ease, border-color 150ms ease, box-shadow 150ms ease, color 150ms ease, filter 150ms ease, opacity 150ms ease;
}

.alliance-card input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.red-card {
  background: #b91c1c;
}

.blue-card {
  background: #1d4ed8;
}

.alliance-card:has(input:checked) {
  border-color: #fff;
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.18);
}

.alliance-choice:has(.red-card input:checked) .blue-card,
.alliance-choice:has(.blue-card input:checked) .red-card {
  border-color: rgba(148, 163, 184, 0.46);
  background: #64748b;
  color: rgba(255, 255, 255, 0.72);
  filter: saturate(0.2);
  opacity: 0.62;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--text);
  min-height: 40px;
  padding: 9px 10px;
  transition: background 150ms ease, border-color 150ms ease, box-shadow 150ms ease;
}

input:hover,
select:hover,
textarea:hover {
  border-color: var(--line-strong);
  background: var(--input-hover);
}

input[type="number"] {
  appearance: textfield;
  -moz-appearance: textfield;
}

input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
  appearance: none;
  margin: 0;
}

input[type="range"] {
  width: 100%;
  padding: 0;
}

.range-scale {
  --range-scale-inset: 16px;
  position: relative;
  display: block;
  height: 32px;
  margin-top: -4px;
  margin-inline: var(--range-scale-inset);
  color: var(--muted);
  font-size: 14px;
  font-weight: 800;
  text-align: center;
  overflow: visible;
}

.range-scale span {
  position: absolute;
  top: 0;
  display: grid;
  min-width: 32px;
  justify-items: center;
  font-variant-numeric: tabular-nums;
  line-height: 1;
  transform: translateX(-50%);
}

.range-scale span::before {
  content: "";
  display: block;
  width: 2px;
  height: 8px;
  margin-bottom: 8px;
  border-radius: 999px;
  background: var(--text);
  opacity: 0.72;
}

.range-scale span:nth-child(1) {
  left: 0;
}

.range-scale span:nth-child(2) {
  left: 20%;
}

.range-scale span:nth-child(3) {
  left: 40%;
}

.range-scale span:nth-child(4) {
  left: 60%;
}

.range-scale span:nth-child(5) {
  left: 80%;
}

.range-scale span:nth-child(6) {
  left: 100%;
}

textarea {
  resize: vertical;
}

.form-section {
  grid-column: span 4;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  padding: 14px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.026);
  border: 1px solid var(--line);
}

.form-section h3 {
  grid-column: 1 / -1;
  font-size: 20px;
}

.quality-section {
  grid-template-columns: 1fr;
}

.reliability-field,
.quality-section .wide {
  grid-column: 1 / -1;
}

.reliability-field {
  display: grid;
  gap: 10px;
  max-width: 760px;
  color: var(--muted);
  font-size: 18px;
  font-weight: 900;
}

.reliability-field input[type="range"] {
  min-height: 32px;
}

.pit-identity-panel {
  display: grid;
  gap: 10px;
  align-items: start;
}

.team-number-field {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  color: var(--text);
}

.team-number-field span {
  font-size: 24px;
  font-weight: 900;
}

.team-number-field input {
  min-height: 50px;
  font-size: 24px;
  font-weight: 900;
}

.pit-fields-panel {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  min-width: 0;
}

.pit-fields-panel .choice-group {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px 14px;
  min-width: 0;
  min-inline-size: 0;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.03);
}

.pit-fields-panel .auto-path-group {
  grid-template-columns: repeat(4, max-content);
  justify-content: space-between;
  column-gap: clamp(12px, 3vw, 42px);
}

.pit-fields-panel .choice-group legend {
  float: left;
  grid-column: 1 / -1;
  width: 100%;
  padding: 0;
  margin: 0 0 6px;
  color: var(--text);
  font-size: 24px;
  font-weight: 900;
  line-height: 1.05;
  white-space: normal;
}

.pit-fields-panel .choice-group .checkbox-row {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  min-width: 0;
  min-height: 36px;
  color: var(--text);
  font-size: 18px;
  font-weight: 900;
  line-height: 1.05;
  overflow: hidden;
  overflow-wrap: anywhere;
}

.pit-fields-panel .auto-path-group .checkbox-row {
  grid-template-columns: 28px max-content;
  gap: 8px;
  min-height: 32px;
}

.pit-fields-panel .auto-path-group .checkbox-row input {
  width: 24px;
  min-width: 24px;
  min-height: 24px;
}

.pit-fields-panel .choice-group .checkbox-row input {
  width: 26px;
  min-width: 26px;
  min-height: 26px;
}

.inline-number-field {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 86px;
  align-items: center;
  gap: 12px;
  color: var(--text);
  font-size: 18px;
  font-weight: 900;
  line-height: 1.08;
  white-space: normal;
}

.inline-number-field input {
  width: 100%;
  min-width: 0;
}

.wide-check {
  grid-column: 1 / -1;
  white-space: nowrap;
}

.auto-path-group .wide-check {
  grid-column: auto;
}

.pit-fields-panel .auto-path-group .auto-color-check,
.pit-archive .pit-fields-panel .auto-path-group .auto-color-check {
  grid-column: auto !important;
  white-space: nowrap;
}

.pit-feature-checks {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.feature-check {
  min-height: 48px;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.03);
  color: var(--text);
  font-size: 18px;
  font-weight: 900;
  line-height: 1.08;
}

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

.pit-identity-panel .pit-number-grid {
  gap: 10px;
}

.pit-identity-panel .pit-number-grid label {
  min-width: 0;
}

.pit-fields-panel .pit-number-grid,
.pit-fields-panel .pit-feature-checks,
.pit-fields-panel > label,
.pit-fields-panel .form-actions {
  grid-column: 1 / -1;
}

.photo-upload-panel {
  display: grid;
  gap: 9px;
}

.photo-preview {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  display: grid;
  place-items: center;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #0d1218;
  color: var(--muted);
  font-size: 13px;
}

#pitForm .photo-preview {
  aspect-ratio: 4 / 3;
  max-height: min(300px, 34vh);
}

button.photo-preview {
  padding: 0;
  cursor: zoom-in;
  font: inherit;
}

.photo-preview img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

.photo-count {
  position: absolute;
  right: 8px;
  bottom: 8px;
  padding: 4px 7px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.72);
  color: var(--text);
  font-size: 11px;
  font-weight: 900;
  line-height: 1;
}

.photo-picker {
  color: var(--text);
  font-weight: 700;
}

.pit-notes-field {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.03);
}

#pitForm .pit-notes-field textarea {
  min-height: 112px;
  max-height: 150px;
  font-size: 15px;
}

.field-cluster {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  align-content: start;
}

.numeric-cluster {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.counter-field {
  display: grid;
  gap: 8px;
  color: #d8e5f3;
  font-size: 16px;
  font-weight: 900;
}

.counter-control {
  display: grid;
  grid-template-columns: 58px minmax(72px, 1fr) 58px;
  min-height: 58px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #0d1218;
}

.counter-control button {
  border: 0;
  background: var(--panel-2);
  color: var(--text);
  font-size: 30px;
  font-weight: 900;
  cursor: pointer;
}

.counter-control button:hover {
  background: rgba(56, 189, 248, 0.18);
}

.counter-control input {
  min-height: 58px;
  border-width: 0 1px;
  border-radius: 0;
  background: #090e14;
  font-size: 28px;
  font-weight: 900;
  text-align: center;
  cursor: pointer;
  user-select: none;
  -moz-appearance: textfield;
}

.counter-control input::-webkit-outer-spin-button,
.counter-control input::-webkit-inner-spin-button {
  margin: 0;
  appearance: none;
}

.counter-control input:hover {
  background: rgba(56, 189, 248, 0.12);
}

.counter-control input:active {
  background: rgba(56, 189, 248, 0.2);
}

.base-control {
  grid-template-columns: 72px minmax(136px, 1fr) 72px;
}

.base-value {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 58px;
  padding: 0 12px;
  border-inline: 1px solid var(--line);
  background: #090e14;
  color: var(--text);
  font-size: 30px;
  font-weight: 900;
  line-height: 1;
  text-align: center;
  white-space: nowrap;
}

.base-control button {
  display: grid;
  place-items: center;
  font-size: 34px;
  line-height: 1;
}

.base-options {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  width: 100%;
  min-height: 58px;
  gap: 6px;
}

.base-options button {
  display: grid;
  place-items: center;
  min-width: 0;
  min-height: 58px;
  padding: 0 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #090e14;
  color: var(--muted);
  font-size: 14px;
  font-weight: 900;
  line-height: 1.05;
  text-align: center;
  white-space: nowrap;
  cursor: pointer;
}

.base-options button[aria-pressed="true"] {
  border-color: var(--primary);
  background: linear-gradient(180deg, rgba(34, 211, 238, 0.28), rgba(34, 211, 238, 0.12));
  color: var(--text);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.18);
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--text);
  font-size: 15px;
  font-weight: 700;
}

.checkbox-row input {
  width: 18px;
  min-height: 18px;
}

.checkbox-row.feature-check {
  color: var(--text);
  font-size: 18px;
  font-weight: 900;
}

.checkbox-row.feature-check input {
  width: 20px;
  min-height: 20px;
}

.wide,
.form-actions {
  grid-column: span 4;
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.search-input {
  max-width: 260px;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 760px;
}

th,
td {
  padding: 11px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

th {
  color: var(--muted);
  font-size: 12px;
}

.team-list,
.record-list,
.pick-list,
.match-groups {
  display: grid;
  gap: 10px;
}

.match-group {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
  box-shadow: var(--shadow-panel);
}

.match-archive {
  padding: 0;
}

.match-archive-summary {
  position: relative;
  min-height: 58px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 16px;
  cursor: pointer;
  list-style: none;
}

.match-groups > .match-archive:not([open]):not(.match-archive-compact) .expand-label {
  position: absolute;
  top: 10px;
  right: 12px;
  z-index: 2;
  display: inline-flex;
  min-width: 88px;
  min-height: 34px;
  align-items: center;
  justify-content: center;
}

.match-groups > .match-archive:not([open]):not(.match-archive-compact) .match-archive-summary {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-areas:
    "score"
    "teams";
  align-items: center;
  justify-items: stretch;
  min-height: 116px;
  padding: 12px 14px;
  gap: 8px;
  overflow: hidden;
}

.match-groups > .match-archive:not([open]):not(.match-archive-compact) .match-summary-title {
  display: grid;
  grid-area: score;
  grid-template-columns: minmax(64px, 96px) minmax(0, 1fr) minmax(64px, 96px);
  align-items: center;
  width: 100%;
  max-width: none;
  min-width: 0;
  gap: 8px;
  overflow: visible;
}

.match-groups > .match-archive:not([open]):not(.match-archive-compact) .match-summary-title > strong {
  justify-self: start;
  line-height: 1;
}

.match-groups > .match-archive:not([open]):not(.match-archive-compact) .match-score-with-rp {
  grid-column: 2;
  justify-self: stretch;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  grid-template-areas:
    "redScore blueScore"
    "redRp blueRp";
  align-items: center;
  justify-items: center;
  width: 100%;
  max-width: 100%;
  gap: 5px 10px;
  overflow: visible;
}

.match-groups > .match-archive:not([open]):not(.match-archive-compact) .match-score-with-rp > .red-score {
  grid-area: redScore;
}

.match-groups > .match-archive:not([open]):not(.match-archive-compact) .match-score-with-rp > .blue-score {
  grid-area: blueScore;
}

.match-groups > .match-archive:not([open]):not(.match-archive-compact) .match-score-with-rp > .red-rp {
  grid-area: redRp;
}

.match-groups > .match-archive:not([open]):not(.match-archive-compact) .match-score-with-rp > .blue-rp {
  grid-area: blueRp;
}

.match-groups > .match-archive:not([open]):not(.match-archive-compact) .match-archive-right {
  display: grid;
  grid-area: teams;
  grid-template-columns: minmax(0, 1fr);
  align-items: center;
  width: 100%;
  gap: 10px;
}

.match-groups > .match-archive:not([open]):not(.match-archive-compact) .match-archive-teams {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 24px minmax(0, 1fr);
  align-items: center;
  justify-items: stretch;
  width: min(100%, 980px);
  margin-inline: auto;
  gap: 6px;
  overflow: hidden;
  white-space: nowrap;
  text-align: center;
}

.match-groups > .match-archive:not([open]):not(.match-archive-compact) .match-team-chip-group {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  justify-content: stretch;
  width: 100%;
  gap: 6px;
}

.match-groups > .match-archive:not([open]):not(.match-archive-compact) .match-team-chip {
  width: 100%;
  min-width: 0;
}

.match-archive-summary::-webkit-details-marker {
  display: none;
}

.match-archive-summary strong {
  font-size: 24px;
}

.match-summary-title {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  flex: 1 1 auto;
  min-width: 0;
  max-width: calc(100% - 620px);
  overflow: hidden;
}

.match-score-badge {
  display: inline-grid;
  grid-template-columns: 74px 74px;
  align-items: center;
  justify-items: start;
  gap: 4px;
  font-size: 24px;
  font-weight: 900;
  white-space: nowrap;
}

.match-score-with-rp {
  width: auto;
  max-width: 100%;
  grid-template-columns: minmax(154px, 1fr) 74px 74px minmax(154px, 1fr);
  justify-items: start;
  gap: 5px;
  overflow: hidden;
}

.match-score-badge > .red-score,
.match-score-badge > .blue-score {
  display: inline-grid;
  width: 74px;
  place-items: center;
  font-variant-numeric: tabular-nums;
  text-align: center;
}

.match-score-separator {
  color: var(--muted);
  font-size: 24px;
  font-weight: 900;
}

.match-rp-compare {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.rp-strip {
  display: inline-grid;
  grid-template-columns: repeat(6, 26px);
  align-items: center;
  gap: 4px;
  min-width: 176px;
  max-width: 100%;
  overflow: hidden;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
}

.rp-label {
  display: none;
  margin-right: 3px;
  font-size: 13px;
  font-weight: 900;
  letter-spacing: 0;
  white-space: nowrap;
}

.red-rp .rp-label {
  color: #fecaca;
}

.blue-rp .rp-label {
  color: #bfdbfe;
}

.rp-icon {
  width: 26px;
  height: 26px;
  display: inline-grid;
  place-items: center;
  border-radius: 7px;
  color: rgba(255, 255, 255, 0.3);
  background: rgba(255, 255, 255, 0.07);
}

.rp-icon.earned {
  color: #fff;
}

.red-rp .rp-icon.earned {
  background: #ef202d;
}

.blue-rp .rp-icon.earned {
  background: #1d4ed8;
}

.rp-icon svg {
  width: 78%;
  height: 78%;
  fill: currentColor;
}

.match-archive.red-win {
  background: rgba(127, 29, 29, 0.18);
  border-color: rgba(239, 68, 68, 0.48);
}

.match-archive.blue-win {
  background: rgba(30, 64, 175, 0.18);
  border-color: rgba(59, 130, 246, 0.48);
}

.match-archive-teams {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 7px;
  min-width: 0;
  color: var(--muted);
  font-weight: 800;
  text-align: right;
}

.match-team-chip-group {
  display: inline-flex;
  flex-wrap: nowrap;
  justify-content: flex-end;
  gap: 5px;
}

.match-team-chip {
  display: inline-grid;
  width: 94px;
  height: 34px;
  place-items: center;
  padding: 2px 6px;
  border: 1px solid transparent;
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.03);
  font-size: 19px;
  font-weight: 900;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  text-align: center;
  cursor: pointer;
}

.match-team-chip.filled.red-score {
  border-color: rgba(239, 68, 68, 0.35);
  background: rgba(127, 29, 29, 0.2);
}

.match-team-chip.filled.blue-score {
  border-color: rgba(59, 130, 246, 0.35);
  background: rgba(30, 64, 175, 0.2);
}

.match-team-chip.estimated {
  border-style: dashed;
  opacity: 0.82;
}

.match-team-chip.missing {
  opacity: 0.42;
  filter: grayscale(0.35);
}

.match-team-chip:hover {
  opacity: 1;
  border-color: var(--accent);
}

.match-archive-right {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  min-width: 0;
  flex: 0 0 auto;
}

.match-collapse-tab {
  display: none;
}

.match-archive[open] .match-collapse-tab,
.match-archive-open .match-collapse-tab {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 96px;
  min-height: 38px;
  padding: 6px 12px;
  font-size: 16px;
}

.match-archive-open .match-archive-summary {
  border-bottom: 1px solid var(--line);
}

.match-archive-open .match-summary-title {
  max-width: none;
  gap: 12px;
  flex-wrap: wrap;
}

.match-archive-open .match-summary-title .match-head-tools {
  margin-left: 4px;
}

.match-archive-teams .versus {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

.match-archive-body {
  container-type: inline-size;
  padding: 16px;
  border-top: 1px solid var(--line);
}

.match-group-head,
.alliance-lane-head,
.match-team-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.match-group-head {
  display: grid;
  grid-template-columns: 1fr;
  align-items: stretch;
  gap: 10px;
  margin-bottom: 14px;
}

.match-group-meta {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-items: center;
  justify-self: stretch;
  min-width: 0;
  color: var(--muted);
  font-size: 18px;
  font-weight: 800;
}

.match-detail-title-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.match-detail-title-row h3 {
  margin: 0;
}

.match-head-tools {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  min-width: 0;
}

.match-score-controls {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  align-items: center;
  justify-items: center;
  width: min(100%, 760px);
  margin-inline: auto;
  gap: 18px;
}

.score-source-badge {
  justify-self: center;
  margin-top: 8px;
  padding: 4px 9px;
  border: 1px solid rgba(125, 211, 252, 0.45);
  border-radius: 999px;
  color: #7dd3fc;
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.match-group-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: nowrap;
}

.match-scouted-count {
  white-space: nowrap;
  color: var(--muted);
  font-size: 16px;
  font-weight: 900;
}

.score-input {
  display: grid;
  grid-template-columns: auto minmax(108px, 148px);
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  font-size: 18px;
  font-weight: 900;
}

.score-input input {
  width: 100%;
  min-height: 52px;
  padding: 8px 12px;
  text-align: center;
  font-size: 24px;
  font-weight: 900;
}

.match-group-meta .small-button {
  min-width: 84px;
  min-height: 38px;
  padding: 6px 12px;
  font-size: 16px;
}

.match-head-tools .small-button {
  min-width: 84px;
  min-height: 38px;
  padding: 6px 12px;
  font-size: 16px;
}

.red-score {
  color: #fecaca;
}

.blue-score {
  color: #bfdbfe;
}

.alliance-lanes {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.alliance-lane {
  container-type: inline-size;
  min-width: 0;
  padding: 14px;
  border-radius: 8px;
  background: #0d1218;
  border: 1px solid var(--line);
}

.red-lane {
  border-color: rgba(239, 68, 68, 0.5);
}

.blue-lane {
  border-color: rgba(59, 130, 246, 0.5);
}

.alliance-lane-head {
  margin-bottom: 10px;
  font-size: 21px;
}

.match-team-list {
  display: grid;
  gap: 8px;
}

.match-team-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 128px;
  align-items: center;
  gap: 16px;
  padding: 14px 16px;
  border-radius: 8px;
  background: var(--panel);
}

.match-team-row.is-estimated {
  border: 1px dashed rgba(245, 158, 11, 0.45);
  background: rgba(245, 158, 11, 0.08);
}

.match-team-row strong {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  font-size: 22px;
}

.match-source-badge {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 3px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 11px;
  font-weight: 900;
  line-height: 1;
  text-transform: uppercase;
}

.match-source-badge.is-manual {
  border-color: rgba(32, 201, 151, 0.42);
  background: rgba(32, 201, 151, 0.12);
  color: #7dd3fc;
}

.match-source-badge.is-estimated {
  border-color: rgba(245, 158, 11, 0.48);
  background: rgba(245, 158, 11, 0.14);
  color: #fbbf24;
}

.match-team-row .muted {
  margin-top: 8px;
  font-size: 18px;
  line-height: 1.35;
}

.match-team-summary span {
  display: block;
  white-space: nowrap;
}

.match-team-row .table-actions {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  align-items: stretch;
  justify-self: end;
  width: 128px;
}

.match-team-row .small-button,
.match-team-row .delete-button {
  display: grid;
  place-items: center;
  width: 100%;
  min-height: 44px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
  font-size: 20px;
  font-weight: 800;
  line-height: 1;
}

.match-team-row .delete-button {
  color: #fca5a5;
}

@container (max-width: 980px) {
  .match-expanded-detail .alliance-lanes,
  .match-archive-body .alliance-lanes {
    grid-template-columns: 1fr;
  }
}

@container (max-width: 760px) {
  .match-archive-body .match-group-head,
  .match-expanded-detail .match-group-head {
    grid-template-columns: 1fr;
    gap: 10px;
    align-items: start;
  }

  .match-archive-body .match-group-meta,
  .match-expanded-detail .match-group-meta {
    justify-self: stretch;
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .match-archive-body .match-score-controls,
  .match-expanded-detail .match-score-controls {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }

  .match-archive-body .score-input,
  .match-expanded-detail .score-input {
    display: grid;
    grid-template-columns: max-content minmax(88px, 1fr);
    gap: 8px;
  }

  .match-archive-body .match-group-actions,
  .match-expanded-detail .match-group-actions {
    display: grid;
    grid-template-columns: repeat(2, max-content);
    gap: 6px;
  }
}

@container (max-width: 430px) {
  .match-archive-body .match-score-controls,
  .match-expanded-detail .match-score-controls {
    grid-template-columns: 1fr;
  }
}

@container (max-width: 420px) {
  .match-team-row {
    grid-template-columns: 1fr;
    align-items: start;
  }

  .match-team-row .table-actions {
    justify-self: start;
    width: min(100%, 180px);
    margin-top: 8px;
  }
}

.match-groups:has(.match-archive[open]) {
  grid-template-columns: minmax(0, 1fr) minmax(300px, 0.72fr);
  align-items: start;
}

.match-groups:has(.match-archive[open]) .match-archive {
  grid-column: 2;
}

.match-groups:has(.match-archive[open]) .match-archive[open] {
  grid-column: 1;
  grid-row: 1 / span 100;
}

.match-groups:has(.match-archive[open]) .match-archive[open] .match-archive-summary {
  border-bottom: 1px solid var(--line);
}

.match-groups:has(.match-archive[open]) .match-archive[open] .match-score-separator,
.match-groups:has(.match-archive[open]) .match-archive[open] .match-score-badge {
  display: none;
}

.match-groups:has(.match-archive[open]) .match-archive[open] .match-archive-right,
.match-groups:has(.match-archive[open]) .match-archive[open] .match-archive-teams,
.match-groups:has(.match-archive[open]) .match-archive[open] .expand-label {
  display: none;
}

.match-groups:has(.match-archive[open]) .match-archive[open] .match-archive-right {
  display: flex;
  margin-left: auto;
}

.match-groups:has(.match-archive[open]) .match-archive[open] .match-group-head {
  display: block;
  margin-bottom: 12px;
}

.match-groups:has(.match-archive[open]) .match-archive[open] .match-group-meta {
  padding: 0;
  border: 0;
  background: transparent;
  overflow: visible;
}

.match-groups:has(.match-archive[open]) .match-archive[open] .score-input input {
  font-size: 26px;
}

.match-groups:has(.match-archive[open]) .match-archive[open] .alliance-lanes {
  grid-template-columns: 1fr;
}

.match-groups:has(.match-archive[open]) .match-archive:not([open]) .match-archive-summary {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-areas:
    "score"
    "teams";
  align-items: center;
  justify-items: stretch;
  min-height: 92px;
  padding: 10px 14px;
  gap: 6px;
}

.match-groups:has(.match-archive[open]) .match-archive:not([open]) .match-summary-title {
  position: relative;
  display: flex;
  grid-area: score;
  align-items: center;
  width: 100%;
  max-width: none;
  justify-content: flex-start;
}

.match-groups:has(.match-archive[open]) .match-archive:not([open]) .match-archive-summary strong {
  font-size: 30px;
}

.match-groups:has(.match-archive[open]) .match-archive:not([open]) .match-score-badge {
  font-size: 30px;
}

.match-groups:has(.match-archive[open]) .match-archive:not([open]) .match-score-with-rp {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  grid-template-columns: 58px max-content max-content 58px;
  align-items: center;
  justify-items: center;
  gap: 6px;
  max-width: none;
}

.match-groups:has(.match-archive[open]) .match-archive:not([open]) .match-rp-compare {
  gap: 3px;
}

.match-groups:has(.match-archive[open]) .match-archive:not([open]) .rp-strip {
  grid-template-columns: repeat(6, 8px);
  align-items: center;
  justify-content: center;
  min-width: 58px;
  gap: 2px;
}

.match-groups:has(.match-archive[open]) .match-archive:not([open]) .rp-label {
  display: none;
}

.match-groups:has(.match-archive[open]) .match-archive:not([open]) .rp-icon {
  width: 8px;
  height: 8px;
  border-radius: 999px;
}

.match-groups:has(.match-archive[open]) .match-archive:not([open]) .rp-icon svg {
  display: none;
}

.match-groups:has(.match-archive[open]) .match-archive:not([open]) .match-archive-teams {
  display: grid;
  grid-area: teams;
  grid-template-columns: 176px 38px 176px;
  align-items: center;
  justify-content: center;
  justify-items: center;
  width: 100%;
  font-size: 20px;
  gap: 8px;
  overflow: hidden;
  white-space: nowrap;
  text-align: center;
}

.match-groups:has(.match-archive[open]) .match-archive:not([open]) .match-team-chip {
  width: 84px;
  height: 28px;
  padding: 1px 5px;
  font-size: 16px;
}

.match-groups:has(.match-archive[open]) .match-archive:not([open]) .match-team-chip-group {
  display: grid;
  grid-template-columns: repeat(2, 84px);
  align-items: center;
  justify-content: center;
  justify-items: center;
  gap: 4px;
}

.match-groups:has(.match-archive[open]) .match-archive:not([open]) .expand-label {
  display: none;
}

.match-expanded-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(300px, 0.72fr);
  gap: 16px;
  align-items: start;
  width: 100%;
}

.match-groups:has(.match-expanded-layout):has(.match-archive[open]),
.match-groups.is-expanded {
  grid-template-columns: 1fr;
}

.match-groups:has(.match-expanded-layout):has(.match-archive[open]) .match-expanded-layout,
.match-groups.is-expanded .match-expanded-layout {
  grid-column: 1;
  grid-row: auto;
}

.match-expanded-detail {
  container-type: inline-size;
  min-width: 0;
  overflow: visible;
}

.match-expanded-detail > .match-archive {
  height: auto;
  margin: 0;
}

.match-compact-list {
  container-type: inline-size;
  display: grid;
  gap: 10px;
  min-width: 0;
  height: auto;
  max-height: none;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.035);
  overflow-y: auto;
  overscroll-behavior: auto;
  touch-action: pan-y;
  scrollbar-gutter: stable;
}

.match-compact-list > .match-archive {
  margin: 0;
}

.match-groups {
  container-type: inline-size;
}

.match-archive-compact {
  min-height: 124px;
  overflow: hidden;
}

.match-archive-compact .match-archive-summary {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-areas:
    "score"
    "teams";
  align-items: center;
  justify-items: stretch;
  min-height: 122px;
  padding: 12px 18px;
  gap: 4px;
}

.match-archive-compact .match-summary-title {
  position: relative;
  display: block;
  grid-area: score;
  width: 100%;
  max-width: none;
  min-height: 62px;
  line-height: 1;
}

.match-archive-compact .match-archive-summary strong {
  position: absolute;
  left: 2px;
  top: 2px;
  z-index: 1;
  font-size: 32px;
  line-height: 1;
  white-space: nowrap;
}

.match-archive-compact .match-score-badge {
  align-self: center;
  font-size: 33px;
  line-height: 1;
}

.match-archive-compact .match-score-with-rp {
  display: grid;
  position: static;
  transform: none;
  margin-inline: auto;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  grid-template-areas:
    "redScore blueScore"
    "redRp blueRp";
  align-items: center;
  justify-items: center;
  gap: 5px 14px;
  width: min(58%, 500px);
  max-width: calc(100% - 176px);
  overflow: visible;
}

.match-archive-compact .match-score-badge > .red-score,
.match-archive-compact .match-score-badge > .blue-score {
  align-self: center;
  width: 100%;
  min-width: 0;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.match-archive-compact .match-score-with-rp > .red-score {
  grid-area: redScore;
}

.match-archive-compact .match-score-with-rp > .blue-score {
  grid-area: blueScore;
}

.match-archive-compact .match-score-with-rp > .red-rp {
  grid-area: redRp;
}

.match-archive-compact .match-score-with-rp > .blue-rp {
  grid-area: blueRp;
}

.match-archive-compact .match-rp-compare {
  gap: 3px;
}

.match-archive-compact .rp-strip {
  align-self: center;
  grid-template-columns: repeat(6, 20px);
  align-items: center;
  justify-content: center;
  justify-items: center;
  min-width: 140px;
  gap: 4px;
}

.match-archive-compact .rp-label,
.match-archive-compact .expand-label {
  display: none;
}

.match-archive-compact .rp-icon {
  display: inline-grid;
  width: 20px;
  height: 20px;
  place-items: center;
  border-radius: 5px;
}

.match-archive-compact .rp-icon svg {
  display: block;
  width: 78%;
  height: 78%;
}

.match-archive-compact .match-archive-right {
  grid-area: teams;
  width: 100%;
  justify-content: center;
}

.match-archive-compact .match-archive-teams {
  display: grid;
  grid-template-columns: minmax(0, 178px) 24px minmax(0, 178px);
  align-items: center;
  justify-content: center;
  justify-items: center;
  width: min(100%, 392px);
  margin-inline: auto;
  font-size: 20px;
  gap: 5px;
  overflow: hidden;
  white-space: nowrap;
  text-align: center;
}

.match-archive-compact .match-team-chip {
  width: 84px;
  height: 28px;
  padding: 1px 5px;
  font-size: 16px;
}

.match-archive-compact .match-team-chip-group {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 84px));
  align-items: center;
  justify-content: center;
  justify-items: center;
  width: 100%;
  gap: 4px;
}

@container (max-width: 700px) {
  .match-archive-compact {
    min-height: 124px;
  }

  .match-archive-compact .match-archive-summary {
    min-height: 122px;
    padding: 12px 16px;
    gap: 4px;
  }

  .match-archive-compact .match-summary-title,
  .match-workspace.editing .match-archive-compact .match-summary-title,
  .match-groups:has(.match-archive[open]) .match-archive-compact .match-summary-title {
    min-height: 60px;
  }

  .match-archive-compact .match-archive-summary strong,
  .match-workspace.editing .match-archive-compact .match-summary-title > strong,
  .match-groups:has(.match-archive[open]) .match-archive-compact .match-summary-title > strong {
    left: 2px;
    top: 2px;
    font-size: 30px;
  }

  .match-archive-compact .match-score-with-rp,
  .match-workspace.editing .match-archive-compact .match-score-with-rp,
  .match-groups:has(.match-archive[open]) .match-archive-compact .match-score-with-rp {
    grid-area: score;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    grid-template-areas:
      "redScore blueScore"
      "redRp blueRp";
    margin-inline: auto;
    width: min(58%, 400px);
    max-width: calc(100% - 138px);
    gap: 5px 8px;
  }

  .match-archive-compact .match-score-with-rp > .red-score,
  .match-workspace.editing .match-archive-compact .match-score-with-rp > .red-score,
  .match-groups:has(.match-archive[open]) .match-archive-compact .match-score-with-rp > .red-score {
    grid-area: redScore;
    justify-self: center;
  }

  .match-archive-compact .match-score-with-rp > .blue-score,
  .match-workspace.editing .match-archive-compact .match-score-with-rp > .blue-score,
  .match-groups:has(.match-archive[open]) .match-archive-compact .match-score-with-rp > .blue-score {
    grid-area: blueScore;
    justify-self: center;
  }

  .match-archive-compact .match-score-with-rp > .red-rp,
  .match-workspace.editing .match-archive-compact .match-score-with-rp > .red-rp,
  .match-groups:has(.match-archive[open]) .match-archive-compact .match-score-with-rp > .red-rp {
    grid-area: redRp;
  }

  .match-archive-compact .match-score-with-rp > .blue-rp,
  .match-workspace.editing .match-archive-compact .match-score-with-rp > .blue-rp,
  .match-groups:has(.match-archive[open]) .match-archive-compact .match-score-with-rp > .blue-rp {
    grid-area: blueRp;
  }

  .match-archive-compact .match-score-badge,
  .match-workspace.editing .match-archive-compact .match-score-badge,
  .match-groups:has(.match-archive[open]) .match-archive-compact .match-score-badge {
    font-size: 30px;
  }

  .match-archive-compact .match-score-badge > .red-score,
  .match-archive-compact .match-score-badge > .blue-score,
  .match-workspace.editing .match-archive-compact .match-score-badge > .red-score,
  .match-workspace.editing .match-archive-compact .match-score-badge > .blue-score,
  .match-groups:has(.match-archive[open]) .match-archive-compact .match-score-badge > .red-score,
  .match-groups:has(.match-archive[open]) .match-archive-compact .match-score-badge > .blue-score {
    width: auto;
    min-width: 92px;
    white-space: nowrap;
  }

  .match-archive-compact .rp-strip,
  .match-workspace.editing .match-archive-compact .match-score-with-rp .rp-strip,
  .match-groups:has(.match-archive[open]) .match-archive-compact .rp-strip {
    grid-template-columns: repeat(6, 10px);
    min-width: 70px;
    gap: 2px;
  }

  .match-archive-compact .rp-icon,
  .match-workspace.editing .match-archive-compact .match-score-with-rp .rp-icon,
  .match-groups:has(.match-archive[open]) .match-archive-compact .rp-icon {
    display: block;
    width: 10px;
    height: 10px;
    border-radius: 999px;
  }

  .match-archive-compact .rp-icon svg,
  .match-workspace.editing .match-archive-compact .match-score-with-rp .rp-icon svg,
  .match-groups:has(.match-archive[open]) .match-archive-compact .rp-icon svg {
    display: none;
  }

  .match-archive-compact .match-archive-teams,
  .match-workspace.editing .match-archive-compact .match-archive-teams,
  .match-groups:has(.match-archive[open]) .match-archive-compact .match-archive-teams {
    grid-template-columns: minmax(0, 1fr) 22px minmax(0, 1fr);
    width: min(100%, 392px);
    gap: 4px;
  }

  .match-archive-compact .match-team-chip-group,
  .match-workspace.editing .match-archive-compact .match-team-chip-group,
  .match-groups:has(.match-archive[open]) .match-archive-compact .match-team-chip-group {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: 100%;
    gap: 5px;
  }

  .match-archive-compact .match-team-chip,
  .match-workspace.editing .match-archive-compact .match-team-chip,
  .match-groups:has(.match-archive[open]) .match-archive-compact .match-team-chip {
    width: 100%;
    min-width: 0;
    height: 30px;
    padding-inline: 4px;
    font-size: 15px;
  }
}

@container (max-width: 460px) {
  .match-archive-compact {
    min-height: 120px;
  }

  .match-archive-compact .match-archive-summary {
    min-height: 118px;
    padding: 12px 12px;
    gap: 4px;
  }

  .match-archive-compact .match-summary-title,
  .match-workspace.editing .match-archive-compact .match-summary-title,
  .match-groups:has(.match-archive[open]) .match-archive-compact .match-summary-title {
    min-height: 58px;
  }

  .match-archive-compact .match-archive-summary strong,
  .match-workspace.editing .match-archive-compact .match-summary-title > strong,
  .match-groups:has(.match-archive[open]) .match-archive-compact .match-summary-title > strong {
    font-size: 28px;
  }

  .match-archive-compact .match-score-badge,
  .match-workspace.editing .match-archive-compact .match-score-badge,
  .match-groups:has(.match-archive[open]) .match-archive-compact .match-score-badge {
    font-size: 27px;
  }

  .match-archive-compact .match-score-badge > .red-score,
  .match-archive-compact .match-score-badge > .blue-score,
  .match-workspace.editing .match-archive-compact .match-score-badge > .red-score,
  .match-workspace.editing .match-archive-compact .match-score-badge > .blue-score,
  .match-groups:has(.match-archive[open]) .match-archive-compact .match-score-badge > .red-score,
  .match-groups:has(.match-archive[open]) .match-archive-compact .match-score-badge > .blue-score {
    min-width: 76px;
  }

  .match-archive-compact .match-score-with-rp,
  .match-workspace.editing .match-archive-compact .match-score-with-rp,
  .match-groups:has(.match-archive[open]) .match-archive-compact .match-score-with-rp {
    width: min(60%, 320px);
    max-width: calc(100% - 94px);
    gap: 4px 6px;
  }

  .match-archive-compact .match-team-chip,
  .match-workspace.editing .match-archive-compact .match-team-chip,
  .match-groups:has(.match-archive[open]) .match-archive-compact .match-team-chip {
    height: 28px;
    font-size: 14px;
  }
}

.match-groups:has(.match-expanded-layout) .match-expanded-layout .match-archive,
.match-groups:has(.match-expanded-layout) .match-expanded-layout .match-archive[open] {
  grid-column: auto;
  grid-row: auto;
}

.match-groups:has(.match-expanded-layout) .match-expanded-layout .match-archive[open] {
  position: static;
}

.team-row,
.record-row,
.pick-row {
  display: grid;
  grid-template-columns: 88px minmax(0, 1fr) auto auto;
  gap: 10px;
  align-items: center;
  padding: 12px;
  background: var(--panel-2);
  border-radius: 8px;
}

.score-bar {
  height: 9px;
  border-radius: 999px;
  background: #0d1218;
  overflow: hidden;
}

.score-bar span {
  display: block;
  height: 100%;
  width: 0;
  background: var(--green);
}

.score-bar.danger span {
  background: var(--red);
}

.ranking-panel {
  padding: 0;
}

.official-ranking-panel {
  display: grid;
  gap: 10px;
  margin-bottom: 14px;
  padding: 12px 14px 14px;
}

.official-ranking-head,
.official-ranking-source {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 12px;
}

.official-ranking-head {
  align-items: center;
}

.official-ranking-table-tools {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.official-ranking-mode {
  display: inline-flex;
  align-items: center;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
  flex: 0 0 auto;
}

.official-ranking-mode-button {
  min-height: 30px;
  padding: 0 11px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 900;
  cursor: pointer;
}

.official-ranking-mode-button:hover,
.official-ranking-mode-button:focus-visible,
.official-ranking-mode-button[aria-pressed="true"] {
  background: var(--panel-2);
  color: var(--text);
}

.official-ranking-head h3 {
  margin: 0;
  font-size: 24px;
  line-height: 1.08;
}

.official-ranking-source {
  flex: 0 1 auto;
}

.official-ranking-actions {
  display: flex;
  align-items: end;
  gap: 8px;
}

.official-ranking-actions .primary-button,
.official-ranking-actions .secondary-button {
  min-height: 38px;
  padding-inline: 16px;
}

.official-ranking-source label {
  width: 116px;
  font-weight: 800;
}

.official-ranking-source label:nth-child(2) {
  width: 176px;
}

.official-ranking-status {
  min-width: 0;
  margin: 0;
}

.official-ranking-refresh-bar {
  display: flex;
  align-items: center;
  flex: 0 0 auto;
  gap: 8px;
}

.official-ranking-auto {
  min-height: 38px;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
  font-size: 14px;
  font-weight: 900;
}

.official-ranking-interval {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 900;
}

.official-ranking-interval select {
  width: 104px;
  min-height: 38px;
}

.official-ranking-table-wrap {
  max-height: min(68vh, 820px);
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
}

.official-ranking-table {
  width: 100%;
  min-width: 1180px;
  margin: 0;
  table-layout: fixed;
  border-collapse: separate;
  border-spacing: 0;
  font-variant-numeric: tabular-nums;
}

.official-ranking-table[data-ranking-mode="standard"] {
  min-width: 1060px;
}

.official-ranking-table[data-ranking-mode="tactical"] {
  min-width: 1340px;
}

.official-ranking-table[data-ranking-mode="tactical"] th {
  padding-right: 10px;
  padding-left: 10px;
}

.official-ranking-rank-col {
  width: 88px;
}

.official-ranking-team-col {
  width: 320px;
}

.official-ranking-rs-col {
  width: 8.5%;
}

.official-ranking-opr-col {
  width: 9%;
}

.official-ranking-points-col {
  width: 10%;
}

.official-ranking-record-col {
  width: 9.5%;
}

.official-ranking-plays-col {
  width: 7%;
}

.official-ranking-confidence-col {
  width: 110px;
}

.official-ranking-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  background: #172231;
  color: var(--muted);
  font-size: 13px;
  font-weight: 900;
  white-space: nowrap;
}

.official-ranking-table th[data-official-column="rank"],
.official-ranking-table td[data-official-column="rank"] {
  position: sticky;
  left: 0;
  z-index: 5;
}

.official-ranking-table th[data-official-column="team"],
.official-ranking-table td[data-official-column="team"] {
  position: sticky;
  left: 88px;
  z-index: 5;
  box-shadow: 2px 0 0 rgba(148, 163, 184, 0.2);
}

.official-ranking-table th[data-official-column="rank"],
.official-ranking-table th[data-official-column="team"] {
  z-index: 8;
  background: #172231;
}

.official-ranking-sort {
  width: 100%;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.official-ranking-table[data-ranking-mode="tactical"] .official-ranking-sort {
  gap: 5px;
}

.official-ranking-static-head {
  text-align: left;
}

.official-ranking-sort:hover,
.official-ranking-sort:focus-visible,
.official-ranking-sort[aria-pressed="true"] {
  color: var(--accent);
}

.official-ranking-active-head {
  background: linear-gradient(180deg, rgba(56, 189, 248, 0.18), rgba(56, 189, 248, 0.08)), #172231;
}

.official-ranking-sort .sort-indicator {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 9px;
  min-width: 9px;
  height: 9px;
  color: var(--muted);
}

.official-ranking-sort[data-sort-direction="asc"] .sort-indicator::before {
  content: "";
  width: 0;
  height: 0;
  border-right: 4px solid transparent;
  border-left: 4px solid transparent;
  border-bottom: 6px solid currentColor;
}

.official-ranking-sort[data-sort-direction="desc"] .sort-indicator::before {
  content: "";
  width: 0;
  height: 0;
  border-right: 4px solid transparent;
  border-left: 4px solid transparent;
  border-top: 6px solid currentColor;
}

.official-ranking-table td {
  padding: 12px 14px;
  border-bottom: 1px solid rgba(148, 163, 184, 0.16);
  font-size: 16px;
  font-weight: 800;
  white-space: nowrap;
}

.official-ranking-table td[data-official-column="rank"],
.official-ranking-table td[data-official-column="team"] {
  background: var(--surface-2) !important;
}

.official-ranking-table tbody tr:nth-child(odd) td {
  background: rgba(255, 255, 255, 0.02);
}

.official-ranking-table tbody tr:nth-child(odd) td[data-official-column="rank"],
.official-ranking-table tbody tr:nth-child(odd) td[data-official-column="team"] {
  background: var(--panel-2) !important;
}

.official-ranking-table tbody tr:hover td[data-official-column="rank"],
.official-ranking-table tbody tr:hover td[data-official-column="team"] {
  background: var(--panel-3) !important;
}

.official-ranking-table tbody tr:hover td {
  background: rgba(56, 189, 248, 0.08);
}

.official-ranking-table td.official-ranking-active-cell {
  background: linear-gradient(90deg, rgba(8, 145, 178, 0.18), rgba(56, 189, 248, 0.08)) !important;
  box-shadow: inset 2px 0 0 rgba(8, 145, 178, 0.72);
}

.official-ranking-table tbody tr:hover td.official-ranking-active-cell {
  background: linear-gradient(90deg, rgba(8, 145, 178, 0.24), rgba(56, 189, 248, 0.12)) !important;
}

.official-rank-cell {
  width: 72px;
  color: var(--accent);
  font-size: 18px;
}

.official-team-cell {
  min-width: 0;
  max-width: 320px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.official-opr-cell {
  color: var(--accent);
  font-weight: 900;
}

.official-epa-cell {
  color: var(--green);
  font-weight: 900;
}

.official-adjusted-epa-cell {
  color: var(--yellow);
  font-weight: 900;
}

.official-confidence-cell {
  color: var(--muted);
  font-size: 14px;
}

.official-ranking-empty td {
  color: var(--muted);
  text-align: center;
}

.ranking-summary {
  display: block;
  padding: 12px 16px;
  cursor: pointer;
  list-style: none;
}

.ranking-summary::-webkit-details-marker {
  display: none;
}

.ranking-summary h3 {
  margin: 0;
  min-width: 0;
  line-height: 1.12;
  overflow-wrap: anywhere;
}

.ranking-summary-head {
  min-height: 34px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
}

.ranking-preview-list {
  display: grid;
  gap: 8px;
  padding-top: 10px;
}

.ranking-preview-list .team-row {
  padding: 9px 10px;
  background: var(--panel);
}

.ranking-panel[open] .ranking-preview-list {
  display: none;
}

.ranking-panel[open] .expand-open {
  display: none;
}

.ranking-panel[open] .expand-close {
  display: inline;
}

.ranking-panel-body {
  padding: 0 16px 16px;
}

.team-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.pit-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 14px;
}

#pit.view.active {
  width: 100%;
  margin-inline: 0;
  max-width: none;
  min-width: 0;
}

.pit-browser-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 0.42fr);
  gap: 14px;
  align-items: start;
}

.pit-compare-layout {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  align-items: start;
}

.pit-compare-browser {
  display: grid;
  gap: 14px;
  align-items: start;
}

.pit-compare-list {
  grid-column: 1 / -1;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  max-height: 300px;
}

.pit-compare-layout .pit-archive-body {
  grid-template-columns: minmax(130px, 170px) minmax(0, 1fr);
  gap: 10px;
  padding: 10px;
}

.pit-compare-layout .pit-archive .pit-fields-panel {
  gap: 8px;
}

.pit-compare-layout .pit-archive .pit-fields-panel .choice-group {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  column-gap: 8px;
  row-gap: 6px;
  padding: 8px 10px;
}

.pit-compare-layout .pit-archive .pit-feature-checks {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.pit-compare-layout .pit-archive .photo-preview {
  max-height: 170px;
}

.pit-compare-layout .pit-archive .pit-notes-field textarea {
  min-height: 274px;
}

.pit-compare-layout .pit-archive .pit-number-grid {
  gap: 8px;
}

.pit-detail-pane,
.pit-list-column {
  min-width: 0;
}

.pit-list-column {
  display: grid;
  gap: 12px;
  align-content: start;
}

.pit-list-only {
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
}

.pit-mini-list {
  min-width: 0;
  min-height: min(320px, calc(100dvh - 24px));
  max-height: min(760px, calc(100dvh - 24px));
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.035);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.035);
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
}

.pit-browser-layout .pit-mini-list,
#pit.view.active:has(#pitForm:not([hidden])) #pitCards .pit-mini-list {
  grid-template-columns: 1fr;
}

#pit.view.active:has(#pitForm:not([hidden])) {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(340px, 0.65fr);
  gap: 0 clamp(12px, 1.1vw, 18px);
  align-items: start;
}

#pit.view.active:has(#pitForm:not([hidden])) .pit-editor-tab {
  grid-column: 1 / -1;
}

#pit.view.active:has(#pitForm:not([hidden])) #pitForm {
  grid-column: 1;
  margin-bottom: 0;
}

#pit.view.active:has(#pitForm:not([hidden])) #pitCards {
  grid-column: 2;
  width: 100%;
  min-width: 0;
  min-height: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.035);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.035);
  overflow-y: auto;
  scrollbar-gutter: stable;
}

#pit.view.active:has(#pitForm:not([hidden])) #pitCards > .pit-list-column,
#pit.view.active:has(#pitForm:not([hidden])) #pitCards .pit-browser-layout,
#pit.view.active:has(#pitForm:not([hidden])) #pitCards .pit-compare-browser {
  min-height: 0;
}

#pit.view.active:has(#pitForm:not([hidden])) #pitCards .pit-editor-mini-list {
  max-height: none;
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
  overflow: visible;
}

@media (max-width: 1480px), (orientation: portrait), (max-aspect-ratio: 4 / 3) {
  #pit.view.active:has(#pitForm:not([hidden])) {
    grid-template-columns: 1fr;
    gap: 14px;
  }

  #pit.view.active:has(#pitForm:not([hidden])) #pitForm,
  #pit.view.active:has(#pitForm:not([hidden])) #pitCards {
    grid-column: 1;
  }

  #pit.view.active:has(#pitForm:not([hidden])) #pitCards {
    height: auto !important;
    max-height: min(720px, calc(100dvh - 24px)) !important;
  }
}

@media (max-width: 1240px), (orientation: portrait) {
  .pit-browser-layout,
  .pit-compare-browser {
    grid-template-columns: 1fr;
  }

  .pit-compare-layout {
    grid-template-columns: 1fr;
  }

  .pit-mini-list {
    max-height: 360px;
  }
}

.pit-card {
  padding: 15px;
}

.team-card {
  padding: 12px;
}

.team-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.team-card-head h3 {
  font-size: 20px;
}

.team-rank-metrics {
  display: grid;
  grid-template-columns: repeat(2, minmax(54px, auto));
  gap: 8px 12px;
  color: var(--muted);
  text-align: right;
}

.team-rank-metrics div {
  display: grid;
  gap: 3px;
  justify-items: end;
}

.team-rank-metric {
  color: var(--muted);
}

.team-rank-epa {
  color: var(--team-epa-color);
}

.team-rank-qual {
  color: var(--team-qual-rank-color);
}

.team-rank-metrics span {
  font-size: 10px;
  font-weight: 900;
  line-height: 1;
  opacity: 0.82;
  text-transform: uppercase;
}

.team-rank-metrics strong {
  color: currentColor;
  font-size: 18px;
  line-height: 1;
}

.pit-archive {
  padding: 0;
}

.pit-archive-compact .pit-archive-summary {
  cursor: default;
}

.pit-editor-tab,
.editor-tab {
  padding: 0;
  margin-bottom: 14px;
}

#matchEditorTab {
  position: static;
  top: auto;
  z-index: auto;
  background: var(--card);
  box-shadow: var(--shadow-sm);
}

.pit-editor-tab-head {
  min-height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 24px;
}

.pit-editor-title {
  min-width: 0;
}

.pit-editor-title h2 {
  margin: 0;
  font-size: 28px;
  line-height: 1.08;
}

.pit-editor-tab-head .eyebrow {
  margin-bottom: 4px;
}

.pit-editor-tab-head .primary-button {
  flex: 0 0 auto;
}

.form-grid[hidden] {
  display: none;
}

.pit-archive-summary {
  min-height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 0 20px;
  cursor: pointer;
  list-style: none;
}

.pit-archive-summary::-webkit-details-marker {
  display: none;
}

.pit-archive-summary strong {
  font-size: clamp(28px, 2vw, 34px);
}

.pit-archive-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.pit-archive-actions .small-button {
  min-width: 120px;
  min-height: 46px;
  padding: 8px 14px;
  font-size: 16px;
}

.pit-archive-status {
  min-width: 92px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.05);
  color: var(--muted);
  font-size: 13px;
  font-weight: 850;
  text-align: center;
}

.pit-archive-status.is-duplicate {
  border-color: rgba(248, 113, 113, 0.72);
  background: rgba(248, 113, 113, 0.14);
  color: #fecaca;
}

.pit-archive-status.is-empty {
  border-color: rgba(148, 163, 184, 0.28);
  background: rgba(148, 163, 184, 0.08);
  color: #9fb0c4;
}

.pit-archive-status.is-complete {
  border-color: rgba(56, 189, 248, 0.52);
  background: rgba(56, 189, 248, 0.13);
  color: #bae6fd;
}

.pit-archive-compact.is-duplicate {
  border-color: rgba(248, 113, 113, 0.82);
  box-shadow: inset 0 0 0 1px rgba(248, 113, 113, 0.22);
}

.pit-archive.is-empty {
  border-color: rgba(148, 163, 184, 0.18);
  background: rgba(15, 23, 42, 0.42);
  opacity: 0.68;
}

.pit-archive.is-empty .pit-archive-summary strong {
  color: #8ea0b8;
}

.pit-archive.is-complete {
  border-color: rgba(56, 189, 248, 0.46);
  background: rgba(56, 189, 248, 0.07);
  box-shadow: inset 0 0 0 1px rgba(56, 189, 248, 0.08);
}

.expand-label {
  flex: 0 0 auto;
  min-width: 92px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
  color: var(--text);
  font-size: 13px;
  font-weight: 800;
  text-align: center;
}

.expand-close,
.pit-archive[open] .expand-open {
  display: none;
}

.pit-archive[open] .expand-close {
  display: inline;
}

.pit-archive-body {
  display: grid;
  grid-template-columns: minmax(145px, 190px) minmax(0, 1fr);
  align-items: start;
  gap: 12px;
  padding: 12px;
  border-top: 1px solid var(--line);
}

.pit-detail-modal .pit-archive-body {
  align-items: stretch;
}

.pit-detail-modal .pit-identity-panel {
  align-self: stretch;
  align-items: stretch;
  grid-template-rows: auto auto minmax(150px, 1fr);
}

.pit-detail-modal .pit-notes-field {
  align-self: stretch;
  min-height: 0;
}

.pit-detail-modal .pit-notes-field textarea {
  height: 100%;
}

@media (max-width: 1100px) {
  .pit-archive-body {
    grid-template-columns: minmax(135px, 180px) minmax(0, 1fr);
  }
}

.pit-archive-edit-head {
  grid-column: 1 / -1;
  margin-bottom: 0;
}

.pit-archive input:disabled,
.pit-archive textarea:disabled {
  opacity: 1;
  color: var(--text);
  -webkit-text-fill-color: var(--text);
}

.pit-archive input[type="checkbox"]:disabled {
  accent-color: var(--accent);
}

.pit-archive .pit-fields-panel {
  gap: 9px;
}

.pit-archive .pit-fields-panel .choice-group {
  grid-template-columns: repeat(3, minmax(72px, 1fr));
  column-gap: 10px;
  row-gap: 6px;
  padding: 10px 12px;
}

.pit-archive .pit-fields-panel .auto-path-group {
  grid-template-columns: repeat(4, max-content);
  justify-content: space-between;
  column-gap: clamp(8px, 2.2vw, 28px);
}

.pit-archive .inline-number-field {
  white-space: normal;
}

.pit-archive .pit-fields-panel .choice-group legend {
  font-size: 16px;
}

.pit-archive .readonly-check {
  min-height: 28px;
  padding: 4px 2px;
  border: 1px solid transparent;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 700;
  color: rgba(154, 168, 182, 0.72);
  gap: 6px;
  min-width: 0;
}

.pit-archive .readonly-check input {
  flex: 0 0 auto;
}

.pit-archive .readonly-check.is-selected {
  border-color: transparent;
  background: transparent;
  color: var(--text);
  font-size: 14px;
  font-weight: 850;
}

.pit-archive .readonly-check.is-selected input {
  filter: none;
}

.pit-archive .feature-check {
  min-height: 38px;
  padding: 8px;
  border-color: var(--line);
  background: rgba(255, 255, 255, 0.03);
  font-size: 15px;
  font-weight: 800;
  line-height: 1.18;
}

.pit-archive .inline-number-field {
  min-height: 34px;
  padding: 0 2px;
}

.pit-archive .pit-number-grid {
  gap: 12px;
}

.pit-archive .pit-feature-checks {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.03);
}

.pit-archive .photo-preview {
  aspect-ratio: 1 / 1;
  max-height: 190px;
}

.pit-archive .pit-notes-field textarea {
  min-height: 76px;
}

.pit-archive .pit-notes-field {
  display: grid;
  align-content: start;
  gap: 8px;
  padding: 10px 12px;
  color: var(--text);
  font-size: 20px;
  font-weight: 900;
  line-height: 1.05;
}

.pit-archive .pit-notes-field textarea {
  min-height: 132px;
  font-size: 14px;
  font-weight: 700;
  line-height: 1.28;
  resize: none;
}

.pit-compare-layout .pit-archive .pit-notes-field textarea {
  min-height: 274px;
}

.pit-archive .pit-fields-panel .choice-group legend,
.pit-archive .inline-number-field,
.pit-archive .feature-check,
.pit-archive .readonly-check,
.pit-archive .readonly-check.is-selected,
.pit-archive .pit-fields-panel .choice-group .checkbox-row {
  font-size: 20px;
  font-weight: 900;
  line-height: 1.05;
}

.pit-archive .inline-number-field input {
  font-size: 20px;
  font-weight: 900;
}

.pit-archive .pit-fields-panel .choice-group .checkbox-row input,
.pit-archive .feature-check input {
  width: 28px;
  min-width: 28px;
  min-height: 28px;
}

.pit-photo,
.pit-photo-placeholder {
  width: 100%;
  aspect-ratio: 1 / 1;
  margin-bottom: 0;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #0d1218;
}

.pit-photo {
  display: block;
  object-fit: cover;
}

.pit-photo-placeholder {
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 13px;
}

.stat-line {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 0;
  border-bottom: 1px solid var(--line);
}

.stat-line:last-child {
  border-bottom: 0;
}

.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 12px;
}

.tag {
  padding: 5px 8px;
  border-radius: 999px;
  background: #0d1218;
  color: var(--muted);
  font-size: 12px;
}

.team-card-actions {
  position: relative;
  --team-pit-button-width: 110px;
  --team-action-gap: 10px;
  margin-top: 10px;
}

.team-card .stat-line {
  padding: 6px 0;
  font-size: 13px;
}

.team-card .stat-line strong {
  font-size: 14px;
}

.team-card .tag-row {
  gap: 5px;
  margin-top: 8px;
}

.team-card .tag {
  padding: 4px 7px;
  font-size: 11px;
}

.team-match-reports {
  margin-top: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.026);
  overflow: hidden;
}

.team-card-actions .team-match-reports {
  margin-top: 0;
  border: 0;
  background: transparent;
  overflow: visible;
}

.team-match-reports summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 38px;
  padding: 8px 10px;
  cursor: pointer;
  list-style: none;
  color: var(--text);
  font-size: 13px;
  font-weight: 850;
}

.team-card-actions .team-match-reports summary {
  margin-right: calc(var(--team-pit-button-width) + var(--team-action-gap));
  justify-content: flex-start;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.026);
}

.team-card-actions .team-match-reports summary strong {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 22px;
  min-width: 26px;
  margin-left: 6px;
  padding: 0 7px;
  font-size: 11px;
  line-height: 1;
}

.team-match-reports summary::-webkit-details-marker {
  display: none;
}

.team-match-reports summary strong {
  min-width: 30px;
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  text-align: center;
}

.team-match-report-list {
  display: grid;
  gap: 6px;
  padding: 8px;
  border-top: 1px solid var(--line);
}

.team-card-actions .team-match-report-list {
  margin-top: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.026);
}

.team-match-report-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
}

.team-match-report-row {
  position: relative;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
  color: var(--text);
  font-size: 12px;
  font-weight: 850;
}

.team-match-report-row::before {
  content: "";
  position: absolute;
  inset: 7px auto 7px 0;
  width: 3px;
  border-radius: 0 999px 999px 0;
  background: var(--muted);
}

.team-match-report-row.team-report-red::before {
  background: var(--red);
}

.team-match-report-row.team-report-blue::before {
  background: var(--blue);
}

.team-match-report-main {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.team-match-report-main strong {
  font-size: 13px;
}

.team-match-alliance {
  padding: 2px 6px;
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.14);
  color: var(--muted);
  font-size: 10px;
  font-weight: 900;
  text-transform: uppercase;
}

.team-match-alliance.red {
  background: rgba(239, 68, 68, 0.14);
  color: #fecaca;
}

.team-match-alliance.blue {
  background: rgba(59, 130, 246, 0.16);
  color: #bfdbfe;
}

@media (max-width: 560px) {
  .team-card-actions {
    --team-pit-button-width: 96px;
    --team-action-gap: 10px;
  }

  .team-match-report-row {
    padding: 9px 12px;
  }

  .team-match-report-row > .small-button {
    min-width: 64px;
  }
}

.team-match-report-row > .small-button {
  justify-self: end;
  width: 72px;
  min-height: 28px;
  padding: 4px 9px;
  font-size: 11px;
}

.team-match-empty {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

.team-card-actions .secondary-button {
  position: absolute;
  top: 0;
  right: 0;
  width: var(--team-pit-button-width);
  min-height: 38px;
  font-size: 13px;
}

.team-card-actions .team-pit-button.has-pit {
  border-color: rgba(22, 163, 74, 0.42);
  background: #dcfce7;
  color: #14532d;
}

.team-card-actions .team-pit-button.has-pit:hover {
  border-color: rgba(22, 163, 74, 0.62);
  background: #bbf7d0;
}

.team-card-actions .team-pit-button.missing-pit {
  border-color: rgba(239, 68, 68, 0.34);
  background: #fee2e2;
  color: #7f1d1d;
}

.team-card-actions .team-pit-button.missing-pit:hover {
  border-color: rgba(239, 68, 68, 0.55);
  background: #fecaca;
}

body.theme-dark .team-card-actions .team-pit-button.has-pit {
  border-color: rgba(34, 197, 94, 0.48);
  background: rgba(22, 101, 52, 0.48);
  color: #dcfce7;
}

body.theme-dark .team-card-actions .team-pit-button.has-pit:hover {
  background: rgba(22, 163, 74, 0.58);
}

body.theme-dark .team-card-actions .team-pit-button.missing-pit {
  border-color: rgba(248, 113, 113, 0.46);
  background: rgba(127, 29, 29, 0.46);
  color: #fee2e2;
}

body.theme-dark .team-card-actions .team-pit-button.missing-pit:hover {
  background: rgba(185, 28, 28, 0.56);
}

.red {
  color: #fecaca;
}

.blue {
  color: #bfdbfe;
}

.delete-button {
  border: 0;
  background: transparent;
  color: #fca5a5;
  cursor: pointer;
}

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

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(0, 0, 0, 0.68);
}

.modal-backdrop[hidden] {
  display: none;
}

.detail-modal {
  width: min(980px, 100%);
  max-height: min(780px, calc(100vh - 36px));
  overflow: auto;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 24px 90px rgba(0, 0, 0, 0.42);
}

.pit-detail-modal {
  width: min(1120px, 100%);
}

.pit-detail-modal .pit-archive-body {
  padding: 12px 0 0;
}

.pit-modal-empty {
  display: grid;
  gap: 14px;
  justify-items: start;
  padding: 18px 0 4px;
}

.photo-gallery-modal {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 8px;
  width: min(1640px, calc(100vw - 64px));
  max-width: calc(100vw - 64px);
  height: min(940px, calc(100dvh - 24px));
  max-height: calc(100dvh - 24px);
  margin: 0 auto;
  padding: 10px;
  overflow: hidden;
}

.photo-gallery-modal .panel-head {
  min-height: 42px;
  margin-bottom: 0;
}

.photo-gallery-modal .eyebrow {
  margin-bottom: 2px;
  font-size: 11px;
  line-height: 1;
}

.photo-gallery-modal h2 {
  font-size: 24px;
  line-height: 1.05;
}

.photo-gallery-modal #closePitPhotoGallery {
  min-height: 32px;
  padding: 0 12px;
  font-size: 14px;
}

.photo-gallery-stage {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 0;
  padding: 0;
  overflow: hidden;
  background: #05080c;
}

.photo-gallery-stage img {
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  display: block;
  object-fit: contain;
  border: 0;
  border-radius: 0;
  background: transparent;
}

.photo-gallery-stage[data-view-mode="fill"] img {
  object-fit: cover;
}

.gallery-arrow {
  position: absolute;
  top: 50%;
  z-index: 2;
  min-height: 100%;
  width: 96px;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: rgba(255, 255, 255, 0);
  font-size: 52px;
  font-weight: 500;
  text-shadow: 0 3px 18px rgba(0, 0, 0, 0);
  transform: translateY(-50%);
  transition: color 120ms ease, background 120ms ease, text-shadow 120ms ease;
}

.gallery-arrow:first-of-type {
  left: 0;
}

.gallery-arrow:last-of-type {
  right: 0;
}

.photo-gallery-stage:hover .gallery-arrow:not(:disabled),
.gallery-arrow:focus-visible {
  color: rgba(255, 255, 255, 0.86);
  text-shadow: 0 3px 18px rgba(0, 0, 0, 0.72);
}

.gallery-arrow:first-of-type:hover,
.gallery-arrow:first-of-type:focus-visible {
  background: linear-gradient(90deg, rgba(0, 0, 0, 0.42), rgba(0, 0, 0, 0));
}

.gallery-arrow:last-of-type:hover,
.gallery-arrow:last-of-type:focus-visible {
  background: linear-gradient(270deg, rgba(0, 0, 0, 0.42), rgba(0, 0, 0, 0));
}

.gallery-arrow:disabled {
  opacity: 0;
  cursor: default;
}

.photo-gallery-footer {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 38px;
  padding: 6px 0 0;
  border-top: 1px solid rgba(148, 163, 184, 0.18);
  background: var(--surface);
  color: var(--muted);
  font-size: 14px;
  font-weight: 900;
  flex-wrap: wrap;
}

.photo-gallery-footer span {
  min-height: 28px;
  display: inline-flex;
  align-items: center;
}

.photo-original-link {
  min-height: 30px;
  padding: 4px 10px;
  font-size: 13px;
}

.photo-original-link[hidden] {
  display: none;
}

.photo-delete-button {
  min-height: 30px;
  padding: 4px 10px;
  font-size: 13px;
  font-weight: 900;
}

.photo-fit-button {
  min-height: 30px;
  padding: 4px 10px;
  font-size: 13px;
  font-weight: 900;
}

.photo-cover-button {
  min-height: 30px;
  padding: 4px 10px;
  font-size: 13px;
  font-weight: 900;
}

.photo-cover-button:disabled {
  opacity: 0.58;
  cursor: default;
}

.photo-delete-button[hidden] {
  display: none;
}

.detail-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.detail-summary div,
.detail-section {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.detail-summary span {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 12px;
}

.detail-summary .reference-ok {
  color: #7dd3fc;
}

.detail-summary .reference-warning {
  color: #fbbf24;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.detail-section h3 {
  margin-bottom: 8px;
}

@media (max-width: 900px) {
  .sidebar {
    padding: 10px;
  }

  .nav-item {
    margin: 0;
    text-align: center;
  }

  .metrics-grid,
  .split-grid,
  .single-grid,
  .team-grid,
  .pit-grid,
  .alliance-lanes,
  .match-groups:has(.match-archive[open]),
  .detail-summary,
  .detail-grid {
    grid-template-columns: 1fr;
  }

  .match-groups:has(.match-archive[open]) .match-archive,
  .match-groups:has(.match-archive[open]) .match-archive[open] {
    grid-column: 1;
    grid-row: auto;
  }

  .form-grid,
  .form-section,
  .pit-form,
  .event-form,
  .import-panel {
    grid-template-columns: 1fr 1fr;
  }

  #matchForm {
    width: 100%;
    margin-left: 0;
    grid-template-columns: repeat(2, minmax(140px, 220px)) minmax(180px, 260px);
  }

  .import-panel {
    align-items: start;
  }

  .event-strip {
    grid-template-columns: 1fr;
  }

  .event-current-row,
  .event-import-form {
    grid-template-columns: 1fr;
  }

  .active-event-label {
    padding-bottom: 0;
  }

  .import-copy,
  .import-controls,
  .import-status {
    grid-column: 1 / -1;
  }

  .import-copy {
    padding-bottom: 0;
  }

  .event-form button {
    min-height: 42px;
  }

  .import-controls {
    grid-template-columns: minmax(110px, 0.75fr) minmax(160px, 1fr) max-content max-content;
    justify-content: stretch;
  }

  .field-cluster,
  .numeric-cluster {
    grid-template-columns: 1fr;
  }

  .pit-fields-panel .auto-path-group,
  .pit-archive .pit-fields-panel .auto-path-group {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .auto-path-group .auto-color-check {
    grid-column: auto !important;
  }

  .form-section,
  .form-section h3,
  .wide,
  .form-actions {
    grid-column: span 2;
  }
}

@media (min-width: 700px) and (max-width: 900px) {
  .metrics-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 1100px), (max-aspect-ratio: 4 / 3) {
  .match-expanded-layout {
    grid-template-columns: 1fr;
  }

  .match-expanded-detail,
  .match-expanded-detail > .match-archive {
    min-width: 0;
    width: 100%;
  }

  .alliance-lanes,
  .match-groups:has(.match-archive[open]),
  .detail-summary,
  .detail-grid {
    grid-template-columns: 1fr;
  }

  .match-groups:has(.match-archive[open]) .match-archive,
  .match-groups:has(.match-archive[open]) .match-archive[open] {
    grid-column: 1;
    grid-row: auto;
    min-width: 0;
  }
}

@media (max-width: 560px) {
  :root {
    --content-pad: 14px;
  }

  .decode-logo {
    display: none;
  }

  .topbar,
  .section-head,
  .panel-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .content {
    padding: var(--content-pad);
  }

  .form-grid,
  .form-section,
  .event-form,
  .import-panel {
    grid-template-columns: minmax(0, 1fr);
  }

  .settings-block {
    grid-template-columns: minmax(0, 1fr);
  }

  .pit-fields-panel .auto-path-group,
  .pit-archive .pit-fields-panel .auto-path-group {
    grid-template-columns: 1fr;
  }

  .auto-path-group .auto-color-check {
    grid-column: 1 !important;
  }

  #matchForm {
    width: 100%;
    grid-template-columns: 1fr;
  }

  #matchForm .match-id-field,
  #matchForm .alliance-choice,
  #matchForm .base-field {
    grid-column: 1;
    grid-row: auto;
    max-width: none;
  }

  .import-controls {
    grid-template-columns: 1fr 1fr;
  }

  .import-controls button {
    min-height: 42px;
  }

  .field-cluster,
  .numeric-cluster,
  .pit-form,
  .pit-archive-body,
  .pit-archive-fields,
  .pit-fields-panel,
  .pit-feature-checks,
  .pit-number-grid {
    grid-template-columns: 1fr;
  }

  .pit-fields-panel .choice-group,
  .pit-archive .pit-fields-panel .choice-group {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .form-section,
  .form-section h3,
  .wide,
  .form-actions {
    grid-column: span 1;
  }

  .team-row,
  .record-row,
  .pick-row {
    grid-template-columns: 1fr;
  }

  .table-actions {
    flex-direction: column;
    align-items: flex-start;
  }
}

/* iPhone-specific layout: keep tablet/desktop tuning intact above this width. */
@media (max-width: 480px) {
  :root {
    --topbar-height: 104px;
    --content-pad: 10px;
  }

  .topbar {
    min-height: var(--topbar-height);
    padding: 8px 10px;
  }

  .brand-title {
    grid-template-columns: minmax(0, 1fr) auto auto auto;
    gap: 7px;
  }

  .brand-text {
    grid-column: 1;
    min-width: 0;
    overflow: hidden;
    font-size: 19px;
    text-overflow: ellipsis;
  }

  .decode-lockup {
    display: none;
  }

  .global-event-button {
    grid-column: 1 / -1;
    order: 2;
    min-height: 42px;
    padding: 6px 9px;
  }

  .global-event-button span {
    font-size: 10px;
  }

  .global-event-button strong {
    font-size: 14px;
  }

  .global-account {
    grid-column: 2 / -1;
    justify-content: flex-end;
    gap: 5px;
  }

  .theme-toggle,
  .global-account-button,
  .global-logout {
    min-width: 38px;
    width: 38px;
    max-width: 38px;
    height: 38px;
    min-height: 38px;
    padding: 0;
  }

  .global-account-button span {
    font-size: 0;
  }

  .global-account-button span::before {
    content: "ME";
    font-size: 11px;
  }

  .global-logout::before {
    content: "Exit";
    font-size: 12px;
  }

  .sidebar {
    gap: 5px;
    padding: 7px 8px;
    scrollbar-width: none;
  }

  .sidebar::-webkit-scrollbar {
    display: none;
  }

  .nav-item {
    flex: 1 1 0;
    flex-basis: auto;
    min-width: 0;
    min-height: 38px;
    padding: 0 4px;
    font-size: clamp(11px, 3.1vw, 13px);
    line-height: 1.08;
  }

  .nav-item.active::after {
    left: 8px;
    right: 8px;
    bottom: 5px;
  }

  .section-head,
  .panel-head,
  .pit-editor-tab-head {
    gap: 10px;
    padding-inline: 14px;
  }

  .pit-editor-title h2,
  .section-head h2 {
    font-size: 26px;
  }

  .pit-editor-tab-head .primary-button,
  .section-actions .primary-button,
  .section-actions .secondary-button,
  .section-actions .search-input {
    width: 100%;
  }

  .pit-progress {
    grid-template-columns: 1fr;
    width: 100%;
    min-width: 0;
  }

  .pit-progress-meta {
    white-space: normal;
  }

  .pit-mini-list,
  .pit-list-only {
    grid-template-columns: 1fr;
    gap: 9px;
    padding: 9px;
  }

  .pit-archive-summary {
    min-height: 58px;
    padding: 0 12px;
  }

  .pit-archive-summary strong {
    font-size: 28px;
  }

  .pit-archive-actions .small-button {
    min-width: 92px;
    min-height: 40px;
    font-size: 14px;
  }

  .match-editor-head h3,
  .match-workspace.editing #matchForm .match-editor-head h3 {
    font-size: 22px;
  }

  .match-editor-head .secondary-button,
  .match-workspace.editing #matchForm .match-editor-head .secondary-button {
    min-width: 92px;
    min-height: 38px;
    font-size: 14px;
  }

  #matchForm {
    gap: 10px;
    padding: 12px;
  }

  #matchForm .match-id-field {
    grid-template-columns: 86px minmax(0, 1fr);
    font-size: 22px;
  }

  #matchForm .match-id-field input,
  .match-workspace.editing #matchForm .match-id-field input {
    min-height: 44px;
    font-size: 24px;
  }

  #matchForm .alliance-choice {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-template-rows: auto 46px;
    min-height: 76px;
  }

  #matchForm .alliance-choice legend {
    grid-column: 1 / -1;
    position: static;
    width: auto;
    height: auto;
    margin: 0;
    overflow: visible;
    clip: auto;
    white-space: normal;
    font-size: 18px;
  }

  #matchForm .alliance-card,
  .match-workspace.editing #matchForm .alliance-card {
    min-height: 46px;
    font-size: 16px;
  }

  #matchForm .auto-section h3,
  #matchForm .teleop-section h3,
  #matchForm .endgame-section h3,
  .match-workspace.editing #matchForm .auto-section h3,
  .match-workspace.editing #matchForm .teleop-section h3,
  .match-workspace.editing #matchForm .endgame-section h3 {
    width: min(86%, 520px);
    height: 58px;
    font-size: 30px;
  }

  #matchForm .form-section {
    gap: 9px;
    padding: 10px;
  }

  #matchForm .checkbox-row,
  .match-workspace.editing #matchForm .checkbox-row {
    min-height: 58px;
    gap: 10px;
    font-size: 19px;
  }

  #matchForm .checkbox-row input,
  .match-workspace.editing #matchForm .checkbox-row input {
    width: 30px;
    min-width: 30px;
    min-height: 30px;
  }

  #matchForm .counter-control,
  .match-workspace.editing #matchForm .counter-control {
    grid-template-columns: 44px minmax(72px, 1fr) 44px;
    min-height: 48px;
  }

  #matchForm .counter-control input,
  .match-workspace.editing #matchForm .counter-control input {
    min-height: 48px;
    font-size: 25px;
  }

  #matchForm .counter-control button,
  .match-workspace.editing #matchForm .counter-control button {
    font-size: 26px;
  }

  #matchForm .auto-section .field-cluster,
  #matchForm .auto-section .numeric-cluster {
    grid-auto-rows: 68px;
  }

  #matchForm .counter-field,
  .match-workspace.editing #matchForm .counter-field {
    font-size: 15px;
  }

  .match-groups > .match-archive:not([open]):not(.match-archive-compact) .match-archive-summary,
  .match-workspace.editing .match-archive-summary {
    min-height: 104px;
    padding: 12px;
  }

  .match-groups > .match-archive:not([open]):not(.match-archive-compact) .match-summary-title > strong,
  .match-workspace.editing .match-summary-title > strong {
    min-width: 58px;
    font-size: 32px;
  }

  .match-groups > .match-archive:not([open]):not(.match-archive-compact) .match-score-badge,
  .match-workspace.editing .match-score-badge {
    font-size: 25px;
  }

  .match-groups > .match-archive:not([open]):not(.match-archive-compact) .match-archive-teams,
  .match-workspace.editing .match-groups > .match-archive:not([open]):not(.match-archive-compact) .match-archive-teams {
    width: 100%;
    grid-template-columns: minmax(0, 1fr) 24px minmax(0, 1fr);
  }

  .match-groups > .match-archive:not([open]):not(.match-archive-compact) .match-team-chip,
  .match-workspace.editing .match-team-chip {
    height: 30px;
    font-size: 15px;
  }

  .match-groups > .match-archive:not([open]):not(.match-archive-compact) .expand-label {
    min-width: 76px;
    min-height: 32px;
    font-size: 13px;
  }
}

@media (orientation: landscape) and (max-height: 620px) {
  :root {
    --content-pad: 12px;
  }

  .topbar {
    min-height: 56px;
    padding: 8px 14px;
  }

  .topbar .eyebrow {
    margin-bottom: 0;
    font-size: 11px;
  }

  h1 {
    font-size: 20px;
  }

  .brand-text {
    font-size: 26px;
  }

  .brand-season {
    font-size: 11px;
    padding-bottom: 3px;
  }

  .decode-wordmark {
    width: 126px;
    height: 42px;
  }

  .decode-logo {
    width: 32px;
    height: 32px;
  }

  h2 {
    font-size: 22px;
  }

  .icon-button {
    width: 42px;
    min-height: 34px;
  }

  .app-shell {
    min-height: 100vh;
  }

  .sidebar {
    position: sticky;
    top: var(--nav-sticky-top);
    display: flex;
    gap: 6px;
    overflow-x: auto;
    overflow-y: hidden;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    padding: 8px 12px;
  }

  .nav-item {
    flex-basis: 96px;
    min-height: 34px;
    margin: 0;
    padding: 0 10px;
    text-align: center;
  }

  .content {
    padding: var(--content-pad);
  }

  .section-head,
  .panel-head {
    margin-bottom: 10px;
  }

  .panel,
  .team-card,
  .metric {
    padding: 12px;
    margin-bottom: 10px;
  }

  .ranking-panel,
  .pit-archive,
  .editor-tab,
  .pit-editor-tab {
    padding: 0;
  }

  .metrics-grid,
  .split-grid,
  .single-grid,
  .team-grid,
  .pit-grid,
  .alliance-lanes,
  .detail-grid {
    gap: 10px;
  }

  .split-grid,
  .team-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .pit-browser-layout {
    grid-template-columns: minmax(0, 1fr) minmax(240px, 0.42fr);
    gap: 10px;
  }

  .pit-compare-browser {
    gap: 10px;
  }

  .pit-compare-layout {
    gap: 10px;
  }

  .pit-list-column {
    gap: 8px;
  }

  .form-grid,
  .form-section,
  .event-form,
  .import-panel {
    gap: 10px;
  }

  .import-controls {
    grid-template-columns: 96px minmax(132px, 1fr) max-content max-content;
    gap: 8px;
  }

  .pit-form,
  .pit-archive-body,
  .pit-detail-modal .pit-archive-body {
    grid-template-columns: minmax(130px, 170px) minmax(0, 1fr);
    gap: 12px;
  }

  .pit-fields-panel {
    gap: 10px;
  }

  .pit-fields-panel .choice-group,
  .pit-archive .pit-fields-panel .choice-group {
    gap: 8px;
    padding: 10px;
  }

  .pit-fields-panel .choice-group legend,
  .pit-archive .pit-fields-panel .choice-group legend {
    font-size: 17px;
  }

  .feature-check,
  .pit-archive .feature-check {
    min-height: 44px;
    padding: 10px;
    font-size: 15px;
  }

  .photo-preview,
  .pit-archive .photo-preview {
    max-height: 42vh;
  }

  .pit-notes-field textarea,
  .pit-archive .pit-notes-field textarea {
    min-height: 84px;
  }

  .modal-backdrop {
    padding: 12px;
  }

  .detail-modal {
    max-height: calc(100dvh - 24px);
    padding: 12px;
  }

  .photo-gallery-modal {
    width: min(1640px, calc(100vw - 32px));
    max-width: calc(100vw - 32px);
    height: calc(100dvh - 24px);
    max-height: calc(100dvh - 24px);
  }

  .pit-detail-modal {
    width: min(1120px, calc(100vw - 16px));
  }
}

@media (orientation: landscape) and (max-height: 620px) and (max-width: 720px) {
  .nav-item {
    font-size: 13px;
  }

  .split-grid,
  .team-grid,
  .pit-grid {
    grid-template-columns: 1fr;
  }

  .pit-browser-layout {
    grid-template-columns: 1fr;
  }

  .pit-compare-browser {
    grid-template-columns: 1fr;
  }

  .pit-compare-layout {
    grid-template-columns: 1fr;
  }

  .pit-form,
  .pit-archive-body,
  .pit-detail-modal .pit-archive-body {
    grid-template-columns: minmax(120px, 160px) minmax(0, 1fr);
  }

  .pit-fields-panel .choice-group,
  .pit-archive .pit-fields-panel .choice-group {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 760px) {
  .match-list-panel,
  .match-groups,
  .match-archive,
  .match-archive-summary,
  .match-summary-title,
  .match-score-badge,
  .match-archive-right,
  .match-archive-teams {
    min-width: 0;
    max-width: 100%;
  }

  .match-archive {
    overflow: hidden;
  }

  .match-archive-summary {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas:
      "score"
      "teams";
    align-items: center;
    justify-items: stretch;
    min-height: 134px;
    padding: 12px;
    gap: 8px;
    overflow: hidden;
  }

  .match-summary-title {
    display: grid;
    grid-area: score;
    grid-template-columns: 62px minmax(0, 1fr);
    align-items: center;
    column-gap: 6px;
    width: 100%;
    max-width: none;
  }

  .match-summary-title > strong {
    justify-self: start;
    font-size: 31px;
    line-height: 1;
  }

  .match-score-separator {
    display: none;
  }

  .match-score-with-rp {
    position: static;
    transform: none;
    justify-self: stretch;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    grid-template-areas:
      "redScore blueScore"
      "redRp blueRp";
    justify-items: center;
    gap: 6px;
    width: 100%;
    max-width: 100%;
    overflow: hidden;
  }

  .match-score-with-rp > .red-score {
    grid-area: redScore;
  }

  .match-score-with-rp > .blue-score {
    grid-area: blueScore;
  }

  .match-score-with-rp > .red-rp {
    grid-area: redRp;
  }

  .match-score-with-rp > .blue-rp {
    grid-area: blueRp;
  }

  .match-score-badge {
    font-size: 27px;
  }

  .match-score-badge > .red-score,
  .match-score-badge > .blue-score {
    width: auto;
    min-width: 76px;
  }

  .rp-strip {
    display: inline-grid;
    grid-template-columns: repeat(6, 8px);
    justify-content: center;
    min-width: 58px;
    gap: 2px;
  }

  .rp-icon {
    display: block;
    width: 8px;
    height: 8px;
    border-radius: 999px;
  }

  .rp-icon svg {
    display: none;
  }

  .match-archive-right {
    display: contents;
  }

  .match-archive-teams {
    grid-area: teams;
    grid-template-columns: minmax(0, 1fr) 22px minmax(0, 1fr);
    width: 100%;
    gap: 4px;
    overflow: hidden;
  }

  .match-team-chip-group {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: 100%;
    gap: 5px;
  }

  .match-team-chip {
    width: 100%;
    min-width: 0;
    height: 28px;
    padding-inline: 4px;
    font-size: 14px;
  }

  .official-ranking-head {
    align-items: stretch;
    flex-direction: column;
  }

  .official-ranking-table-tools {
    align-items: stretch;
    flex-direction: column;
  }

  .official-ranking-refresh-bar {
    align-items: stretch;
    flex-direction: column;
  }

  .official-ranking-mode {
    align-self: stretch;
  }

  .official-ranking-mode-button {
    flex: 1;
  }

  .official-ranking-source {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    justify-content: stretch;
  }

  .official-ranking-source label,
  .official-ranking-source label:nth-child(2),
  .official-ranking-actions {
    width: 100%;
  }

  .official-ranking-actions {
    grid-column: 1 / -1;
  }

  .official-ranking-actions .primary-button,
  .official-ranking-actions .secondary-button {
    flex: 1;
  }

  .official-ranking-interval {
    justify-content: space-between;
  }

  .official-ranking-interval select {
    flex: 1;
  }

  .official-ranking-panel {
    padding: 10px;
  }

  .official-ranking-table-wrap {
    max-height: none;
    overflow: visible;
    border: 0;
    background: transparent;
  }

  #ranking.view.active .official-ranking-table-wrap {
    max-height: none;
  }

  .official-ranking-table,
  .official-ranking-table[data-ranking-mode="standard"],
  .official-ranking-table[data-ranking-mode="tactical"] {
    display: block;
    width: 100%;
    min-width: 0;
    table-layout: auto;
  }

  .official-ranking-table colgroup,
  .official-ranking-table thead {
    display: none;
  }

  .official-ranking-table tbody {
    display: grid;
    gap: 10px;
  }

  .official-ranking-table tbody tr {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    padding: 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface-2);
  }

  .official-ranking-table td,
  .official-ranking-table th[data-official-column="rank"],
  .official-ranking-table td[data-official-column="rank"],
  .official-ranking-table th[data-official-column="team"],
  .official-ranking-table td[data-official-column="team"] {
    position: static;
    left: auto;
    z-index: auto;
    display: grid;
    min-width: 0;
    padding: 8px 9px;
    border: 1px solid rgba(148, 163, 184, 0.14);
    border-radius: 7px;
    background: var(--panel-2) !important;
    box-shadow: none;
    font-size: 15px;
    line-height: 1.15;
    white-space: normal;
  }

  .official-ranking-table td::before {
    content: attr(data-official-label);
    margin-bottom: 3px;
    color: var(--muted);
    font-size: 10px;
    font-weight: 900;
    letter-spacing: 0.04em;
    text-transform: uppercase;
  }

  .official-ranking-table td[data-official-column="rank"] {
    align-content: center;
    color: var(--accent);
    font-size: 22px;
  }

  .official-ranking-table td[data-official-column="team"] {
    align-content: center;
    color: var(--text);
    font-size: 18px;
  }

  .official-ranking-table td[data-official-column="team"]::before {
    content: "Team";
  }

  .official-team-cell {
    max-width: none;
    overflow: visible;
    text-overflow: clip;
  }

  .official-ranking-table td.official-ranking-active-cell {
    box-shadow: inset 0 0 0 2px rgba(8, 145, 178, 0.52);
  }
}

/* Stable match editing workspace: left match list, right scoring form. */
#matchEventContent {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}

.match-workspace {
  display: grid;
  grid-column: 1 / -1;
  grid-template-columns: 1fr;
  gap: 16px;
  align-items: start;
  width: 100%;
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
}

.match-list-panel {
  min-width: 0;
  overflow: visible;
}

.match-report-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
}

.match-report-head h2 {
  margin: 0;
  color: var(--text);
  font-size: clamp(28px, 2.2vw, 36px);
  font-weight: 900;
  line-height: 1.08;
  letter-spacing: 0;
}

.match-report-title-block {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.match-report-title-block span {
  color: var(--muted);
  font-size: 16px;
  font-weight: 850;
  line-height: 1.1;
}

.match-report-tools {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 10px;
  min-width: min(820px, 64%);
}

.match-report-tools .secondary-button {
  flex: 0 0 auto;
  white-space: nowrap;
}

.match-report-tools .match-auto-refresh {
  min-height: 40px;
  margin: 0;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
  white-space: nowrap;
}

.match-auto-refresh-interval {
  flex: 0 0 112px;
  min-height: 40px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--text);
  font-size: 14px;
  font-weight: 850;
}

.match-report-tools .search-input {
  width: min(380px, 100%);
  margin: 0;
}

@media (max-width: 560px) {
  .match-report-head {
    align-items: stretch;
    flex-direction: column;
    gap: 12px;
  }

  .match-report-tools {
    align-items: stretch;
    flex-direction: column;
    min-width: 0;
    width: 100%;
  }

  .match-report-tools .secondary-button,
  .match-report-tools .match-auto-refresh,
  .match-auto-refresh-interval,
  .match-report-tools .search-input {
    width: 100%;
  }
}

#matchForm {
  --graphic-alliance-color: #ef202d;
  --graphic-alliance-deep: #991b1b;
  --graphic-alliance-ring: #fecaca;
  --graphic-alliance-soft: rgba(239, 32, 45, 0.18);
  width: 100%;
  max-width: none;
  min-width: 0;
  margin: 0;
  justify-content: stretch;
}

#matchForm:has(.red-card input:checked) {
  --graphic-alliance-color: #ef202d;
  --graphic-alliance-deep: #991b1b;
  --graphic-alliance-ring: #fecaca;
  --graphic-alliance-soft: rgba(239, 32, 45, 0.18);
}

#matchForm:has(.blue-card input:checked) {
  --graphic-alliance-color: #2563eb;
  --graphic-alliance-deep: #1e3a8a;
  --graphic-alliance-ring: #bfdbfe;
  --graphic-alliance-soft: rgba(37, 99, 235, 0.18);
}

#matchForm[hidden] {
  display: none;
}

/* Match editor polish: compact stacked ID fields and balanced scoring sections. */
#matchForm {
  grid-template-columns: minmax(170px, 250px) minmax(240px, 1fr);
  align-items: start;
  gap: 12px 16px;
  box-sizing: border-box;
  overflow-x: hidden;
}

.match-editor-head {
  display: flex;
  grid-column: 1 / -1;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  min-height: 58px;
  padding-bottom: 4px;
}

.match-editor-head h3 {
  color: var(--text);
  font-size: 32px;
  font-weight: 900;
  line-height: 1;
  text-transform: uppercase;
}

.match-editor-head .secondary-button {
  min-width: 132px;
  min-height: 48px;
  font-size: 18px;
  font-weight: 900;
}

#matchForm .match-id-field {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  align-items: center;
  grid-column: 1;
  gap: 10px;
  max-width: none;
  width: 100%;
  color: var(--muted);
  font-size: 30px;
  font-weight: 800;
  line-height: 1;
}

#matchForm .match-id-field:nth-of-type(1) {
  grid-row: 2;
}

#matchForm .match-id-field:nth-of-type(2) {
  grid-row: 3;
}

#matchForm .match-id-field input {
  min-height: 54px;
  font-size: 30px;
}

#matchForm .match-number-control {
  display: grid;
  grid-template-columns: minmax(0, 1fr) max-content;
  gap: 8px;
  align-items: center;
}

#matchForm .practice-toggle-button {
  min-height: 54px;
  padding: 0 14px;
  border: 1px solid rgba(245, 158, 11, 0.45);
  border-radius: 8px;
  background: rgba(245, 158, 11, 0.12);
  color: #92400e;
  font-size: 15px;
  font-weight: 900;
}

#matchForm .practice-toggle-button.is-active {
  border-color: rgba(245, 158, 11, 0.88);
  background: #f59e0b;
  color: #111827;
}

body.theme-dark #matchForm .practice-toggle-button {
  color: #fbbf24;
}

body.theme-dark #matchForm .practice-toggle-button.is-active {
  color: #111827;
}

#matchForm .alliance-choice {
  grid-column: 2;
  grid-row: 2 / span 2;
  align-self: stretch;
  grid-template-columns: 1fr;
  grid-template-rows: auto 1fr 1fr;
  gap: 8px;
  min-height: 154px;
}

#matchForm .alliance-choice legend {
  font-size: 22px;
  line-height: 1;
}

#matchForm .alliance-card {
  min-height: 54px;
  font-size: 20px;
}

.graphic-scorer {
  grid-column: 1 / -1;
  display: grid;
  justify-items: start;
  gap: 10px;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
}

.graphic-scorer-head {
  display: none;
}

.graphic-alliance-label {
  margin: 0;
  color: #9a9a9a;
  font-size: 24px;
  font-weight: 500;
  line-height: 1;
}

.graphic-scoreboard {
  display: none !important;
  position: absolute;
  left: 9.5%;
  top: 5.6%;
  z-index: 2;
  display: grid;
  grid-template-columns: 66px 140px 66px;
  align-items: center;
  width: 44.5%;
  min-height: 162px;
  overflow: hidden;
  border: 4px solid #0a84ff;
  border-radius: 0;
  background: rgba(210, 251, 255, 0.78);
  color: #06121f;
}

.graphic-scoreboard button {
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  min-height: 162px;
  border: 0;
  background: transparent;
  color: #10bac3;
  font-size: 60px;
  font-weight: 950;
  cursor: pointer;
}

.graphic-scoreboard strong {
  display: grid;
  place-items: center;
  min-height: 162px;
  border-inline: 1px solid rgba(74, 172, 185, 0.24);
  color: #000000;
  font-size: 86px;
  font-weight: 950;
  line-height: 1;
}

.graphic-scorer-stage {
  --graphic-scale: 1;
  position: relative;
  width: min(100%, 604px);
  height: calc(1047px * var(--graphic-scale));
  overflow: visible;
}

.graphic-field {
  position: absolute;
  left: 0;
  top: 0;
  width: 604px;
  height: 1047px;
  box-sizing: border-box;
  min-height: 0;
  overflow: hidden;
  border: 4px solid var(--graphic-alliance-color, #0a84ff);
  border-radius: 0;
  background: #e5e5e5;
  box-shadow: 0 0 0 2px var(--graphic-alliance-ring, rgba(255, 255, 255, 0.72));
  transform: scale(var(--graphic-scale));
  transform-origin: top left;
}

.graphic-field img {
  position: absolute;
  left: 0;
  top: -8.7%;
  width: 100%;
  height: 108.7%;
  object-fit: cover;
  object-position: 98% center;
  user-select: none;
  pointer-events: none;
}

.graphic-stage-title {
  position: absolute;
  left: 5%;
  top: 2.2%;
  z-index: 3;
  display: grid;
  place-items: center;
  width: min(86%, 520px);
  min-height: 76px;
  padding: 0 22px;
  border: 1.5px solid var(--graphic-alliance-color, #9ee2ff);
  border-radius: 12px;
  background: rgba(229, 248, 255, 0.93);
  box-shadow: 0 2px 0 var(--graphic-alliance-soft, rgba(14, 165, 233, 0.12));
  color: #111827;
  font-size: 42px;
  font-weight: 900;
  line-height: 1;
  text-align: center;
  white-space: nowrap;
  pointer-events: none;
}

.graphic-side-buttons {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
}

.graphic-phase-switch {
  position: absolute;
  left: 5%;
  right: 5%;
  bottom: 1.8%;
  z-index: 5;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  padding: 8px;
  border: 5px solid var(--graphic-alliance-ring, rgba(255, 255, 255, 0.9));
  border-radius: 18px;
  background: rgba(229, 248, 255, 0.9);
  box-shadow: 0 0 0 2px var(--graphic-alliance-color, transparent), 0 8px 14px rgba(15, 23, 42, 0.28);
}

.graphic-phase-switch button {
  display: grid;
  place-items: center;
  min-height: 58px;
  min-width: 0;
  padding: 0 10px;
  border: 2px solid transparent;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.72);
  color: #334155;
  font-size: 27px;
  font-weight: 950;
  line-height: 1;
  white-space: nowrap;
  cursor: pointer;
}

.graphic-phase-switch button[aria-pressed="true"] {
  border-color: var(--graphic-alliance-color, #0ea5e9);
  background: var(--graphic-alliance-soft, rgba(14, 165, 233, 0.16));
  color: #0f172a;
}

.graphic-score-button {
  position: relative;
  z-index: 1;
  display: grid;
  place-items: center;
  min-width: 0;
  min-height: 74px;
  padding: 8px;
  border: 8px solid var(--graphic-alliance-ring, #ffffff);
  border-radius: 14px;
  color: #ffffff;
  box-shadow: 0 0 0 2px var(--graphic-alliance-color, transparent), 0 7px 8px rgba(15, 23, 42, 0.36);
  cursor: pointer;
  font-size: 35px;
  font-weight: 950;
  line-height: 1.18;
  text-align: center;
  transition: transform 120ms ease, box-shadow 120ms ease, filter 120ms ease;
}

.graphic-score-button:hover {
  filter: brightness(1.04);
  transform: translateY(-1px);
}

.graphic-score-button:active {
  transform: translateY(1px) scale(0.985);
}

.graphic-score-button::after {
  content: attr(data-count);
  position: absolute;
  right: -46px;
  top: -26px;
  z-index: 4;
  display: none;
  min-width: 52px;
  height: 48px;
  padding-inline: 11px;
  border: 5px solid var(--graphic-alliance-ring, #ffffff);
  border-radius: 999px;
  background: var(--graphic-alliance-deep, #0f172a);
  color: #ffffff;
  box-shadow: 0 0 0 2px var(--graphic-alliance-color, transparent), 0 5px 10px rgba(15, 23, 42, 0.3);
  font-size: 26px;
  font-weight: 950;
  line-height: 38px;
}

.graphic-score-button.has-count::after {
  display: grid;
  place-items: center;
}

.graphic-score-button.miss-shot::after,
.graphic-score-button.overflow::after {
  right: auto;
  left: -58px;
  top: -28px;
  transform: scale(0.9);
  transform-origin: center;
}

.graphic-score-button.far-shot::after {
  right: auto;
  left: -42px;
  top: -26px;
}

.graphic-score-button.motif::after {
  right: auto;
  left: -58px;
  top: -28px;
  transform: scale(0.9);
  transform-origin: center;
}

.graphic-score-button.base-state::after {
  right: -46px;
  top: -26px;
}

.graphic-score-button.near-shot,
.graphic-score-button.far-shot,
.graphic-score-button.overflow {
  background: #11bbc6;
}

.graphic-score-button.miss-shot {
  background: #ff902e;
}

.graphic-score-button.motif {
  background: #6254f3;
}

.graphic-score-button.near-shot {
  position: absolute;
  left: 24.3%;
  top: 42.4%;
  width: 25.5%;
  min-height: 13.2%;
}

.graphic-score-button.far-shot {
  position: absolute;
  left: 5.5%;
  bottom: 10.2%;
  width: 25.5%;
  min-height: 13.1%;
}

.graphic-score-button.base-state {
  position: absolute;
  display: flex;
  align-items: center;
  justify-content: center;
  left: 36.35%;
  bottom: 19.1%;
  width: 21.5%;
  min-height: 11.3%;
  padding-inline: 4px;
  background-color: #8376f4;
  font-size: 30px;
  line-height: 1;
}

.graphic-side-buttons .graphic-score-button {
  pointer-events: auto;
}

.graphic-score-button.is-empty {
  opacity: 1;
}

.graphic-score-button.miss-shot {
  position: absolute;
  right: 5.3%;
  top: 34.9%;
  width: 19.5%;
  min-height: 10.4%;
  border-width: 8px;
  font-size: 28px;
}

.graphic-score-button.overflow {
  position: absolute;
  grid-auto-rows: min-content;
  align-content: center;
  justify-items: center;
  right: 5.3%;
  top: 52.8%;
  width: 19.5%;
  min-height: 10.5%;
  border-width: 8px;
  padding-inline: 4px;
  font-size: 28px;
  line-height: 0.96;
  white-space: nowrap;
  word-break: normal;
  overflow-wrap: normal;
}

.graphic-score-button.overflow span {
  display: block;
}

.graphic-score-button.motif {
  position: absolute;
  right: 5.7%;
  bottom: 17.8%;
  width: 19%;
  min-height: 10.4%;
  border: 6px solid var(--graphic-alliance-color, #6254f3);
  border-radius: 6px;
  background: rgba(193, 248, 255, 0.86);
  color: var(--graphic-alliance-deep, #6254f3);
  box-shadow: 0 0 0 2px var(--graphic-alliance-ring, transparent);
  font-size: 31px;
}

.graphic-score-button.base-state[data-base-state="partial"] {
  background-color: #6657e8;
}

.graphic-score-button.base-state[data-base-state="full"] {
  background-color: #4b38c6;
}

.graphic-score-button.base-state[data-base-state="bonus"] {
  background-color: #2f238f;
}

.graphic-score-button.base-state[data-base-state="lift"] {
  background-color: #2f238f;
}

@media (max-width: 760px) {
  .graphic-field {
    min-height: 0;
  }

  .graphic-alliance-label {
    font-size: 22px;
  }

  .graphic-scoreboard {
    grid-template-columns: 18% 64% 18%;
    min-height: 14.2%;
  }

  .graphic-scoreboard button,
  .graphic-scoreboard strong {
    min-height: 100%;
  }

  .graphic-scoreboard strong {
    font-size: clamp(58px, 14vw, 86px);
  }

  .graphic-scoreboard button {
    font-size: clamp(42px, 10vw, 60px);
  }

  .graphic-score-button {
    overflow: visible;
  }
}

#matchForm > .form-section,
#matchForm > .form-actions {
  grid-column: 1 / -1;
}

#matchForm .form-section {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px 16px;
  align-items: start;
  min-width: 0;
}

#matchForm .form-section h3 {
  grid-column: 1 / -1;
  font-size: 30px;
  line-height: 1;
}

#matchForm .auto-section h3,
#matchForm .teleop-section h3,
#matchForm .endgame-section h3 {
  align-self: start;
  justify-self: center;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: min(86%, 520px);
  height: clamp(58px, 7.3vw, 76px);
  min-height: 0;
  margin: 0 auto 8px;
  padding: 0 22px;
  border: 1.5px solid #9ee2ff;
  border-radius: 12px;
  background: rgba(229, 248, 255, 0.93);
  box-shadow: 0 2px 0 rgba(14, 165, 233, 0.12);
  color: #111827;
  font-size: clamp(30px, 5.4vw, 46px);
  font-weight: 950;
  line-height: 1;
  letter-spacing: 0;
  text-align: center;
}

#matchForm .auto-section {
  align-items: stretch;
  grid-template-columns: 1fr;
}

#matchForm .auto-section .field-cluster,
#matchForm .auto-section .numeric-cluster {
  grid-auto-rows: 76px;
  grid-column: 1;
}

#matchForm .auto-section .checkbox-row,
#matchForm .auto-section .counter-field {
  align-self: stretch;
}

#matchForm .auto-section .checkbox-row {
  min-height: 0;
}

#matchForm .teleop-section {
  grid-template-columns: 1fr;
}

#matchForm .teleop-section > .counter-field,
#matchForm .teleop-section > .phase-disabled-field {
  grid-column: 1;
}

#matchForm .field-cluster,
#matchForm .numeric-cluster {
  grid-template-columns: 1fr;
  gap: 10px;
  min-width: 0;
}

#matchForm .checkbox-row {
  min-height: 84px;
  gap: 14px;
  font-size: 24px;
  font-weight: 900;
  line-height: 1.06;
}

#matchForm .checkbox-row input {
  width: 40px;
  min-width: 40px;
  min-height: 40px;
}

#matchForm .phase-disabled-field {
  align-self: stretch;
}

#matchForm .form-section:has(.base-field) .phase-disabled-field {
  min-height: 58px;
}

#matchForm .base-field {
  grid-column: 1;
  justify-self: stretch;
  width: 100%;
}

#matchForm .counter-control {
  grid-template-columns: 58px minmax(96px, 1fr) 58px;
}

#matchForm .base-control {
  grid-template-columns: 72px minmax(136px, 1fr) 72px;
}

#matchForm .base-value {
  min-height: 58px;
  font-size: 32px;
}

#matchForm .base-control button {
  font-size: 36px;
}

#matchForm .base-options {
  min-height: 58px;
}

#matchForm .base-options button {
  min-height: 58px;
  font-size: 15px;
}

#matchForm .quality-section .wide {
  grid-column: 1 / -1;
}

@media (orientation: landscape) and (min-width: 900px) {
  .match-workspace.editing #matchForm {
    grid-template-columns: minmax(360px, 1fr) minmax(360px, 604px);
  }
}

@media (max-width: 760px) {
  #matchForm,
  #matchForm .form-section {
    grid-template-columns: 1fr;
  }

  #matchForm .match-id-field,
  #matchForm .alliance-choice {
    grid-column: 1;
    grid-row: auto;
    max-width: none;
  }
}

@media (max-width: 560px) {
  #matchForm .match-id-field {
    grid-template-columns: 1fr;
  }
}

/* Match editing split: the editor uses a dedicated compact half-width layout. */
@media (orientation: landscape) and (min-width: 900px) {
  .match-workspace.editing {
    display: grid;
    grid-template-columns: 1fr;
    gap: 16px;
    align-items: start;
    overflow: hidden;
  }

  #matchEventContent:has(#matchForm:not([hidden])) .match-workspace.editing #matchForm {
    order: 1;
    position: static;
    grid-column: 1;
    grid-row: auto;
    width: 100%;
    max-width: none;
    max-height: none;
    overflow: visible;
    padding: 14px;
    gap: 10px 12px;
    grid-template-columns: minmax(360px, 1fr) minmax(360px, 604px);
  }

  .match-workspace.editing #matchForm .graphic-scorer {
    grid-column: 2;
    justify-items: end;
    align-self: start;
    width: 100%;
  }

  .match-workspace.editing #matchForm .graphic-scorer-stage {
    width: min(100%, 604px);
  }

  .match-workspace.editing #matchForm .graphic-stage-title {
    width: min(86%, 520px);
    min-height: 76px;
    font-size: 42px;
  }

  .match-workspace.editing #matchForm .graphic-score-button {
    border-width: 8px;
    border-radius: 14px;
    font-size: 35px;
  }

  .match-workspace.editing #matchForm .graphic-score-button::after {
    right: -46px;
    top: -26px;
    min-width: 52px;
    height: 48px;
    border-width: 5px;
    font-size: 26px;
    line-height: 38px;
  }

  .match-workspace.editing #matchForm .graphic-score-button.miss-shot::after,
  .match-workspace.editing #matchForm .graphic-score-button.overflow::after {
    right: auto;
    left: -58px;
    top: -28px;
    transform: scale(0.9);
    transform-origin: center;
  }

  .match-workspace.editing #matchForm .graphic-score-button.far-shot::after {
    right: auto;
    left: -42px;
    top: -26px;
  }

  .match-workspace.editing #matchForm .graphic-score-button.motif::after {
    right: auto;
    left: -58px;
    top: -28px;
    transform: scale(0.9);
    transform-origin: center;
  }

  .match-workspace.editing #matchForm .graphic-score-button.base-state::after {
    right: -46px;
    top: -26px;
  }

  .match-workspace.editing #matchForm .graphic-score-button.miss-shot {
    font-size: 28px;
  }

  .match-workspace.editing #matchForm .graphic-score-button.overflow {
    grid-auto-rows: min-content;
    align-content: center;
    justify-items: center;
    padding-inline: 4px;
    font-size: 28px;
    line-height: 0.96;
    white-space: nowrap;
    word-break: normal;
    overflow-wrap: normal;
  }

  .match-workspace.editing #matchForm .graphic-score-button.motif {
    border-width: 6px;
    border-radius: 6px;
    font-size: 31px;
  }

  .match-workspace.editing #matchForm .graphic-score-button.base-state {
    font-size: 30px;
    line-height: 1;
  }

  .match-workspace.editing #matchForm .graphic-scorer-head {
    display: none;
  }

  .match-workspace.editing #matchForm .auto-section,
  .match-workspace.editing #matchForm .teleop-section {
    grid-column: 1;
    align-self: start;
    min-height: 0;
  }

  .match-workspace.editing #matchForm .graphic-scorer-auto,
  .match-workspace.editing #matchForm .auto-section {
    grid-row: 4;
  }

  .match-workspace.editing #matchForm .graphic-scorer-teleop,
  .match-workspace.editing #matchForm .teleop-section {
    grid-row: 5;
  }

  .match-workspace.editing #matchForm .auto-section,
  .match-workspace.editing #matchForm .teleop-section {
    align-self: stretch;
    max-height: none;
  }

  .match-workspace.editing #matchForm .quality-section {
    grid-column: 1 / -1;
    grid-row: 6;
  }

  .match-workspace.editing #matchForm > .form-actions {
    grid-column: 1 / -1;
    grid-row: 7;
  }

  .match-workspace.editing #matchForm .match-editor-head {
    min-height: 42px;
    padding-bottom: 0;
  }

  .match-workspace.editing #matchForm .match-editor-head h3 {
    font-size: 22px;
  }

  .match-workspace.editing #matchForm .match-editor-head .secondary-button {
    min-width: 104px;
    min-height: 38px;
    font-size: 15px;
  }

  #matchEventContent:has(#matchForm:not([hidden])) .match-workspace.editing .match-list-panel {
    order: 2;
    grid-column: 1;
    grid-row: auto;
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
    align-self: start;
    width: 100%;
    max-width: none;
    max-height: 360px;
    margin-bottom: 0;
    overflow: auto;
  }

  .match-workspace.editing .match-groups {
    min-height: 0;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.035);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.035);
    overflow-y: auto;
    scrollbar-gutter: stable;
  }

  .match-workspace.editing .match-groups:has(.match-archive[open]) {
    grid-template-columns: 1fr;
  }

  .match-workspace.editing .match-groups:has(.match-archive[open]) .match-archive,
  .match-workspace.editing .match-groups:has(.match-archive[open]) .match-archive[open] {
    grid-column: 1;
    grid-row: auto;
  }

  .match-workspace.editing .match-groups:has(.match-archive[open]) .match-archive[open] .match-archive-body {
    display: none;
  }

  .match-workspace.editing .match-groups:has(.match-archive[open]) .match-collapse-tab,
  .match-workspace.editing .match-groups:has(.match-archive[open]) .expand-label {
    display: none;
  }

  .match-workspace.editing #matchForm .match-id-field {
    display: grid;
    grid-template-columns: max-content minmax(0, 1fr);
    align-items: center;
    gap: 10px;
    font-size: 20px;
    line-height: 1;
  }

  .match-workspace.editing #matchForm .match-id-field input {
    min-height: 50px;
    padding: 8px 12px;
    font-size: 28px;
  }

  .match-workspace.editing #matchForm .alliance-choice {
    align-self: stretch;
    height: 100%;
    min-height: 0;
    gap: 10px;
    grid-template-rows: repeat(2, minmax(0, 1fr));
  }

  .match-workspace.editing #matchForm .alliance-choice legend {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
  }

  .match-workspace.editing #matchForm .alliance-card {
    min-height: 0;
    height: 100%;
    font-size: 22px;
  }

  .match-workspace.editing #matchForm .alliance-card:has(input:checked) {
    box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.22);
  }

  .match-workspace.editing #matchForm .form-section {
    gap: 8px 10px;
    padding: 10px;
  }

  .match-workspace.editing #matchForm .form-section h3 {
    font-size: 20px;
  }

  .match-workspace.editing #matchForm .auto-section h3,
  .match-workspace.editing #matchForm .teleop-section h3,
  .match-workspace.editing #matchForm .endgame-section h3 {
    height: 58px;
    font-size: 34px;
  }

  .match-workspace.editing #matchForm .checkbox-row {
    min-height: 68px;
    gap: 12px;
    font-size: 23px;
    font-weight: 900;
    line-height: 1.06;
  }

  .match-workspace.editing #matchForm .checkbox-row input {
    width: 34px;
    min-width: 34px;
    min-height: 34px;
  }

  .match-workspace.editing #matchForm .phase-disabled-field {
    transform: none;
  }

  .match-workspace.editing #matchForm .form-section:has(.base-field) .phase-disabled-field {
    min-height: 58px;
    transform: none;
  }

  .match-workspace.editing #matchForm .field-cluster,
  .match-workspace.editing #matchForm .numeric-cluster {
    gap: 6px;
  }

  .match-workspace.editing #matchForm label {
    font-size: 15px;
  }

  .match-workspace.editing #matchForm .counter-field {
    gap: 5px;
    color: #c7d5e6;
    font-size: 17px;
    font-weight: 900;
    line-height: 1.08;
  }

  .match-workspace.editing #matchForm .counter-control {
    grid-template-columns: 40px minmax(62px, 1fr) 40px;
    min-height: 42px;
  }

  .match-workspace.editing #matchForm .counter-control input {
    min-height: 42px;
    font-size: 23px;
  }

  .match-workspace.editing #matchForm .counter-control button {
    font-size: 24px;
  }

  .match-workspace.editing #matchForm .base-control {
    grid-template-columns: 56px minmax(128px, 1fr) 56px;
    min-height: 58px;
  }

  .match-workspace.editing #matchForm .base-value {
    min-height: 58px;
    font-size: 30px;
    line-height: 1;
  }

  .match-workspace.editing #matchForm .base-control button {
    font-size: 32px;
    line-height: 1;
  }

  .match-workspace.editing #matchForm input,
  .match-workspace.editing #matchForm select,
  .match-workspace.editing #matchForm textarea {
    min-height: 38px;
  }

  .match-workspace.editing #matchForm .reliability-field {
    gap: 7px;
    font-size: 15px;
  }

  .match-workspace.editing #matchForm textarea {
    min-height: 78px;
  }

  @media (max-width: 1179px) {
    #matchEventContent:has(#matchForm:not([hidden])) .match-workspace.editing #matchForm {
      grid-template-columns: 1fr;
    }

    .match-workspace.editing #matchForm .graphic-scorer {
      grid-column: 1;
      grid-row: auto;
      justify-items: start;
    }

    .match-workspace.editing #matchForm .auto-section,
    .match-workspace.editing #matchForm .teleop-section {
      grid-column: 1;
      grid-row: auto;
    }
  }

  .match-workspace.editing .match-archive-summary {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas:
      "score"
      "teams";
    align-items: center;
    min-height: 72px;
    padding: 8px 10px;
    gap: 4px;
    overflow: hidden;
  }

  .match-workspace.editing .match-summary-title {
    position: relative;
    display: flex;
    grid-area: score;
    align-items: center;
    width: 100%;
    max-width: none;
    min-width: 0;
    justify-content: flex-start;
  }

  .match-workspace.editing .match-summary-title > strong {
    justify-self: start;
  }

  .match-workspace.editing .match-score-separator {
    margin-left: 12px;
  }

  .match-workspace.editing .match-archive-right {
    display: contents;
  }

  .match-workspace.editing .match-archive-teams {
    grid-area: teams;
    width: 100%;
    justify-content: center;
    text-align: center;
    overflow: hidden;
  }

  .match-workspace.editing .expand-label {
    grid-area: action;
    min-width: 88px;
  }

  .match-workspace.editing .match-archive-summary {
    pointer-events: none;
  }

  .match-workspace.editing .match-archive[open] .match-archive-body {
    display: none;
  }

  .match-workspace.editing .match-archive[open] .match-archive-summary {
    border-bottom: 0;
  }

  .match-workspace.editing .expand-label {
    display: none;
  }

  .match-workspace.editing .match-score-with-rp {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    grid-template-columns: 58px max-content max-content 58px;
    align-items: center;
    justify-items: center;
    gap: 4px;
    margin-inline: auto;
    overflow: visible;
  }

  .match-workspace.editing .match-score-with-rp .rp-strip {
    display: inline-grid;
    grid-template-columns: repeat(6, 8px);
    align-items: center;
    justify-content: center;
    min-width: 58px;
    gap: 2px;
  }

  .match-workspace.editing .match-team-chip-group {
    display: grid;
    grid-template-columns: repeat(2, 84px);
    align-items: center;
    justify-content: center;
    justify-items: center;
    gap: 3px;
  }

  .match-workspace.editing .match-score-with-rp .rp-icon {
    width: 8px;
    height: 8px;
    border-radius: 999px;
  }

  .match-workspace.editing .match-score-with-rp .rp-icon svg {
    display: none;
  }

  .match-workspace.editing .match-score-badge:not(.match-score-with-rp) {
    grid-template-columns: max-content max-content;
  }

  .match-workspace.editing .match-score-badge > .red-score,
  .match-workspace.editing .match-score-badge > .blue-score {
    width: auto;
    min-width: 52px;
    padding: 0 2px;
  }

  .match-workspace.editing .match-team-chip {
    width: 84px;
    height: 28px;
    font-size: 16px;
  }

  .match-workspace.editing .match-archive-summary,
  .match-groups:has(.match-archive[open]) .match-archive:not([open]) .match-archive-summary {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas:
      "score"
      "teams";
    align-items: center;
    justify-items: stretch;
    min-height: 112px;
    padding: 14px 18px;
    gap: 8px;
    overflow: hidden;
  }

  .match-workspace.editing .match-summary-title,
  .match-groups:has(.match-archive[open]) .match-archive:not([open]) .match-summary-title {
    position: relative;
    display: flex;
    grid-area: score;
    align-items: center;
    width: 100%;
    max-width: none;
    min-width: 0;
    min-height: 42px;
    justify-content: flex-start;
    overflow: visible;
  }

  .match-workspace.editing .match-summary-title > strong,
  .match-groups:has(.match-archive[open]) .match-archive:not([open]) .match-summary-title > strong {
    min-width: 82px;
    font-size: 34px;
    line-height: 1;
  }

  .match-workspace.editing .match-score-separator,
  .match-groups:has(.match-archive[open]) .match-archive:not([open]) .match-score-separator {
    margin-left: 2px;
    font-size: 30px;
  }

  .match-workspace.editing .match-score-with-rp,
  .match-groups:has(.match-archive[open]) .match-archive:not([open]) .match-score-with-rp {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    grid-template-columns: 58px max-content max-content 58px;
    align-items: center;
    justify-items: center;
    gap: 6px;
    margin-inline: 0;
    max-width: none;
    overflow: visible;
  }

  .match-workspace.editing .match-score-badge,
  .match-groups:has(.match-archive[open]) .match-archive:not([open]) .match-score-badge {
    font-size: 32px;
  }

  .match-workspace.editing .match-score-badge > .red-score,
  .match-workspace.editing .match-score-badge > .blue-score,
  .match-groups:has(.match-archive[open]) .match-archive:not([open]) .match-score-badge > .red-score,
  .match-groups:has(.match-archive[open]) .match-archive:not([open]) .match-score-badge > .blue-score {
    width: auto;
    min-width: 58px;
    padding: 0 2px;
  }

  .match-workspace.editing .match-score-with-rp .rp-strip,
  .match-groups:has(.match-archive[open]) .match-archive:not([open]) .rp-strip {
    display: inline-grid;
    grid-template-columns: repeat(6, 8px);
    align-items: center;
    justify-content: center;
    min-width: 58px;
    gap: 2px;
  }

  .match-workspace.editing .match-score-with-rp .rp-icon,
  .match-groups:has(.match-archive[open]) .match-archive:not([open]) .rp-icon {
    width: 8px;
    height: 8px;
    border-radius: 999px;
  }

  .match-workspace.editing .match-score-with-rp .rp-icon svg,
  .match-groups:has(.match-archive[open]) .match-archive:not([open]) .rp-icon svg {
    display: none;
  }

  .match-workspace.editing .match-archive-right,
  .match-groups:has(.match-archive[open]) .match-archive:not([open]) .match-archive-right {
    display: contents;
  }

  .match-workspace.editing .match-archive-teams,
  .match-groups:has(.match-archive[open]) .match-archive:not([open]) .match-archive-teams {
    display: grid;
    grid-area: teams;
    grid-template-columns: minmax(0, 1fr) 38px minmax(0, 1fr);
    align-items: center;
    justify-content: stretch;
    justify-items: stretch;
    width: 100%;
    gap: 8px;
    overflow: hidden;
    white-space: nowrap;
    text-align: center;
  }

  .match-workspace.editing .match-team-chip-group,
  .match-groups:has(.match-archive[open]) .match-archive:not([open]) .match-team-chip-group {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: center;
    justify-content: stretch;
    justify-items: stretch;
    gap: 4px;
    min-width: 0;
    width: 100%;
  }

  .match-workspace.editing .match-team-chip,
  .match-groups:has(.match-archive[open]) .match-archive:not([open]) .match-team-chip {
    width: 100%;
    min-width: 0;
    height: 32px;
    padding: 2px 6px;
    font-size: 18px;
  }

  .match-workspace.editing .expand-label,
  .match-groups:has(.match-archive[open]) .match-archive:not([open]) .expand-label {
    display: none;
  }
}

/* Portrait scouting should open straight into the editor, not the result list. */
@media (orientation: portrait) {
  .match-workspace.editing .match-list-panel {
    display: grid;
    order: 2;
    max-height: min(720px, calc(100dvh - 24px)) !important;
    overflow-y: auto;
  }

  .match-workspace.editing #matchForm {
    order: 1;
    grid-column: 1;
    grid-row: auto;
    width: 100%;
    max-width: none;
    margin: 0;
  }
}

/* Keep compact match cards centered even when an editor or detail panel is open. */
.match-workspace.editing .match-archive-compact .match-summary-title,
.match-groups:has(.match-archive[open]) .match-archive-compact .match-summary-title {
  display: block;
  position: relative;
  min-height: 62px;
  line-height: 1;
}

.match-workspace.editing .match-archive-compact .match-summary-title > strong,
.match-groups:has(.match-archive[open]) .match-archive-compact .match-summary-title > strong {
  position: absolute;
  left: 2px;
  top: 2px;
  z-index: 1;
}

.match-workspace.editing .match-archive-compact .match-score-with-rp,
.match-groups:has(.match-archive[open]) .match-archive-compact .match-score-with-rp {
  display: grid;
  position: static;
  margin-inline: auto;
  transform: none;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  grid-template-areas:
    "redScore blueScore"
    "redRp blueRp";
  align-items: center;
  justify-items: center;
  gap: 5px 14px;
  width: min(58%, 500px);
  max-width: calc(100% - 176px);
}

.match-workspace.editing .match-archive-compact .match-score-badge > .red-score,
.match-workspace.editing .match-archive-compact .match-score-badge > .blue-score,
.match-groups:has(.match-archive[open]) .match-archive-compact .match-score-badge > .red-score,
.match-groups:has(.match-archive[open]) .match-archive-compact .match-score-badge > .blue-score {
  align-self: center;
  width: 100%;
  min-width: 0;
  line-height: 1;
}

.match-workspace.editing .match-archive-compact .match-score-with-rp .rp-strip,
.match-groups:has(.match-archive[open]) .match-archive-compact .rp-strip {
  grid-template-columns: repeat(6, 20px);
  min-width: 140px;
  gap: 4px;
}

.match-workspace.editing .match-archive-compact .match-score-with-rp .rp-icon,
.match-groups:has(.match-archive[open]) .match-archive-compact .rp-icon {
  display: inline-grid;
  width: 20px;
  height: 20px;
  place-items: center;
  border-radius: 5px;
}

.match-workspace.editing .match-archive-compact .match-score-with-rp .rp-icon svg,
.match-groups:has(.match-archive[open]) .match-archive-compact .rp-icon svg {
  display: block;
  width: 78%;
  height: 78%;
}

@container (max-width: 700px) {
  .match-workspace.editing .match-archive-compact .match-score-with-rp .rp-strip,
  .match-groups:has(.match-archive[open]) .match-archive-compact .rp-strip {
    grid-template-columns: repeat(6, 10px);
    min-width: 70px;
    gap: 2px;
  }

  .match-workspace.editing .match-archive-compact .match-score-with-rp .rp-icon,
  .match-groups:has(.match-archive[open]) .match-archive-compact .rp-icon {
    display: block;
    width: 10px;
    height: 10px;
    border-radius: 999px;
  }

  .match-workspace.editing .match-archive-compact .match-score-with-rp .rp-icon svg,
  .match-groups:has(.match-archive[open]) .match-archive-compact .rp-icon svg {
    display: none;
  }
}

/* Match tabs split by their own width so iPad split-screen does not crush RP icons. */
@container (max-width: 1180px) {
  .match-groups > .match-archive:not([open]):not(.match-archive-compact) .match-archive-summary {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas:
      "score"
      "teams";
    align-items: center;
    justify-items: stretch;
    min-height: 116px;
    padding: 12px 14px;
    gap: 8px;
    overflow: hidden;
  }

  .match-groups > .match-archive:not([open]):not(.match-archive-compact) .match-summary-title {
    display: grid;
    grid-area: score;
    grid-template-columns: minmax(60px, 90px) minmax(0, 1fr) minmax(60px, 90px);
    align-items: center;
    width: 100%;
    max-width: none;
    min-width: 0;
    gap: 8px;
    overflow: visible;
  }

  .match-groups > .match-archive:not([open]):not(.match-archive-compact) .match-summary-title > strong {
    justify-self: start;
    font-size: 34px;
    line-height: 1;
  }

  .match-groups > .match-archive:not([open]):not(.match-archive-compact) .match-score-with-rp {
    position: static;
    transform: none;
    display: grid;
    grid-column: 2;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    grid-template-areas:
      "redScore blueScore"
      "redRp blueRp";
    align-items: center;
    justify-items: center;
    width: 100%;
    max-width: 100%;
    gap: 5px 10px;
    overflow: visible;
  }

  .match-groups > .match-archive:not([open]):not(.match-archive-compact) .match-score-with-rp > .red-score {
    grid-area: redScore;
  }

  .match-groups > .match-archive:not([open]):not(.match-archive-compact) .match-score-with-rp > .blue-score {
    grid-area: blueScore;
  }

  .match-groups > .match-archive:not([open]):not(.match-archive-compact) .match-score-with-rp > .red-rp {
    grid-area: redRp;
  }

  .match-groups > .match-archive:not([open]):not(.match-archive-compact) .match-score-with-rp > .blue-rp {
    grid-area: blueRp;
  }

  .match-groups > .match-archive:not([open]):not(.match-archive-compact) .match-score-badge {
    font-size: 30px;
  }

  .match-groups > .match-archive:not([open]):not(.match-archive-compact) .match-score-badge > .red-score,
  .match-groups > .match-archive:not([open]):not(.match-archive-compact) .match-score-badge > .blue-score {
    width: auto;
    min-width: 88px;
    padding: 0 2px;
  }

  .match-groups > .match-archive:not([open]):not(.match-archive-compact) .rp-strip {
    display: inline-grid;
    grid-template-columns: repeat(6, 14px);
    justify-content: center;
    min-width: 92px;
    gap: 2px;
    overflow: visible;
  }

  .match-groups > .match-archive:not([open]):not(.match-archive-compact) .rp-icon {
    display: block;
    width: 14px;
    height: 14px;
    border-radius: 999px;
  }

  .match-groups > .match-archive:not([open]):not(.match-archive-compact) .rp-icon svg {
    display: none;
  }

  .match-groups > .match-archive:not([open]):not(.match-archive-compact) .match-archive-right {
    display: grid;
    grid-area: teams;
    grid-template-columns: minmax(0, 1fr);
    align-items: center;
    width: 100%;
    gap: 10px;
  }

  .match-groups > .match-archive:not([open]):not(.match-archive-compact) .match-archive-teams {
    display: grid;
    grid-area: auto;
    grid-template-columns: minmax(0, 1fr) 24px minmax(0, 1fr);
    align-items: center;
    justify-items: stretch;
    width: min(100%, 960px);
    margin-inline: auto;
    gap: 6px;
    overflow: hidden;
    white-space: nowrap;
    text-align: center;
  }

  .match-groups > .match-archive:not([open]):not(.match-archive-compact) .match-team-chip-group {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    justify-content: stretch;
    width: 100%;
    gap: 6px;
  }

  .match-groups > .match-archive:not([open]):not(.match-archive-compact) .match-team-chip {
    width: 100%;
    min-width: 0;
    height: 32px;
    padding-inline: 4px;
    font-size: 18px;
  }

  .match-groups > .match-archive:not([open]):not(.match-archive-compact) .expand-label {
    display: inline-flex;
    justify-content: center;
  }
}

.match-workspace.editing .match-groups > .match-archive:not([open]):not(.match-archive-compact) .match-archive-teams {
  grid-template-columns: minmax(0, 1fr) 38px minmax(0, 1fr);
  width: min(100%, 980px);
  max-width: 100%;
  margin-inline: auto;
  gap: 8px;
}

.match-workspace.editing .match-groups > .match-archive:not([open]):not(.match-archive-compact) .match-archive-right {
  display: block;
  grid-template-columns: minmax(0, 1fr);
  justify-content: stretch;
}

.match-workspace.editing .match-groups > .match-archive:not([open]):not(.match-archive-compact) .match-archive-teams {
  grid-area: auto;
}

.match-workspace.editing .match-groups > .match-archive:not([open]):not(.match-archive-compact) .match-team-chip-group {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  width: 100%;
  min-width: 0;
  gap: 6px;
}

.match-workspace.editing .match-groups > .match-archive:not([open]):not(.match-archive-compact) .match-team-chip {
  width: 100%;
  min-width: 0;
}

@container (max-width: 620px) {
  .match-groups > .match-archive:not([open]):not(.match-archive-compact) .match-archive-summary {
    min-height: 154px;
  }

  .match-groups > .match-archive:not([open]):not(.match-archive-compact) .match-archive-right {
    grid-template-columns: minmax(0, 1fr);
  }

  .match-groups > .match-archive:not([open]):not(.match-archive-compact) .expand-label {
    top: 10px;
    right: 12px;
    width: auto;
  }
}

/* Adaptive workspace rules for mixed desktop, laptop, and tablet ratios. */
@media (min-width: 1500px) {
  .team-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

@media (max-width: 1200px) {
  .team-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 900px), (orientation: portrait) {
  .team-grid,
  .pit-form,
  #pit.view.active:has(#pitForm:not([hidden])) #pitForm {
    grid-template-columns: 1fr;
  }

  .pit-editor-tab-head,
  .section-head {
    align-items: stretch;
  }

  .pit-editor-tab-head {
    flex-direction: column;
  }

  .pit-editor-tab-head .primary-button,
  .section-actions,
  .section-actions .primary-button,
  .section-actions .search-input {
    width: 100%;
  }
}

@media (max-width: 1179px), (max-aspect-ratio: 4 / 3) {
  .match-workspace.editing {
    grid-template-columns: 1fr !important;
  }

  #matchEventContent:has(#matchForm:not([hidden])) .match-workspace.editing #matchForm {
    order: 1;
    grid-template-columns: 1fr !important;
  }

  .match-workspace.editing #matchForm > * {
    grid-column: 1 !important;
    grid-row: auto !important;
  }

  .match-workspace.editing #matchForm .graphic-scorer,
  .match-workspace.editing #matchForm .auto-section,
  .match-workspace.editing #matchForm .teleop-section {
    grid-column: 1 !important;
    grid-row: auto !important;
  }

  .match-workspace.editing #matchForm .graphic-scorer {
    justify-items: start !important;
  }

  .match-workspace.editing .match-list-panel {
    order: 2;
    height: auto !important;
    max-height: min(720px, calc(100dvh - 24px)) !important;
    overflow-y: auto;
  }
}

@media (max-width: 480px) {
  #matchForm .match-id-field,
  .match-workspace.editing #matchForm .match-id-field {
    grid-template-columns: 86px minmax(0, 1fr);
  }

  #matchForm .alliance-choice,
  .match-workspace.editing #matchForm .alliance-choice {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-template-rows: auto 46px;
    min-height: 76px;
  }

  .match-workspace.editing #matchForm .alliance-choice legend {
    position: static;
    width: auto;
    height: auto;
    padding: 0;
    margin: 0;
    overflow: visible;
    clip: auto;
    white-space: normal;
    border: 0;
  }
}

body.auth-pending .auth-brand .decode-lockup {
  display: inline-flex;
  background: transparent;
}

body.auth-pending .auth-brand .brand-text {
  grid-column: auto;
  min-width: 0;
  overflow: visible;
  text-overflow: clip;
}

body.auth-pending .auth-brand .decode-logo {
  display: block;
  width: auto;
  height: var(--decode-icon-height);
  object-fit: contain;
  object-position: center;
}

body.theme-light .auth-card,
body.theme-light .panel,
body.theme-light .settings-block,
body.theme-light .ranking-panel,
body.theme-light .detail-modal,
body.theme-light .pit-card,
body.theme-light .match-archive,
body.theme-light .team-card {
  box-shadow: var(--shadow-panel);
}

body.theme-light .sidebar {
  border-bottom-color: rgba(100, 116, 139, 0.22);
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 8px 22px rgba(15, 23, 42, 0.08);
}

body.theme-light .nav-item {
  color: #526277;
}

body.theme-light .nav-item.active,
body.theme-light .nav-item:hover {
  color: #142033;
  background: #ffffff;
  box-shadow: inset 0 0 0 1px rgba(100, 116, 139, 0.18);
}

body.theme-light .nav-item.active::after {
  background: #06728e;
}

body.theme-light .match-list-panel,
body.theme-light .match-group,
body.theme-light .match-archive {
  background: #ffffff;
  border-color: rgba(100, 116, 139, 0.22);
}

body.theme-light .team-match-reports {
  background: #f8fafc;
}

body.theme-light .team-match-report-row {
  background: #ffffff;
}

body.theme-light .team-match-alliance.red {
  background: #fee2e2;
  color: #b91c1c;
}

body.theme-light .team-match-alliance.blue {
  background: #dbeafe;
  color: #1d4ed8;
}

body.theme-light .match-archive.red-win {
  background: #fff1f2;
  border-color: rgba(225, 29, 72, 0.42);
}

body.theme-light .match-archive.blue-win {
  background: #eef5ff;
  border-color: rgba(37, 99, 235, 0.42);
}

body.theme-light .match-archive-summary strong,
body.theme-light .match-group-head h3 {
  color: #142033;
}

body.theme-light .match-score-badge,
body.theme-light .match-score-separator,
body.theme-light .match-archive-teams .versus {
  color: #526277;
}

body.theme-light .red-score,
body.theme-light .match-score-badge > .red-score {
  color: #b91c1c;
}

body.theme-light .blue-score,
body.theme-light .match-score-badge > .blue-score {
  color: #1d4ed8;
}

body.theme-light .rp-icon {
  color: #64748b;
  background: rgba(148, 163, 184, 0.2);
}

body.theme-light .rp-icon.earned {
  color: #ffffff;
}

body.theme-light .red-rp .rp-icon.earned {
  background: #e11d48;
}

body.theme-light .blue-rp .rp-icon.earned {
  background: #2563eb;
}

body.theme-light .match-team-chip {
  color: #142033;
  background: #f8fafc;
  border-color: rgba(100, 116, 139, 0.2);
}

body.theme-light .match-team-chip.filled.red-score {
  color: #9f1239;
  background: #ffe4e6;
  border-color: rgba(225, 29, 72, 0.46);
}

body.theme-light .match-team-chip.filled.blue-score {
  color: #1d4ed8;
  background: #dbeafe;
  border-color: rgba(37, 99, 235, 0.46);
}

body.theme-light .match-team-chip.missing {
  opacity: 0.78;
  filter: none;
}

body.theme-light .match-archive-open .match-archive-summary,
body.theme-light .match-groups:has(.match-archive[open]) .match-archive[open] .match-archive-summary {
  border-bottom-color: rgba(100, 116, 139, 0.22);
}

body.theme-light .match-groups:has(.match-archive[open]) .match-archive[open] .match-group-meta {
  background: transparent;
  border-color: transparent;
}

body.theme-light .alliance-lane {
  background: #ffffff;
}

body.theme-light .red-lane {
  background: #fff7f7;
  border-color: rgba(225, 29, 72, 0.32);
}

body.theme-light .blue-lane {
  background: #f5f9ff;
  border-color: rgba(37, 99, 235, 0.32);
}

body.theme-light .match-team-row {
  background: #f8fafc;
}

body.theme-light .match-team-row .muted,
body.theme-light .match-group-meta {
  color: #526277;
}

body.theme-light .form-section,
body.theme-light .pit-fields-panel .choice-group,
body.theme-light .pit-archive .pit-fields-panel .choice-group,
body.theme-light .feature-check,
body.theme-light .pit-archive .feature-check,
body.theme-light .record-row,
body.theme-light .admin-user-row,
body.theme-light .match-expanded-detail,
body.theme-light .pit-archive-body,
body.theme-light .pit-detail-modal .pit-archive-body {
  background: rgba(255, 255, 255, 0.68);
}

body.theme-light .photo-upload-panel,
body.theme-light .counter-control,
body.theme-light .counter-control input,
body.theme-light .base-value,
body.theme-light .base-options button,
body.theme-light .team-list-empty,
body.theme-light .match-empty,
body.theme-light .official-ranking-interval select {
  background: #f8fafc;
}

body.theme-light .counter-field {
  color: #334155;
}

body.theme-light .match-workspace.editing #matchForm .counter-field {
  color: #334155;
}

body.theme-light .counter-control input:hover {
  background: #edf6ff;
}

body.theme-light .counter-control input:active {
  background: #dbeafe;
}

body.theme-light .counter-control button,
body.theme-light .base-control button,
body.theme-light .match-team-row .small-button,
body.theme-light .match-team-row .delete-button,
body.theme-light .role-pill,
body.theme-light .official-ranking-table thead th {
  background: #e9f0f8;
}

body.theme-light .official-ranking-table thead th.official-ranking-active-head {
  background: linear-gradient(180deg, rgba(14, 165, 233, 0.2), rgba(14, 165, 233, 0.1)), #e9f0f8;
}

body.theme-light .admin-user-row.is-pending-approval {
  background: rgba(245, 158, 11, 0.11);
}

body.theme-light .role-pill.is-disabled {
  color: #991b1b;
}

body.theme-light .role-pill.is-pending {
  color: #92400e;
}

body.theme-light .role-pill.is-email {
  color: #075985;
}

body.theme-light .role-pill.is-active {
  color: #047857;
}

body.theme-light .base-options button[aria-pressed="true"] {
  background: #dff7fb;
  border-color: rgba(6, 182, 212, 0.58);
}

body.theme-light .status-pill {
  color: #075e49;
  background: #e8f8f2;
  border-color: rgba(32, 201, 151, 0.42);
}

body.theme-light .status-pill.secondary {
  color: #07566b;
  background: #e7f5fb;
  border-color: rgba(6, 114, 142, 0.32);
}

body.theme-light .official-ranking-table tbody tr:nth-child(odd) td {
  background: rgba(15, 23, 42, 0.025);
}

body.theme-light .official-ranking-table tbody tr:hover td,
body.theme-light .match-archive:hover,
body.theme-light .pit-archive:hover {
  background: rgba(6, 114, 142, 0.08);
}

@media (max-width: 760px) {
  body.theme-light .official-ranking-table tbody tr {
    background: var(--surface-2);
  }

  body.theme-light .official-ranking-table tbody tr:nth-child(odd) td,
  body.theme-light .official-ranking-table tbody tr:hover td,
  body.theme-light .official-ranking-table td,
  body.theme-light .official-ranking-table td[data-official-column="rank"],
  body.theme-light .official-ranking-table td[data-official-column="team"] {
    background: var(--panel-2) !important;
  }
}

body.theme-light .red-card {
  background: #dc2626;
}

body.theme-light .blue-card {
  background: #2563eb;
}

body.theme-light .delete-button,
body.theme-light .match-team-row .delete-button,
body.theme-light .pit-archive-action.is-danger {
  color: #b91c1c;
}

body.theme-light .alliance-red,
body.theme-light .red-text {
  color: #b91c1c;
}

body.theme-light .alliance-blue,
body.theme-light .blue-text {
  color: #1d4ed8;
}

/* Viewport-fit pass: keep live scouting work inside the visible screen. */
:root {
  --work-nav-height: 68px;
}

.view.active {
  min-width: 0;
}

#match.view.active:has(#matchForm:not([hidden])) .section-head,
#match.view.active:has(#matchForm:not([hidden])) #matchEditorTab {
  display: none;
}

#matchEventContent:has(#matchForm:not([hidden])) .match-report-head {
  display: none;
}

#matchEventContent:has(#matchForm:not([hidden])) {
  gap: 0;
}

#match.view.active:not(:has(#matchForm:not([hidden]))) {
  min-height: 420px;
  overflow: visible;
}

#match.view.active:not(:has(#matchForm:not([hidden]))) #matchEventContent,
#match.view.active:not(:has(#matchForm:not([hidden]))) .match-workspace,
#match.view.active:not(:has(#matchForm:not([hidden]))) .match-list-panel,
#match.view.active:not(:has(#matchForm:not([hidden]))) .match-groups {
  height: auto !important;
  max-height: none !important;
  overflow: visible !important;
}

#matchForm .match-phase-tabs {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  min-width: 0;
  margin: 0;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.035);
}

#matchForm .match-phase-tab {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 42px;
  padding: 0 10px;
  border-radius: 6px;
  color: var(--muted);
  font-size: 16px;
  font-weight: 950;
  cursor: pointer;
}

#matchForm .match-phase-tab input {
  position: absolute;
  inset: 0;
  opacity: 0;
  pointer-events: none;
}

#matchForm .match-phase-tab:has(input:checked) {
  background: var(--panel-2);
  color: var(--text);
  box-shadow: inset 0 -2px 0 var(--accent);
}

#matchForm:has(input[name="matchPhase"][value="auto"]:checked) .graphic-scorer-teleop,
#matchForm:has(input[name="matchPhase"][value="auto"]:checked) .teleop-section,
#matchForm:has(input[name="matchPhase"][value="auto"]:checked) .quality-section,
#matchForm:has(input[name="matchPhase"][value="teleop"]:checked) .graphic-scorer-auto,
#matchForm:has(input[name="matchPhase"][value="teleop"]:checked) .auto-section,
#matchForm:has(input[name="matchPhase"][value="teleop"]:checked) .quality-section,
#matchForm:has(input[name="matchPhase"][value="quality"]:checked) .graphic-scorer,
#matchForm:has(input[name="matchPhase"][value="quality"]:checked) .auto-section,
#matchForm:has(input[name="matchPhase"][value="quality"]:checked) .teleop-section {
  display: none !important;
}

@media (orientation: landscape) and (min-width: 900px) {
  #matchEventContent:has(#matchForm:not([hidden])) .match-workspace.editing {
    height: calc(100dvh - var(--nav-sticky-top) - var(--work-nav-height) - var(--content-pad) - var(--content-pad)) !important;
    max-height: calc(100dvh - var(--nav-sticky-top) - var(--work-nav-height) - var(--content-pad) - var(--content-pad)) !important;
    min-height: 500px;
    overflow: hidden;
  }

  #matchEventContent:has(#matchForm:not([hidden])) .match-workspace.editing .match-list-panel {
    display: none;
  }

  #matchEventContent:has(#matchForm:not([hidden])) .match-workspace.editing #matchForm {
    display: grid;
    grid-template-columns: minmax(360px, 1fr) minmax(360px, 604px);
    grid-template-rows: auto auto auto auto auto minmax(0, 1fr) auto;
    height: 100%;
    max-height: 100%;
    padding: 10px;
    gap: 8px 12px;
    overflow: hidden;
  }

  .match-workspace.editing #matchForm .match-editor-head {
    grid-column: 1;
    grid-row: 1;
    min-height: 34px;
  }

  .match-workspace.editing #matchForm .match-editor-head h3 {
    font-size: 20px;
  }

  .match-workspace.editing #matchForm .match-editor-head .secondary-button {
    min-width: 96px;
    min-height: 34px;
    font-size: 14px;
  }

  .match-workspace.editing #matchForm .match-id-field {
    grid-row: 2 !important;
    grid-template-columns: max-content minmax(0, 1fr);
    gap: 8px;
    font-size: 18px;
  }

  .match-workspace.editing #matchForm .match-id-field:nth-of-type(1) {
    grid-column: 1;
    grid-row: 2 !important;
  }

  .match-workspace.editing #matchForm .match-id-field:nth-of-type(2) {
    grid-column: 1;
    grid-row: 3 !important;
  }

  .match-workspace.editing #matchForm .match-id-field input {
    min-height: 44px;
    padding: 7px 10px;
    font-size: 24px;
  }

  .match-workspace.editing #matchForm .alliance-choice {
    grid-column: 1;
    grid-row: 4 !important;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-template-rows: 44px;
    min-height: 44px;
    height: auto;
    gap: 8px;
  }

  .match-workspace.editing #matchForm .alliance-choice legend {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
  }

  .match-workspace.editing #matchForm .alliance-card {
    min-height: 44px;
    height: 44px;
    font-size: 18px;
  }

  .match-workspace.editing #matchForm .match-phase-tabs {
    grid-column: 1;
    grid-row: 5;
  }

  .match-workspace.editing #matchForm .auto-section,
  .match-workspace.editing #matchForm .teleop-section {
    grid-column: 1 !important;
    grid-row: 6 !important;
    align-self: stretch;
    min-height: 0;
    max-height: 100%;
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-gutter: stable;
  }

  .match-workspace.editing #matchForm .quality-section {
    grid-column: 1 / -1 !important;
    grid-row: 6 !important;
    align-self: stretch;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-gutter: stable;
  }

  .match-workspace.editing #matchForm .graphic-scorer {
    grid-column: 2 !important;
    grid-row: 1 / -1 !important;
    align-self: stretch;
    justify-items: end;
    align-content: center;
    width: 100%;
    min-height: 0;
    height: 100%;
    overflow: visible;
  }

  .match-workspace.editing #matchForm .graphic-scorer-stage {
    width: min(100%, 604px);
  }

  .match-workspace.editing #matchForm > .form-actions {
    grid-column: 1;
    grid-row: 7;
    align-self: end;
    margin: 0;
  }

  .match-workspace.editing #matchForm .form-section {
    padding: 8px;
    gap: 7px 9px;
    align-content: start;
  }

  .match-workspace.editing #matchForm .auto-section h3,
  .match-workspace.editing #matchForm .teleop-section h3 {
    height: 46px;
    margin-bottom: 2px;
    font-size: 28px;
  }

  .match-workspace.editing #matchForm .checkbox-row {
    min-height: 48px;
    gap: 10px;
    font-size: 18px;
  }

  .match-workspace.editing #matchForm .checkbox-row input {
    width: 28px;
    min-width: 28px;
    min-height: 28px;
  }

  .match-workspace.editing #matchForm .auto-section .field-cluster,
  .match-workspace.editing #matchForm .auto-section .numeric-cluster {
    grid-auto-rows: auto;
  }

  .match-workspace.editing #matchForm .auto-section {
    grid-template-columns: minmax(170px, 0.44fr) minmax(220px, 0.56fr);
  }

  .match-workspace.editing #matchForm .auto-section h3 {
    grid-column: 1 / -1;
  }

  .match-workspace.editing #matchForm .auto-section .field-cluster {
    grid-column: 1;
    grid-row: 2;
    align-content: start;
  }

  .match-workspace.editing #matchForm .auto-section .numeric-cluster {
    grid-column: 2;
    grid-row: 2;
    align-content: start;
  }

  .match-workspace.editing #matchForm .teleop-section,
  .match-workspace.editing #matchForm .quality-section {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .match-workspace.editing #matchForm .teleop-section h3,
  .match-workspace.editing #matchForm .quality-section h3,
  .match-workspace.editing #matchForm .quality-section .reliability-field,
  .match-workspace.editing #matchForm .quality-section .wide {
    grid-column: 1 / -1;
  }

  .match-workspace.editing #matchForm .teleop-section > .counter-field,
  .match-workspace.editing #matchForm .teleop-section > .phase-disabled-field {
    grid-column: auto;
  }

  .match-workspace.editing #matchForm .teleop-section .base-field {
    grid-column: auto;
  }

  .match-workspace.editing #matchForm .quality-section .reliability-field {
    gap: 4px;
    font-size: 14px;
  }

  .match-workspace.editing #matchForm .quality-section .range-scale {
    font-size: 12px;
  }

  .match-workspace.editing #matchForm .quality-section input[type="range"] {
    min-height: 24px;
  }

  .match-workspace.editing #matchForm .quality-section textarea {
    min-height: 52px;
    max-height: 58px;
  }

  .match-workspace.editing #matchForm .counter-field {
    gap: 4px;
    font-size: 15px;
  }

  .match-workspace.editing #matchForm .counter-control {
    grid-template-columns: 38px minmax(58px, 1fr) 38px;
    min-height: 40px;
  }

  .match-workspace.editing #matchForm .counter-control input {
    min-height: 40px;
    font-size: 22px;
  }

  .match-workspace.editing #matchForm .counter-control button {
    font-size: 22px;
  }

  .match-workspace.editing #matchForm .base-control {
    grid-template-columns: 38px minmax(58px, 1fr) 38px;
    min-height: 40px;
  }

  .match-workspace.editing #matchForm .base-value {
    min-height: 40px;
    font-size: 22px;
  }

  .match-workspace.editing #matchForm .base-options {
    min-height: 44px;
    gap: 2px;
  }

  .match-workspace.editing #matchForm .base-options button {
    min-height: 44px;
    padding: 0 2px;
    border-radius: 7px;
    font-size: 12px;
  }
}

@media (orientation: landscape) and (min-width: 900px) and (max-height: 760px) {
  :root {
    --content-pad: 10px;
    --work-nav-height: 68px;
  }

  #matchEventContent:has(#matchForm:not([hidden])) .match-workspace.editing {
    min-height: 430px;
  }

  #matchEventContent:has(#matchForm:not([hidden])) .match-workspace.editing #matchForm {
    padding: 8px;
    gap: 6px 10px;
  }

  .match-workspace.editing #matchForm .match-editor-head {
    display: none;
  }

  .match-workspace.editing #matchForm .match-id-field {
    font-size: 16px;
  }

  .match-workspace.editing #matchForm .match-id-field input,
  .match-workspace.editing #matchForm .alliance-card,
  #matchForm .match-phase-tab {
    min-height: 38px;
    height: 38px;
  }

  .match-workspace.editing #matchForm .auto-section h3,
  .match-workspace.editing #matchForm .teleop-section h3 {
    height: 40px;
    font-size: 24px;
  }

  .match-workspace.editing #matchForm .checkbox-row {
    min-height: 42px;
    font-size: 16px;
  }
}

@media (max-width: 899px), (orientation: portrait) {
  #matchForm .match-phase-tabs {
    order: 0;
  }

  .match-workspace.editing #matchForm .graphic-scorer,
  .match-workspace.editing #matchForm .auto-section,
  .match-workspace.editing #matchForm .teleop-section,
  .match-workspace.editing #matchForm .quality-section {
    grid-column: 1 !important;
    grid-row: auto !important;
  }
}

#pit.view.active:has(#pitForm:not([hidden])) #pitForm,
#pit.view.active:has(#pitForm:not([hidden])) #pitCards,
#dashboard .dashboard-settings-panel,
#dashboard .dashboard-admin-users {
  max-height: min(860px, calc(100dvh - var(--nav-sticky-top) - var(--work-nav-height) - var(--content-pad) - var(--content-pad)));
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
}

#pit.view.active:has(#pitForm:not([hidden])) {
  height: min(860px, calc(100dvh - var(--nav-sticky-top) - var(--work-nav-height) - var(--content-pad) - var(--content-pad)));
  overflow: hidden;
}

#pit.view.active:has(#pitForm:not([hidden])) .pit-editor-tab,
#pit.view.active:has(#pitForm:not([hidden])) #pitCards {
  display: none;
}

#pit.view.active:has(#pitForm:not([hidden])) #pitForm {
  height: 100%;
}

#dashboard.view.active.settings-focus {
  height: min(860px, calc(100dvh - var(--nav-sticky-top) - var(--work-nav-height) - var(--content-pad) - var(--content-pad)));
  overflow: hidden;
}

#dashboard.view.active.settings-focus > :not(#dashboardSettings) {
  display: none;
}

#dashboard.view.active.settings-focus #dashboardSettings {
  height: 100%;
  max-height: 100%;
  margin: 0;
  box-sizing: border-box;
}

#ranking.view.active {
  max-height: min(860px, calc(100dvh - var(--nav-sticky-top) - var(--work-nav-height) - var(--content-pad) - var(--content-pad)));
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
}

#ranking.view.active .official-ranking-table-wrap {
  max-height: min(620px, calc(100dvh - var(--nav-sticky-top) - 190px));
}

#ranking.view.active .split-grid {
  grid-template-columns: repeat(auto-fit, minmax(310px, 1fr));
}

/* Phone match cards: split title, score, and team chips into separate rows. */
@media (max-width: 560px) {
  .match-groups > .match-archive:not([open]):not(.match-archive-compact) .match-archive-summary {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas:
      "title action"
      "score score"
      "teams teams";
    align-items: center;
    min-height: 0;
    padding: 14px;
    gap: 10px 12px;
    overflow: hidden;
  }

  .match-groups > .match-archive:not([open]):not(.match-archive-compact) .match-summary-title {
    display: contents;
    width: auto;
    min-height: 0;
    max-width: none;
  }

  .match-groups > .match-archive:not([open]):not(.match-archive-compact) .match-summary-title > strong {
    position: static;
    grid-area: title;
    align-self: center;
    justify-self: start;
    font-size: clamp(38px, 12vw, 54px);
    line-height: 1;
  }

  .match-groups > .match-archive:not([open]):not(.match-archive-compact) .match-archive-right {
    display: contents;
  }

  .match-groups > .match-archive:not([open]):not(.match-archive-compact) .expand-label {
    position: static;
    grid-area: action;
    min-width: 76px;
    min-height: 42px;
    padding: 0 10px;
    font-size: 16px;
  }

  .match-groups > .match-archive:not([open]):not(.match-archive-compact) .match-score-badge,
  .match-groups > .match-archive:not([open]):not(.match-archive-compact) .match-score-with-rp {
    grid-area: score;
    justify-self: center;
    display: grid;
    width: min(100%, 286px);
    max-width: 100%;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-template-areas:
      "redScore blueScore"
      "redRp blueRp";
    align-items: center;
    justify-items: center;
    gap: 5px 8px;
    overflow: hidden;
    font-size: clamp(30px, 9.5vw, 40px);
    line-height: 1;
  }

  .match-groups > .match-archive:not([open]):not(.match-archive-compact) .match-score-badge > .red-score,
  .match-groups > .match-archive:not([open]):not(.match-archive-compact) .match-score-badge > .blue-score {
    width: auto;
    min-width: 0;
    padding: 0;
    justify-self: center;
  }

  .match-groups > .match-archive:not([open]):not(.match-archive-compact) .match-score-badge > .red-score {
    grid-area: redScore;
  }

  .match-groups > .match-archive:not([open]):not(.match-archive-compact) .match-score-badge > .blue-score {
    grid-area: blueScore;
  }

  .match-groups > .match-archive:not([open]):not(.match-archive-compact) .match-score-with-rp > .red-rp {
    grid-area: redRp;
  }

  .match-groups > .match-archive:not([open]):not(.match-archive-compact) .match-score-with-rp > .blue-rp {
    grid-area: blueRp;
  }

  .match-groups > .match-archive:not([open]):not(.match-archive-compact) .rp-strip {
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    width: min(100%, 92px);
    min-width: 0;
    gap: 2px;
  }

  .match-groups > .match-archive:not([open]):not(.match-archive-compact) .rp-icon {
    width: 9px;
    height: 9px;
    border-radius: 999px;
  }

  .match-groups > .match-archive:not([open]):not(.match-archive-compact) .rp-icon svg {
    display: none;
  }

  .match-groups > .match-archive:not([open]):not(.match-archive-compact) .match-archive-teams {
    grid-area: teams;
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas:
      "redTeams"
      "versus"
      "blueTeams";
    justify-items: stretch;
    width: 100%;
    gap: 5px;
    overflow: visible;
    white-space: normal;
  }

  .match-groups > .match-archive:not([open]):not(.match-archive-compact) .match-team-chip-group {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: 100%;
    gap: 8px;
  }

  .match-groups > .match-archive:not([open]):not(.match-archive-compact) .match-team-chip-group:first-child {
    grid-area: redTeams;
  }

  .match-groups > .match-archive:not([open]):not(.match-archive-compact) .match-team-chip-group:last-child {
    grid-area: blueTeams;
  }

  .match-groups > .match-archive:not([open]):not(.match-archive-compact) .match-archive-teams .versus {
    grid-area: versus;
    justify-self: center;
    min-width: 0;
    font-size: 13px;
    line-height: 1;
  }

  .match-groups > .match-archive:not([open]):not(.match-archive-compact) .match-team-chip {
    width: 100%;
    min-width: 0;
    height: 36px;
    padding: 2px 4px;
    overflow: visible;
    font-size: 19px;
    text-overflow: clip;
    white-space: nowrap;
  }

  .match-archive-compact .match-archive-summary {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) !important;
    grid-template-areas:
      "title"
      "score"
      "teams" !important;
    min-height: 0 !important;
    padding: 14px !important;
    gap: 10px !important;
  }

  .match-archive-compact .match-summary-title {
    display: contents !important;
    min-height: 0 !important;
  }

  .match-archive-compact .match-archive-summary strong,
  .match-workspace.editing .match-archive-compact .match-summary-title > strong,
  .match-groups:has(.match-archive[open]) .match-archive-compact .match-summary-title > strong {
    position: static !important;
    grid-area: title !important;
    font-size: clamp(36px, 11vw, 48px) !important;
    line-height: 1 !important;
  }

  .match-archive-compact .match-score-badge,
  .match-workspace.editing .match-archive-compact .match-score-badge,
  .match-groups:has(.match-archive[open]) .match-archive-compact .match-score-badge,
  .match-archive-compact .match-score-with-rp,
  .match-workspace.editing .match-archive-compact .match-score-with-rp,
  .match-groups:has(.match-archive[open]) .match-archive-compact .match-score-with-rp {
    grid-area: score !important;
    display: grid !important;
    width: min(100%, 286px) !important;
    max-width: 100% !important;
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    grid-template-areas:
      "redScore blueScore"
      "redRp blueRp" !important;
    justify-self: center !important;
    justify-items: center !important;
    gap: 5px 8px !important;
    overflow: hidden !important;
    font-size: clamp(30px, 9.5vw, 40px) !important;
  }

  .match-archive-compact .rp-strip,
  .match-workspace.editing .match-archive-compact .match-score-with-rp .rp-strip,
  .match-groups:has(.match-archive[open]) .match-archive-compact .rp-strip {
    grid-template-columns: repeat(6, minmax(0, 1fr)) !important;
    width: min(100%, 92px) !important;
    min-width: 0 !important;
  }

  .match-archive-compact .rp-icon,
  .match-workspace.editing .match-archive-compact .match-score-with-rp .rp-icon,
  .match-groups:has(.match-archive[open]) .match-archive-compact .rp-icon {
    width: 9px !important;
    height: 9px !important;
    border-radius: 999px !important;
  }

  .match-archive-compact .rp-icon svg,
  .match-workspace.editing .match-archive-compact .match-score-with-rp .rp-icon svg,
  .match-groups:has(.match-archive[open]) .match-archive-compact .rp-icon svg {
    display: none !important;
  }

  .match-archive-compact .match-archive-right {
    display: contents !important;
  }

  .match-archive-compact .match-archive-teams,
  .match-workspace.editing .match-archive-compact .match-archive-teams,
  .match-groups:has(.match-archive[open]) .match-archive-compact .match-archive-teams {
    grid-area: teams !important;
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) !important;
    grid-template-areas:
      "redTeams"
      "versus"
      "blueTeams" !important;
    justify-items: stretch !important;
    width: 100% !important;
    gap: 5px !important;
    overflow: visible !important;
    white-space: normal !important;
  }

  .match-archive-compact .match-team-chip-group,
  .match-workspace.editing .match-archive-compact .match-team-chip-group,
  .match-groups:has(.match-archive[open]) .match-archive-compact .match-team-chip-group {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    width: 100% !important;
    gap: 8px !important;
  }

  .match-archive-compact .match-team-chip-group:first-child,
  .match-workspace.editing .match-archive-compact .match-team-chip-group:first-child,
  .match-groups:has(.match-archive[open]) .match-archive-compact .match-team-chip-group:first-child {
    grid-area: redTeams !important;
  }

  .match-archive-compact .match-team-chip-group:last-child,
  .match-workspace.editing .match-archive-compact .match-team-chip-group:last-child,
  .match-groups:has(.match-archive[open]) .match-archive-compact .match-team-chip-group:last-child {
    grid-area: blueTeams !important;
  }

  .match-archive-compact .match-archive-teams .versus,
  .match-workspace.editing .match-archive-compact .match-archive-teams .versus,
  .match-groups:has(.match-archive[open]) .match-archive-compact .match-archive-teams .versus {
    grid-area: versus !important;
    justify-self: center !important;
    min-width: 0 !important;
    font-size: 13px !important;
    line-height: 1 !important;
  }

  .match-archive-compact .match-team-chip,
  .match-workspace.editing .match-archive-compact .match-team-chip,
  .match-groups:has(.match-archive[open]) .match-archive-compact .match-team-chip {
    width: 100% !important;
    min-width: 0 !important;
    height: 36px !important;
    padding: 2px 4px !important;
    overflow: visible !important;
    font-size: 19px !important;
    text-overflow: clip !important;
    white-space: nowrap !important;
  }

  .match-archive-compact .match-score-badge > .red-score,
  .match-workspace.editing .match-archive-compact .match-score-badge > .red-score,
  .match-groups:has(.match-archive[open]) .match-archive-compact .match-score-badge > .red-score {
    grid-area: redScore !important;
  }

  .match-archive-compact .match-score-badge > .blue-score,
  .match-workspace.editing .match-archive-compact .match-score-badge > .blue-score,
  .match-groups:has(.match-archive[open]) .match-archive-compact .match-score-badge > .blue-score {
    grid-area: blueScore !important;
  }
}

@media (max-width: 380px) {
  .match-groups > .match-archive:not([open]):not(.match-archive-compact) .match-archive-summary,
  .match-archive-compact .match-archive-summary {
    padding: 12px !important;
    gap: 8px !important;
  }

  .match-groups > .match-archive:not([open]):not(.match-archive-compact) .match-score-badge,
  .match-groups > .match-archive:not([open]):not(.match-archive-compact) .match-score-with-rp,
  .match-archive-compact .match-score-badge,
  .match-archive-compact .match-score-with-rp {
    width: min(100%, 260px) !important;
    font-size: 30px !important;
  }

  .match-groups > .match-archive:not([open]):not(.match-archive-compact) .match-team-chip,
  .match-archive-compact .match-team-chip,
  .match-workspace.editing .match-archive-compact .match-team-chip,
  .match-groups:has(.match-archive[open]) .match-archive-compact .match-team-chip {
    height: 34px !important;
    font-size: 17px !important;
  }
}

/* Phone match editor fields: keep "Match #" and "Team #" as unbroken labels. */
@media (max-width: 560px) {
  #matchForm,
  .match-workspace.editing #matchForm {
    grid-template-columns: minmax(0, 1fr) !important;
    overflow-x: hidden;
  }

  #matchForm > *,
  .match-workspace.editing #matchForm > * {
    min-width: 0;
    max-width: 100%;
  }

  #matchForm .match-id-field,
  .match-workspace.editing #matchForm .match-id-field {
    display: grid;
    grid-template-columns: max-content minmax(0, 1fr) !important;
    align-items: center;
    gap: 10px;
    white-space: nowrap;
    font-size: clamp(26px, 8vw, 34px);
    line-height: 1;
  }

  #matchForm .match-id-field input,
  .match-workspace.editing #matchForm .match-id-field input {
    width: 100%;
    min-width: 0;
    max-width: 100%;
    padding-inline: 10px;
    font-size: clamp(26px, 7.4vw, 32px);
  }

  #matchForm .graphic-scorer,
  .match-workspace.editing #matchForm .graphic-scorer {
    width: 100%;
    min-width: 0;
    max-width: 100%;
    justify-items: center;
    overflow: hidden;
  }

  #matchForm .graphic-scorer-stage,
  .match-workspace.editing #matchForm .graphic-scorer-stage {
    max-width: 100% !important;
  }
}

@media (max-width: 380px) {
  #matchForm .match-id-field,
  .match-workspace.editing #matchForm .match-id-field {
    gap: 8px;
    font-size: clamp(23px, 7.4vw, 28px);
  }

  #matchForm .match-id-field input,
  .match-workspace.editing #matchForm .match-id-field input {
    padding-inline: 8px;
    font-size: clamp(24px, 7vw, 29px);
  }
}

/* iPad portrait: keep the active scoring phase inside the visible work area. */
@media (orientation: portrait) and (min-width: 700px) and (max-width: 899px) {
  #matchEventContent:has(#matchForm:not([hidden])) .match-workspace.editing {
    height: min(1040px, calc(100dvh - var(--nav-sticky-top) - var(--work-nav-height) - var(--content-pad) - var(--content-pad)));
    min-height: 760px;
    overflow: hidden;
  }

  #matchEventContent:has(#matchForm:not([hidden])) .match-workspace.editing .match-list-panel {
    display: none;
  }

  #matchEventContent:has(#matchForm:not([hidden])) .match-workspace.editing #matchForm {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    grid-template-rows: auto auto auto auto minmax(0, 1fr) auto;
    height: 100%;
    max-height: 100%;
    padding: 14px;
    gap: 10px 14px;
    overflow: hidden;
  }

  .match-workspace.editing #matchForm .match-editor-head {
    grid-column: 1 / -1;
    grid-row: 1;
    min-height: 44px;
  }

  .match-workspace.editing #matchForm .match-id-field {
    grid-row: 2 !important;
    grid-template-columns: max-content minmax(0, 1fr) !important;
    gap: 10px;
    white-space: nowrap;
    font-size: 24px;
  }

  .match-workspace.editing #matchForm .match-id-field:nth-of-type(1) {
    grid-column: 1;
  }

  .match-workspace.editing #matchForm .match-id-field:nth-of-type(2) {
    grid-column: 2;
  }

  .match-workspace.editing #matchForm .match-id-field input {
    width: 100%;
    min-width: 0;
    min-height: 48px;
    padding: 8px 10px;
    font-size: 28px;
  }

  .match-workspace.editing #matchForm .alliance-choice {
    grid-column: 1 / -1;
    grid-row: 3 !important;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-template-rows: auto 48px;
    min-height: 82px;
    height: auto;
    gap: 8px;
  }

  .match-workspace.editing #matchForm .alliance-choice legend {
    position: static;
    grid-column: 1 / -1;
    width: auto;
    height: auto;
    padding: 0;
    margin: 0;
    overflow: visible;
    clip: auto;
    white-space: normal;
    border: 0;
  }

  .match-workspace.editing #matchForm .alliance-card {
    min-height: 48px;
    height: 48px;
    font-size: 18px;
  }

  .match-workspace.editing #matchForm .match-phase-tabs {
    grid-column: 1 / -1;
    grid-row: 4;
  }

  .match-workspace.editing #matchForm .auto-section,
  .match-workspace.editing #matchForm .teleop-section {
    grid-column: 1 !important;
    grid-row: 5 !important;
    align-self: stretch;
    min-height: 0;
    max-height: 100%;
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-gutter: stable;
  }

  .match-workspace.editing #matchForm .quality-section {
    grid-column: 1 / -1 !important;
    grid-row: 5 !important;
    align-self: stretch;
    min-height: 0;
    max-height: 100%;
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-gutter: stable;
  }

  .match-workspace.editing #matchForm .graphic-scorer {
    grid-column: 2 !important;
    grid-row: 5 !important;
    align-self: stretch;
    justify-items: end;
    align-content: start;
    width: 100%;
    min-width: 0;
    min-height: 0;
    height: 100%;
    overflow: hidden;
  }

  .match-workspace.editing #matchForm .graphic-scorer-stage {
    width: min(100%, 604px);
    max-width: 100%;
  }

  .match-workspace.editing #matchForm > .form-actions {
    grid-column: 1 / -1;
    grid-row: 6;
    margin: 0;
  }

  .match-workspace.editing #matchForm .form-section {
    padding: 10px;
    gap: 8px 10px;
  }

  .match-workspace.editing #matchForm .auto-section {
    grid-template-columns: minmax(0, 1fr);
  }

  .match-workspace.editing #matchForm .teleop-section {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .match-workspace.editing #matchForm .teleop-section .base-field {
    grid-column: auto !important;
  }

  .match-workspace.editing #matchForm .auto-section h3,
  .match-workspace.editing #matchForm .teleop-section h3 {
    height: 44px;
    font-size: 26px;
  }

  .match-workspace.editing #matchForm .checkbox-row {
    min-height: 46px;
    font-size: 17px;
  }

  .match-workspace.editing #matchForm .counter-control {
    min-height: 40px;
  }

  .match-workspace.editing #matchForm .base-control {
    grid-template-columns: 38px minmax(58px, 1fr) 38px;
    min-height: 40px;
  }

  .match-workspace.editing #matchForm .base-value {
    min-height: 40px;
    font-size: 22px;
  }

  .match-workspace.editing #matchForm .base-options {
    min-height: 60px;
    gap: 2px;
  }

  .match-workspace.editing #matchForm .base-options button {
    min-height: 60px;
    padding: 0 2px;
    border-radius: 7px;
    font-size: 12px;
  }
}

/* Keep Endgame Base compact with the TeleOp controls, even in cached responsive layers. */
.match-workspace.editing #matchForm .teleop-section > .counter-field.base-field,
#matchForm .teleop-section > .counter-field.base-field {
  grid-column: auto !important;
  justify-self: stretch;
  width: 100%;
}

.match-workspace.editing #matchForm .teleop-section > .counter-field.base-field .base-options,
#matchForm .teleop-section > .counter-field.base-field .base-options {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

/* Keep collapsed match rows stable when playoff labels and score badges are long. */
.match-groups > .match-archive:not([open]):not(.match-archive-compact) .match-archive-summary {
  display: grid !important;
  grid-template-columns: minmax(132px, 220px) minmax(0, 1fr) minmax(76px, 100px);
  grid-template-areas:
    "title score action"
    "teams teams teams";
  align-items: center;
  justify-items: stretch;
  min-height: 126px;
  padding: 12px 14px;
  gap: 10px 12px;
}

.match-groups > .match-archive:not([open]):not(.match-archive-compact) .match-summary-title {
  display: contents;
}

.match-groups > .match-archive:not([open]):not(.match-archive-compact) .match-summary-title > strong {
  grid-area: title;
  align-self: center;
  justify-self: start;
  min-width: 0;
  max-width: 100%;
  white-space: normal;
  overflow-wrap: anywhere;
  line-height: 1.02;
}

.match-groups > .match-archive:not([open]):not(.match-archive-compact) .match-summary-title > .match-score-badge {
  grid-area: score;
  grid-column: auto;
  align-self: center;
  justify-self: center;
  justify-content: center;
  justify-items: center;
  width: min(100%, 720px);
  max-width: 100%;
  min-width: 0;
  margin: 0;
}

.match-groups > .match-archive:not([open]):not(.match-archive-compact) .match-summary-title > .match-score-badge:not(.match-score-with-rp) {
  grid-template-columns: max-content max-content;
  gap: 14px;
  font-size: 30px;
}

.match-groups > .match-archive:not([open]):not(.match-archive-compact) .match-score-badge > .red-score,
.match-groups > .match-archive:not([open]):not(.match-archive-compact) .match-score-badge > .blue-score {
  width: auto;
  min-width: 104px;
}

.match-groups > .match-archive:not([open]):not(.match-archive-compact) .match-score-with-rp {
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  grid-template-areas:
    "redScore blueScore"
    "redRp blueRp";
  gap: 5px 16px;
}

.match-groups > .match-archive:not([open]):not(.match-archive-compact) .match-archive-right {
  display: contents;
}

.match-groups > .match-archive:not([open]):not(.match-archive-compact) .match-archive-teams {
  grid-area: teams;
  align-self: center;
  justify-self: center;
}

.match-groups > .match-archive:not([open]):not(.match-archive-compact) .expand-label {
  position: static;
  grid-area: action;
  align-self: start;
  justify-self: end;
}

.match-archive-compact .match-summary-title > .match-score-badge:not(.match-score-with-rp) {
  display: grid;
  grid-template-columns: max-content max-content;
  justify-content: center;
  justify-items: center;
  width: min(58%, 360px);
  max-width: calc(100% - 176px);
  margin-inline: auto;
  gap: 12px;
}

.match-archive-compact .match-summary-title > .match-score-badge:not(.match-score-with-rp) > .red-score,
.match-archive-compact .match-summary-title > .match-score-badge:not(.match-score-with-rp) > .blue-score {
  width: auto;
  min-width: 92px;
}

@media (max-width: 760px) {
  .match-groups > .match-archive:not([open]):not(.match-archive-compact) .match-archive-summary {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas:
      "title"
      "score"
      "teams"
      "action";
    min-height: 154px;
    gap: 8px;
  }

  .match-groups > .match-archive:not([open]):not(.match-archive-compact) .match-summary-title > strong {
    justify-self: center;
    text-align: center;
  }

  .match-groups > .match-archive:not([open]):not(.match-archive-compact) .match-summary-title > .match-score-badge:not(.match-score-with-rp) {
    font-size: 27px;
    gap: 10px;
  }

  .match-groups > .match-archive:not([open]):not(.match-archive-compact) .match-score-badge > .red-score,
  .match-groups > .match-archive:not([open]):not(.match-archive-compact) .match-score-badge > .blue-score {
    min-width: 82px;
  }

  .match-groups > .match-archive:not([open]):not(.match-archive-compact) .expand-label {
    align-self: center;
    justify-self: center;
  }

  .match-archive-compact .match-summary-title > .match-score-badge:not(.match-score-with-rp) {
    width: min(62%, 320px);
    max-width: calc(100% - 110px);
  }

  .match-archive-compact .match-summary-title > .match-score-badge:not(.match-score-with-rp) > .red-score,
  .match-archive-compact .match-summary-title > .match-score-badge:not(.match-score-with-rp) > .blue-score {
    min-width: 76px;
  }
}

/* Match row alignment foundation: score and team columns share the same stable grid. */
.match-groups > .match-archive:not([open]):not(.match-archive-compact) .match-archive-summary {
  display: grid !important;
  grid-template-columns: minmax(92px, 170px) minmax(0, 1fr) minmax(88px, 118px) !important;
  grid-template-areas:
    "title score action"
    "title teams action" !important;
  align-items: center !important;
  justify-items: stretch !important;
  min-height: 132px !important;
  padding: 14px 16px !important;
  gap: 8px 16px !important;
  overflow: hidden !important;
}

.match-groups > .match-archive:not([open]):not(.match-archive-compact) .match-summary-title,
.match-archive-compact .match-summary-title,
.match-workspace.editing .match-summary-title {
  display: contents !important;
}

.match-groups > .match-archive:not([open]):not(.match-archive-compact) .match-summary-title > strong {
  grid-area: title !important;
  align-self: center !important;
  justify-self: start !important;
  min-width: 0 !important;
  max-width: 100% !important;
  font-size: 26px !important;
  line-height: 1.02 !important;
  white-space: normal !important;
  overflow-wrap: anywhere !important;
}

.match-score-board {
  display: grid !important;
  grid-template-columns: minmax(0, 1fr) 28px minmax(0, 1fr) !important;
  grid-template-areas: none !important;
  align-items: start !important;
  justify-items: stretch !important;
  justify-content: stretch !important;
  width: min(100%, 980px) !important;
  max-width: 100% !important;
  min-width: 0 !important;
  margin: 0 auto !important;
  gap: 8px !important;
  overflow: visible !important;
}

.match-score-board .red-score-side {
  grid-column: 1 !important;
}

.match-score-board .blue-score-side {
  grid-column: 3 !important;
}

.match-groups > .match-archive:not([open]):not(.match-archive-compact) .match-summary-title > .match-score-board {
  grid-area: score !important;
  align-self: end !important;
  justify-self: center !important;
}

.match-score-side {
  display: grid !important;
  grid-template-rows: auto auto !important;
  align-content: start !important;
  align-items: start !important;
  justify-items: center !important;
  min-width: 0 !important;
  min-height: 64px !important;
  gap: 6px !important;
}

.match-score-side:not(:has(.rp-strip)) {
  grid-template-rows: auto !important;
}

.match-score-value,
.match-score-badge .match-score-value,
.match-score-board .red-score,
.match-score-board .blue-score {
  display: inline-grid !important;
  width: auto !important;
  min-width: 108px !important;
  place-items: center !important;
  padding: 0 4px !important;
  font-size: 30px !important;
  font-weight: 950 !important;
  line-height: 1 !important;
  font-variant-numeric: tabular-nums !important;
  text-align: center !important;
  white-space: nowrap !important;
}

.match-score-board .rp-strip {
  display: grid !important;
  grid-template-columns: repeat(6, 26px) !important;
  align-items: center !important;
  justify-content: center !important;
  justify-items: center !important;
  width: max-content !important;
  min-width: 0 !important;
  max-width: 100% !important;
  gap: 4px !important;
  overflow: visible !important;
}

.match-score-board .rp-icon {
  flex: 0 0 auto !important;
  width: 26px !important;
  height: 26px !important;
}

.match-score-board .rp-icon svg {
  display: block !important;
  width: 78% !important;
  height: 78% !important;
}

.match-groups > .match-archive:not([open]):not(.match-archive-compact) .match-archive-right {
  display: contents !important;
}

.match-groups > .match-archive:not([open]):not(.match-archive-compact) .match-archive-teams {
  grid-area: teams !important;
  display: grid !important;
  grid-template-columns: minmax(0, 1fr) 28px minmax(0, 1fr) !important;
  align-self: start !important;
  align-items: center !important;
  justify-self: center !important;
  justify-items: stretch !important;
  width: min(100%, 980px) !important;
  margin-inline: auto !important;
  gap: 8px !important;
  overflow: hidden !important;
  white-space: nowrap !important;
  text-align: center !important;
}

.match-groups > .match-archive:not([open]):not(.match-archive-compact) .match-team-chip-group,
.match-archive-compact .match-team-chip-group {
  display: grid !important;
  grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  align-items: center !important;
  justify-items: stretch !important;
  grid-area: auto !important;
  width: 100% !important;
  min-width: 0 !important;
  gap: 6px !important;
}

.match-archive-teams .red-team-chip-group {
  grid-area: auto / 1 / auto / 2 !important;
}

.match-archive-teams .versus {
  grid-area: auto / 2 / auto / 3 !important;
}

.match-archive-teams .blue-team-chip-group {
  grid-area: auto / 3 / auto / 4 !important;
}

.match-groups > .match-archive:not([open]):not(.match-archive-compact) .match-team-chip,
.match-archive-compact .match-team-chip {
  width: 100% !important;
  min-width: 0 !important;
}

.match-archive-teams .versus {
  align-self: center !important;
  justify-self: center !important;
  width: 28px !important;
  text-align: center !important;
}

.match-groups > .match-archive:not([open]):not(.match-archive-compact) .expand-label {
  position: static !important;
  grid-area: action !important;
  align-self: center !important;
  justify-self: end !important;
  min-width: 88px !important;
}

.match-archive-compact {
  min-height: 132px !important;
  overflow: hidden !important;
}

.match-archive-compact .match-archive-summary {
  display: grid !important;
  grid-template-columns: minmax(0, 1fr) !important;
  grid-template-areas:
    "title"
    "score"
    "teams" !important;
  align-items: center !important;
  justify-items: stretch !important;
  min-height: 132px !important;
  padding: 14px 18px !important;
  gap: 8px !important;
  overflow: hidden !important;
}

.match-archive-compact .match-summary-title > strong {
  position: static !important;
  grid-area: title !important;
  align-self: center !important;
  justify-self: start !important;
  max-width: 100% !important;
  font-size: 28px !important;
  line-height: 1.02 !important;
  white-space: normal !important;
  overflow-wrap: anywhere !important;
}

.match-archive-compact .match-summary-title > .match-score-board {
  grid-area: score !important;
  align-self: center !important;
  justify-self: center !important;
  width: min(100%, 430px) !important;
  gap: 6px !important;
}

.match-archive-compact .match-score-side {
  min-height: 52px !important;
  gap: 5px !important;
}

.match-archive-compact .match-score-value,
.match-archive-compact .match-score-board .red-score,
.match-archive-compact .match-score-board .blue-score {
  min-width: 82px !important;
  font-size: 25px !important;
}

.match-archive-compact .match-score-board .rp-strip {
  grid-template-columns: repeat(6, 16px) !important;
  gap: 3px !important;
}

.match-archive-compact .match-score-board .rp-icon {
  width: 16px !important;
  height: 16px !important;
  border-radius: 4px !important;
}

.match-archive-compact .match-archive-right {
  display: contents !important;
}

.match-archive-compact .match-archive-teams {
  grid-area: teams !important;
  display: grid !important;
  grid-template-columns: minmax(0, 1fr) 28px minmax(0, 1fr) !important;
  grid-template-areas: none !important;
  align-items: center !important;
  justify-items: stretch !important;
  width: min(100%, 430px) !important;
  margin-inline: auto !important;
  gap: 6px !important;
  overflow: hidden !important;
  white-space: nowrap !important;
  text-align: center !important;
}

.match-archive-compact .match-team-chip {
  height: 28px !important;
  padding: 1px 5px !important;
  font-size: 16px !important;
}

@media (max-width: 760px) {
  .match-groups > .match-archive:not([open]):not(.match-archive-compact) .match-archive-summary {
    grid-template-columns: minmax(0, 1fr) !important;
    grid-template-areas:
      "title"
      "score"
      "teams"
      "action" !important;
    min-height: 176px !important;
    padding: 14px !important;
    gap: 8px !important;
  }

  .match-groups > .match-archive:not([open]):not(.match-archive-compact) .match-summary-title > strong {
    justify-self: center !important;
    text-align: center !important;
    font-size: 25px !important;
  }

  .match-groups > .match-archive:not([open]):not(.match-archive-compact) .match-summary-title > .match-score-board,
  .match-groups > .match-archive:not([open]):not(.match-archive-compact) .match-archive-teams {
    width: 100% !important;
  }

  .match-score-board {
    grid-template-columns: minmax(0, 1fr) 24px minmax(0, 1fr) !important;
    gap: 5px !important;
  }

  .match-score-side {
    min-height: 54px !important;
  }

  .match-score-value,
  .match-score-board .red-score,
  .match-score-board .blue-score {
    min-width: 78px !important;
    font-size: 25px !important;
  }

  .match-score-board .rp-strip {
    grid-template-columns: repeat(6, 16px) !important;
    gap: 3px !important;
  }

  .match-score-board .rp-icon {
    width: 16px !important;
    height: 16px !important;
    border-radius: 4px !important;
  }

  .match-groups > .match-archive:not([open]):not(.match-archive-compact) .match-archive-teams,
  .match-archive-compact .match-archive-teams {
    grid-template-columns: minmax(0, 1fr) 24px minmax(0, 1fr) !important;
    grid-template-areas: none !important;
    gap: 5px !important;
  }

  .match-groups > .match-archive:not([open]):not(.match-archive-compact) .match-team-chip-group,
  .match-archive-compact .match-team-chip-group {
    gap: 4px !important;
  }

  .match-team-chip {
    height: 30px !important;
    font-size: 16px !important;
  }

  .match-groups > .match-archive:not([open]):not(.match-archive-compact) .expand-label {
    justify-self: center !important;
  }
}
