/* rr/assets/styles.css */
:root {
  /* base text */
  --text: #eef2f6;
  --text-muted: #9aa4b2;

  /* brand accents */
  --clubops-red: #f86a6a;
  --clubops-blue: #58b2e7;
  --accent: #58b2e7;
  --accent-ink: #000000;
  --accent-start: #78cdff;
  --accent-end: #458eb8;

  /* semantic */
  --ok: #7cf29a;
  --info: #67abd3;
  --danger: #f86a6a;
  --danger-start: #f86a6a;
  --danger-end: #cf5959;
  --warning: #ffcd70;
  --start: #6ad26a;
  --end: #ff5555;
  /* OK scale */
  --ok-100: #cfffdb;
  --ok-200: #bcfacc;
  --ok-300: #9ef9b5;
  --ok-400: #7cf29a;
  --ok-500: #5acc77;
  --ok-600: #36c26e;
  --ok-700: #2ca25a;
  --ok-800: #146533;
  --ok-900: #0b5025;
  --on-ok: #052b15;
  /* Warning scale */
  --warning-100: #fdd099;
  --warning-200: #f6b76a;
  --warning-300: #ffac46;
  --warning-400: #fa8c0a; /* slightly deeper than --warning (actually AnanteOrange(TM) 🤭) */
  --warning-500: #e67c00; /* border */
  --warning-600: #999999; /* On second thoughts that was a silly idea */
  --warning-700: #777777; /* border */
  --warning-800: #555555;
  --warning-900: #333333;
  --on-warning: #3a2b00;
  /* Danger scale */
  --danger-100: #fda4a4;
  --danger-200: #fa8383;
  --danger-300: #f27272;
  --danger-400: #f86a6a;
  --danger-500: #e55f5f;
  --danger-600: #cc4545;
  --danger-700: #ad3333;
  --danger-800: #892020;
  --danger-900: #601313;
  --on-danger: #2b0505;

  /* Help button */
  --help-bg: #41704d;
  --help-fg: #ffffff;
  --help-border: #25482e;
  --help-bg-hover: #7cf29a;
  --help-fg-hover: #000000;

  /* dark surfaces */
  --bg-0: #0c0f13;
  --bg-1: #0f1216;
  --surface-0: #151d27;
  --surface-1: #293039;
  --surface-2: #263548;
  --surface-3: #284167;
  --surface-4: #2f5083;
  --surface-hover: #202a37;

  /* borders / dividers */
  --border-0: #232a34;
  --border-1: #384556;
  --border-2: #475974;
  --border-3: #667ea1;
  --border-4: #678cc5;
  --divider: #22333f;

  /* table / misc tints */
  --row-border: #243041;
  --chip-text: #cfe5e7;
  --ghost-text: #cfd8e3;
  --label: #b6c2d0;

  /* badges & avatars */
  --badge-bg: #111821;
  --badge-text: #bbccdd;
  --avatar-bg: #243041;
  --avatar-text: #99ffee;

  /* headings */
  --h1: #dfedff;
  --h2: #d4e6ff;
  --h3: #cae1fd;
  --h4: #c5dfff;
  --court-title: #b9d8fd;

  /* slots / chips */
  --slot-border: #334;

  /* overlays */
  --header-bg: #000000;
  --footer-bg: #000000;

  /* print */
  --print-bg: #fff;
  --print-text: #000;
  --print-border: #ddd;

  /* misc */
  --shadow: 0 8px 24px rgba(0, 0, 0, 0.25), 0 2px 6px rgba(0, 0, 0, 0.2);
  --radius: 1rem;
  --ring: 0 0 0 2px var(--accent);
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  background: linear-gradient(180deg, var(--bg-0), var(--bg-1) 20%);
  color: var(--text);
  font: 16px/1.45 system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial;
}

* {
  box-sizing: border-box;
}

.logo {
  max-height: 5rem;
  max-width: 6rem;
  width: auto;
  filter: brightness(150%);
}

h1,
h2,
h3 {
  margin: 0 0 0.4rem;
}
h1 {
  font-size: 1.5rem;
  color: var(--h1);
}
h2 {
  font-size: 1.25rem;
  color: var(--h2);
}
h3 {
  font-size: 1.1rem;
  color: var(--h3);
}
h4 {
  font-size: 1rem;
  color: var(--h4);
}
a {
  color: var(--accent);
}
p {
  font-size: 1rem;
}
hr {
  margin: 1rem;
}

/* Layout */
header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--header-bg);
  backdrop-filter: saturate(120%) blur(8px);
  border-bottom: 1px solid var(--border-0);
  box-shadow: var(--shadow);
}
.wrap {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0.75rem 1rem;
}
.row {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  flex-wrap: wrap;
}
.grow {
  flex: 1;
}
.next-step {
  font-weight: bolder;
  font-size: 1.5rem;
  color: var(--ok);
}
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0.35rem 0.6rem;
  border-radius: 999px;
  border: 1px solid var(--border-2);
  background: var(--surface-2);
  color: var(--chip-text);
}

.icon {
  font-size: 1rem;
  filter: brightness(125%);
}
.icon-list {
  font-size: 1.25rem;
  margin-left: -1rem;
  margin-right: 0.25rem;
  filter: brightness(150%);
}
.icon-list-image {
  height: 1.25rem;
  width: 1.25rem;
  margin-left: -1rem;
  margin-right: 0.25rem;
  filter: brightness(150%);
}

.toolbar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
button,
.btn {
  appearance: none;
  border: none;
  border-radius: 12px;
  padding: 0.6rem 0.8rem;
  background: var(--surface-2);
  color: var(--text);
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: 0.15s transform, 0.15s background;
}
.fs-btn {
  padding: 0;
  font-size: 1rem;
}
button:hover {
  transform: translateY(-1px);
  background: var(--surface-hover);
}
button:active {
  transform: translateY(0);
}
button:disabled,
.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  filter: grayscale(0.2);
  box-shadow: none;
  transform: none;
}
button:disabled:hover,
button:disabled:active {
  background: inherit;
  transform: none;
}
.btn-accent {
  background: linear-gradient(180deg, var(--accent-start), var(--accent-end));
  color: var(--accent-ink);
  font-weight: 900;
}
.btn-accent:hover {
  color: var(--text);
}
.btn-danger {
  background: linear-gradient(180deg, var(--danger-start), var(--danger-end));
  color: var(--ghost-text);
}
.btn-ghost {
  background: transparent;
  border: 1px solid var(--border-1);
  color: var(--ghost-text);
}
.btn-temp {
  background: var(--warning-400);
  border: 1px solid var(--warning);
  color: var(--warning-100);
}
.btn-help {
  background: var(--help-bg);
  color: var(--help-fg);
  border: 1px solid var(--help-border);
  border-radius: 10px;
  padding: 6px 10px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.25s ease, transform 0.02s ease;
}
.btn-help:hover {
  background: var(--help-bg-hover);
  color: var(--help-fg-hover);
}
.btn-help:active {
  transform: translateY(1px);
}
.btn-help[disabled] {
  opacity: 0.6;
  cursor: not-allowed;
}

.grid {
  display: grid;
  gap: 0.75rem;
}
/* default = 1 column */
.cols-2,
.cols-3 {
  grid-template-columns: 1fr;
}
/* responsive 2/3 columns */
/* ≥641px: allow 2 columns */
@media (min-width: 641px) {
  .cols-2 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .cols-3 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
/* ≥1100px: allow 3 columns */
@media (min-width: 1100px) {
  .cols-3 {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}
.cols-2 > .full-span,
.cols-3 > .full-span {
  grid-column: 1 / -1;
}
/* Flexible auto-fit grid to prevent tiny inputs when cramped */
.cols-auto {
  grid-template-columns: repeat(auto-fit, minmax(24ch, 1fr));
}
.cols-auto-small {
  grid-template-columns: repeat(
    auto-fit,
    minmax(3ch, 1fr)
  ); /* smaller inputs, e.g. numbers, so 3 chars */
}

/* Selectable Card Grid/List Layouts */
.options-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; }
.options-list { display: flex; flex-direction: column; gap: 0.75rem; }
.option-card,
.option-sub-card {
  position: relative;
  display: flex;
  flex-direction: column;
  padding: 1rem;
  border: 1px solid var(--border-1);
  border-radius: var(--radius);
  background: var(--surface-0);
  cursor: pointer;
  transition: all 0.25s ease;
  user-select: none;
}
.option-sub-card {
  padding: 0.25rem;
  border-radius: 0.5rem;
  background: var(--surface-0);
  transition: none;
}
.option-card:hover,
.option-sub-card:hover {
  border-color: var(--border-4);
  background: var(--surface-2);
  transform: translateY(0.125rem);
}
.option-card.selected,
.option-sub-card.selected {
  border: 0.125rem solid var(--border-4);
  background: var(--surface-4);
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}
.card-header {
  font-weight: 400;
  color: var(--text-muted);
  margin-bottom: 0.25rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.option-card.selected .card-header {
  font-weight: 700;
  color: var(--text);
}
.card-desc {
  font-size: 0.85rem;
  color: var(--text-muted);
  line-height: 1.4;
}
.sub-settings-panel {
  padding: 0.75rem;
  margin-left: 1rem;
  margin-right: 1rem;
  border: 1px dotted var(--border-3);
  background: var(--surface-3);
  animation: fadeIn 0.5s ease-in-out;
}

/* Draggable list */
.dnd-list {
  list-style: none;
  margin: 0;
  padding: 0;
  border: 1px solid var(--border-1);
  border-radius: 10px;
  background: var(--surface-0);
}
.dnd-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--row-border);
}
.dnd-item:last-child {
  border-bottom: 0;
}
.dnd-handle {
  cursor: grab;
  user-select: none;
  font-size: 1.1rem;
  opacity: 0.7;
}
.dnd-item.dragging {
  opacity: 0.6;
  background: var(--surface-hover);
}
.dnd-spacer {
  flex: 1;
}
.dnd-item button {
  padding: 0.35rem 0.5rem;
  border-radius: 8px;
}

.card {
  background: linear-gradient(180deg, var(--surface-1), var(--surface-0));
  border: 1px solid var(--border-0);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1rem;
}
.card h3 {
  margin-bottom: 0.6rem;
}

/* =========================
          Navigation tabs rail
          Breakpoints:
            ≤640px  : phone (pills)
            641–899 : small/tablet (pills)
            ≥900px  : large (discs)
            ≥1200px : XL discs tweaks
       ========================= */
nav.tabs {
  display: flex;
  gap: 8px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--divider);
  width: 100%;
}
/* base variables for pills */
:root {
  --tab-fs: 1rem;
  --tab-weight: 600;
  --tab-radius: 1rem;
  --tab-pad-inline: 1rem;
  --tab-pad-block: 0.65rem;
}
/* equal-width tab cell */
.btn-tab {
  flex: 1 1 0;
  min-width: 0;
  display: grid;
  place-items: center;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  background: var(--surface-1);
  border: 1px solid var(--border-1);
  color: var(--text-muted);
  font-size: var(--tab-fs);
  font-weight: var(--tab-weight);
  /* pill by default */
  padding-inline: var(--tab-pad-inline);
  padding-block: var(--tab-pad-block);
  border-radius: var(--tab-radius);
  /* disc mode will override these */
  aspect-ratio: auto;
  height: auto;
}
/* active */
.btn-tab[aria-current="page"],
.btn-tab[aria-selected="true"] {
  background: var(--surface-3);
  border-color: var(--border-2);
  color: var(--text);
  box-shadow: var(--ring);
}
/* ---------- ≤640px (phones): compact pills ---------- */
@media (max-width: 640px) {
  :root {
    --tab-fs: 0.85rem;
    --tab-weight: 400;
    --tab-radius: 14px;
    --tab-pad-inline: 0.8rem;
    --tab-pad-block: 0.55rem;
  }
}
/* ---------- 641–899px (small/tablet): comfy pills ---------- */
@media (min-width: 641px) and (max-width: 899px) {
  :root {
    --tab-fs: 0.95rem;
    --tab-weight: 600;
    --tab-radius: 16px;
    --tab-pad-inline: 0.95rem;
    --tab-pad-block: 0.6rem;
  }
}
/* ---------- ≥900px (large): discs that fill the row ---------- */
@media (min-width: 900px) and (min-height: 700px) {
  :root {
    --tab-fs: 1.25rem;
    --tab-weight: 900;
  }
  .btn-tab {
    aspect-ratio: 1 / 1; /* perfect squares */
    padding: 0; /* clean discs */
    border-radius: 50%;
  }
}
/* ---------- ≥1200px (XL): larger label in discs ---------- */
@media (min-width: 1200px) and (min-height: 700px) {
  :root {
    --tab-fs: 1.5rem;
  }
}

.inline-controls {
  align-items: center;
  gap: 0.5rem;
}
.inline-controls select {
  width: auto;
  min-width: 160px;
}
.inline-controls label {
  white-space: nowrap;
}

input,
select {
  width: 100%;
  padding: 0.55rem 0.65rem;
  border-radius: 10px;
  border: 1px solid var(--border-1);
  background: var(--surface-0);
  color: var(--text);
  min-width: 0; /* prevents overflow in grid children on narrow layouts */
}
input:focus,
select:focus,
textarea:focus {
  outline: none;
  box-shadow: var(--ring);
}
label {
  font-size: 0.85rem;
  color: var(--label);
}

/* Table layout */
.table-wrap {
  max-height: 60vh;
  overflow: auto;
}
@media (max-height: 820px) {
  .table-wrap {
    max-height: 50vh;
  }
}
@media (max-height: 660px) {
  .table-wrap {
    max-height: 40vh;
  }
}
@media (max-height: 540px) {
  .table-wrap {
    max-height: 30vh;
  }
}
table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
}
th,
td {
  padding: 0.6rem 0.5rem;
  border-bottom: 1px solid var(--row-border);
  text-align: left;
  vertical-align: middle;
}
thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--surface-2);
  font-weight: 800;
  border-bottom: 3px solid var(--border-0);
  box-shadow: 0 2px 0 var(--border-0), 0 4px 12px rgba(0, 0, 0, 0.25);
}

.player-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 0.35rem 0.55rem;
  border-radius: 999px;
  border: 1px solid var(--border-0);
  background: var(--badge-bg);
}
.player-avatar {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--avatar-bg);
  display: inline-grid;
  place-items: center;
  font-size: 0.75rem;
  color: var(--avatar-text);
}
.inactive {
  opacity: 0.5;
  filter: grayscale(0.2);
}
.ok {
  color: var(--ok);
}
.info {
  color: var(--info);
}
.warning {
  color: var(--warning);
}
.danger {
  color: var(--danger);
}

.alpha {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.alpha .alpha-btn {
  min-width: 28px;
  text-align: center;
  padding: 0.35rem 0.5rem;
  border: 1px solid var(--border-1);
  border-radius: 10px;
  background: var(--surface-1);
  cursor: pointer;
  box-shadow: var(--shadow);
}
.alpha .alpha-btn[aria-pressed="true"] {
  background: var(--surface-3);
  border-color: var(--border-2);
  box-shadow: var(--ring);
}
.alpha .spacer {
  flex: 1;
}

.player-card {
  display: flex;
  align-items: center;
  position: relative;
  gap: 10px;
  padding: 0.5rem 0.65rem;
  border: 1px solid var(--border-0);
  border-radius: 0.75rem;
  background: var(--surface-0);
}
.player-card.inactive {
  background: linear-gradient(180deg, var(--surface-1), var(--surface-0));
  border-color: var(--border-1);
  color: var(--warning); /* keeps text readable but “dim” */
  filter: grayscale(0.15);
}
/* Subtle left status bar for active and inactive */
.player-card.active::before,
.player-card.inactive::before {
  content: "";
  position: absolute;
  inset: 0 0 0 0;
  border-left: 4px solid var(--warning);
  border-radius: 0.75rem;
  pointer-events: none;
}
.player-card.active::before {
  border-left: 4px solid var(--ok);
}

.pin-btn {
  margin-left: auto;
  border: 1px solid var(--border-1);
  background: var(--surface-1);
  border-radius: 0.5rem;
  padding: 0.25rem 0.25rem;
}
.pin-btn.is-pinned {
  background: var(--surface-3);
  box-shadow: var(--ring);
}

/* Court cards */
.court {
  position: relative;
}
.court h4 {
  margin: 0 0 0.25rem;
  font-size: 1rem;
  color: var(--court-title);
}
.teams {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 10px;
}
.vs {
  opacity: 0.7;
  font-weight: 700;
}

.team {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.slot {
  min-width: 110px;
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 0.35rem 0.55rem;
  border-radius: 10px;
  border: 1px dashed var(--slot-border);
  cursor: grab;
}
.slot.dragging {
  opacity: 0.6;
}

.scorebox {
  display: flex;
  align-items: center;
  gap: 8px;
}
.scorebox input[type="number"] {
  width: 70px;
  text-align: center;
  font-size: 1.1rem;
}

.badge {
  font-size: 0.75rem;
  padding: 0.2rem 0.45rem;
  border-radius: 999px;
  border: 1px solid var(--border-1);
  background: var(--badge-bg);
  color: var(--badge-text);
}
.badge-warn {
  color: var(--warning-400);
}
.badge-length {
  display: inline-block;
  margin-left: 0.25rem;
  padding: 0.15rem 0.45rem;
  border-radius: 999px;
  border: 1px solid var(--border-1);
  background: var(--surface-1);
  color: var(--text);
  font-size: 0.8rem;
  vertical-align: middle;
}
.badge-length.shrunk {
  color: var(--warning-400);
  border-color: var(--warning-500);
}
.badge-lock {
  margin-left: 8px;
  background: var(--warning-600);
  border-color: var(--warning-700);
  color: var(--on-warning);
}
.badge-computed {
  font-size: 0.75rem;
  padding: 0.15rem 0.4rem;
  border-radius: 999px;
  border: 1px solid var(--border-1);
  background: var(--badge-bg);
  color: var(--badge-text);
  margin-left: 6px;
  display: inline-flex;
  align-items: center;
}
.badge-status.status-unplayed {
  color: var(--warning-600);
}
.badge-status.status-playing {
  color: var(--ok-400);
  border-color: color-mix(in srgb, var(--ok-600) 35%, var(--border-0));
}
.badge-status.status-played {
  color: var(--ok-800);
}
.card.status-playing {
  border-color: color-mix(in srgb, var(--ok-600) 40%, var(--border-0));
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--ok-600) 12%, transparent) inset;
  background:
    linear-gradient(0deg, color-mix(in srgb, var(--ok-600) 6%, transparent), transparent) ;
}
.card.status-played {
  color: var(--text-muted);
  background: var(--surface-0);
  opacity: .95;
}

/* Locked state for Session Setup */
#sessionSetupBlock.is-locked {
  position: relative;
  opacity: 0.6;
  filter: grayscale(0.15);
}
/* Prevent clicks on children when locked (inert also helps) */
#sessionSetupBlock.is-locked > * {
  pointer-events: none;
}
/* Keep Help button interactive */
#sessionSetupBlock.is-locked .btn-help {
  pointer-events: auto;
}
/* Optional subtle hatch & caption */
#sessionSetupBlock.is-locked::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: repeating-linear-gradient(
    -45deg,
    transparent 0 12px,
    rgba(255, 255, 255, 0.03) 12px 24px
  );
  border-radius: var(--radius);
  display: grid;
  place-items: end center;
  padding: 6px;
  color: var(--text-muted);
  font-size: 0.85rem;
}
.session-hints {
  margin-top: 0.5rem;
  margin-bottom: 1.5rem;
  color: var(--clubops-blue);
  font-weight: bold;
  font-size: 0.85rem;
}

.credits-content h2,
.privacy-content h2,
.terms-content h2 {
  text-align: center;
}
.credits-content a,
.privacy-content a,
.terms-content a {
  color: var(--clubops-blue);
}
.credits-content a:hover,
.privacy-content a:hover,
.terms-content a:hover {
  color: var(--clubops-red);
}
.credits-content .credit-cards {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  justify-content: center;
  margin-bottom: 1.5rem;
}
.credit-card,
.summary-box {
  background: var(--surface-3);
  color: var(--text);
  border: 1px solid var(--border-3);
  border-radius: 1rem;
  padding: 0.65rem;
  margin: 0.5rem;
}
.credit-card {
  min-width: 8rem;
  max-width: 12rem;
  font-size: 0.9rem;
}
.credit-card p {
  font-size: 0.75rem;
  color: var(--colour-text-primary);
  margin-bottom: 0.75rem;
}
.summary-box {
  width: 95%;
  font-size: 1.1rem;
}

.message-box {
  position: fixed;
  box-sizing: border-box;
  overflow: hidden;
  top: 20vh;
  left: 50%;
  transform: translateX(-50%);
  display: none;
  white-space: pre-wrap;
  padding: 1rem;
  width: 80%;
  font-weight: bold;
  font-size: 1.5rem;
  text-align: center;
  opacity: 0;
  border-radius: 1rem;
  transition: opacity 0.5s ease;
  z-index: 999;
  box-sizing: border-box;
}
.message-box.success {
  background-color: var(--ok-900); /* fallback for older browsers */
  background-color: color-mix(in srgb, var(--ok-900), transparent 50%);
  color: var(--ok-100);
}
.message-box.error {
  background-color: var(--danger-900);
  background-color: color-mix(in srgb, var(--danger-900), transparent 50%);
  color: var(--danger-100);
}
.message-box.warning {
  background-color: var(--warning-500);
  background-color: color-mix(in srgb, var(--warning-500), transparent 55%);
  color: var(--warning-100);
}
.message-box.success:hover {
  background-color: var(--ok-900);
}
.message-box.error:hover {
  background-color: var(--danger-900);
}
.message-box.warning:hover {
  background-color: var(--warning-500);
}
.message-hint {
  position: absolute;
  right: 0.5rem;
  top: 0.25rem;
  font-size: 0.85rem;
  opacity: 0;
  transition: opacity 120ms ease;
  pointer-events: none;
}
.message-progress-bar {
  position: absolute;
  bottom: 0;
  left: 0;
  height: 0.5rem;
  width: 100%;
  background-color: var(--warning-600);
  transform: translateX(0%);
}
.warning-box {
  background-color: var(--warning-500);
  color: var(--warning-100);
  padding: 1rem;
  border-radius: 0.5rem;
  font-size: 1rem;
  margin-bottom: 1.5rem;
}

.footerbar {
  position: sticky;
  bottom: 0;
  background: var(--footer-bg);
  backdrop-filter: blur(8px);
  border-top: 1px solid var(--divider);
  padding: 8px 16px;
}
.footer-legal {
  flex: 0 0 auto;
  width: max-content;
  margin: 0 auto;
  text-align: center;
}
/* each <p> becomes one unbreakable line */
.footer-legal p {
  margin: 0;
  line-height: 1.2;
  white-space: nowrap;
  font-size: smaller;
}
.footer-spacer {
  flex: 1; /* blank filler to push the center into exact middle */
}
footer a {
  color: var(--accent);
  text-decoration: none;
}
footer a:hover {
  color: var(--danger);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.player-mini {
  margin-left: auto;
}
table.mini {
  width: auto;
  border-collapse: separate;
  border-spacing: 0;
}
table.mini th,
table.mini td {
  padding: 0.25rem 0.4rem;
  border-bottom: 1px solid var(--row-border);
  font-size: 0.85rem;
  text-align: left;
}
table.mini thead th {
  position: static;
  background: var(--surface-1);
  color: var(--text-muted);
  font-weight: 600;
  border-bottom: 1px solid var(--border-0);
}
table.mini thead.mini-head {
  cursor: pointer;
  user-select: none;
}
table.mini thead.mini-head:active {
  transform: translateY(1px);
}

/* Timing bar container (sticks to schedule header area) */
.timebar-wrap {
  margin: 0.5rem 0 0.75rem;
  position: relative;
}
/* The scrollable rail */
.timebar {
  overflow-x: auto;
  overflow-y: hidden;
  white-space: nowrap;
  padding: 0.5rem;
  border: 2px solid var(--border-2);
  border-radius: 14px;
  background: var(--surface-0);
  scroll-behavior: smooth;
}
/* Start & End anchors */
.timebar-ends {
  position: relative;
  display: flex;
  justify-content: space-between;
  font-weight: 700;
  font-size: 1rem;
  margin-top: 0.25rem;
}
.timebar-ends .tstart {
  color: var(--start);
}
.timebar-ends .tend {
  color: var(--end);
}
/* Round pills */
.time-pill {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 5.5rem;
  height: 3rem;
  margin: 0.25rem 0.25rem;
  border-radius: 0.75rem;
  border: 2px solid var(--border-2);
  background: var(--surface-2);
  color: var(--text);
  cursor: pointer;
  transition: transform 0.06s ease, box-shadow 0.12s ease;
}
.time-pill .pill-title {
  font-size: 0.9rem;
  font-weight: 600;
  margin-bottom: 2px;
}
.time-pill .pill-time {
  font-size: 0.8rem;
  color: var(--text-muted);
}
.time-pill:hover {
  background: var(--surface-3);
  box-shadow: 0 2px 1rem var(--surface-3);
}
.time-pill:active {
  transform: translateY(1px);
}
/* Hint card when timing is not available */
.timebar-hint {
  margin-bottom: 0.75rem;
}
.time-pill.is-done {
  border-color: var(--ok);
  background: linear-gradient(
    180deg,
    rgba(124, 242, 154, 0.12),
    var(--surface-2)
  );
}
.time-pill.is-editable {
  box-shadow: 0 0 0 2px var(--accent);
}
.time-pill.is-locked {
  opacity: 0.55;
}

/* Modal for help etc */
.help-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}
.help-backdrop.show {
  display: flex;
}
.help-modal {
  width: min(800px, 90vw);
  max-height: 95vh;
  background: var(--surface-2);
  color: var(--text);
  border: 2px solid var(--border-0);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1rem;
  overflow-y: auto;
}
/* Optional: make the insights modal wider/taller */
#insightBackdrop.help-modal {
  width: min(960px, 96vw);
  max-height: 96vh;
}
.help-modal h3 {
  margin: 0 0 0.5rem;
  padding: 0.75rem;
  background: var(--surface-0);
}
.help-modal h4 {
  margin: 0 0 0.25rem;
  padding: 0.25rem;
  background: var(--surface-1);
}
.help-modal ul {
  margin: 0.25rem 0 0 1.1rem;
  padding: 0;
}
.help-modal li {
  margin: 0.2rem 0;
}
.help-close {
  float: right;
  background: transparent;
  border: 1px solid var(--border-0);
  border-radius: 0.5rem;
  padding: 0;
  font-size: 1rem;
}

/* Progress bar */
.progressbar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1rem;
}
:root {
  --pb-height: 3.5rem;
}
.pb-seg,
.pb-progress {
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 0.5rem;
  font-size: 1.1rem;
  font-weight: 700;
  border: 1px solid var(--border-0);
  box-shadow: var(--shadow);
  min-height: var(--pb-height);
}
.pb-seg {
  padding: 0 0.5rem;
  white-space: nowrap;
  background: var(--surface-2);
  color: var(--text);
}
.pb-flag {
  width: 3.5rem;
  font-size: 1.5rem;
  justify-content: center;
}
.pb-progress {
  flex: 1;
  overflow: hidden;
  padding: 0;
  background: var(--surface-1);
  justify-content: flex-start;
}
.pb-seg.pb-bad,
.pb-flag.pb-bad,
.pb-progress.pb-bad {
  background: var(--danger-700);
  color: var(--on-danger);
}
.pb-progress.pb-warn {
  background: var(--warning-600);
  color: var(--on-warning);
}
.pb-seg.pb-ok,
.pb-flag.pb-ok,
.pb-progress.pb-ok {
  background: var(--ok-700);
  color: var(--on-ok);
}
.pb-progress-fill {
  height: 3rem;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  padding-left: 0.5rem;
  font-weight: 700;
  white-space: nowrap;
  background: var(--ok-700);
  color: var(--on-ok);
  transition: width 0.3s ease;
}
.pb-ok {
  background: var(--ok-600);
  border-color: var(--ok-700);
  color: var(--on-ok);
}
.pb-bad {
  background: var(--danger-600);
  border-color: var(--danger-700);
  color: var(--on-danger);
}
.pb-warn {
  background: var(--warning-600);
  border-color: var(--warning-700);
  color: var(--on-warning);
}
/* Full screen Insights cards - let's zoom in some */
.card.is-fullscreen {
  height: auto;
  font-size: 1.5rem;
  line-height: 1.6;
}
.card.is-fullscreen h3 {
  font-size: 2rem;
}
.card.is-fullscreen h4 {
  font-size: 1.5rem;
}
.card.is-fullscreen .badge,
.card.is-fullscreen .chip,
.card.is-fullscreen p {
  font-size: 1.25em;
  padding: 0.3rem 0.7rem;
}

/* === Sit-out Distribution heatmap === */
:root {
  --hm-row-h: 28px;
  --hm-cell: 18px;
  --hm-gap: 8px;
}
/* When shown in the modal, let the grid use modal's scroll */
.heatmap-wrap.is-fullscreen .hm-track-scroll {
  max-height: none;
}
.heatmap-body.is-fullscreen {
  max-height: none;
}
.heatmap-head {
  display: grid;
  grid-template-columns: 30% 1fr 10%;
  align-items: center;
  gap: var(--hm-gap);
  margin-bottom: 0.4rem;
}
.heatmap-head .hm-name {
  font-weight: 700;
}
.hm-track-label {
  padding: 0.25rem 0.5rem;
  white-space: nowrap;
  color: var(--muted);
  text-align: center;
}
.heatmap-body {
  display: grid;
  grid-template-columns: 30% 1fr 10%;
  gap: var(--hm-gap);
  max-height: calc(
    var(--hm-row-h) * 5 + 1px
  ); /* 5 rows visible, then vertical scroll */
  overflow-y: auto;
}
.hm-name-col,
.hm-max-col {
  display: grid;
  grid-auto-rows: var(--hm-row-h);
  align-items: center;
}
.hm-name-cell {
  padding: 0 0.25rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.hm-max-cell {
  text-align: center;
  font-weight: 700;
}
.hm-track-scroll {
  overflow-x: auto; /* single horizontal scrollbar here */
  overflow-y: hidden;
}
/* Slim + themed scrollbars (both horizontal and vertical) */
.heatmap-body,
.hm-track-scroll {
  scrollbar-width: thin; /* Firefox */
  scrollbar-color: var(--surface-4) var(--surface-3);
}
.heatmap-body::-webkit-scrollbar,
.hm-track-scroll::-webkit-scrollbar {
  height: 8px; /* horizontal size */
  width: 8px; /* vertical size */
}
.heatmap-body::-webkit-scrollbar-track,
.hm-track-scroll::-webkit-scrollbar-track {
  background: var(--surface-3);
  border-radius: 8px;
}
.heatmap-body::-webkit-scrollbar-thumb,
.hm-track-scroll::-webkit-scrollbar-thumb {
  background: var(--surface-4);
  border-radius: 8px;
}
.hm-track-inner {
  display: grid;
  grid-auto-rows: var(--hm-row-h);
  width: max-content;
}
.hm-track {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: var(--hm-cell);
  gap: 4px;
  place-items: center;
}
.hm-cell {
  width: var(--hm-cell);
  height: var(--hm-cell);
  border-radius: 4px;
  box-shadow: inset 0 0 0 1px var(--border-1);
}
.heatmap-legend {
  display: flex;
  gap: 0.25rem;
  justify-content: center;
  margin-top: 0.25rem;
  font-size: 0.75rem;
}
.hm-swatch {
  display: inline-block;
  width: 0.75rem;
  height: 0.75rem;
  border-radius: 3px;
  margin-right: 0;
  vertical-align: -2px;
  box-shadow: inset 0 0 0 1px var(--border-1);
}
.hm-cell.sit,
.hm-swatch.sit {
  background: var(--danger-700);
}
.hm-cell.play,
.hm-swatch.play {
  background: var(--ok-700);
}

/* === Partner & Opponent Matrices (shared styles) === */
.matrix-wrap {
  position: relative; /* anchor sticky cells */
  overflow: auto; /* both axes when needed */
  max-height: none;
  margin-top: 0.5rem;
  border: 1px solid var(--border-0);
  border-radius: var(--radius);
  background: var(--surface-1);
}
/* Cap viewport in-card to ~5 rows & ~5 cols; auto in fullscreen */
.matrix-wrap.limit-5 {
  /* 5 body rows + header row height */
  max-height: calc((5 + 1) * 2rem); /* 2.25rem seems to be a good heuristic at most screen sizes */
  /* 5 body cols + row-header col width (approx 140px each) */
  max-width: calc((5 + 1) * 6rem); /* Again, a decent heuristic */
}
/* --- Matrix fullscreen scaling --- */
.modal-scaled.help-modal {
  width: 96vw;
}
.matrix-scaled, 
.matrix-scaled * {
  font-weight: 400;
  font-size: calc(1rem * var(--matrix-scale));
  line-height: calc(1.1em * var(--matrix-scale));
}
.matrix-scaled td,
.matrix-scaled th {
  padding: calc(0.25em * var(--matrix-scale));
  line-height: calc(1.2em * var(--matrix-scale));
  font-size: inherit;
}

.partner-matrix,
.opponent-matrix {
  border-collapse: collapse;
  width: max-content; /* don’t stretch; let scrollbars appear */
  min-width: 100%;
  font-variant-numeric: tabular-nums;
}
/* Cells */
.partner-matrix th,
.partner-matrix td,
.opponent-matrix th,
.opponent-matrix td {
  border: 1px solid var(--border-1);
  padding: 0.3rem 0.5rem;
  text-align: center;
  white-space: nowrap;
}
/* Row header (first column) */
.partner-matrix th:first-child,
.opponent-matrix th:first-child {
  text-align: right;
}
/* Sticky top row and first column for both matrices */
.partner-matrix thead th,
.opponent-matrix thead th {
  position: sticky;
  top: 0;
  background: var(--surface-2);
  z-index: 2; /* above body cells */
}
.partner-matrix th:first-child,
.opponent-matrix th:first-child {
  position: sticky;
  left: 0;
  background: var(--surface-2);
  z-index: 3; /* above sticky top */
}
/* Softer outer-left border for first col + top row cells */
.partner-matrix th:first-child,
.partner-matrix td:first-child,
.opponent-matrix th:first-child,
.opponent-matrix td:first-child,
.partner-matrix tr:first-child th,
.partner-matrix tr:first-child td,
.opponent-matrix tr:first-child th,
.opponent-matrix tr:first-child td {
  border-left: 1px solid var(--border-0);
}
/* Utility classes (apply to both matrices) */
.matrix-rowhead {
  /* use on row <th> if needed */
  text-align: right;
  white-space: nowrap;
}
.matrix-diag {
  /* diagonal (self) cells */
  color: var(--text-muted);
  font-style: italic;
}
.matrix-blank {
  /* for intentional blanks */
  background: var(--surface-0);
}
.matrix-strong {
  /* highlight max */
  font-weight: 700;
  background: color-mix(in srgb, var(--accent) 10%, transparent);
}
.matrix-row-sum {
  /* rightmost totals col */
  font-weight: 600;
  background: var(--surface-0);
}
/* N/A cells in matrices (diagonal or overlapping pairs) */
.matrix-na {
  color: var(--text-muted);
  background: var(--surface-0);
  font-style: italic;
}

/* ==============================
   Help tab Flow (circles + arrows + panels)
   ============================== */
.flow {
  /* component vars (easy to tweak) */
  --flow-col-left: 10rem;
  --flow-gap-x: 1rem;
  --flow-gap-y: 2.75rem;

  --circle-size: 7.5rem;

  --arrow-offset-top: 7rem; /* where arrow sits under circle (top) */
  --arrow-stem-w: 2.25rem; /* rectangle width */
  --arrow-stem-h: 1.5rem; /* rectangle height */
  --arrow-head-w: 2rem; /* each side of triangle */
  --arrow-head-h: 1.75rem; /* triangle height */
  --arrow-color: var(--text);

  --panel-pad: 0.5rem 1rem;
  --panel-gap-above: 0.5rem;
  --panel-h: 7rem;

  --bullet-color: var(--accent);

  width: min(64rem, 100%);
  display: grid;
  grid-template-columns: var(--flow-col-left) 1fr;
  column-gap: var(--flow-gap-x);
  row-gap: var(--flow-gap-y);
  align-items: start;
  padding-top: 1rem;
  padding-bottom: 2rem;
}
/* left stack (circle + arrow) */
.left {
  position: relative;
  width: var(--flow-col-left);
  height: var(--circle-size); /* enough; arrow is positioned absolutely */
  display: flex;
  justify-content: center;
  align-items: flex-start;
  z-index: 2;
}
/* circle = active tab look using your tokens */
.circle {
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: var(--circle-size);
  height: var(--circle-size);
  border-radius: 50%;
  background: var(--surface-3);
  border: 0.0625rem solid var(--border-2);
  box-shadow: var(--ring);
  display: grid;
  place-items: center;
  z-index: 2;
}
.circle span {
  display: block;
  color: var(--text);
  font-weight: 600;
  text-align: center;
  line-height: 1.1;
  font-size: 1.25rem;
  padding: 0 0.625rem;
}
/* arrow (rectangle + wide triangle) */
.arrow {
  position: absolute;
  top: var(--arrow-offset-top);
  left: 50%;
  transform: translateX(-50%);
  width: calc(
    var(--arrow-head-w) * 2
  ); /* for click area; purely visual parts below */
  height: calc(var(--arrow-stem-h) + var(--arrow-head-h));
  z-index: 1;
}
.arrow::before,
.arrow::after {
  content: "";
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
}
/* rectangle */
.arrow::before {
  width: var(--arrow-stem-w);
  height: var(--arrow-stem-h);
  top: -0.25rem;
  background: var(--arrow-color);
  border-top-left-radius: 0.25rem;
  border-top-right-radius: 0.25rem;
}
/* wider triangle */
.arrow::after {
  top: calc(var(--arrow-stem-h) - 0.25rem);
  border-left: var(--arrow-head-w) solid transparent;
  border-right: var(--arrow-head-w) solid transparent;
  border-top: var(--arrow-head-h) solid var(--arrow-color);
}
.left.last .arrow {
  display: none;
}
/* panels – a panel is just a .card with the following overrides */
.panel {
  background: linear-gradient(180deg, var(--surface-2), var(--surface-1));
  padding: var(--panel-pad);
  margin-top: var(--panel-gap-above);
  height: var(--panel-h);
  z-index: 0;
}
/* panel content */
.panel p {
  margin: 0.125rem 0 0;
  font-size: 1rem;
}
.panel ul {
  margin: 0.125rem 0 0;
  padding-left: 1rem;
}
.panel li {
  list-style: none;
  position: relative;
  padding-left: 0.25rem;
  font-size: 1rem;
}
.panel li::before {
  content: "•";
  position: absolute;
  left: -1rem;
  top: -0.4rem;
  font-size: 1.5rem;
  color: var(--bullet-color);
}

/* =========================
        Responsive type scale
        ========================= */
html {
  font-size: 16px;
}
/* compact viewports (either narrow or short) */
@media (max-width: 640px), (max-height: 600px) {
  html {
    font-size: 12px;
  }
}
/* large displays */
@media (min-width: 1200px) and (min-height: 800px) {
  html {
    font-size: 18px;
  }
}
/* XL displays */
@media (min-width: 1600px) and (min-height: 1000px) {
  html {
    font-size: 20px;
  }
}

/* Print */
@media print {
  header,
  nav.tabs,
  .footerbar,
  .toolbar {
    display: none !important;
  }
  body {
    background: var(--print-bg);
    color: var(--print-text);
  }
  .card {
    box-shadow: none;
    border-color: var(--print-border);
  }
}
