:root {
  color-scheme: light;
  font-family: "Segoe UI Variable", "Segoe UI", "Microsoft YaHei", sans-serif;
  font-synthesis: none;
  color: #18212a;
  background: #f4f7fa;
  --canvas: #f4f7fa;
  --surface: #ffffff;
  --ink: #18212a;
  --ink-soft: #34414d;
  --blue: #3157d5;
  --blue-dark: #203da4;
  --cyan: #008c9f;
  --coral: #f46054;
  --coral-dark: #d84b40;
  --green: #15956b;
  --line: #dce3ea;
  --line-strong: #c7d0da;
  --muted: #687582;
  --radius: 8px;
  --shadow: 0 14px 36px rgba(29, 48, 74, .09);
  --motion-ease: cubic-bezier(.22, 1, .36, 1);
}

* { box-sizing: border-box; }
html { min-width: 320px; background: var(--canvas); }
body { margin: 0; min-width: 320px; min-height: 100vh; overflow-x: hidden; background: var(--canvas); }
button, input, select, textarea { font: inherit; letter-spacing: 0; }
button { cursor: pointer; }
[hidden] { display: none !important; }
a { color: inherit; }
img { display: block; max-width: 100%; }

h1, h2, .rating, .summary-metric strong {
  font-family: Bahnschrift, "Arial Narrow", "Microsoft YaHei", sans-serif;
  font-stretch: condensed;
  letter-spacing: 0;
}

button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 3px solid rgba(0, 140, 159, .28);
  outline-offset: 2px;
}

/* Authentication: two bounded cards, with the real competition as context. */
.auth-shell {
  width: min(1160px, 100%);
  min-height: 100svh;
  margin: 0 auto;
  padding: clamp(24px, 5vw, 56px);
  display: grid;
  grid-template-columns: minmax(0, 1.12fr) minmax(360px, .88fr);
  align-items: center;
  gap: clamp(20px, 4vw, 44px);
}
.auth-media {
  position: relative;
  min-height: 500px;
  height: min(640px, calc(100svh - 96px));
  overflow: hidden;
  border: 1px solid #213448;
  border-radius: var(--radius);
  background: #dfe8ef;
  box-shadow: var(--shadow);
  animation: auth-enter 520ms var(--motion-ease) both;
}
.auth-media img { width: 100%; height: 100%; object-fit: cover; object-position: 54% center; filter: saturate(.82) contrast(1.04); }
.auth-media::before {
  content: "";
  position: absolute;
  inset: 12px;
  border: 1px solid rgba(255, 255, 255, .55);
  border-radius: 4px;
  pointer-events: none;
}
.auth-media::after {
  content: "ARENA / MATCHDAY 01";
  position: absolute;
  right: 20px;
  bottom: 18px;
  padding: 7px 9px;
  color: #fff;
  background: rgba(24, 33, 42, .88);
  font: 700 10px/1 Consolas, monospace;
}
.auth-brand {
  position: absolute;
  z-index: 1;
  top: 22px;
  left: 22px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 13px;
  color: #fff;
  background: rgba(24, 33, 42, .9);
  border-radius: 5px;
}
.brand-mark {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  flex: 0 0 42px;
  overflow: hidden;
  border: 1px solid rgba(100, 216, 231, .72);
  border-radius: 5px;
  background: #fff;
}
.brand-mark img { width: 100%; height: 100%; padding: 3px; object-fit: contain; }
.auth-brand strong, .logo strong { display: block; font-size: 19px; line-height: 1; }
.auth-brand span:last-child, .logo small {
  display: block;
  margin-top: 4px;
  font: 600 9px/1 Consolas, monospace;
  opacity: .72;
}
.auth-panel {
  min-width: 0;
  padding: clamp(28px, 4vw, 46px);
  border: 1px solid var(--line);
  border-top: 4px solid var(--blue);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  animation: auth-enter 520ms 80ms var(--motion-ease) both;
}
.auth-form-wrap { width: 100%; }
.eyebrow, #page-kicker {
  margin: 0 0 9px;
  color: var(--cyan);
  font: 700 11px/1 Consolas, monospace;
}
.auth-form-wrap h1 { margin: 0 0 28px; font-size: 34px; line-height: 1.08; }
.segmented {
  width: 100%;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #edf2f6;
}
.segmented button {
  min-width: 0;
  min-height: 38px;
  padding: 0 14px;
  border: 0;
  border-radius: 4px;
  color: var(--muted);
  background: transparent;
  white-space: normal;
  transition: color 140ms ease, background-color 140ms ease, box-shadow 140ms ease;
}
.segmented button.is-active { color: #fff; background: var(--blue); box-shadow: 0 1px 3px rgba(32, 61, 164, .24); }
.segmented.compact { width: auto; grid-template-columns: repeat(3, minmax(72px, 1fr)); }
.segmented.compact button { min-height: 34px; padding: 0 15px; font-size: 13px; }
.auth-note { min-height: 18px; margin: 12px 0 -6px; color: var(--muted); font-size: 12px; }
.form-stack { display: grid; gap: 17px; margin-top: 22px; }
label { min-width: 0; display: grid; gap: 7px; color: var(--ink-soft); font-size: 13px; font-weight: 650; }
input, select, textarea {
  width: 100%;
  max-width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: var(--surface);
  color: var(--ink);
  outline: none;
}
input, select { min-height: 44px; padding: 0 12px; }
textarea { resize: vertical; padding: 10px 12px; }
input:focus, select:focus, textarea:focus { border-color: var(--cyan); box-shadow: 0 0 0 3px rgba(0, 140, 159, .1); }
.primary-button, .quiet-button, .icon-button { min-height: 38px; border: 1px solid transparent; border-radius: 6px; }
.primary-button, .quiet-button, .icon-button {
  transition: color 140ms ease, border-color 140ms ease, background-color 140ms ease,
    box-shadow 140ms ease, transform 140ms var(--motion-ease);
}
.primary-button:active, .quiet-button:active, .icon-button:active { transform: translateY(1px); }
.primary-button {
  padding: 0 17px;
  color: #fff;
  border-color: var(--blue);
  background: var(--blue);
  font-weight: 750;
  box-shadow: 3px 3px 0 rgba(32, 61, 164, .14);
}
.primary-button:hover { border-color: var(--blue-dark); background: var(--blue-dark); transform: translateY(-1px); }
.quiet-button { padding: 0 13px; color: var(--ink-soft); border-color: var(--line-strong); background: var(--surface); }
.icon-button { width: 38px; padding: 0; color: var(--ink-soft); background: transparent; font-size: 21px; }
.form-error { min-height: 18px; margin: 0; color: #b93830; font-size: 12px; font-weight: 600; }

/* Compact match-day navigation. */
.app-shell { min-height: 100vh; }
.sidebar {
  position: sticky;
  z-index: 20;
  top: 0;
  height: 70px;
  display: grid;
  grid-template-columns: 240px minmax(420px, 1fr) auto;
  align-items: center;
  padding: 0 24px;
  color: #eef4f9;
  background: var(--ink);
  border-bottom: 4px solid var(--coral);
}
.logo { display: flex; align-items: center; gap: 11px; color: inherit; text-decoration: none; }
.logo .brand-mark { width: 36px; height: 36px; flex-basis: 36px; color: #70d8e4; }
.main-nav { justify-self: center; height: 100%; display: flex; align-items: stretch; gap: 2px; }
.main-nav button {
  min-width: 112px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 14px;
  border: 0;
  border-left: 1px solid rgba(255, 255, 255, .08);
  color: #adbac7;
  background: transparent;
  transition: color 150ms ease, background-color 150ms ease, box-shadow 150ms ease;
}
.main-nav button:last-child { border-right: 1px solid rgba(255, 255, 255, .08); }
.main-nav button:hover { color: #fff; background: rgba(255, 255, 255, .06); }
.main-nav button.is-active { color: #fff; background: var(--blue); box-shadow: inset 0 -4px 0 #68d4df; }
.sidebar-footer { display: flex; align-items: center; gap: 14px; }
.sidebar-footer .quiet-button { min-height: 32px; color: #d8e1e9; border-color: #52606d; background: transparent; }
.worker-state {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #adbac6;
  font: 600 11px/1 Consolas, monospace;
  white-space: nowrap;
}
.worker-state i { width: 8px; height: 8px; border: 1px solid #778693; border-radius: 50%; background: #64717d; }
.worker-state.is-online i {
  border-color: #63d7b1;
  background: var(--green);
  box-shadow: 0 0 0 3px rgba(21, 149, 107, .2);
  animation: signal-pulse 2.4s ease-in-out infinite;
}

.workspace { min-width: 0; }
.topbar {
  height: 74px;
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 0 max(28px, calc((100vw - 1420px) / 2));
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, .97);
}
.topbar h1 { margin: 0; font-size: 25px; line-height: 1; }
#page-kicker { margin-bottom: 7px; font-size: 10px; }
.topbar-actions { min-width: 0; margin-left: auto; display: flex; align-items: center; gap: 14px; }
.user-chip {
  max-width: 190px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #53616e;
  font: 600 12px/1 Consolas, monospace;
}
#mobile-menu { display: none; }
.content { width: 100%; max-width: 1420px; margin: 0 auto; padding: 26px 28px 52px; }
.view { display: none; }
.view.is-active { display: block; animation: view-enter 260ms var(--motion-ease) both; }

/* Signature element: one arena card plus four field-coordinate metrics. */
.summary-strip {
  display: grid;
  grid-template-columns: minmax(300px, 2fr) repeat(4, minmax(130px, 1fr));
  gap: 12px;
  margin-bottom: 28px;
}
.arena-card, .summary-metric {
  position: relative;
  min-width: 0;
  height: 150px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 0 8px 20px rgba(29, 48, 74, .06);
}
.arena-card { background: #dce7ee; }
.arena-card::after {
  content: "";
  position: absolute;
  z-index: 1;
  top: -2px;
  right: 0;
  left: 0;
  height: 2px;
  background: rgba(100, 216, 231, .86);
  box-shadow: 0 0 14px rgba(100, 216, 231, .72);
  animation: arena-scan 4.8s linear infinite;
  pointer-events: none;
}
.arena-card img { width: 100%; height: 100%; object-fit: cover; object-position: center 52%; filter: saturate(.78) contrast(1.03); }
.arena-card-label {
  position: absolute;
  left: 12px;
  bottom: 12px;
  padding: 8px 10px;
  color: #fff;
  background: rgba(24, 33, 42, .9);
  border-left: 3px solid #62d7e3;
}
.arena-card-label span { display: block; font: 700 9px/1 Consolas, monospace; color: #83e0e8; }
.arena-card-label strong { display: block; margin-top: 4px; font-size: 13px; }
.summary-metric {
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: 20px;
  border-top: 4px solid var(--blue);
  animation: metric-enter 380ms var(--motion-ease) both;
}
.summary-metric:nth-child(2) { animation-delay: 40ms; }
.summary-metric:nth-child(3) { animation-delay: 80ms; }
.summary-metric:nth-child(4) { animation-delay: 120ms; }
.summary-metric:nth-child(5) { animation-delay: 160ms; }
.summary-metric:nth-child(3) { border-top-color: var(--cyan); }
.summary-metric:nth-child(4) { border-top-color: var(--coral); }
.summary-metric:nth-child(5) { border-top-color: var(--green); }
.summary-metric::after {
  content: attr(data-slot);
  position: absolute;
  top: 14px;
  right: 14px;
  color: #a0abb6;
  font: 700 9px/1 Consolas, monospace;
}
.summary-metric span { color: var(--muted); font: 650 11px/1.2 Consolas, monospace; }
.summary-metric strong {
  display: block;
  margin-top: 9px;
  color: var(--ink);
  font-size: 32px;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.section-toolbar {
  min-width: 0;
  min-height: 50px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 12px;
}
.section-toolbar h2, .admin-toolbar h2 { margin: 0; font-size: 20px; }
.section-toolbar p { margin: 5px 0 0; }
.muted { color: var(--muted); font-size: 12px; }
.ranking-context { min-width: 0; display: grid; justify-items: end; gap: 6px; }
.elo-key { color: var(--muted); font: 650 11px/1 Consolas, monospace; white-space: nowrap; }
.elo-key strong { color: var(--blue-dark); font-size: 13px; }
.table-frame {
  min-width: 0;
  min-height: 280px;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-top: 3px solid var(--blue);
  border-radius: var(--radius);
  background: var(--surface);
}
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th {
  height: 43px;
  padding: 0 14px;
  color: #596673;
  background: #edf2f6;
  font: 700 10px/1 Consolas, monospace;
  text-align: left;
  white-space: nowrap;
}
td { position: relative; height: 61px; padding: 8px 14px; border-top: 1px solid #e3e9ee; white-space: nowrap; }
tbody tr { animation: row-enter 260ms var(--motion-ease) both; transition: background-color 120ms ease; }
tbody tr:nth-child(2) { animation-delay: 25ms; }
tbody tr:nth-child(3) { animation-delay: 50ms; }
tbody tr:nth-child(4) { animation-delay: 75ms; }
tbody tr:nth-child(5) { animation-delay: 100ms; }
tbody tr:nth-child(n+6) { animation-delay: 125ms; }
tbody tr:hover { background: #f7f9fb; }
#leaderboard-body tr:nth-child(-n+3) td:first-child::after {
  content: "";
  position: absolute;
  top: 13px;
  bottom: 13px;
  left: 0;
  width: 3px;
  background: var(--coral);
}
.rank-cell { width: 58px; color: #73808b; font: 800 12px/1 Consolas, monospace; font-variant-numeric: tabular-nums; }
.rank-cell.top { color: var(--coral-dark); }
.strategy-name { display: block; color: var(--ink); font-weight: 750; overflow-wrap: anywhere; }
.strategy-meta { display: block; margin-top: 4px; color: #75818c; font: 500 10px/1 Consolas, monospace; overflow-wrap: anywhere; }
.rating { color: var(--blue-dark); font-variant-numeric: tabular-nums; }
.rating-value { display: block; font-size: 18px; font-weight: 800; }
.rating-delta { display: block; margin-top: 4px; color: var(--muted); font: 650 10px/1 Consolas, monospace; }
.baseline-expectation strong { display: block; color: var(--cyan); font-size: 15px; font-variant-numeric: tabular-nums; }
.baseline-expectation span { display: block; margin-top: 4px; color: var(--muted); font-size: 10px; }
.status {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 8px;
  border-left: 3px solid #8d99a5;
  border-radius: 2px;
  color: #3e4a55;
  background: #e9eef2;
  font-size: 11px;
  font-weight: 700;
}
.status.published { color: #0d6a4c; border-color: var(--green); background: #e2f3ec; }
.status.running { color: #74520f; border-color: #d69a2c; background: #fff0d3; }
.status.failed { color: #a43730; border-color: var(--coral); background: #fde9e7; }
.kind { color: var(--cyan); font: 750 10px/1 Consolas, monospace; text-transform: uppercase; }
.quiet-link { color: var(--blue); font-weight: 700; text-decoration: none; }
.quiet-link:hover { text-decoration: underline; }
.empty-state { min-height: 232px; display: grid; place-items: center; color: var(--muted); font-size: 13px; }
.admin-toolbar {
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 18px;
}
.admin-toolbar > div { min-width: 0; }
.admin-toolbar .muted { max-width: 660px; margin: 7px 0 0; }
.invite-result { display: flex; align-items: center; gap: 12px; margin: 0 0 18px; }
.invite-result input {
  min-width: 0;
  flex: 1;
  border-left: 4px solid var(--cyan);
  border-radius: 2px;
  background: #edf4f7;
  font: 600 12px/1 Consolas, monospace;
}
.database-status {
  min-width: 0;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  border: 1px solid var(--line);
  border-top: 4px solid var(--green);
  border-radius: var(--radius);
  background: var(--surface);
}
.database-metric {
  min-width: 0;
  min-height: 96px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 17px 20px;
  border-right: 1px solid var(--line);
}
.database-metric:last-child { border-right: 0; }
.database-metric span { color: var(--muted); font: 700 10px/1.2 Consolas, monospace; }
.database-metric strong { margin-top: 9px; overflow-wrap: anywhere; color: var(--ink); font-size: 20px; font-variant-numeric: tabular-nums; }
.database-metric small { margin-top: 5px; color: var(--muted); font-size: 10px; }
.admin-section { margin-top: 30px; }
.admin-table-frame table { min-width: 920px; }
.database-table-frame { min-height: 0; }
.database-table-frame table { min-width: 580px; }
.database-table-frame td:last-child { width: 140px; color: var(--blue-dark); font-size: 17px; font-weight: 800; font-variant-numeric: tabular-nums; }
.account-id, .table-code { display: block; margin-top: 4px; color: #75818c; font: 500 10px/1.2 Consolas, monospace; overflow-wrap: anywhere; }
.password-storage { display: block; color: #0d6a4c; font-weight: 750; }
.password-note { display: block; margin-top: 4px; color: var(--muted); font-size: 10px; }
.role-badge { display: inline-block; padding-left: 8px; border-left: 3px solid var(--line-strong); font-size: 12px; font-weight: 750; }
.role-badge.super { color: var(--blue-dark); border-color: var(--coral); }
.quiet-button:disabled { cursor: not-allowed; opacity: .48; }
.password-target { margin: 0; padding: 12px 14px; border-left: 4px solid var(--coral); color: var(--ink-soft); background: #f4f7fa; font-size: 13px; line-height: 1.55; }

dialog {
  width: min(700px, calc(100% - 28px));
  max-height: calc(100vh - 40px);
  padding: 0;
  overflow: auto;
  border: 1px solid var(--line);
  border-top: 5px solid var(--blue);
  border-radius: var(--radius);
  box-shadow: 0 24px 70px rgba(18, 31, 46, .25);
}
dialog[open] { animation: dialog-enter 220ms var(--motion-ease) both; }
dialog::backdrop { background: rgba(18, 31, 46, .6); }
.dialog-form { display: grid; gap: 18px; padding: 24px; background: var(--surface); }
.dialog-form header, .dialog-form footer { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.dialog-form h2 { margin: 0; font-size: 22px; }
.dialog-form footer { justify-content: flex-end; padding-top: 5px; }
.two-columns { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
fieldset { min-width: 0; margin: 0; padding: 12px; display: flex; gap: 22px; border: 1px solid var(--line); border-radius: 6px; }
legend { padding: 0 5px; color: var(--ink-soft); font-size: 12px; font-weight: 650; }
.check-label { display: flex; align-items: center; gap: 7px; }
.check-label input { width: 16px; min-height: 16px; accent-color: var(--blue); }
.field-label { display: block; margin-bottom: 7px; color: var(--ink-soft); font-size: 13px; font-weight: 650; }
.source-switch { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.code-field textarea {
  min-height: 230px;
  padding: 14px;
  tab-size: 4;
  color: #e9f1f7;
  background: #18212a;
  border-color: #2f4355;
  font: 500 13px/1.65 Consolas, "Cascadia Code", monospace;
  white-space: pre;
}
.code-field textarea::placeholder { color: #8fa0af; }
.code-field textarea:focus { border-color: #64d9e4; box-shadow: 0 0 0 3px rgba(0, 140, 159, .14); }
.file-drop {
  min-height: 82px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  border: 1px dashed #91a5b6;
  border-radius: 6px;
  background: #edf4f7;
}
.file-drop:hover { border-color: var(--cyan); background: #e6f4f5; }
.file-drop input { position: absolute; width: 1px; height: 1px; min-height: 0; opacity: 0; }
.file-drop span { color: var(--muted); font-size: 12px; font-weight: 500; overflow-wrap: anywhere; }
.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 30;
  max-width: min(380px, calc(100% - 48px));
  padding: 13px 16px;
  border-left: 4px solid #64d9e4;
  border-radius: 3px;
  color: #fff;
  background: var(--ink);
  box-shadow: 0 8px 24px rgba(0, 0, 0, .22);
  font-size: 13px;
  animation: toast-enter 220ms var(--motion-ease) both;
}

@keyframes auth-enter {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes view-enter {
  from { opacity: 0; transform: translateY(7px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes metric-enter {
  from { opacity: 0; transform: translateY(9px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes row-enter {
  from { opacity: 0; transform: translateX(7px); }
  to { opacity: 1; transform: translateX(0); }
}
@keyframes arena-scan {
  0%, 12% { top: -2px; opacity: 0; }
  18% { opacity: .9; }
  72% { opacity: .6; }
  82%, 100% { top: 100%; opacity: 0; }
}
@keyframes signal-pulse {
  0%, 100% { box-shadow: 0 0 0 3px rgba(21, 149, 107, .18); }
  50% { box-shadow: 0 0 0 6px rgba(21, 149, 107, 0); }
}
@keyframes dialog-enter {
  from { opacity: 0; transform: translateY(10px) scale(.985); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes toast-enter {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (max-width: 1160px) {
  .sidebar { grid-template-columns: 205px 1fr auto; padding: 0 16px; }
  .main-nav button { min-width: 90px; padding: 0 10px; }
  .worker-state span { display: none; }
  .summary-strip { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .arena-card { height: 312px; grid-column: span 2; grid-row: span 2; }
}

@media (max-width: 820px) {
  .auth-shell { padding: 26px; grid-template-columns: minmax(0, .95fr) minmax(330px, 1.05fr); gap: 20px; }
  .auth-media { min-height: 470px; height: calc(100svh - 52px); }
  .auth-panel { padding: 30px; }
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: 238px;
    height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    padding: 20px 14px 16px;
    border-right: 4px solid var(--coral);
    border-bottom: 0;
    transform: translateX(-100%);
    transition: transform .18s ease;
  }
  .sidebar.is-open { transform: translateX(0); }
  .logo { min-height: 52px; padding: 0 6px 18px; }
  .main-nav { width: 100%; height: auto; display: grid; gap: 4px; margin-top: 18px; }
  .main-nav button { min-width: 0; height: 44px; justify-content: flex-start; border: 0; border-radius: 4px; }
  .main-nav button:last-child { border: 0; }
  .sidebar-footer { margin-top: auto; display: grid; padding: 14px 4px 0; border-top: 1px solid #3a4855; }
  .worker-state span { display: inline; }
  #mobile-menu { display: inline-grid; place-items: center; }
  .topbar { height: 74px; padding: 0 18px; border-top: 4px solid var(--coral); }
  .content { padding: 22px 18px 40px; }
  .database-status { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .database-metric:nth-child(2) { border-right: 0; }
  .database-metric:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
}

@media (max-width: 820px) {
  .auth-shell { min-height: 0; padding: 18px; grid-template-columns: minmax(0, 1fr); align-content: start; gap: 16px; }
  .auth-media { min-height: 0; height: auto; aspect-ratio: 16 / 8.5; }
  .auth-media::before { inset: 7px; }
  .auth-media::after { right: 12px; bottom: 10px; font-size: 8px; }
  .auth-brand { top: 12px; left: 12px; padding: 7px 9px; }
  .auth-brand .brand-mark { width: 34px; height: 34px; flex-basis: 34px; }
  .auth-brand strong { font-size: 15px; }
  .auth-panel { padding: 26px 22px 28px; }
  .auth-form-wrap h1 { margin-bottom: 22px; font-size: 29px; }
  .summary-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .arena-card { height: 178px; grid-column: 1 / -1; grid-row: auto; }
  .summary-metric { height: 116px; padding: 15px; }
  .summary-metric strong { font-size: 27px; }

  .table-frame { min-height: 0; overflow: visible; border: 0; border-radius: 0; background: transparent; }
  table, tbody { display: block; width: 100%; }
  thead {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
    border: 0;
  }
  tbody { display: grid; gap: 10px; }
  tbody tr {
    min-width: 0;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    column-gap: 16px;
    row-gap: 0;
    padding: 12px 14px;
    border: 1px solid var(--line);
    border-left: 4px solid var(--blue);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: 0 6px 16px rgba(29, 48, 74, .05);
  }
  tbody tr:hover { background: var(--surface); }
  td {
    min-width: 0;
    height: auto;
    padding: 8px 0;
    border: 0;
    white-space: normal;
    overflow-wrap: anywhere;
  }
  td::before {
    content: attr(data-label);
    display: block;
    margin-bottom: 5px;
    color: #87939e;
    font: 700 9px/1 Consolas, monospace;
  }
  #leaderboard-body tr:nth-child(-n+3) td:first-child::after { display: none; }
  #strategy-body td:first-child, #jobs-body td:first-child, #jobs-body td:nth-child(2) { grid-column: 1 / -1; }
  td[colspan] { grid-column: 1 / -1; padding: 0; }
  td[colspan]::before { display: none; }
  td[colspan] .empty-state { min-height: 120px; }
  .rank-cell { width: auto; }
  .empty-state { min-height: 180px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
  .section-toolbar { align-items: flex-start; flex-direction: column; }
  .section-toolbar > * { max-width: 100%; }
  .ranking-context { justify-items: start; }
  .segmented.compact { width: 100%; grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .source-switch button { padding: 0 8px; font-size: 12px; }
  .two-columns { grid-template-columns: 1fr; }
  .dialog-form { padding: 19px; }
  .invite-result { align-items: stretch; flex-direction: column; }
  .admin-toolbar { align-items: flex-start; flex-direction: column; }
  .admin-toolbar .primary-button { width: 100%; }
  .admin-table-frame table, .database-table-frame table { min-width: 0; }
  #admin-users-body td:first-child { grid-column: 1 / -1; }
}

@media (max-width: 460px) {
  .topbar { display: grid; grid-template-columns: 38px minmax(0, 1fr) auto; gap: 10px; padding: 0 12px; }
  .topbar-actions { margin-left: 0; }
  .topbar-actions .user-chip { display: none; }
  .topbar h1 { overflow: hidden; font-size: 20px; text-overflow: ellipsis; white-space: nowrap; }
  #page-kicker { display: none; }
  .topbar .primary-button { min-height: 36px; padding: 0 10px; font-size: 12px; }
  .content { padding: 18px 12px 36px; }
  .auth-shell { padding: 12px; }
  .auth-panel { padding: 23px 17px 25px; }
  .auth-media { aspect-ratio: 16 / 9.5; }
  .auth-brand span:last-child { display: none; }
  .arena-card { height: 150px; }
  .summary-metric { height: 108px; padding: 13px; }
  .summary-metric::after { top: 11px; right: 11px; }
  .database-status { grid-template-columns: 1fr; }
  .database-metric { min-height: 82px; border-right: 0; border-bottom: 1px solid var(--line); }
  .database-metric:nth-child(2) { border-right: 0; }
  .database-metric:last-child { border-bottom: 0; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    scroll-behavior: auto !important;
    transition-duration: .01ms !important;
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
  }
}
