/*
 * Board game score calculators (/tools/wingspan-score-calculator, /tools/7-wonders-score-calculator).
 * Shared score grid: categories are rows and players are columns. Under 900px only the active
 * player's column is shown and tabs switch between players, so the page never scrolls sideways.
 * Builds on the "Free tools" block in site.css (.nk-input, .nk-table, .nk-text-btn).
 */

/* ---- Steppers: big −/+ buttons around a numeric input ---- */
.bg-step {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.bg-step__btn {
  flex: none;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 1.5px solid #ddd5c8;
  border-radius: 50%;
  background: #fffdf9;
  color: #3b302b;
  font-family: inherit;
  font-size: 22px;
  font-weight: 500;
  line-height: 1;
  cursor: pointer;
  touch-action: manipulation;
  display: flex;
  align-items: center;
  justify-content: center;
  transition:
    background-color 0.15s ease,
    border-color 0.15s ease;
}
.bg-step__btn:hover {
  background: #f2ebe0;
  border-color: #c8bbae;
}
.bg-step__btn:active {
  background: #ede5d8;
}
.bg-step__btn:focus-visible,
.bg-tab:focus-visible,
.bg-toggle input:focus-visible + span {
  outline: 2px solid #8b5e3c;
  outline-offset: 2px;
}
.bg-step__num {
  width: 100%;
  max-width: 84px;
  height: 44px;
  padding: 0 6px;
  text-align: center;
  font-size: 18px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.bg-step--count .bg-step__num {
  max-width: 64px;
}
.bg-count {
  min-width: 40px;
  text-align: center;
  font-size: 24px;
  font-weight: 800;
  color: #2e2018;
  font-variant-numeric: tabular-nums;
}

/* ---- Score grid ---- */
.bg-grid-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
}
.bg-grid {
  width: 100%;
  border-collapse: collapse;
  font-variant-numeric: tabular-nums;
}
.bg-grid th,
.bg-grid td {
  padding: 10px 6px;
  border-bottom: 1px solid #e5ddd2;
  vertical-align: middle;
}
.bg-grid thead th {
  padding-top: 0;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #8b5e3c;
  text-align: left;
}
.bg-grid tbody th {
  text-align: left;
  font-weight: 400;
  padding-left: 0;
  width: 40%;
}
.bg-grid td {
  text-align: center;
  min-width: 120px;
}
.bg-cat {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}
.bg-cat__swatch {
  flex: none;
  width: 10px;
  height: 10px;
  margin-top: 6px;
  border-radius: 50%;
}
.bg-cat__label {
  display: block;
  font-size: 15px;
  font-weight: 600;
  line-height: 1.35;
  color: #2e2018;
}
.bg-cat__hint {
  display: block;
  margin-top: 2px;
  font-size: 13px;
  line-height: 1.4;
  color: #7a6a5c;
}
.bg-name {
  height: 44px;
  text-align: center;
  font-size: 16px;
  font-weight: 700;
}
.bg-note {
  display: block;
  min-height: 16px;
  margin-top: 4px;
  font-size: 12px;
  font-weight: 600;
  color: #8b5e3c;
}
.bg-grid tr.bg-group > th {
  padding: 18px 0 6px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #8b5e3c;
}
.bg-grid tr.bg-sub > th {
  padding-left: 20px;
}
.bg-computed {
  font-size: 20px;
  font-weight: 800;
  color: #2e2018;
}
.bg-grid tr.bg-sci-total > * {
  background: #f7f1e8;
}
.bg-grid tr.bg-tiebreak > * {
  background: #f7f1e8;
}
.bg-grid tr.bg-tiebreak > th,
.bg-grid tr.bg-sci-total > th {
  padding-left: 12px;
  border-radius: 14px 0 0 14px;
}
.bg-grid tr.bg-tiebreak > td:last-child,
.bg-grid tr.bg-sci-total > td:last-child {
  border-radius: 0 14px 14px 0;
}
.bg-grid tfoot th,
.bg-grid tfoot td {
  border-bottom: 0;
  padding-top: 16px;
}
.bg-grid tfoot th {
  text-align: left;
  padding-left: 0;
  font-size: 15px;
  font-weight: 700;
  color: #2e2018;
}
.bg-total {
  font-size: 30px;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: #2e2018;
}
.bg-grid td[data-lead] .bg-total {
  background: #ffb900;
  border-radius: 999px;
  padding: 0 0.3em;
}

/* ---- Player tabs and prev/next (mobile only) ---- */
.bg-tabs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
  padding: 2px 2px 6px;
  margin: 0 -2px;
  scrollbar-width: thin;
}
.bg-tab {
  flex: none;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  min-height: 52px;
  min-width: 84px;
  max-width: 150px;
  padding: 8px 16px;
  border: 1px solid #e5ddd2;
  border-radius: 18px;
  background: transparent;
  font-family: inherit;
  text-align: left;
  cursor: pointer;
  color: #7a6a5c;
}
.bg-tab[aria-pressed='true'] {
  background: #fffdf9;
  border-color: rgba(59, 48, 43, 0.28);
  color: #2e2018;
  box-shadow: 0 0 0 1px rgba(59, 48, 43, 0.06);
}
.bg-tab__name {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 14px;
  font-weight: 600;
}
.bg-tab__total {
  font-size: 18px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  color: #2e2018;
}
.bg-mnav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.bg-mnav__pos {
  font-size: 14px;
  color: #7a6a5c;
}

@media (max-width: 899px) {
  .bg-grid [data-col] {
    display: none;
  }
  .bg-grid[data-active='0'] [data-col='0'],
  .bg-grid[data-active='1'] [data-col='1'],
  .bg-grid[data-active='2'] [data-col='2'],
  .bg-grid[data-active='3'] [data-col='3'],
  .bg-grid[data-active='4'] [data-col='4'],
  .bg-grid[data-active='5'] [data-col='5'],
  .bg-grid[data-active='6'] [data-col='6'] {
    display: table-cell;
  }
  .bg-grid td {
    min-width: 0;
    width: 60%;
  }
  .bg-grid thead th.bg-head-cat {
    vertical-align: middle;
  }
}
@media (max-width: 380px) {
  .bg-step__btn {
    width: 40px;
    height: 40px;
  }
  .bg-step {
    gap: 4px;
  }
}
@media (min-width: 900px) {
  .bg-tabs,
  .bg-mnav {
    display: none;
  }
  .bg-grid tbody th {
    width: auto;
    min-width: 190px;
  }
  .bg-grid td {
    padding: 10px 4px;
  }
  .bg-step {
    gap: 4px;
  }
  .bg-step__btn {
    width: 34px;
    height: 34px;
    font-size: 19px;
  }
  .bg-step__num {
    height: 40px;
    max-width: 64px;
    font-size: 17px;
  }
}

/* ---- Setup: expansion toggles ---- */
.bg-toggle {
  position: relative;
  display: inline-flex;
  cursor: pointer;
}
.bg-toggle input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}
.bg-toggle span {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 16px;
  border: 1px solid #e5ddd2;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 500;
  color: #7a6a5c;
  transition:
    background-color 0.15s ease,
    color 0.15s ease;
}
.bg-toggle span::before {
  content: '';
  width: 16px;
  height: 16px;
  border-radius: 5px;
  border: 1.5px solid #c8bbae;
  background: #fffdf9;
  flex: none;
}
.bg-toggle input:checked + span {
  background: #fffdf9;
  border-color: rgba(59, 48, 43, 0.28);
  color: #2e2018;
}
.bg-toggle input:checked + span::before {
  background: #8b5e3c;
  border-color: #8b5e3c;
  box-shadow: inset 0 0 0 3px #fffdf9;
}

/* ---- Ranking ---- */
.bg-rank {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.bg-rank li {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-radius: 16px;
  background: #f7f1e8;
}
.bg-rank li[data-winner] {
  background: #fbf3df;
  box-shadow: inset 0 0 0 1.5px #ffb900;
}
.bg-rank__pos {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: #fffdf9;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 700;
  color: #8b5e3c;
}
.bg-rank li[data-winner] .bg-rank__pos {
  background: #ffb900;
  color: #2e2018;
}
.bg-rank__name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 16px;
  font-weight: 600;
  color: #2e2018;
}
.bg-rank__tb {
  display: block;
  font-size: 12px;
  font-weight: 400;
  color: #7a6a5c;
}
.bg-rank__pts {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: #2e2018;
  font-variant-numeric: tabular-nums;
}

@media (prefers-reduced-motion: reduce) {
  .bg-step__btn,
  .bg-toggle span {
    transition: none;
  }
}
.bg-tabs { scroll-margin-top: 16px; }
.bg-mnav .nk-text-btn, .bg-mnav__pos { white-space: nowrap; }
.bg-mnav .nk-text-btn:disabled { opacity: 0.35; cursor: default; text-decoration: none; }
.bg-step__btn:disabled { opacity: 0.4; cursor: default; }
.bg-group .bg-cat__swatch { margin-top: 2px; }
@media (max-width: 480px) {
  .bg-chart th, .bg-chart td { padding: 10px 6px; }
  .bg-chart thead th { letter-spacing: 0.02em; font-size: 11px; }
}
