/* ---- Palette (from the reference): light grey page, white panels, blue primary, orange for the live/active card,
   green and red only for scoring meaning. Swap --acc / --live to retheme. ---- */
:root,
[data-bs-theme="light"] {
  --bs-body-bg: #eceef3;
  --bs-body-color: #1c2030;
  --bs-secondary-color: #5f6678;
  --bs-tertiary-bg: #f3f4f8;
  --bs-secondary-bg: #e3e6ee;
  --bs-border-color: #dce0e8;
  --bs-link-color: #3f51d8;
  --bs-link-hover-color: #2f3fb8;
  --bs-focus-ring-color: rgba(63, 81, 216, 0.25);
  --bs-border-radius: 0.5rem;
  --bs-border-radius-sm: 0.375rem;
  --bs-border-radius-lg: 0.75rem;
  --bg: #eceef3;
  --card: #fff;
  --ink: #1c2030;
  --mut: #5f6678;
  --line: #dce0e8;
  --line2: #c9cfda;
  --acc: #3f51d8;
  --btn: #3f51d8;
  --sel-bg: #1c2030;
  --sel-fg: #fff;
  --live: #d2401d;
  --bl: #7c87a0;
  --tr: #c62f2f;
  --db: #14804c;
  --num: var(--bs-body-font-family);
}
.btn-primary {
  --bs-btn-color: #fff;
  --bs-btn-bg: var(--btn);
  --bs-btn-border-color: var(--btn);
  --bs-btn-hover-color: #fff;
  --bs-btn-hover-bg: #3445bc;
  --bs-btn-hover-border-color: #3445bc;
  --bs-btn-active-color: #fff;
  --bs-btn-active-bg: #2b3aa0;
  --bs-btn-active-border-color: #2b3aa0;
  --bs-btn-focus-shadow-rgb: 63, 81, 216;
  font-weight: 600;
}
.btn-outline-secondary {
  --bs-btn-color: var(--ink);
  --bs-btn-bg: var(--card);
  --bs-btn-border-color: var(--line2);
  --bs-btn-hover-color: var(--ink);
  --bs-btn-hover-bg: var(--card);
  --bs-btn-hover-border-color: var(--mut);
  --bs-btn-active-color: var(--ink);
  --bs-btn-active-bg: var(--card);
  --bs-btn-active-border-color: var(--mut);
}
.navbar {
  padding: 0.9rem 0;
}
.navbar-brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 1.25rem;
  font-style: italic;
  font-weight: 800;
  letter-spacing: 0.02em;
}
.navbar-brand img {
  width: 2.75rem;
  height: 2.75rem;
  flex: none;
}
.nav .nav-link {
  color: var(--mut);
  background: none;
  border: 0;
  font-weight: 500;
  padding: 0.4rem 0.9rem;
}
.nav .nav-link:hover {
  color: var(--ink);
}
.nav .nav-link.active {
  color: var(--ink);
  font-weight: 700;
}
.d-flex > .form-control {
  width: auto;
  flex: 1 1 11.25rem;
}
.d-flex > .form-select {
  width: auto;
  flex: 1 1 11.25rem;
  max-width: 100%;
}
.d-flex > #vr {
  flex: 0 0 auto;
}
#cm {
  flex: 0 0 auto;
}
.bdg {
  --bs-badge-color: var(--ink);
  background: transparent;
  border: 1px solid var(--line2);
  font-weight: 600;
}
.alert {
  position: sticky;
  top: 0;
  z-index: 5;
  font-weight: 600;
}

/* ---- layout ---- */
.shell {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 1rem;
  padding: 1.5rem;
  margin-bottom: 2rem;
}
.hd {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  margin: 0 0 0.875rem;
}
h4 {
  margin: 0 0 0.625rem;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--ink);
}
body {
  font-variant-numeric: tabular-nums;
}
.mut {
  color: var(--mut);
}
.sec {
  border-top: 1px solid var(--line);
  padding-top: 1rem;
  padding-bottom: 1rem;
}
.shell > .sec:first-child,
.col-lg-5 > .sec:first-child,
.panel > .sec:first-child {
  border-top: 0;
  padding-top: 0;
}
.hint {
  margin: 0.625rem 0;
  color: var(--mut);
}
.hint b {
  color: var(--ink);
}
.panel {
  background: var(--bs-tertiary-bg);
  border-radius: var(--bs-border-radius-lg);
  padding: 1.125rem 1.25rem;
}
.lv {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  margin-bottom: 0.75rem;
  flex-wrap: wrap;
  row-gap: 0.4rem;
}
.bd {
  max-width: 32.5rem;
  margin: 0.75rem auto 0;
}
.live {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 2px 0.625rem;
  border-radius: 62.4375rem;
  background: var(--bs-secondary-bg);
  color: var(--ink);
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  line-height: 1.7;
}
.live:before {
  content: "";
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 50%;
  background: var(--tr);
}
.turn {
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
  flex-wrap: wrap;
  padding: 2px 0 2px 0.875rem;
  margin-bottom: 0.375rem;
  border-left: 0.25rem solid var(--acc);
}
.turn small {
  font-size: 0.8125rem;
  color: var(--mut);
}
.turn b {
  font-size: clamp(1.625rem, 9vw, 2.5rem);
  line-height: 1;
  font-weight: 800;
  text-transform: uppercase;
  overflow-wrap: anywhere;
  min-width: 0;
}
.gt {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(6.875rem, 1fr));
  gap: 0.625rem;
  margin-bottom: 0.75rem;
}
.gt .btn {
  padding: 1rem 0.5rem;
  font-weight: 600;
  border-radius: var(--bs-border-radius-lg);
}
.pills .btn {
  border: 0;
  background: transparent;
  color: var(--mut);
  font-weight: 500;
}
.pills .btn:hover {
  color: var(--ink);
  background: var(--bs-secondary-bg);
}
.pills .btn-primary,
.pills .btn-primary:hover {
  background: var(--bs-secondary-bg);
  color: var(--ink);
  font-weight: 700;
}

/* ---- match cards (the live match list) ---- */
.pl {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.375rem 1rem;
  padding: 0.875rem 1rem 0;
  margin-bottom: 0.625rem;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--bs-border-radius-lg);
  overflow: hidden;
  color: var(--ink);
}
.pl.cur {
  background: var(--live);
  border-color: var(--live);
  color: #fff;
}
.pl h3 {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
  display: flex;
  gap: 0.375rem 0.625rem;
  align-items: center;
  flex-wrap: wrap;
  min-width: 0;
}
.mem {
  display: inline-flex;
  gap: 0.625rem;
  font-size: 0.8125rem;
  font-weight: 400;
  color: var(--mut);
}
.mem .now {
  color: var(--ink);
  font-weight: 700;
  border-bottom: 2px solid var(--acc);
}
.slots {
  grid-column: 1/-1;
  display: flex;
  gap: 0.375rem;
  align-items: center;
  min-width: 0;
}
.dt {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 1 3.5rem;
  width: 3.5rem;
  min-width: 0;
  height: 2.5rem;
  padding: 0 0.25rem;
  overflow: hidden;
  white-space: nowrap;
  border-radius: 0.375rem;
  border: 1px solid var(--c, var(--line2));
  background: color-mix(in srgb, var(--c, var(--line2)) 14%, transparent);
  font-size: 1.125rem;
  font-weight: 600;
  line-height: 1;
  color: var(--ink);
}
.dt.e {
  border-style: dashed;
  background: none;
  color: var(--mut);
}
.dt.nx {
  border-style: solid;
  border-color: var(--acc);
}
.vt {
  font-size: 1.625rem;
  font-weight: 700;
  line-height: 1;
  margin-left: 0.5rem;
  min-width: 2.8ch;
  white-space: nowrap;
}
.rm {
  grid-row: 1;
  grid-column: 2;
  text-align: right;
  align-self: start;
  min-width: 0;
}
.rem {
  font-size: clamp(2.75rem, 12vw, 3.75rem);
  font-weight: 700;
  line-height: 0.95;
  letter-spacing: -0.02em;
  white-space: nowrap;
}
.bar {
  height: 3px;
  background: var(--line);
  margin-top: 0.5rem;
}
.bar i {
  display: block;
  height: 100%;
  background: var(--acc);
}
.fin {
  grid-column: 1/-1;
  display: flex;
  gap: 0.5rem;
  align-items: center;
  padding: 0.5rem 0.625rem;
  border-radius: 0.375rem;
  background: var(--bs-tertiary-bg);
}
.st {
  grid-column: 1/-1;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  border-top: 1px solid var(--line);
  margin: 0.375rem -1rem 0;
}
.st > div {
  padding: 0.5rem 1rem;
}
.st > div + div {
  border-left: 1px solid var(--line);
}
.st small {
  display: block;
  color: var(--mut);
  font-size: 0.75rem;
}
.st b {
  font-size: 1.1875rem;
  font-weight: 700;
  line-height: 1.1;
}
.dl {
  font-size: 0.75rem;
  font-weight: 600;
  margin-left: 0.3125rem;
}
.up {
  color: var(--db);
}
.dn {
  color: var(--tr);
}
.pl.cur .bdg,
.pl.cur .live {
  color: #fff;
  border-color: rgba(255, 255, 255, 0.6);
  background: rgba(255, 255, 255, 0.18);
}
.pl.cur .mem,
.pl.cur .st small,
.pl.cur .fin .mut,
.pl.cur .mut {
  color: #fff;
}
.pl.cur .mem .now {
  color: #fff;
  border-bottom-color: #fff;
}
.pl.cur .dt {
  --c: rgba(255, 255, 255, 0.8);
  color: #fff;
}
.pl.cur .dt.e {
  background: none;
  color: #fff;
}
.pl.cur .dt.nx {
  border-color: #fff;
  background: rgba(255, 255, 255, 0.28);
}
.pl.cur .fin {
  background: rgba(0, 0, 0, 0.2);
}
.pl.cur .st,
.pl.cur .st > div + div {
  border-color: rgba(255, 255, 255, 0.3);
}
.pl.cur .bar {
  background: rgba(255, 255, 255, 0.3);
}
.pl.cur .bar i {
  background: #fff;
}
.pl.cur .dl,
.pl.cur .dn,
.pl.cur .up {
  color: #fff;
}

/* ---- tables, lists, lobby, stats ---- */
td,
th {
  text-align: right;
}
td:first-child,
th:first-child {
  text-align: left;
}
th {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--mut);
}
.hl td,
.hl th {
  text-align: left;
}
.hl td:last-child,
.hl th:last-child {
  text-align: right;
}
.mmt td,
.mmt th {
  text-align: center;
  font-size: 1.25rem;
  font-weight: 600;
}
.mmt td:first-child,
.mmt th:first-child {
  text-align: left;
}
.mmt .cl {
  color: var(--db);
}
.mmt .cur {
  background: color-mix(in srgb, var(--live) 9%, transparent);
}
.hist td:nth-child(2) {
  text-align: left;
}
.seg {
  cursor: pointer;
  stroke: #111;
  stroke-width: 1;
}
.seg:hover {
  filter: brightness(1.25);
}
.tm {
  border: 1px solid var(--line2);
  border-radius: var(--bs-border-radius);
  padding: 0.625rem 0.75rem;
  margin-bottom: 0.5rem;
  background: var(--card);
}
.tm.act {
  border-color: var(--acc);
}
.mm {
  margin: 0.5rem 0 0;
  padding-left: 1.375rem;
}
.mm li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 3px 0;
}
.tiles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(7.375rem, 1fr));
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  margin: 0.25rem 0 1rem;
}
.tile {
  padding: 0.625rem 0.875rem;
  border-left: 1px solid var(--line);
}
.tile:first-child {
  border-left: 0;
  padding-left: 0;
}
.tile small {
  display: block;
  color: var(--mut);
  font-size: 0.75rem;
}
.tile b {
  font-size: 1.875rem;
  font-weight: 700;
  line-height: 1.15;
}
.tile .dl {
  display: block;
  margin: 0;
}
.cv {
  height: 15rem;
  position: relative;
}
.g {
  display: grid;
  grid-template-columns: minmax(4rem, 6.875rem) 1fr 5.625rem;
  gap: 0.625rem;
  align-items: center;
  margin: 0.5625rem 0;
}
.g span {
  font-size: 1rem;
  font-weight: 600;
}
.g small {
  display: block;
  font-size: 0.75rem;
  font-weight: 400;
  color: var(--mut);
}
.gb {
  height: 0.375rem;
  background: var(--line);
  border-radius: 3px;
  overflow: hidden;
}
.gb i {
  display: block;
  height: 100%;
}
.g b {
  font-size: 0.875rem;
  font-weight: 600;
  text-align: right;
}
@media (max-width: 576px) {
  .shell {
    padding: 1rem;
    border-radius: 0.75rem;
  }
  .st {
    grid-template-columns: repeat(2, 1fr);
  }
  .st > div:nth-child(n + 3) {
    border-top: 1px solid var(--line);
  }
  .st > div:nth-child(3) {
    border-left: 0;
  }
  .panel {
    padding: 0.875rem;
  }
  .hd {
    font-size: 1.3rem;
  }
}
.choose {
  background: var(--card);
  border: 1px solid var(--acc);
  border-radius: var(--bs-border-radius);
  padding: 0.625rem 0.75rem;
  margin: 0.5rem 0;
}

/* ---- dark theme: near-black, cool greys; the board and the orange live card keep their colours ---- */
[data-bs-theme="dark"] {
  --bs-body-bg: #0f1114;
  --bs-body-color: #e7eaee;
  --bs-secondary-color: #98a1ad;
  --bs-tertiary-bg: #1d2128;
  --bs-secondary-bg: #262b33;
  --bs-border-color: #2a2f36;
  --bs-link-color: #8e9bff;
  --bs-link-hover-color: #b0baff;
  --bs-focus-ring-color: rgba(142, 155, 255, 0.35);
  --bg: #0f1114;
  --card: #171a1f;
  --ink: #e7eaee;
  --mut: #98a1ad;
  --line: #2a2f36;
  --line2: #3a414a;
  --acc: #8e9bff;
  --btn: #4a5ce8;
  --sel-bg: #e7eaee;
  --sel-fg: #0f1114;
  --bl: #8a94a8;
  --tr: #f07a6b;
  --db: #47c08a;
}
/* ---- total entry keypad ---- */
.kpw {
  max-width: 26rem;
  margin: 0.75rem auto 0;
}
.kd {
  font-size: 3.5rem;
  font-weight: 700;
  line-height: 1;
  text-align: center;
  padding: 0.5rem;
  margin-bottom: 0.6rem;
  min-height: 4.5rem;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--bs-border-radius-lg);
}
.kg {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
}
.kg .btn {
  min-height: 3.6rem;
  font-size: 1.4rem;
  font-weight: 600;
}
.kq {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.6rem;
  justify-content: center;
}
.seg.hit {
  stroke: #fff;
  stroke-width: 4;
  filter: brightness(1.5);
}
.heat {
  display: block;
  width: 100%;
  max-width: 22rem;
  margin: 0 auto;
}
@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
    animation: none !important;
  }
}

/* ---- scale: everything is in rem, so a TV or large monitor simply raises the root size ---- */
html {
  font-size: 16px;
}
@media (min-width: 1600px) {
  html {
    font-size: 18px;
  }
}
@media (min-width: 1900px) {
  html {
    font-size: 22px;
  }
}
@media (min-width: 2400px) {
  html {
    font-size: 28px;
  }
}
@media (min-width: 3200px) {
  html {
    font-size: 36px;
  }
}
@media (min-width: 3800px) {
  html {
    font-size: 42px;
  }
}
.container {
  max-width: 82rem;
}
/* ---- hierarchy: the accent colour is reserved for the one primary action; selections are ink ---- */
.btn-dark {
  --bs-btn-color: var(--sel-fg);
  --bs-btn-bg: var(--sel-bg);
  --bs-btn-border-color: var(--sel-bg);
  --bs-btn-hover-color: var(--sel-fg);
  --bs-btn-hover-bg: var(--sel-bg);
  --bs-btn-hover-border-color: var(--sel-bg);
  --bs-btn-active-color: var(--sel-fg);
  --bs-btn-active-bg: var(--sel-bg);
  --bs-btn-active-border-color: var(--sel-bg);
  font-weight: 600;
}
.pills .btn-dark,
.pills .btn-dark:hover {
  background: var(--bs-secondary-bg);
  color: var(--ink);
  font-weight: 700;
  border: 0;
}
.startbar {
  margin-top: 1.5rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--line);
}
.lobby-note {
  color: var(--mut);
  margin: 0.5rem 0 0;
}
/* ---- tables ---- */
.table {
  --bs-table-bg: transparent;
  --bs-table-color: var(--ink);
}
table.table th {
  color: var(--mut);
  font-weight: 600;
}
.hist th:nth-child(2) {
  text-align: left;
}
/* ---- cards: room at the bottom when there is no stats grid (Killer), full-bleed stats otherwise ---- */
.pl {
  padding-bottom: 0.875rem;
}
.st {
  margin-bottom: -0.875rem;
}
/* ---- the board never pushes the controls off a short laptop screen ---- */
.bd {
  max-width: clamp(18rem, calc(100vh - 22rem), 32.5rem);
}
/* ---- phones: one compact nav row, no stats grid on the cards, so the board is reachable without scrolling ---- */
.cards,
.hsec,
.col-lg-5,
.col-lg-7 {
  min-width: 0;
}
@media (max-width: 991.98px) {
  .col-lg-5 {
    display: contents;
  }
  .cards,
  .hsec {
    flex: 0 0 100%;
    width: 100%;
    max-width: 100%;
    padding-left: calc(var(--bs-gutter-x) * 0.5);
    padding-right: calc(var(--bs-gutter-x) * 0.5);
    margin-top: var(--bs-gutter-y);
  }
  .col-lg-7 {
    order: 1;
  }
  .hsec {
    order: 2;
  }
}
@media (min-width: 576px) and (max-width: 991.98px) {
  .cards {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0 0.75rem;
  }
  .cards > .hd,
  .cards > .sec {
    grid-column: 1/-1;
  }
}
@media (max-width: 767px) {
  .pl .st {
    display: none;
  }
  .cards > .hd {
    display: none;
  }
}
@media (max-width: 576px) {
  .navbar {
    padding: 0.5rem 0;
  }
  .navbar .container {
    flex-wrap: nowrap;
  }
  .navbar-brand {
    margin-right: 0.25rem;
    gap: 0.375rem;
    font-size: 1rem;
  }
  .navbar-brand img {
    width: 2rem;
    height: 2rem;
  }
  .nav {
    flex-wrap: nowrap;
  }
  .nav .nav-link {
    padding: 0.4rem 0.3rem;
    font-size: 0.85rem;
  }
}
@media (max-width: 576px) {
  .kg {
    gap: 0.4rem;
  }
  .kg .btn {
    min-height: 2.9rem;
    font-size: 1.25rem;
  }
  .kd {
    font-size: 2.4rem;
    min-height: 3.2rem;
    padding: 0.25rem;
    margin-bottom: 0.4rem;
  }
  .kpw > p {
    display: none;
  }
  .kq {
    margin-top: 0.4rem;
  }
  .kpw {
    margin-top: 0.4rem;
  }
  .lv > .mut {
    display: none;
  }
  .pl {
    padding-top: 0.6rem;
    padding-bottom: 0.6rem;
    margin-bottom: 0.5rem;
  }
  .dt {
    height: 2.25rem;
  }
  .panel {
    padding: 0.7rem;
  }
  .lv {
    margin-bottom: 0.4rem;
  }
  .turn {
    margin-bottom: 0.1rem;
  }
  .turn b {
    font-size: 1.9rem;
  }
  .bd {
    margin-top: 0.4rem;
  }
}
@media (max-width: 360px) {
  .navbar-brand {
    font-size: 0.9rem;
    gap: 0.25rem;
    margin-right: 0;
  }
  .navbar-brand img {
    width: 1.75rem;
    height: 1.75rem;
  }
  .nav .nav-link {
    padding: 0.4rem 0.3rem;
    font-size: 0.8rem;
  }
}
@media (pointer: coarse) {
  .btn-sm {
    min-height: 2.5rem;
  }
}
