/* Cue table and full cue card. Colours are tokens on the component root, so a host can
   override them; the table drawing's palette is its own in both schemes. */
.mb-cue,
.mb-return-target {
  --mb-table: light-dark(#dce7db, #677e6a);
  --mb-table-near: light-dark(#e5ece1, #5c7260);
  --mb-court-line: light-dark(#fafcf9, #d9e6db);
  --mb-table-edge: light-dark(#657f6d, #b5c8b8);
  --mb-table-grid: light-dark(#a9bdaa, #91a794);
  /* Dark: a soft green a step above the table, not a near-white that glares against it. */
  --mb-target: light-dark(#285d42, #a4c59b);
  --mb-target-any: color-mix(in oklab, var(--mb-target) 34%, var(--mb-table));
  --mb-arrow: light-dark(#285d42, #1f4a35);
  --mb-net-thread: light-dark(#4c635b80, #dce8df85);
  --mb-net-edge: light-dark(#536c5f, #d0ded2);
  --mb-floor: light-dark(#f8faf6, #223028);
  --mb-floor-line: light-dark(#d5dfd2, #47594d);
  --mb-floor-chosen: light-dark(#fcf4e8, #4a3a1c);
  --mb-floor-chosen-line: light-dark(#d7b47d, #b98e4c);
  --mb-shoe: #fbfaf6;
  --mb-shoe-sole: #d9a55a;
  --mb-shoe-edge: #8a6a3a;
  --mb-shoe-lace: #6b767c;
  --mb-shoe-accent: #2f6fd0;
  --mb-shoe-inside: #39424a;
  --mb-note-fill: light-dark(#fff6dc, #4a3a1c);
  --mb-note-ink: light-dark(#8f5a0c, #f0c987);
  --mb-fh-fill: light-dark(#f6ecd9, #4a3a1c);
  --mb-fh-ink: light-dark(#8f5a0c, #f0c987);
  --mb-bh-fill: light-dark(#e4ecfa, #1f3357);
  --mb-bh-ink: light-dark(#2c59a6, #a9c6f7);
  --mb-ink: var(--mb-color-ink);
  --mb-muted: var(--mb-color-muted);
  --mb-line: var(--mb-color-line);
  --mb-surface: var(--mb-color-panel);
  --mb-soft: var(--mb-color-panel-soft);
  --mb-firing: light-dark(#e8590c, #ffb057);
}
.mb-return-target {
  display: block;
  flex: none;
}
.mb-visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* FH and BH */
.mb-hand-tag {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  padding: 2px 6px;
  border: 1px solid transparent;
  border-radius: 6px;
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.3;
  letter-spacing: 0.02em;
}
.mb-hand-tag[data-size='lg'] {
  padding: 3px 9px;
  border-radius: 8px;
  font-size: 17px;
}
.mb-hand-tag[data-hand='FH'] {
  background: var(--mb-fh-fill);
  color: var(--mb-fh-ink);
}
.mb-hand-tag[data-hand='BH'] {
  background: var(--mb-bh-fill);
  color: var(--mb-bh-ink);
}
/* A ball that can come to either wing: both hands, each in its own colour. */
.mb-hand-tag[data-hand='either'] {
  gap: 0;
  padding: 0;
  overflow: hidden;
}
.mb-hand-tag[data-hand='either'] > [data-half] {
  padding: 2px 4px;
}
.mb-hand-tag[data-hand='either'][data-size='lg'] > [data-half] {
  padding: 3px 7px;
}
.mb-hand-tag [data-half='FH'] {
  background: var(--mb-fh-fill);
  color: var(--mb-fh-ink);
}
.mb-hand-tag [data-half='BH'] {
  background: var(--mb-bh-fill);
  color: var(--mb-bh-ink);
}
.mb-hand-choice {
  display: inline-flex;
  gap: 4px;
}
button.mb-hand-tag {
  min-width: 44px;
  min-height: 44px;
  cursor: pointer;
}
button.mb-hand-tag[aria-pressed='false'] {
  background: transparent;
  color: var(--mb-muted);
  border-color: var(--mb-line);
}
button.mb-hand-tag[aria-pressed='true'] {
  border-color: currentColor;
}
button.mb-hand-tag[data-hand='either'] {
  align-items: stretch;
  color: var(--mb-ink);
}
button.mb-hand-tag[data-hand='either'] > [data-half] {
  display: inline-flex;
  align-items: center;
}
button.mb-hand-tag[data-hand='either'][aria-pressed='false'] > [data-half] {
  background: transparent;
  color: var(--mb-muted);
}
button.mb-hand-tag:disabled {
  cursor: default;
  opacity: 0.6;
}

/* A robot serve */
.mb-cue-serve {
  display: inline-flex;
  align-items: center;
  flex: none;
  padding: 0 5px;
  border: 1px solid currentColor;
  border-radius: 999px;
  color: var(--mb-muted);
  font-size: 9px;
  font-weight: 700;
  line-height: 13px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.mb-cue-serve[data-size='lg'] {
  position: absolute;
  top: 0;
  left: 0;
  padding: 2px 9px;
  font-size: 12px;
  line-height: 16px;
}
.mb-cue-ball {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
}

/* The player's own serve, on the line before ball 1 */
.mb-cue-table tbody tr.mb-serve-row > *,
.mb-cue-table tbody tr.mb-serve-add-row > * {
  background: color-mix(in oklab, var(--mb-target) 7%, transparent);
}
.mb-cue-table tbody tr.mb-serve-row > :first-child,
.mb-cue-table tbody tr.mb-serve-add-row > :first-child {
  border-radius: 8px 0 0 8px;
  color: var(--mb-muted);
}
.mb-cue-table tbody tr.mb-serve-row > :last-child,
.mb-cue-table tbody tr.mb-serve-add-row > :last-child {
  border-radius: 0 8px 8px 0;
}
.mb-cue-table tbody tr.mb-serve-row[data-interactive]:hover > * {
  background: color-mix(in oklab, var(--mb-target) 12%, transparent);
}
.mb-cue-table tbody tr.mb-serve-row[data-selected] > * {
  background: color-mix(in oklab, var(--mb-ink) 9%, transparent);
}
.mb-serve-spin {
  font-size: 14px;
  font-weight: 700;
  line-height: 1.2;
}
.mb-serve-add {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  width: 100%;
  min-height: 44px;
  padding: 6px 4px;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  font-size: 14px;
  font-weight: 700;
  text-align: start;
  cursor: pointer;
}
.mb-serve-add small {
  color: var(--mb-muted);
  font-size: 12px;
  font-weight: 500;
}
.mb-serve-add::before {
  content: none;
}

/* Compact table */
.mb-cue-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  color: var(--mb-ink);
  font-size: 13px;
  line-height: 1.3;
}
.mb-cue-table th,
.mb-cue-table td {
  padding: 0 2px;
  text-align: center;
  vertical-align: middle;
}
.mb-cue-table [data-align='start'] {
  text-align: start;
  padding-inline-start: 4px;
}
/* The headings are plain words over a line: a filled bar would stack on an open first row. */
.mb-cue-table thead th,
.mb-cue-table thead td {
  height: 28px;
  border-bottom: 1px solid var(--mb-line);
  color: var(--mb-muted);
  font-size: 12px;
  font-weight: 600;
}
/* Room under the line, so an open or tinted first row does not touch it. */
.mb-cue-table tbody::before {
  content: '';
  display: table-row;
  height: 6px;
}
.mb-cue-table tr > :first-child {
  padding-inline-start: 3px;
}
.mb-cue-table tr > :last-child {
  padding-inline-end: 5px;
}
.mb-cue-table tbody th,
.mb-cue-table tbody td {
  height: 62px;
  border-top: 1px solid var(--mb-line);
}
.mb-cue-table tbody tr:first-child > * {
  border-top-color: transparent;
}
.mb-cue-table tbody th {
  width: 24px;
  font-size: 15px;
  font-weight: 700;
}
.mb-cue-table tbody tr[data-interactive] {
  cursor: pointer;
}
.mb-cue-table tbody tr[data-interactive]:hover > * {
  background: color-mix(in oklab, var(--mb-soft) 55%, transparent);
}
.mb-cue-table tbody tr[data-selected] > * {
  background: color-mix(in oklab, var(--mb-ink) 9%, transparent);
}
.mb-cue-table tbody tr[data-selected] > *,
.mb-cue-table tbody tr[data-selected] + tr > * {
  border-top-color: transparent;
}
.mb-cue-table tbody tr[data-selected] > :first-child {
  border-radius: 8px 0 0 8px;
}
.mb-cue-table tbody tr[data-selected] > :last-child {
  border-radius: 0 8px 8px 0;
}
.mb-cue-table tbody tr[data-firing] > th {
  box-shadow: inset 3px 0 0 var(--mb-firing);
}
.mb-cue-table figure {
  display: inline-block;
  vertical-align: middle;
}
/* A row that opens says so with a caret at its end, turned over while it is open. */
.mb-cue-table .mb-cue-open-mark {
  width: 28px;
  color: var(--mb-muted);
}
.mb-cue-open-mark svg {
  display: block;
  margin: auto;
  transition: transform 0.15s;
}
.mb-cue-table tr[data-selected] > .mb-cue-open-mark svg {
  transform: rotate(180deg);
}
.mb-cue-table tr[data-interactive]:hover > .mb-cue-open-mark {
  color: var(--mb-ink);
}
@media (prefers-reduced-motion: reduce) {
  .mb-cue-open-mark svg {
    transition: none;
  }
}
.mb-cue-open {
  min-width: 24px;
  min-height: 44px;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: inherit;
  font: inherit;
  cursor: pointer;
}
.mb-cue-stroke {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-width: 0;
}
.mb-cue-stroke-name {
  font-size: 14px;
  font-weight: 700;
  line-height: 1.15;
}
.mb-cue-return {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}
.mb-cue-return-label {
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}
/* "Down the line" is wider than the drawing above it. */
.mb-cue-return-label[data-direction] {
  max-width: 84px;
  line-height: 1.15;
  white-space: normal;
}
.mb-cue-position {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
}
.mb-cue-empty {
  color: var(--mb-muted);
}
.mb-cue-note-hint {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  width: 20px;
  height: 44px;
  margin: 0 -3px;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: transparent;
  cursor: help;
}
.mb-cue-note-hint:hover::after,
.mb-cue-note-hint:focus::after {
  content: attr(data-note);
  position: absolute;
  z-index: 3;
  left: 50%;
  bottom: calc(100% - 6px);
  transform: translateX(-50%);
  width: max-content;
  max-width: 220px;
  padding: 6px 9px;
  border-radius: 7px;
  background: var(--mb-ink);
  color: var(--mb-surface);
  font-size: 12px;
  font-weight: 500;
  line-height: 1.35;
  text-align: start;
  white-space: normal;
  pointer-events: none;
}

/* Full card */
.mb-cue-editor {
  /* Its own width decides whether the return buttons fit beside the table. */
  container-type: inline-size;
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
  max-width: calc(var(--mb-cue-width, 320px) + 34px);
  box-sizing: border-box;
  padding: 16px;
  border: 1px solid var(--mb-line);
  border-radius: 14px;
  background: var(--mb-surface);
  color: var(--mb-ink);
  font-size: 14px;
  line-height: 1.4;
}
.mb-cue-editor-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 10px;
  min-width: 0;
}
.mb-cue-number {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  width: 30px;
  height: 30px;
  border: 1.5px solid currentColor;
  border-radius: 50%;
  font-size: 15px;
  font-weight: 700;
}
/* Two classes, so a page's own heading rules do not resize it. */
.mb-cue .mb-cue-editor-stroke {
  margin: 0;
  min-width: 0;
  font-size: 26px;
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: -0.02em;
}
.mb-stroke-field {
  position: relative;
  display: flex;
  flex: 1 1 170px;
  min-width: 0;
}
.mb-stroke-field svg {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--mb-muted);
  pointer-events: none;
}
.mb-stroke-select {
  appearance: none;
  -webkit-appearance: none;
  flex: 1;
  width: 100%;
  min-width: 0;
  min-height: 44px;
  padding: 4px 34px 4px 10px;
  border: 1px solid var(--mb-line);
  border-radius: 8px;
  background: var(--mb-surface);
  color: inherit;
  font: inherit;
  font-size: 20px;
  font-weight: 700;
}
.mb-cue-scene {
  position: relative;
  align-self: center;
  max-width: 100%;
  line-height: 0;
}
.mb-cue-scene svg {
  display: block;
  max-width: 100%;
  height: auto;
}
/* The same table at the size of a row. */
.mb-return-scene {
  display: inline-block;
  align-self: auto;
}
.mb-cue-scene-ball {
  position: absolute;
  transform: translate(-50%, -50%);
  pointer-events: none;
}
.mb-return-zone[role='button'],
.mb-floor-zone[role='button'] {
  cursor: pointer;
  outline: none;
}
.mb-return-zone[role='button']:hover:not([data-selected='true']) {
  fill: color-mix(in oklab, var(--mb-table) 70%, var(--mb-target));
}
.mb-floor-zone[role='button']:hover:not([data-selected='true']) {
  fill: color-mix(in oklab, var(--mb-floor) 40%, var(--mb-floor-chosen));
}
.mb-return-zone[role='button']:focus-visible,
.mb-floor-zone[role='button']:focus-visible {
  stroke: var(--mb-color-focus);
  stroke-width: 1.4;
}
.mb-return-zone[aria-disabled='true'],
.mb-floor-zone[aria-disabled='true'] {
  cursor: default;
}
.mb-cue-facts {
  display: grid;
  /* Equal columns: Ball and Position stay put whatever the return is called. */
  grid-template-columns: repeat(3, minmax(0, 1fr));
  align-items: start;
  gap: 8px;
  margin: 0;
  text-align: center;
}
.mb-cue-facts > div {
  display: flex;
  flex-direction: column;
  align-items: center;
}
.mb-cue-facts dt {
  color: var(--mb-muted);
  font-size: 12px;
}
.mb-cue-facts dd {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  white-space: nowrap;
}
.mb-cue-facts dd[data-strong] {
  font-weight: 700;
}
.mb-cue-facts[data-columns='2'] {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
.mb-cue-facts[data-columns='2'] dd {
  white-space: normal;
}
.mb-cue-facts dd[data-empty] {
  color: var(--mb-muted);
  font-weight: 500;
}
/* The table, with the returns that are not a square: beside it where the card is wide
   enough, in a row under it otherwise. */
.mb-cue-editor[data-editable] {
  max-width: calc(var(--mb-cue-width, 320px) + 34px + 140px);
}
.mb-cue-stage {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}
.mb-cue-return-choice {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
  width: 100%;
}
.mb-cue-return-title,
.mb-cue-return-hint {
  grid-column: 1 / -1;
  color: var(--mb-muted);
  font-size: 12px;
  line-height: 1.3;
}
.mb-cue-return-title {
  font-weight: 600;
}
.mb-cue-position-title {
  margin-top: 10px;
}
/* The end of the editor's header: a quiet bin that takes the cue or the serve away, then a
   filled check that closes the editor with its changes. */
.mb-cue-editor-actions {
  display: inline-flex;
  flex: none;
  gap: 8px;
  margin-left: auto;
}
.mb-cue-done {
  display: inline-grid;
  place-items: center;
  flex: none;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 1px solid var(--mb-color-accent);
  border-radius: 8px;
  background: var(--mb-color-accent);
  color: var(--mb-color-on-accent);
  cursor: pointer;
}
.mb-cue-done:hover:not(:disabled) {
  background: var(--mb-color-accent-hover);
}
.mb-cue-done:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
.mb-cue-remove {
  display: inline-grid;
  place-items: center;
  flex: none;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 1px solid var(--mb-color-line);
  border-radius: 8px;
  background: none;
  color: var(--mb-color-danger);
  cursor: pointer;
}
.mb-cue-remove:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
.mb-cue-return-option {
  min-width: 0;
  min-height: 44px;
  padding: 4px 6px;
  border: 1px solid var(--mb-line);
  border-radius: 8px;
  background: var(--mb-surface);
  color: inherit;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.15;
  cursor: pointer;
}
/* The serve in full: spins beside the table where there is room, above it otherwise. */
.mb-serve-editor,
.mb-serve-editor[data-editable] {
  max-width: 494px;
}
.mb-serve-stage {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.mb-serve-spins {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
}
.mb-serve-spins > .mb-cue-return-title {
  grid-column: 1 / -1;
}
.mb-serve-landing {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}
.mb-serve-table {
  display: flex;
  justify-content: center;
  /* Room for the depth names, which hang off the drawing's left edge. */
  padding-left: 62px;
}
.mb-serve-drawing {
  min-width: 0;
  max-width: 100%;
}
.mb-serve-drawing svg {
  display: block;
  max-width: 100%;
  height: auto;
}
/* The depth of each row of squares, beside the row. */
.mb-serve-court {
  position: relative;
}
.mb-serve-depth {
  position: absolute;
  right: 100%;
  margin-right: 6px;
  transform: translateY(-50%);
  color: var(--mb-muted);
  font-size: 12px;
  line-height: 1;
  white-space: nowrap;
}
.mb-serve-sides {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  margin-top: 2px;
  color: var(--mb-muted);
  font-size: 12px;
  text-align: center;
}
@container (min-width: 430px) {
  .mb-serve-stage {
    flex-direction: row;
    align-items: flex-start;
    gap: 20px;
  }
  .mb-serve-spins {
    display: flex;
    flex: 0 0 132px;
    flex-direction: column;
  }
  .mb-serve-landing {
    flex: 1 1 0;
  }
}
@container (min-width: 356px) {
  .mb-cue-stage {
    flex-direction: row;
    gap: 14px;
  }
  .mb-cue-stage > .mb-cue-scene {
    flex: 1 1 0;
    min-width: 0;
    max-width: var(--mb-cue-width, 320px);
  }
  .mb-cue-return-choice {
    display: flex;
    flex: 0 0 124px;
    flex-direction: column;
    width: auto;
  }
  .mb-cue-return-option {
    padding: 4px 12px;
    font-size: 14px;
    text-align: start;
  }
}
.mb-cue-return-option:hover:not(:disabled, [aria-pressed='true']) {
  background: var(--mb-soft);
}
.mb-cue-return-option[aria-pressed='true'] {
  border-color: var(--mb-target);
  background: var(--mb-target);
  color: var(--mb-surface);
}
.mb-cue-return-option:disabled {
  cursor: default;
  opacity: 0.6;
}
.mb-cue-note {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--mb-note-fill);
}
/* While editing, the note is a small plain field: it is rarely used, so it takes one line
   and no panel of its own. */
.mb-cue-note[data-editing] {
  flex-direction: row;
  align-items: center;
  gap: 8px;
  padding: 0;
  background: none;
}
.mb-cue-note[data-editing] .mb-cue-note-title {
  flex: none;
  color: var(--mb-muted);
  font-weight: 500;
}
.mb-cue-note[data-editing] textarea {
  min-height: 36px;
  border-color: var(--mb-color-line-strong);
  font-size: 16px;
}
.mb-cue-note-title {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--mb-note-ink);
  font-size: 12px;
  font-weight: 600;
}
.mb-cue-note p {
  margin: 0;
  font-size: 15px;
}
.mb-cue-note textarea {
  width: 100%;
  padding: 6px 8px;
  border: 1px solid var(--mb-floor-chosen-line);
  border-radius: 6px;
  background: var(--mb-surface);
  color: inherit;
  font: inherit;
  font-size: 16px;
  resize: vertical;
}
.mb-cue button:focus-visible,
.mb-cue select:focus-visible,
.mb-cue textarea:focus-visible {
  outline: 2px solid var(--mb-color-focus);
  outline-offset: 2px;
}

/* A spin pad outside the sequence editor has no `.bf-composer` to take its colours from. */
.mb-spin-pad:not(.bf-composer *) {
  --bf-canvas: var(--mb-color-panel);
  --bf-line: var(--mb-color-line);
  --bf-ink: var(--mb-color-ink);
  --bf-muted: var(--mb-color-muted);
  --bf-focus: var(--mb-color-focus);
  --bs-top: light-dark(#368b61, #419870);
  --bs-back: light-dark(#d75e69, #dc6676);
  --bs-side: light-dark(#9654d3, #b779ed);
}
.mb-spin-pad {
  width: 100%;
  font-size: 14px;
  line-height: 1.4;
}
.mb-spin-pad,
.mb-spin-pad * {
  box-sizing: border-box;
}

/* Ball surfaces follow the host; spin hue stays independent of the brand palette. */
.mb-spin-ball {
  margin: 0;
  line-height: 0;
  flex-shrink: 0;
  --bf-canvas: var(--mb-color-panel);
  --bf-line: var(--mb-color-line);
  --bf-ink: var(--mb-color-ink);
  --bs-top: light-dark(#368b61, #419870);
  --bs-back: light-dark(#d75e69, #dc6676);
  --bs-side: light-dark(#9654d3, #b779ed);
}

/* What a selected row opens sits directly under it, inside the table. */
.mb-cue-table .mb-cue-open-row > td {
  padding: 4px 0 16px;
  text-align: left;
}
/* With the actions in the header, the stroke takes the line under it: its name is never cut. */
.mb-cue-editor-head:has(.mb-cue-editor-actions) .mb-stroke-field {
  order: 1;
  flex: 1 1 100%;
}
