/* "Kit & Court" system: chalk-cool paper, navy ink, and one kit-blue accent.
   Team colours supply the rest of the chroma, so the frame stays disciplined. */
:root {
  color-scheme: light;
  --page: #f2f4f7;
  --surface: #ffffff;
  --surface-soft: #eceff4;
  --surface-strong: #e1e6ee;
  --surface-strong-hover: #d4dbe6;
  --text: #0e1726;
  --text-muted: #4e5a6e;
  --text-faint: #5f6b80;
  --primary: #2447e0;
  --primary-hover: #1d3ac2;
  --primary-soft: #e7ecfd;
  --on-primary: #ffffff;
  --on-inverse: #ffffff;
  --on-team: #ffffff;
  --focus: #1d4ed8;
  --danger: #b42318;
  --danger-soft: #fef3f2;
  --warning: #9a6700;
  --warning-soft: #fff8e6;
  --warning-strong: #704d00;
  --info-strong: #24425c;
  --info-soft: #edf5fb;
  --success: #16794b;
  --success-soft: #e9f7ef;
  --line: #d4dae4;
  --line-soft: #e4e8ef;
  --field: #f5f7fa;
  --field-focus: #ffffff;
  --table-head: #f3f5f8;
  --row-alt: #f8fafc;
  --placeholder: #5f6b80;
  --tile: rgb(255 255 255 / 0.66);
  --hairline: rgb(14 23 38 / 0.08);
  --overlay-weak: rgb(14 23 38 / 0.06);
  --overlay: rgb(14 23 38 / 0.07);
  --header-bg: rgb(242 244 247 / 0.9);
  --scrim: rgb(10 16 28 / 0.56);
  --accent-blue: #2563eb;
  --accent-amber: #b45309;
  --coverage-0-bg: #f5f6f7;
  --coverage-1-fg: #0f5132;
  --coverage-1-bg: #e8f7ee;
  --coverage-2-fg: #704d00;
  --coverage-2-bg: #fff2cc;
  --coverage-3-fg: #842029;
  --coverage-3-bg: #fbe5e7;
  --court-line: rgb(14 23 38 / 0.07);
  --shadow-rgb: 14 23 38;
  /* Layered depth instead of one mega-shadow: contact, ambient, drop. */
  --shadow: 0 1px 2px rgb(14 23 38 / 0.06), 0 4px 12px rgb(14 23 38 / 0.05), 0 16px 44px rgb(14 23 38 / 0.06);
  --radius-small: 8px;
  --radius: 14px;
  --radius-large: 24px;
  --content: 1240px;
  --font: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-head: "Archivo", ui-sans-serif, system-ui, sans-serif;
  --font-display: "Archivo Black", "Archivo", ui-sans-serif, system-ui, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-spring: cubic-bezier(0.34, 1.3, 0.5, 1);
}

/* Dark theme ("board night"). Every surface, hairline, and status colour is
   re-derived rather than filtered, so text keeps its WCAG AA contrast in both
   schemes. The block exists twice on purpose: once for OS preference (unless
   the visitor pinned light) and once for an explicit data-theme="dark" pin —
   custom properties cannot be shared across a media-query boundary. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --page: #0b101e;
    --surface: #131a2b;
    --surface-soft: #1a2236;
    --surface-strong: #253048;
    --surface-strong-hover: #2f3c58;
    --text: #e9edf6;
    --text-muted: #a7b2c8;
    --text-faint: #8b96ad;
    --primary: #8da2ff;
    --primary-hover: #a8b8ff;
    --primary-soft: #1d2745;
    --on-primary: #0b101e;
    --on-inverse: #0b101e;
    --focus: #86aaff;
    --danger: #ffa39b;
    --danger-soft: #3a1f1d;
    --warning: #f0c35a;
    --warning-soft: #372c11;
    --warning-strong: #f2d489;
    --info-strong: #bcd9f2;
    --info-soft: #16293a;
    --success: #5ddb96;
    --success-soft: #16321f;
    --line: #2c3752;
    --line-soft: #232d45;
    --field: #0e1424;
    --field-focus: #131a2b;
    --table-head: #1c2539;
    --row-alt: #171f32;
    --placeholder: #8b96ad;
    --tile: rgb(255 255 255 / 0.05);
    --hairline: rgb(255 255 255 / 0.1);
    --overlay-weak: rgb(255 255 255 / 0.07);
    --overlay: rgb(255 255 255 / 0.11);
    --header-bg: rgb(11 16 30 / 0.9);
    --scrim: rgb(0 0 0 / 0.66);
    --accent-blue: #86aaff;
    --accent-amber: #efb264;
    --coverage-0-bg: #1c2539;
    --coverage-1-fg: #8ff0b5;
    --coverage-1-bg: #14301f;
    --coverage-2-fg: #f2d489;
    --coverage-2-bg: #372c11;
    --coverage-3-fg: #ffb3ac;
    --coverage-3-bg: #3d1d1f;
    --court-line: rgb(255 255 255 / 0.06);
    --shadow-rgb: 0 0 0;
    --shadow: 0 1px 2px rgb(0 0 0 / 0.3), 0 4px 12px rgb(0 0 0 / 0.26), 0 16px 44px rgb(0 0 0 / 0.3);
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #0b101e;
  --surface: #131a2b;
  --surface-soft: #1a2236;
  --surface-strong: #253048;
  --surface-strong-hover: #2f3c58;
  --text: #e9edf6;
  --text-muted: #a7b2c8;
  --text-faint: #8b96ad;
  --primary: #8da2ff;
  --primary-hover: #a8b8ff;
  --primary-soft: #1d2745;
  --on-primary: #0b101e;
  --on-inverse: #0b101e;
  --focus: #86aaff;
  --danger: #ffa39b;
  --danger-soft: #3a1f1d;
  --warning: #f0c35a;
  --warning-soft: #372c11;
  --warning-strong: #f2d489;
  --info-strong: #bcd9f2;
  --info-soft: #16293a;
  --success: #5ddb96;
  --success-soft: #16321f;
  --line: #2c3752;
  --line-soft: #232d45;
  --field: #0e1424;
  --field-focus: #131a2b;
  --table-head: #1c2539;
  --row-alt: #171f32;
  --placeholder: #8b96ad;
  --tile: rgb(255 255 255 / 0.05);
  --hairline: rgb(255 255 255 / 0.1);
  --overlay-weak: rgb(255 255 255 / 0.07);
  --overlay: rgb(255 255 255 / 0.11);
  --header-bg: rgb(11 16 30 / 0.9);
  --scrim: rgb(0 0 0 / 0.66);
  --accent-blue: #86aaff;
  --accent-amber: #efb264;
  --coverage-0-bg: #1c2539;
  --coverage-1-fg: #8ff0b5;
  --coverage-1-bg: #14301f;
  --coverage-2-fg: #f2d489;
  --coverage-2-bg: #372c11;
  --coverage-3-fg: #ffb3ac;
  --coverage-3-bg: #3d1d1f;
  --court-line: rgb(255 255 255 / 0.06);
  --shadow-rgb: 0 0 0;
  --shadow: 0 1px 2px rgb(0 0 0 / 0.3), 0 4px 12px rgb(0 0 0 / 0.26), 0 16px 44px rgb(0 0 0 / 0.3);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  background: var(--page);
}

body {
  margin: 0;
  min-width: 320px;
  overflow-x: clip;
  color: var(--text);
  background: var(--page);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

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

button,
a,
input,
textarea,
select,
summary {
  -webkit-tap-highlight-color: transparent;
}

button {
  color: inherit;
}

img,
svg {
  display: block;
  max-width: 100%;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1,
h2,
h3 {
  letter-spacing: -0.02em;
  line-height: 1.1;
}

h1 {
  margin-bottom: 16px;
  font-family: var(--font-display);
  font-size: clamp(2.3rem, 5.4vw, 4.6rem);
  font-weight: 400;
  letter-spacing: 0.005em;
  line-height: 0.98;
  text-transform: uppercase;
  text-wrap: balance;
}

h2 {
  margin-bottom: 10px;
  font-family: var(--font-head);
  font-size: clamp(1.5rem, 2.8vw, 2.3rem);
  font-weight: 740;
}

h3,
.button,
legend,
.team-name-input,
.brand__name {
  font-family: var(--font-head);
}

.content-section h2,
.results-header h2 {
  font-family: var(--font-display);
  font-weight: 400;
  letter-spacing: 0;
  line-height: 1.06;
  text-wrap: balance;
}

h3 {
  margin-bottom: 8px;
  font-size: 1.08rem;
  font-weight: 700;
}

p {
  margin-bottom: 1rem;
}

code,
kbd {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible,
summary:focus-visible,
[tabindex]:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
}

.sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

.skip-link {
  position: fixed;
  z-index: 1000;
  top: 12px;
  left: 12px;
  transform: translateY(-160%);
  padding: 10px 14px;
  border-radius: var(--radius-small);
  color: var(--on-inverse);
  background: var(--text);
  text-decoration: none;
}

.skip-link:focus {
  transform: translateY(0);
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  border-bottom: 1px solid var(--hairline);
  background: var(--header-bg);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

.theme-toggle {
  flex: 0 0 auto;
  width: 38px;
  height: 38px;
}

.theme-toggle__icon {
  position: relative;
  width: 18px;
  height: 18px;
  overflow: hidden;
  border: 2px solid currentcolor;
  border-radius: 50%;
}

/* auto = half-filled disc, light = empty, dark = filled */
.theme-toggle__icon::before {
  position: absolute;
  inset: -2px;
  width: 50%;
  background: currentcolor;
  content: "";
  transition: width 200ms var(--ease-out), opacity 200ms var(--ease-out);
}

:root[data-theme="light"] .theme-toggle__icon::before {
  opacity: 0;
}

:root[data-theme="dark"] .theme-toggle__icon::before {
  width: 100%;
}

.site-header__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: min(calc(100% - 40px), var(--content));
  min-height: 72px;
  margin: 0 auto;
  gap: 24px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: var(--text);
  text-decoration: none;
}

.brand__mark {
  display: grid;
  grid-template-columns: repeat(2, 11px);
  grid-template-rows: repeat(2, 11px);
  gap: 3px;
  width: 28px;
  height: 28px;
}

.brand__mark i {
  display: block;
  border-radius: 3px;
  background: var(--primary);
}

.brand__mark i:nth-child(2) {
  background: var(--accent-blue);
}

.brand__mark i:nth-child(3) {
  grid-column: span 2;
  background: var(--accent-amber);
}

.brand__name {
  font-weight: 760;
  letter-spacing: -0.02em;
}

.brand__name span {
  color: var(--text-muted);
  font-weight: 600;
}

.utility-nav,
.footer-actions,
.inline-actions,
.results-header__actions,
.result-toolbar__group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.button,
.icon-button,
.export-option {
  border: 0;
  cursor: pointer;
  transition: transform 180ms var(--ease-out), background-color 160ms ease, color 160ms ease, box-shadow 180ms var(--ease-out), opacity 160ms ease;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 10px 16px;
  border-radius: 11px;
  font-weight: 680;
  text-decoration: none;
  white-space: nowrap;
}

.button:hover:not(:disabled) {
  transform: translateY(-1px);
}

.button:active:not(:disabled) {
  transform: translateY(0) scale(0.985);
}

.button:disabled {
  cursor: not-allowed;
  opacity: 0.43;
}

.button--primary {
  color: var(--on-primary);
  background: var(--primary);
  box-shadow: 0 10px 24px color-mix(in srgb, var(--primary) 26%, transparent);
}

.button--primary:hover:not(:disabled) {
  background: var(--primary-hover);
  box-shadow: 0 14px 30px color-mix(in srgb, var(--primary) 32%, transparent);
}

.button--secondary {
  color: var(--text);
  background: var(--surface-strong);
}

.button--secondary:hover:not(:disabled) {
  background: var(--surface-strong-hover);
}

.button--quiet {
  color: var(--text-muted);
  background: transparent;
}

.button--quiet:hover:not(:disabled) {
  color: var(--text);
  background: var(--overlay-weak);
}

.button--danger {
  color: var(--danger);
  background: var(--danger-soft);
}

.button--small {
  min-height: 38px;
  padding: 8px 12px;
  border-radius: 9px;
  font-size: 0.9rem;
}

.icon-button {
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  width: 42px;
  height: 42px;
  border-radius: 9px;
  color: var(--text-muted);
  background: transparent;
  font-size: 1.2rem;
}

.icon-button:hover {
  color: var(--text);
  background: var(--overlay);
}

.count-badge {
  display: inline-grid;
  place-items: center;
  min-width: 24px;
  height: 24px;
  padding: 0 7px;
  border-radius: 999px;
  color: var(--text-muted);
  background: var(--surface-strong);
  font-size: 0.76rem;
  font-weight: 750;
  font-variant-numeric: tabular-nums;
}

main {
  width: min(calc(100% - 40px), var(--content));
  margin: 0 auto;
}

.tool-shell,
.share-view {
  padding: clamp(46px, 7vw, 92px) 0 72px;
}

/* Court motif: the centre circle and halfway line of a pitch, drawn in
   hairline ink behind the hero. Decorative only. */
.tool-shell {
  position: relative;
}

.tool-shell::before {
  position: absolute;
  top: clamp(-30px, -2vw, -10px);
  right: -60px;
  z-index: -1;
  width: clamp(280px, 30vw, 460px);
  height: clamp(280px, 30vw, 460px);
  border: 2px solid var(--court-line);
  border-radius: 50%;
  content: "";
  pointer-events: none;
}

.tool-shell::after {
  position: absolute;
  top: clamp(60px, 8vw, 130px);
  right: calc(-60px + clamp(90px, 10vw, 150px));
  z-index: -1;
  width: clamp(100px, 10vw, 160px);
  height: clamp(100px, 10vw, 160px);
  border: 2px solid var(--court-line);
  border-radius: 50%;
  content: "";
  pointer-events: none;
}

.tool-intro {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 40px;
  margin-bottom: 30px;
}

.tool-intro > div:first-child {
  max-width: 860px;
}

.tool-intro__lede {
  max-width: 780px;
  margin-bottom: 0;
  color: var(--text-muted);
  font-size: clamp(1.02rem, 1.6vw, 1.22rem);
}

.eyebrow,
.step-label {
  margin-bottom: 8px;
  color: var(--primary);
  font-size: 0.76rem;
  font-weight: 780;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.tool-intro .eyebrow {
  display: flex;
  align-items: center;
  gap: 10px;
}

.tool-intro .eyebrow::before {
  width: 26px;
  height: 2px;
  background: var(--primary);
  content: "";
}

.privacy-status {
  display: flex;
  align-items: center;
  flex: 0 0 auto;
  gap: 11px;
  padding: 12px 14px;
  border-radius: 12px;
  color: var(--text-muted);
  background: var(--primary-soft);
}

.privacy-status span:last-child {
  display: grid;
}

.privacy-status strong {
  color: var(--text);
  font-size: 0.9rem;
}

.privacy-status small {
  font-size: 0.75rem;
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 0 5px rgb(22 121 75 / 0.12);
}

.setup-grid {
  display: grid;
  grid-template-columns: minmax(0, 7fr) minmax(340px, 5fr);
  overflow: hidden;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-large);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.setup-panel {
  min-width: 0;
  padding: clamp(22px, 3vw, 36px);
}

.setup-panel--roster {
  background: var(--surface);
}

.setup-panel--options {
  background: var(--surface-soft);
}

.panel-heading,
.section-heading-row,
.results-header,
.result-toolbar,
.dialog-header,
.dialog-footer,
.save-current-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

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

.panel-heading h2 {
  margin-bottom: 0;
  font-size: 1.35rem;
}

.participant-counter {
  color: var(--text-muted);
  font-size: 0.88rem;
  font-variant-numeric: tabular-nums;
}

textarea,
input[type="text"],
input[type="url"],
input[type="number"],
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 9px;
  color: var(--text);
  background: var(--surface);
}

textarea,
input[type="text"],
input[type="url"],
input[type="number"] {
  padding: 11px 12px;
}

select {
  min-height: 44px;
  padding: 9px 36px 9px 12px;
}

textarea::placeholder,
input::placeholder {
  color: var(--placeholder);
}

#names-input {
  min-height: 300px;
  resize: vertical;
  border: 0;
  border-radius: 12px;
  background: var(--field);
  box-shadow: inset 0 0 0 1px var(--hairline);
  font-size: 1.05rem;
  line-height: 1.55;
}

#names-input:focus {
  background: var(--field-focus);
  box-shadow: inset 0 0 0 2px var(--focus);
  outline: 0;
}

.field-help,
.input-status,
.storage-description,
.result-subtitle,
.muted {
  color: var(--text-muted);
  font-size: 0.88rem;
}

.field-help {
  margin: 9px 0 12px;
}

.input-status {
  min-height: 22px;
  margin: 12px 0 0;
}

.input-status[data-tone="warning"] {
  color: var(--warning);
}

.input-status[data-tone="success"] {
  color: var(--success);
}

.inline-actions--wrap {
  flex-wrap: wrap;
}

.inline-actions--between {
  justify-content: space-between;
  margin-top: 4px;
}

.compact-select {
  width: 132px;
}

.compact-select select {
  min-height: 38px;
  padding-top: 6px;
  padding-bottom: 6px;
  font-size: 0.88rem;
}

fieldset {
  min-width: 0;
  padding: 0;
  margin: 0;
  border: 0;
}

legend {
  margin-bottom: 9px;
  color: var(--text-muted);
  font-size: 0.78rem;
  font-weight: 750;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.split-control {
  display: grid;
  gap: 8px;
  margin-bottom: 22px;
}

.split-option {
  display: grid;
  grid-template-columns: 22px 1fr 76px;
  align-items: center;
  gap: 10px;
  min-height: 54px;
  padding: 7px 9px 7px 13px;
  border-radius: 11px;
  cursor: pointer;
  background: var(--tile);
}

.split-option:has(input[type="radio"]:checked) {
  box-shadow: inset 0 0 0 2px var(--primary);
  background: var(--surface);
}

.split-option input[type="radio"],
.mode-option input[type="radio"],
.check-row input,
.checkbox-grid input {
  width: 18px;
  height: 18px;
  accent-color: var(--primary);
}

.number-input {
  min-width: 0;
  height: 38px;
  padding: 6px 8px !important;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.mode-control {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 20px;
}

.mode-control legend {
  grid-column: 1 / -1;
}

.mode-option {
  position: relative;
  display: flex;
  min-width: 0;
  min-height: 104px;
  padding: 14px;
  border-radius: 12px;
  cursor: pointer;
  background: var(--tile);
  flex-direction: column;
  align-items: flex-start;
}

.mode-option:has(input:checked) {
  color: var(--text);
  background: var(--surface);
  box-shadow: inset 0 0 0 2px var(--primary);
}

.mode-option input {
  position: absolute;
  top: 12px;
  right: 12px;
}

.mode-option__title {
  margin: 18px 0 4px;
  font-weight: 760;
}

.mode-option__description {
  color: var(--text-muted);
  font-size: 0.78rem;
  line-height: 1.25;
}

.seed-row {
  display: grid;
  grid-template-columns: 56px 1fr;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
}

.seed-row > label {
  color: var(--text-muted);
  font-size: 0.82rem;
  font-weight: 700;
}

.seed-control {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 42px 42px;
  gap: 4px;
  border-radius: 10px;
  background: var(--surface);
}

.seed-control input {
  min-width: 0;
  border: 0;
  background: transparent;
  font-family: var(--font-mono);
  font-size: 0.86rem;
}

/* FLIP helper: app.js measures, inverts with a transform, then adds this class
   and clears the transform so the row glides to its new slot. */
.participant-row.is-flipping {
  transition: transform 280ms var(--ease-out);
}

.button--generate {
  width: 100%;
  min-height: 60px;
  margin-bottom: 8px;
  gap: 12px;
  border-radius: 14px;
  font-size: 1.02rem;
  font-weight: 800;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

/* Drafting state: a quiet pulse while the worker searches. */
.button--generate:disabled {
  opacity: 0.82;
  animation: drafting-pulse 1.1s ease-in-out infinite;
}

@keyframes drafting-pulse {
  0%, 100% { box-shadow: 0 10px 24px color-mix(in srgb, var(--primary) 22%, transparent); }
  50% { box-shadow: 0 10px 34px color-mix(in srgb, var(--primary) 42%, transparent); }
}

.button--generate kbd {
  padding: 2px 7px;
  border: 1px solid color-mix(in srgb, var(--on-primary) 36%, transparent);
  border-radius: 5px;
  color: var(--on-primary);
  font-size: 0.72rem;
}

.notice,
.validation-panel {
  border-radius: var(--radius);
}

.notice {
  padding: 14px 16px;
  color: var(--text-muted);
  background: var(--surface-soft);
}

.notice--warning {
  color: var(--warning-strong);
  background: var(--warning-soft);
}

.notice--info {
  color: var(--info-strong);
  background: var(--info-soft);
}

.page-not-found {
  margin-top: 24px;
}

.validation-panel {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  margin-top: 20px;
  padding: 18px 20px;
  color: var(--danger);
  background: var(--danger-soft);
}

.validation-panel h2 {
  margin-bottom: 8px;
  font-size: 1.05rem;
}

.validation-panel ul {
  padding-left: 20px;
  margin: 0;
}

.results-workspace,
.round-results {
  margin-top: 42px;
  padding-top: 34px;
  border-top: 1px solid var(--line);
  /* The generate handoff scrolls here; keep the section clear of the sticky header. */
  scroll-margin-top: 88px;
}

.results-header {
  align-items: flex-end;
  margin-bottom: 18px;
}

.results-header h2 {
  margin-bottom: 4px;
}

.result-subtitle {
  margin-bottom: 0;
}

.project-name-field {
  width: min(240px, 40vw);
}

.project-name-field input,
#project-name-input {
  font-weight: 680;
}

.result-toolbar {
  position: sticky;
  z-index: 10;
  top: 82px;
  flex-wrap: wrap;
  padding: 10px;
  margin-bottom: 18px;
  border-radius: 12px;
  background: var(--header-bg);
  box-shadow: 0 8px 30px rgb(var(--shadow-rgb) / 0.08);
  backdrop-filter: blur(10px);
}

.result-toolbar__group {
  flex-wrap: wrap;
}

/* auto-fit collapses unused tracks, so the six generator metrics and the four
   share-page metrics both fill the row, and narrow screens reflow instead of
   forcing a sideways scroll. */
.metric-rail {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(148px, 1fr));
  gap: 10px;
  padding: 2px 2px 10px;
}

/* Scoreboard chips: heavy tabular numerals over a hairline base. */
.metric {
  min-width: 128px;
  padding: 14px 15px 13px;
  border: 1px solid var(--line-soft);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: 0 8px 30px rgb(var(--shadow-rgb) / 0.05);
}

.metric__value {
  display: block;
  margin-bottom: 3px;
  font-family: var(--font-display);
  font-size: 1.8rem;
  font-weight: 400;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.01em;
  line-height: 1;
}

.metric__label {
  display: block;
  color: var(--text);
  font-size: 0.83rem;
  font-weight: 700;
}

.metric__hint {
  display: block;
  margin-top: 4px;
  color: var(--text-muted);
  font-size: 0.72rem;
}

.metric[data-tone="good"] .metric__value {
  color: var(--success);
}

.metric[data-tone="warning"] .metric__value {
  color: var(--warning);
}

.metric[data-tone="bad"] .metric__value {
  color: var(--danger);
}

.result-explanation {
  margin: 12px 0 22px;
  border-radius: 12px;
  background: var(--surface-soft);
}

.result-explanation summary {
  padding: 14px 16px;
  cursor: pointer;
  font-weight: 690;
}

.result-explanation__content {
  padding: 0 16px 16px;
  color: var(--text-muted);
}

.result-explanation__content ul {
  padding-left: 20px;
}

.result-explanation code {
  color: var(--text);
  word-break: break-all;
}

.team-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(270px, 1fr));
  align-items: start;
  gap: 16px;
  counter-reset: team;
}

.team-card {
  --team-color: var(--accent-blue);
  overflow: hidden;
  border: 1px solid var(--line-soft);
  border-radius: 16px;
  background: var(--surface);
  box-shadow: 0 10px 36px rgb(var(--shadow-rgb) / 0.07);
  counter-increment: team;
  transition: transform 220ms var(--ease-out), box-shadow 220ms var(--ease-out);
}

.team-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 16px 44px rgb(var(--shadow-rgb) / 0.11);
}

.team-card[data-drag-over="true"] {
  box-shadow: 0 0 0 3px var(--focus), 0 10px 36px rgb(var(--shadow-rgb) / 0.07);
}

.team-card__header {
  position: relative;
  display: grid;
  grid-template-columns: 8px minmax(0, 1fr) auto;
  align-items: stretch;
  min-height: 64px;
  background: color-mix(in srgb, var(--team-color) 10%, var(--surface));
}

/* Jersey numeral: each card carries its draft position as a watermark
   behind the header controls. */
.team-card__header::after {
  position: absolute;
  right: 8px;
  bottom: -7px;
  color: color-mix(in srgb, var(--team-color) 20%, transparent);
  content: counter(team, decimal-leading-zero);
  font-family: var(--font-display);
  font-size: 2.7rem;
  line-height: 1;
  pointer-events: none;
}

.team-card__stripe {
  background: var(--team-color);
}

.team-card__title-wrap {
  min-width: 0;
  padding: 13px 10px 11px 14px;
}

.team-name-input {
  width: 100%;
  padding: 0 !important;
  border: 0 !important;
  background: transparent !important;
  font-size: 1.08rem;
  font-weight: 800;
  letter-spacing: -0.01em;
}

.team-card__summary {
  display: block;
  margin-top: 2px;
  color: var(--text-muted);
  font-size: 0.74rem;
  font-variant-numeric: tabular-nums;
}

.team-card__controls {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  padding: 8px 8px 8px 0;
}

.team-color-input {
  width: 34px;
  height: 34px;
  padding: 2px;
  border: 0;
  border-radius: 8px;
  cursor: pointer;
  background: transparent;
}

.lock-button[aria-pressed="true"] {
  color: var(--on-team);
  background: var(--team-color);
}

/* Draft reveal: on a fresh generation the grid gets data-reveal="true" and the
   cards deal in like draft picks. Delays are set by app.js in --deal-delay
   (45ms per card for the first eight, 12ms after, so 20 teams still settle
   inside the 700ms budget). Member lists fade as one block per card — row-level
   stagger multiplies into seconds on real rosters. */
@keyframes deal-in {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes block-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

.team-grid[data-reveal="true"] .team-card {
  animation: deal-in 320ms var(--ease-out) both;
  animation-delay: var(--deal-delay, 0ms);
}

.team-grid[data-reveal="true"] .participant-list {
  animation: block-in 240ms var(--ease-out) both;
  animation-delay: calc(var(--deal-delay, 0ms) + 60ms);
}

.metric-rail[data-reveal="true"] .metric {
  animation: deal-in 300ms var(--ease-out) both;
  animation-delay: calc(var(--deal-order, 0) * 40ms + 420ms);
}

/* While the worker drafts, the setup board recedes a step. */
.generator-form[data-busy="true"] {
  opacity: 0.72;
  transition: opacity 160ms var(--ease-out);
}

.participant-list {
  min-height: 58px;
  padding: 0;
  margin: 0;
  list-style: none;
}

.participant-row {
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr) auto;
  align-items: center;
  gap: 9px;
  min-height: 54px;
  padding: 7px 9px 7px 13px;
  border-top: 1px solid var(--line-soft);
  background: var(--surface);
}

.participant-row[draggable="true"] {
  cursor: grab;
}

.participant-row[draggable="true"]:active {
  cursor: grabbing;
}

.participant-row[data-locked="true"] {
  background: var(--row-alt);
}

.drag-handle {
  display: inline-grid;
  place-items: center;
  width: 24px;
  height: 32px;
  color: var(--text-faint);
  font-size: 1rem;
  user-select: none;
}

.participant-row__identity {
  min-width: 0;
}

.participant-row__name {
  display: flex;
  align-items: center;
  min-width: 0;
  gap: 6px;
  font-size: 0.92rem;
  font-weight: 680;
}

.participant-row__name > span:first-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.captain-mark {
  flex: 0 0 auto;
  color: var(--warning);
  font-size: 0.78rem;
  font-weight: 700;
}

.participant-row__meta {
  overflow: hidden;
  color: var(--text-muted);
  font-size: 0.72rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.participant-actions {
  display: flex;
  align-items: center;
  gap: 2px;
}

.participant-action {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 0;
  border-radius: 8px;
  color: var(--text-muted);
  cursor: pointer;
  background: transparent;
}

.participant-action:hover,
.participant-action[aria-pressed="true"] {
  color: var(--text);
  background: var(--surface-soft);
}

.participant-action[data-action="swap"][aria-pressed="true"] {
  color: var(--on-primary);
  background: var(--primary);
}

.team-card__footer {
  display: flex;
  justify-content: space-between;
  padding: 8px 12px 11px;
  border-top: 1px solid var(--line-soft);
  color: var(--text-muted);
  font-size: 0.74rem;
}

.bench-panel,
.fairness-insights,
.rotation-summary {
  margin-top: 22px;
  padding: 20px;
  border-radius: var(--radius);
  background: var(--surface);
}

.bench-panel ul {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 0;
  margin: 0;
  list-style: none;
}

.bench-panel li {
  padding: 8px 11px;
  border-radius: 9px;
  background: var(--surface-soft);
}

.matrix-wrap,
.roster-table-wrap,
.csv-preview-wrap {
  overflow: auto;
  max-width: 100%;
  border-radius: 10px;
}

.coverage-matrix,
.roster-table,
.csv-preview,
.rotation-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 0.82rem;
}

.coverage-matrix th,
.coverage-matrix td,
.roster-table th,
.roster-table td,
.csv-preview th,
.csv-preview td,
.rotation-table th,
.rotation-table td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--line-soft);
  text-align: left;
  white-space: nowrap;
}

.coverage-matrix th,
.roster-table th,
.csv-preview th,
.rotation-table th {
  position: sticky;
  z-index: 2;
  top: 0;
  color: var(--text-muted);
  background: var(--table-head);
  font-size: 0.72rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.coverage-matrix th:first-child,
.coverage-matrix td:first-child,
.roster-table th:first-child,
.roster-table td:first-child {
  position: sticky;
  z-index: 3;
  left: 0;
  background: var(--surface);
}

.coverage-cell {
  min-width: 38px;
  text-align: center !important;
  font-variant-numeric: tabular-nums;
}

.coverage-cell[data-count="0"] {
  color: var(--text-faint);
  background: var(--coverage-0-bg);
}

.coverage-cell[data-count="1"] {
  color: var(--coverage-1-fg);
  background: var(--coverage-1-bg);
}

.coverage-cell[data-count="2"] {
  color: var(--coverage-2-fg);
  background: var(--coverage-2-bg);
}

.coverage-cell[data-count="3"],
.coverage-cell[data-count="4"],
.coverage-cell[data-count="5"] {
  color: var(--coverage-3-fg);
  background: var(--coverage-3-bg);
}

.content-section {
  padding: clamp(56px, 8vw, 96px) 0;
  border-top: 1px solid var(--line-soft);
}

.content-section__intro {
  max-width: 780px;
  margin-bottom: 38px;
}

.content-section__intro > p:last-child,
.content-section--split > div:first-child p:last-child {
  color: var(--text-muted);
  font-size: 1.05rem;
}

/* Playbook cards: the three modes are three plays, numbered like set pieces. */
.mode-guide {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
}

.mode-guide article {
  position: relative;
  padding: 22px 22px 18px;
  border: 1px solid var(--line-soft);
  border-radius: 16px;
  background: var(--surface);
  transition: transform 220ms var(--ease-out), box-shadow 220ms var(--ease-out);
}

.mode-guide article:hover {
  transform: translateY(-2px);
  box-shadow: 0 14px 40px rgb(var(--shadow-rgb) / 0.08);
}

.mode-guide article::before {
  position: absolute;
  top: 0;
  left: 22px;
  width: 44px;
  height: 4px;
  border-radius: 0 0 4px 4px;
  background: var(--primary);
  content: "";
}

.mode-guide article:nth-child(2)::before {
  background: var(--accent-blue);
}

.mode-guide article:nth-child(3)::before {
  background: var(--accent-amber);
}

.mode-guide article p {
  margin-bottom: 0;
}

.mode-number {
  display: block;
  margin-bottom: 16px;
  color: var(--text-faint);
  font-family: var(--font-display);
  font-size: 1.05rem;
  line-height: 1;
}

.mode-guide p,
.use-case-list p,
.method-columns p {
  color: var(--text-muted);
}

.content-section--split,
.content-section--method {
  display: grid;
  grid-template-columns: minmax(250px, 0.8fr) minmax(0, 1.2fr);
  gap: clamp(40px, 8vw, 100px);
}

.use-case-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 26px 34px;
}

.use-case-list article {
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line-soft);
}

.content-section--method {
  align-items: start;
}

.method-columns {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 32px;
  grid-column: 2;
}

.content-section--method > .button {
  justify-self: start;
  grid-column: 2;
}

.site-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 30px;
  width: min(calc(100% - 40px), var(--content));
  padding: 34px 0 46px;
  margin: 0 auto;
  border-top: 1px solid var(--line);
}

.site-footer p {
  margin: 4px 0 0;
  color: var(--text-muted);
  font-size: 0.86rem;
}

.footer-actions {
  flex-wrap: wrap;
  justify-content: flex-end;
}

.app-dialog {
  width: min(620px, calc(100% - 28px));
  max-height: min(88vh, 920px);
  padding: 0;
  border: 0;
  border-radius: 18px;
  color: var(--text);
  background: var(--surface);
  box-shadow: 0 28px 90px rgb(var(--shadow-rgb) / 0.28);
}

.app-dialog--wide {
  width: min(1040px, calc(100% - 28px));
}

.app-dialog::backdrop {
  background: var(--scrim);
  backdrop-filter: blur(3px);
}

.dialog-frame {
  display: flex;
  max-height: inherit;
  margin: 0;
  flex-direction: column;
}

.dialog-header,
.dialog-footer {
  flex: 0 0 auto;
  padding: 18px 22px;
  background: var(--surface);
}

.dialog-header {
  border-bottom: 1px solid var(--line-soft);
}

.dialog-header h2 {
  margin: 0;
  font-size: 1.45rem;
}

.dialog-header .eyebrow {
  margin-bottom: 3px;
}

.dialog-close {
  font-size: 1.7rem;
  line-height: 1;
}

.dialog-body {
  min-height: 0;
  padding: 22px;
  overflow: auto;
}

.dialog-footer {
  border-top: 1px solid var(--line-soft);
}

.advanced-body {
  display: grid;
  gap: 28px;
}

.advanced-section {
  padding-bottom: 26px;
  border-bottom: 1px solid var(--line-soft);
}

.advanced-section:last-child {
  padding-bottom: 0;
  border-bottom: 0;
}

.advanced-section > p,
.section-heading-row p {
  margin-bottom: 12px;
  color: var(--text-muted);
  font-size: 0.88rem;
}

.section-heading-row h3,
.section-heading-row h2 {
  margin-bottom: 4px;
}

.roster-table-wrap {
  max-height: 430px;
  box-shadow: inset 0 0 0 1px var(--line-soft);
}

.roster-table input,
.roster-table select {
  min-width: 112px;
  min-height: 36px;
  padding: 6px 8px;
  border-color: transparent;
  background: transparent;
}

.roster-table input:focus,
.roster-table select:focus {
  border-color: var(--focus);
  background: var(--surface);
}

.roster-table .name-cell input {
  min-width: 180px;
  font-weight: 650;
}

.roster-table .skill-cell input {
  min-width: 70px;
  width: 70px;
}

.row-remove-button {
  color: var(--danger);
}

.custom-field-builder,
.rule-builder,
.csv-mapping-grid,
.form-stack,
.checkbox-grid {
  display: grid;
  gap: 12px;
}

.custom-field-builder {
  grid-template-columns: minmax(180px, 1fr) 160px auto;
  align-items: end;
  margin-top: 14px;
}

.custom-field-builder label,
.rule-builder label,
.form-stack > label,
.save-current-row label,
.csv-mapping-grid label,
.share-result label {
  display: grid;
  gap: 6px;
  color: var(--text-muted);
  font-size: 0.82rem;
  font-weight: 650;
}

.checkbox-grid {
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.check-row,
.checkbox-grid label {
  display: flex !important;
  align-items: center;
  gap: 9px !important;
  min-height: 42px;
  padding: 9px 11px;
  border-radius: 9px;
  color: var(--text) !important;
  background: var(--surface-soft);
  cursor: pointer;
}

.rule-builder {
  grid-template-columns: minmax(180px, 0.8fr) minmax(260px, 1.3fr) auto;
  align-items: end;
  padding: 16px;
  border-radius: 12px;
  background: var(--surface-soft);
}

#people-rule-fields,
#spread-rule-fields {
  display: grid;
  gap: 10px;
}

#spread-rule-fields {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

#spread-rule-fields .check-row {
  grid-column: 1 / -1;
}

.rule-list {
  display: grid;
  gap: 8px;
  margin-top: 14px;
}

.rule-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  min-height: 48px;
  padding: 9px 11px 9px 14px;
  border-radius: 10px;
  background: var(--surface-soft);
}

.rule-item p {
  margin: 0;
  font-size: 0.88rem;
}

.rule-item small {
  color: var(--text-muted);
}

.form-stack {
  gap: 16px;
}

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

.export-option {
  display: grid;
  gap: 4px;
  min-height: 92px;
  padding: 16px;
  border-radius: 12px;
  text-align: left;
  background: var(--surface-soft);
}

.export-option:hover {
  background: var(--surface-strong);
  transform: translateY(-1px);
}

.export-option span {
  color: var(--text-muted);
  font-size: 0.8rem;
}

.csv-mapping-grid {
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  margin-bottom: 18px;
}

.csv-preview-wrap {
  max-height: 320px;
  margin-top: 16px;
  box-shadow: inset 0 0 0 1px var(--line-soft);
}

.csv-preview caption {
  padding: 10px;
  color: var(--text-muted);
  text-align: left;
}

.import-issues {
  padding: 14px;
  border-radius: 10px;
  color: var(--danger);
  background: var(--danger-soft);
}

.import-issues ul {
  max-height: 170px;
  margin-bottom: 0;
  overflow: auto;
}

.save-current-row {
  align-items: end;
}

.save-current-row label {
  flex: 1;
}

.saved-project-list {
  display: grid;
  gap: 8px;
  margin-top: 18px;
}

.saved-project-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 11px;
  background: var(--surface-soft);
}

.saved-project-item p {
  margin: 3px 0 0;
  color: var(--text-muted);
  font-size: 0.78rem;
}

.saved-project-item__actions {
  display: flex;
  gap: 4px;
}

.share-preview,
.share-result {
  padding: 14px;
  border-radius: 10px;
  background: var(--surface-soft);
}

.share-preview p,
.share-result p {
  margin-bottom: 0;
  color: var(--text-muted);
  font-size: 0.84rem;
}

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

.compare-column {
  min-width: 0;
}

.compare-column h3 {
  position: sticky;
  top: -22px;
  z-index: 2;
  padding: 11px 0;
  background: var(--surface);
}

.compare-team {
  padding: 12px;
  margin-bottom: 8px;
  border-radius: 10px;
  background: var(--surface-soft);
}

.compare-team ul {
  padding-left: 18px;
  margin: 6px 0 0;
  color: var(--text-muted);
  font-size: 0.84rem;
}

.prose {
  max-width: 780px;
  color: var(--text-muted);
}

.prose h3 {
  margin-top: 26px;
  color: var(--text);
}

.prose h3:first-child {
  margin-top: 0;
}

.toast-region {
  position: fixed;
  z-index: 200;
  right: 18px;
  bottom: 18px;
  display: grid;
  width: min(360px, calc(100% - 36px));
  gap: 8px;
  pointer-events: none;
}

.toast {
  padding: 12px 14px;
  border-radius: 10px;
  color: var(--on-inverse);
  background: var(--text);
  box-shadow: 0 12px 38px rgb(var(--shadow-rgb) / 0.24);
  animation: toast-in 180ms ease both;
}

.toast[data-tone="error"] {
  background: var(--danger);
}

.toast[data-tone="success"] {
  background: var(--success);
}

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

.round-list {
  display: grid;
  gap: 14px;
  margin-top: 18px;
}

.round-card {
  overflow: hidden;
  border-radius: 14px;
  background: var(--surface);
  box-shadow: 0 10px 36px rgb(var(--shadow-rgb) / 0.06);
}

.round-card > summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px;
  cursor: pointer;
  font-weight: 720;
  list-style: none;
}

.round-card > summary::-webkit-details-marker {
  display: none;
}

.round-card__content {
  padding: 0 18px 18px;
}

.court-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 0;
  margin: 0 0 14px;
  list-style: none;
}

.court-list li {
  padding: 7px 10px;
  border-radius: 8px;
  color: var(--text-muted);
  background: var(--surface-soft);
  font-size: 0.8rem;
}

.share-view {
  min-height: 70vh;
}

.share-view__header {
  max-width: 800px;
  margin-bottom: 28px;
}

.share-view__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 28px;
}

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

body.presentation-mode {
  overflow: auto;
  background: var(--surface);
}

body.presentation-mode .site-header,
body.presentation-mode .site-footer,
body.presentation-mode .tool-intro,
body.presentation-mode .generator-form,
body.presentation-mode .validation-panel,
body.presentation-mode .content-section,
body.presentation-mode .results-header__actions,
body.presentation-mode .result-toolbar,
body.presentation-mode .result-explanation,
body.presentation-mode .fairness-insights {
  display: none !important;
}

body.presentation-mode main {
  width: min(calc(100% - 32px), 1600px);
}

body.presentation-mode .tool-shell,
body.presentation-mode .share-view {
  padding-top: 28px;
}

body.presentation-mode .results-workspace {
  margin-top: 0;
  padding-top: 0;
  border-top: 0;
}

body.presentation-mode .team-card {
  box-shadow: 0 0 0 1px var(--line);
}

@media (max-width: 1040px) {
  .setup-grid {
    grid-template-columns: 1fr;
  }

  .setup-panel--options {
    padding-top: 28px;
  }

  .content-section--split,
  .content-section--method {
    grid-template-columns: 1fr;
    gap: 34px;
  }

  .method-columns,
  .content-section--method > .button {
    grid-column: 1;
  }

  .result-toolbar {
    position: static;
  }
}

@media (max-width: 760px) {
  .site-header__inner,
  main,
  .site-footer {
    width: min(calc(100% - 24px), var(--content));
  }

  .site-header__inner {
    min-height: 62px;
  }

  .brand__name {
    font-size: 0.9rem;
  }

  .hide-on-narrow {
    display: none !important;
  }

  .tool-shell,
  .share-view {
    padding-top: 38px;
  }

  .tool-shell::before,
  .tool-shell::after {
    display: none;
  }

  .tool-intro {
    display: grid;
    gap: 18px;
  }

  .privacy-status {
    width: fit-content;
  }

  .setup-panel {
    padding: 20px;
  }

  #names-input {
    min-height: 230px;
  }

  .mode-control {
    grid-template-columns: 1fr;
  }

  .mode-option {
    min-height: 72px;
    padding: 12px 42px 12px 14px;
  }

  .mode-option__title {
    margin: 0 0 3px;
  }

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

  .results-header,
  .result-toolbar,
  .section-heading-row,
  .site-footer {
    align-items: flex-start;
    flex-direction: column;
  }

  .results-header__actions,
  .project-name-field,
  .result-toolbar__group {
    width: 100%;
  }

  .results-header__actions .button,
  .project-name-field {
    flex: 1;
  }

  .result-toolbar__group .button {
    flex: 1 1 auto;
  }

  .team-grid {
    grid-template-columns: 1fr;
  }

  .mode-guide,
  .use-case-list,
  .method-columns,
  .export-grid,
  .compare-grid {
    grid-template-columns: 1fr;
  }

  .content-section {
    padding: 64px 0;
  }

  .site-footer {
    align-items: stretch;
  }

  .footer-actions {
    justify-content: flex-start;
  }

  .app-dialog,
  .app-dialog--wide {
    width: calc(100% - 12px);
    max-height: calc(100dvh - 12px);
    border-radius: 14px;
  }

  .dialog-header,
  .dialog-footer,
  .dialog-body {
    padding-right: 16px;
    padding-left: 16px;
  }

  .dialog-footer .button {
    flex: 1;
  }

  .custom-field-builder,
  .rule-builder,
  #spread-rule-fields {
    grid-template-columns: 1fr;
  }

  #spread-rule-fields .check-row {
    grid-column: 1;
  }

  .save-current-row {
    align-items: stretch;
    flex-direction: column;
  }

  .saved-project-item {
    grid-template-columns: 1fr;
  }

  .saved-project-item__actions .button {
    flex: 1;
  }

  .participant-row {
    grid-template-columns: 18px minmax(0, 1fr) auto;
    padding-left: 9px;
  }

  .participant-actions .participant-action[data-action="lock"],
  .participant-actions .participant-action[data-action="captain"] {
    display: none;
  }
}

@media (max-width: 420px) {
  h1 {
    font-size: 2.05rem;
  }

  .utility-nav {
    gap: 2px;
  }

  .utility-nav .button {
    padding-right: 8px;
    padding-left: 8px;
  }

  .setup-panel {
    padding: 16px;
  }

  .panel-heading {
    align-items: flex-start;
  }

  .compact-select {
    width: 116px;
  }

  .split-option {
    grid-template-columns: 20px minmax(0, 1fr) 68px;
  }

  .inline-actions--between {
    align-items: stretch;
    flex-direction: column;
  }

  .inline-actions--between .button {
    justify-content: space-between;
    width: 100%;
  }

  .participant-actions {
    gap: 0;
  }

  .participant-action {
    width: 32px;
  }
}

/* Touch devices get full-size hit areas regardless of viewport width. Declared
   after the width queries so it wins over the compact phone layout. */
@media (pointer: coarse) {
  .participant-action {
    width: 40px;
    height: 40px;
  }

  .icon-button {
    width: 44px;
    height: 44px;
  }

  .export-option {
    min-height: 104px;
  }

  .participant-row {
    min-height: 58px;
  }
}

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

@media print {
  /* Printing always uses the light palette, even from a dark-mode browser. */
  :root {
    color-scheme: light;
    --page: #fff;
    --surface: #fff;
    --surface-soft: #f4f4f2;
    --surface-strong: #e8e5dd;
    --text: #111827;
    --text-muted: #444c58;
    --text-faint: #5c6470;
    --line: #ccd0d6;
    --line-soft: #e2e4e8;
    --table-head: #f2f2f0;
    --row-alt: #fafafa;
    --coverage-0-bg: #f5f6f7;
    --coverage-1-fg: #0f5132;
    --coverage-1-bg: #e8f7ee;
    --coverage-2-fg: #704d00;
    --coverage-2-bg: #fff2cc;
    --coverage-3-fg: #842029;
    --coverage-3-bg: #fbe5e7;
    --shadow-rgb: 23 32 51;
  }

  .site-header,
  .site-footer,
  .tool-intro,
  .generator-form,
  .validation-panel,
  .result-toolbar,
  .results-header__actions,
  .result-explanation,
  .fairness-insights,
  .content-section,
  .toast-region,
  dialog {
    display: none !important;
  }

  body,
  main {
    width: 100%;
    margin: 0;
    background: #fff;
  }

  .tool-shell {
    padding: 0;
  }

  .results-workspace,
  .round-results {
    display: block !important;
    margin: 0;
    padding: 0;
    border: 0;
  }

  .metric-rail {
    grid-template-columns: repeat(6, 1fr);
    overflow: visible;
  }

  .metric,
  .team-card,
  .round-card {
    break-inside: avoid;
    box-shadow: none;
    outline: 1px solid #ddd;
  }

  .team-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .participant-actions,
  .team-card__controls {
    display: none;
  }
}
