:root {
  --bg: #0d1117;
  --bg-raised: #151b23;
  --bg-hover: #1c242e;
  --bg-inset: #0a0e14;
  --border: #262e3a;
  --border-strong: #37414f;
  --text: #e6edf3;
  --text-dim: #8d97a5;
  --text-faint: #5d6775;
  --accent: #d50a0a;
  --accent-soft: rgba(213, 10, 10, 0.14);
  --ok: #3fb950;
  --warn: #d29922;
  --bad: #f85149;
  --info: #58a6ff;
  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 8px 28px rgba(0, 0, 0, 0.5);
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace;
  /* Safe-area insets, so the standalone PWA clears the notch and the iPhone
     home indicator. Zero everywhere else. */
  --sat: env(safe-area-inset-top, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
  --sal: env(safe-area-inset-left, 0px);
  --sar: env(safe-area-inset-right, 0px);
  --tabbar-h: 56px;
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial,
    sans-serif;
  -webkit-font-smoothing: antialiased;
  /* Stop iOS from rubber-banding the whole page behind the standalone shell,
     and from auto-inflating text in landscape. */
  overscroll-behavior-y: none;
  -webkit-text-size-adjust: 100%;
}

/* Kill the 300ms tap delay and the grey flash on tap targets. */
a,
button,
.tab,
.player-row,
select {
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

a {
  color: inherit;
  text-decoration: none;
}

/* ------------------------------------------------------------------ topbar */
.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 16px;
  height: calc(52px + var(--sat));
  padding: var(--sat) calc(18px + var(--sar)) 0 calc(18px + var(--sal));
  background: rgba(13, 17, 23, 0.92);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.brand-mark {
  display: block;
  border-radius: 5px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 650;
  letter-spacing: -0.01em;
  white-space: nowrap;
}
.brand-mark {
  font-size: 18px;
}
.brand-text {
  color: var(--text);
}

.mainnav {
  display: flex;
  align-items: center;
  gap: 2px;
  min-width: 0;
  flex: 1;
  overflow-x: auto;
  scrollbar-width: none;
}
.mainnav::-webkit-scrollbar {
  display: none;
}
.mainnav a {
  padding: 5px 11px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 550;
  color: var(--text-dim);
  white-space: nowrap;
  transition: 0.12s;
}
.mainnav a:hover {
  color: var(--text);
  background: var(--bg-hover);
}
.mainnav a.active {
  color: var(--text);
  background: var(--bg-hover);
  box-shadow: inset 0 -2px 0 var(--accent);
}

.switcher {
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
}
.switcher[hidden] {
  display: none;
}
.switcher-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--text-faint);
}
.switcher select {
  width: auto;
  max-width: 230px;
  padding: 5px 8px;
  font-size: 12px;
  font-weight: 550;
  background: var(--bg-raised);
  border-color: var(--border-strong);
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.conn-status {
  font-size: 12px;
  color: var(--text-dim);
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}
.conn-status::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--text-faint);
}
.conn-status.online::before {
  background: var(--ok);
  box-shadow: 0 0 6px var(--ok);
}
.conn-status.offline::before {
  background: var(--bad);
}

.icon-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-dim);
  border-radius: var(--radius-sm);
  width: 30px;
  height: 30px;
  font-size: 15px;
  cursor: pointer;
  transition: 0.15s;
}
.icon-btn:hover {
  color: var(--text);
  border-color: var(--border-strong);
  background: var(--bg-hover);
}
.icon-btn.spinning {
  animation: spin 0.7s linear infinite;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* -------------------------------------------------------------------- app */
.app {
  max-width: 1240px;
  margin: 0 auto;
  padding: 22px calc(18px + var(--sar)) 80px calc(18px + var(--sal));
}

/* ------------------------------------------------- mobile bottom tab bar */
.tabbar {
  display: none;
}
.tabbar[hidden] {
  display: none !important;
}
.tabbar a {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 7px 2px;
  color: var(--text-faint);
  font-size: 10px;
  font-weight: 650;
  letter-spacing: 0.02em;
  min-height: 48px;
  transition: color 0.12s;
}
.tabbar a .ico {
  font-size: 19px;
  line-height: 1;
}
.tabbar a.active {
  color: var(--accent);
}
.tabbar a:active {
  background: var(--bg-hover);
}

h1 {
  font-size: 21px;
  margin: 0 0 4px;
  letter-spacing: -0.02em;
}
h2 {
  font-size: 15px;
  margin: 0 0 12px;
  letter-spacing: -0.01em;
}
h3 {
  font-size: 13px;
  margin: 0 0 8px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 600;
}

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}
.page-sub {
  color: var(--text-dim);
  font-size: 13px;
}

/* ------------------------------------------------------------------ cards */
.card {
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}

.grid {
  display: grid;
  gap: 14px;
}
.grid-leagues {
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
}
.grid-2 {
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
}

.league-card {
  display: block;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  transition: 0.15s;
  position: relative;
}
.league-card:hover {
  border-color: var(--border-strong);
  background: var(--bg-hover);
  transform: translateY(-1px);
}
.league-card .lc-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 12px;
}
.league-card .lc-name {
  font-weight: 600;
  font-size: 15px;
  letter-spacing: -0.01em;
  line-height: 1.3;
}
.league-card .lc-meta {
  color: var(--text-faint);
  font-size: 12px;
  margin-top: 3px;
}
.league-card .lc-team {
  display: flex;
  align-items: center;
  gap: 9px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}
.league-card .lc-logo {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--bg-inset);
  flex-shrink: 0;
}
.league-card .lc-team-name {
  font-size: 13px;
  font-weight: 550;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.league-card .lc-record {
  color: var(--text-dim);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}
.league-card.dead {
  opacity: 0.6;
}

/* ------------------------------------------------------------------- tabs */
.tabs {
  display: flex;
  gap: 2px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 20px;
  overflow-x: auto;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar {
  display: none;
}
.tab {
  padding: 9px 14px;
  font-size: 13px;
  font-weight: 550;
  color: var(--text-dim);
  border-bottom: 2px solid transparent;
  cursor: pointer;
  white-space: nowrap;
  transition: 0.12s;
}
.tab:hover {
  color: var(--text);
}
.tab.active {
  color: var(--text);
  border-bottom-color: var(--accent);
}

/* ----------------------------------------------------------------- badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 7px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
  background: var(--bg-inset);
  border: 1px solid var(--border);
  color: var(--text-dim);
  white-space: nowrap;
}
.badge.accent {
  background: var(--accent-soft);
  border-color: rgba(213, 10, 10, 0.4);
  color: #ff6b6b;
}
.badge.ok {
  color: var(--ok);
  border-color: rgba(63, 185, 80, 0.35);
  background: rgba(63, 185, 80, 0.1);
}
.badge.warn {
  color: var(--warn);
  border-color: rgba(210, 153, 34, 0.35);
  background: rgba(210, 153, 34, 0.1);
}
.badge.bad {
  color: var(--bad);
  border-color: rgba(248, 81, 73, 0.35);
  background: rgba(248, 81, 73, 0.1);
}
.badge.info {
  color: var(--info);
  border-color: rgba(88, 166, 255, 0.35);
  background: rgba(88, 166, 255, 0.1);
}

/* A badge that navigates somewhere should look like it does. */
a.badge {
  cursor: pointer;
  transition: 0.12s;
}
a.badge:hover {
  border-color: var(--info);
  color: var(--info);
  background: rgba(88, 166, 255, 0.12);
}
a.badge.accent:hover {
  border-color: var(--accent);
  color: #ff6b6b;
  background: var(--accent-soft);
}

.team-link {
  color: inherit;
  border-bottom: 1px dotted var(--text-faint);
  transition: 0.12s;
}
.team-link:hover {
  color: var(--info);
  border-bottom-color: var(--info);
}

.pos-pill {
  display: inline-block;
  min-width: 34px;
  text-align: center;
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.03em;
  background: var(--bg-inset);
  border: 1px solid var(--border);
  color: var(--text-dim);
}
.pos-QB { color: #ff6b81; border-color: rgba(255,107,129,.4); background: rgba(255,107,129,.1); }
.pos-RB { color: #4ade80; border-color: rgba(74,222,128,.4); background: rgba(74,222,128,.1); }
.pos-WR { color: #60a5fa; border-color: rgba(96,165,250,.4); background: rgba(96,165,250,.1); }
.pos-TE { color: #fbbf24; border-color: rgba(251,191,36,.4); background: rgba(251,191,36,.1); }
.pos-K  { color: #c084fc; border-color: rgba(192,132,252,.4); background: rgba(192,132,252,.1); }
.pos-DST, .pos-D\/ST { color: #a8a29e; border-color: rgba(168,162,158,.4); background: rgba(168,162,158,.1); }

/* --------------------------------------------------------------- controls */
button,
select,
input,
textarea {
  font: inherit;
  color: inherit;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 7px 13px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--bg-raised);
  color: var(--text);
  font-size: 13px;
  font-weight: 550;
  cursor: pointer;
  transition: 0.13s;
  white-space: nowrap;
}
.btn:hover:not(:disabled) {
  background: var(--bg-hover);
  border-color: #46525f;
}
.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.btn.primary:hover:not(:disabled) {
  background: #ea1717;
  border-color: #ea1717;
}
.btn.danger {
  color: var(--bad);
  border-color: rgba(248, 81, 73, 0.4);
}
.btn.danger:hover:not(:disabled) {
  background: rgba(248, 81, 73, 0.12);
}
.btn.ghost {
  border-color: transparent;
  background: transparent;
  color: var(--text-dim);
}
.btn.ghost:hover:not(:disabled) {
  background: var(--bg-hover);
  color: var(--text);
}
.btn.sm {
  padding: 4px 9px;
  font-size: 12px;
}

select,
input[type="text"],
input[type="number"],
input[type="search"],
input[type="password"],
textarea {
  background: var(--bg-inset);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 7px 10px;
  font-size: 13px;
  outline: none;
  transition: border-color 0.13s;
  width: 100%;
}
select:focus,
input:focus,
textarea:focus {
  border-color: var(--info);
}
textarea {
  font-family: var(--mono);
  font-size: 12px;
  resize: vertical;
  min-height: 120px;
}
input[type="checkbox"] {
  width: auto;
  accent-color: var(--accent);
}

.toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}
.toolbar .grow {
  flex: 1;
  min-width: 180px;
}

/* Controls sized by their content on desktop; full-width once stacked. */
.w-auto {
  width: auto;
}
.field {
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.field label {
  font-size: 11px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
}
.field .hint {
  font-size: 12px;
  color: var(--text-faint);
  text-transform: none;
  letter-spacing: 0;
}

/* ------------------------------------------------------------- player row */
.slot-group + .slot-group {
  margin-top: 18px;
}

.player-row {
  display: grid;
  grid-template-columns: 46px 1fr auto;
  align-items: center;
  gap: 11px;
  padding: 8px 11px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-raised);
  transition: 0.12s;
}
.player-row + .player-row {
  margin-top: 5px;
}
.player-row:hover {
  border-color: var(--border-strong);
  background: var(--bg-hover);
}
.player-row.empty {
  border-style: dashed;
  background: transparent;
  color: var(--text-faint);
}
.player-row.selected {
  border-color: var(--accent);
  background: var(--accent-soft);
  box-shadow: 0 0 0 1px var(--accent);
}
.player-row.swap-target {
  border-color: var(--ok);
  background: rgba(63, 185, 80, 0.08);
  cursor: pointer;
}
.player-row.bench {
  opacity: 0.92;
}

.slot-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-dim);
  text-align: center;
  letter-spacing: 0.04em;
  padding: 3px 0;
  border-radius: 4px;
  background: var(--bg-inset);
}
.slot-label.starter {
  color: var(--text);
}
.slot-label.ir {
  color: var(--bad);
}
.slot-label.depth-rank {
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  color: var(--text-faint);
  background: transparent;
}

.pro-logo {
  width: 42px;
  height: 42px;
  object-fit: contain;
  flex-shrink: 0;
}

.p-main {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
}
.p-head {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  object-fit: cover;
  object-position: top center;
  background: var(--bg-inset);
  flex-shrink: 0;
}
.p-text {
  min-width: 0;
}
.p-name {
  font-size: 13px;
  font-weight: 550;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 6px;
}
.p-sub {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--text-faint);
  margin-top: 2px;
}
.inj {
  font-size: 10px;
  font-weight: 700;
}
.inj.warn {
  color: var(--warn);
}
.inj.bad {
  color: var(--bad);
}

.p-stats {
  display: flex;
  align-items: center;
  gap: 14px;
}
.stat {
  text-align: right;
  min-width: 44px;
}
.stat .v {
  font-size: 13px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  display: block;
  line-height: 1.2;
}
.stat .k {
  font-size: 9px;
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.stat .v.muted {
  color: var(--text-faint);
  font-weight: 500;
}
.p-actions {
  display: flex;
  gap: 5px;
}

.stat.clickable {
  cursor: pointer;
  border-radius: var(--radius-sm);
  padding: 2px 5px;
  margin: -2px -1px;
  transition: 0.12s;
}
.stat.clickable:hover {
  background: var(--bg-inset);
  box-shadow: inset 0 0 0 1px var(--border-strong);
}
.stat.clickable:hover .v {
  color: var(--info);
}

/* ------------------------------------------------------ scoring breakdown */
.bd-head {
  display: flex;
  align-items: center;
  gap: 11px;
  min-width: 0;
}
.bd-head > div {
  min-width: 0;
}
.bd-head .p-sub {
  flex-wrap: wrap;
}
.bd-name {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.01em;
  display: flex;
  align-items: center;
  gap: 7px;
  flex-wrap: wrap;
}

.bd-totals {
  display: flex;
  gap: 10px;
}
.bd-total {
  flex: 1;
  background: var(--bg-inset);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
}
.bd-total .k {
  display: block;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-faint);
  font-weight: 600;
}
.bd-total .v {
  font-size: 20px;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}

.bd-table td,
.bd-table th {
  padding: 6px 10px;
}
.bd-table td:first-child {
  white-space: normal;
  font-size: 12px;
  color: var(--text-dim);
}
.bd-abbr {
  display: inline-block;
  min-width: 46px;
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 700;
  color: var(--text-faint);
}
.pts-pos {
  color: var(--ok);
  font-weight: 600;
}
.pts-neg {
  color: var(--bad);
  font-weight: 600;
}

/* ---------------------------------------------------------------- trades */
.trade-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.trade-col h3 {
  display: flex;
  align-items: baseline;
  gap: 6px;
}
.trade-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 320px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 6px;
}
.trade-pick {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 8px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 12px;
}
.trade-pick:hover {
  background: var(--bg-hover);
}
.trade-pick input {
  flex-shrink: 0;
}
.tp-name {
  font-weight: 550;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.tp-meta {
  margin-left: auto;
  color: var(--text-faint);
  font-size: 11px;
  white-space: nowrap;
}

.trade-summary {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.trade-move {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 10px;
  background: var(--bg-inset);
  border-radius: var(--radius-sm);
  font-size: 13px;
}

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

/* ------------------------------------------------------------------ table */
.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
th {
  text-align: left;
  padding: 9px 12px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-dim);
  font-weight: 600;
  background: var(--bg-inset);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
td {
  padding: 9px 12px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
tbody tr:last-child td {
  border-bottom: none;
}
tbody tr:hover {
  background: var(--bg-hover);
}
tbody tr.is-me {
  background: var(--accent-soft);
}
tbody tr.is-me:hover {
  background: rgba(213, 10, 10, 0.2);
}
.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* On a phone the Delete button must fit without scrolling the table sideways. */
@media (max-width: 640px) {
  .admin-table .col-created {
    display: none;
  }
  .admin-table td:first-child {
    white-space: normal;
  }
}

/* --------------------------------------------------------------- settings */
.kv {
  display: grid;
  grid-template-columns: minmax(160px, 40%) 1fr;
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.kv > dt,
.kv > dd {
  background: var(--bg-raised);
  padding: 8px 12px;
  margin: 0;
  font-size: 13px;
}
.kv > dt {
  color: var(--text-dim);
}
.kv > dd {
  font-weight: 500;
}

.scoring-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.scoring-item {
  background: var(--bg-raised);
  padding: 8px 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}
.scoring-item .label {
  font-size: 12px;
  color: var(--text-dim);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.scoring-item .pts {
  font-weight: 650;
  font-variant-numeric: tabular-nums;
  font-size: 13px;
}
.scoring-item .pts.pos {
  color: var(--ok);
}
.scoring-item .pts.neg {
  color: var(--bad);
}

.section {
  margin-bottom: 26px;
}

/* --------------------------------------------------------------- matchups */
.matchup {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-raised);
}
.matchup + .matchup {
  margin-top: 8px;
}
.mu-side {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
}
.mu-side.away {
  flex-direction: row-reverse;
  text-align: right;
}
.mu-logo {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--bg-inset);
  object-fit: cover;
  flex-shrink: 0;
}
.mu-name {
  font-size: 13px;
  font-weight: 550;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.mu-score {
  font-size: 16px;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
}
.mu-vs {
  color: var(--text-faint);
  font-size: 11px;
  font-weight: 600;
}
.mu-proj {
  font-size: 10px;
  color: var(--text-faint);
  font-variant-numeric: tabular-nums;
}
.live-dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--ok);
  margin-left: 5px;
  vertical-align: middle;
  animation: pulse 1.6s ease-in-out infinite;
}
@keyframes pulse {
  50% {
    opacity: 0.25;
  }
}
.mu-side.winner .mu-name,
.mu-side.winner .mu-score {
  color: var(--ok);
}

/* A matchup card that opens the matchup page */
.matchup.linked {
  cursor: pointer;
  transition: 0.12s;
}
.matchup.linked:hover {
  border-color: var(--border-strong);
  background: var(--bg-hover);
}
.matchup.linked.mine:hover {
  border-color: var(--accent);
}

/* Matchup page: score header, then both lineups side by side */
.mu-detail-head {
  margin-bottom: 14px;
}
.mu-detail-head .mu-name a:hover {
  color: var(--info);
}
.mu-weeks {
  margin: -6px 0 14px;
  font-size: 12px;
  color: var(--text-faint);
}
.mu-detail-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  align-items: start;
}
.mu-col {
  min-width: 0;
}
.mu-col-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  padding: 10px 12px;
  margin-bottom: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-inset);
}
.mu-col-head h3 {
  margin: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.mu-col.is-me .mu-col-head {
  border-color: rgba(213, 10, 10, 0.5);
  background: linear-gradient(var(--accent-soft), var(--accent-soft)), var(--bg-inset);
}
/* Two lineups side by side leave less room per row than a roster page. */
.mu-col .player-row {
  grid-template-columns: 40px minmax(0, 1fr) auto;
  gap: 8px;
  padding: 7px 9px;
}
.mu-col .p-stats {
  gap: 10px;
}

/* Your own game, on the cross-league board */
.matchup.mine {
  border-color: rgba(213, 10, 10, 0.5);
  background: linear-gradient(var(--accent-soft), var(--accent-soft)), var(--bg-raised);
}
.mu-side.is-me .mu-name {
  font-weight: 700;
}

.league-block {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 14px;
}
.league-block-head {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 11px 14px;
  background: var(--bg-inset);
  border-bottom: 1px solid var(--border);
}
.league-block-head .lb-name {
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -0.01em;
}
.league-block-head .lb-name:hover {
  color: var(--info);
}
.league-block-body {
  padding: 12px;
}
.league-block-body .matchup {
  border-radius: var(--radius-sm);
}

/* Setup screen: cookie walkthrough */
.setup-browsers {
  margin: 6px 0 4px;
  padding-left: 18px;
  font-size: 13px;
  color: var(--text-dim);
}
.setup-browsers li + li {
  margin-top: 3px;
}
.setup-help {
  margin-bottom: 20px;
  font-size: 13px;
  color: var(--text-dim);
}
.setup-help summary {
  cursor: pointer;
  color: var(--text);
  font-weight: 600;
}
.setup-help p {
  margin: 8px 0 4px;
}
.setup-example {
  margin: 0 0 6px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-inset);
  font-size: 12px;
  white-space: pre-wrap;
  word-break: break-all;
  overflow-x: auto;
}
kbd {
  font-family: inherit;
  font-size: 12px;
  padding: 1px 5px;
  border: 1px solid var(--border-strong);
  border-bottom-width: 2px;
  border-radius: 4px;
  background: var(--bg-inset);
}

/* ----------------------------------------------------------------- states */
.empty-state {
  text-align: center;
  padding: 56px 20px;
  color: var(--text-dim);
}
.empty-state .big {
  font-size: 34px;
  margin-bottom: 12px;
}
.empty-state h2 {
  color: var(--text);
  margin-bottom: 6px;
}

.alert {
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  border: 1px solid;
  margin-bottom: 14px;
  display: flex;
  gap: 9px;
  align-items: flex-start;
}
.alert.error {
  background: rgba(248, 81, 73, 0.09);
  border-color: rgba(248, 81, 73, 0.35);
  color: #ffb3ae;
}
.alert.warn {
  background: rgba(210, 153, 34, 0.09);
  border-color: rgba(210, 153, 34, 0.35);
  color: #f0cc72;
}
.alert.info {
  background: rgba(88, 166, 255, 0.08);
  border-color: rgba(88, 166, 255, 0.3);
  color: #a5cdff;
}

.skeleton {
  background: linear-gradient(90deg, var(--bg-raised) 25%, var(--bg-hover) 50%, var(--bg-raised) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.3s infinite;
  border-radius: var(--radius-sm);
  height: 46px;
}
.skeleton + .skeleton {
  margin-top: 6px;
}
@keyframes shimmer {
  to {
    background-position: -200% 0;
  }
}

/* ----------------------------------------------------------------- toasts */
.toast-host {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: min(400px, calc(100vw - 40px));
}
.toast {
  background: var(--bg-raised);
  border: 1px solid var(--border-strong);
  border-left: 3px solid var(--info);
  border-radius: var(--radius-sm);
  padding: 11px 14px;
  font-size: 13px;
  box-shadow: var(--shadow);
  animation: slide-in 0.2s ease-out;
}
.toast.ok {
  border-left-color: var(--ok);
}
.toast.error {
  border-left-color: var(--bad);
}
.toast .t-title {
  font-weight: 600;
  margin-bottom: 2px;
}
.toast .t-body {
  color: var(--text-dim);
  font-size: 12px;
}
@keyframes slide-in {
  from {
    opacity: 0;
    transform: translateX(16px);
  }
}

/* ----------------------------------------------------------------- modals */
.modal-host {
  position: fixed;
  inset: 0;
  z-index: 90;
  background: rgba(0, 0, 0, 0.65);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  backdrop-filter: blur(3px);
}
.modal-host[hidden] {
  display: none;
}
.modal {
  background: var(--bg-raised);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  width: 100%;
  max-width: 520px;
  max-height: 86vh;
  display: flex;
  flex-direction: column;
  animation: pop 0.16s ease-out;
}
.modal.wide {
  max-width: 760px;
}
@keyframes pop {
  from {
    opacity: 0;
    transform: scale(0.97);
  }
}
.modal-head {
  padding: 15px 18px;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}
.modal-body {
  padding: 18px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-width: 0;
}
/* Flex children default to min-width:auto, which lets a wide table push the
   whole dialog past the viewport instead of scrolling inside its own wrapper. */
.modal-body > * {
  min-width: 0;
  max-width: 100%;
}
.modal-head {
  min-width: 0;
}
.modal-head > span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.modal-foot {
  padding: 13px 18px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 9px;
}

/* ------------------------------------------------------------ setup page */
.setup {
  max-width: 620px;
  margin: 40px auto;
}
.auth-screen {
  max-width: 400px;
  margin: 8vh auto;
}
.auth-logo {
  display: flex;
  justify-content: center;
  margin-bottom: 14px;
}
.auth-logo img {
  border-radius: 14px;
}
.setup ol {
  padding-left: 20px;
  color: var(--text-dim);
  font-size: 13px;
  line-height: 1.8;
}
.setup code {
  font-family: var(--mono);
  font-size: 12px;
  background: var(--bg-inset);
  padding: 1px 5px;
  border-radius: 3px;
  color: var(--info);
  border: 1px solid var(--border);
}

.mono {
  font-family: var(--mono);
  font-size: 12px;
}
.dim {
  color: var(--text-dim);
}
.faint {
  color: var(--text-faint);
}
.right {
  text-align: right;
}
.row {
  display: flex;
  align-items: center;
  gap: 10px;
}
.row.wrap {
  flex-wrap: wrap;
}
.spacer {
  flex: 1;
}

/* ==========================================================================
   Mobile. Below 820px the app becomes a bottom-tab phone layout: primary
   navigation moves off the cramped top bar, rows reflow to two lines, and
   every tap target clears 44px.
   ========================================================================== */
@media (max-width: 820px) {
  .app {
    padding: 14px calc(12px + var(--sal)) calc(var(--tabbar-h) + var(--sab) + 24px)
      calc(12px + var(--sar));
  }

  /* Top bar keeps identity + league switcher; nav moves to the bottom. */
  .mainnav {
    display: none;
  }
  .conn-status {
    display: none;
  }
  .brand-text {
    display: none;
  }
  .topbar {
    gap: 10px;
  }
  .topbar-right {
    flex: 1;
    justify-content: flex-end;
    min-width: 0;
  }
  .switcher {
    flex: 1;
    min-width: 0;
  }
  .switcher-label {
    display: none;
  }
  .switcher select {
    max-width: none;
    width: 100%;
    font-size: 14px;
    padding: 8px 10px;
  }

  .tabbar {
    display: flex;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 50;
    background: rgba(13, 17, 23, 0.96);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-top: 1px solid var(--border);
    padding: 0 var(--sar) var(--sab) var(--sal);
  }

  h1 {
    font-size: 19px;
  }
  .page-head {
    margin-bottom: 14px;
  }

  /* A select sized to its longest option ("Beautiful Brown Cocaine") is wider
     than the phone, and that widened the whole document. Let them shrink. */
  .w-auto,
  select.w-auto {
    width: 100%;
    min-width: 0;
    max-width: 100%;
  }
  .page-head .row,
  .toolbar {
    width: 100%;
    flex-wrap: wrap;
  }
  .page-head .row > * {
    min-width: 0;
  }
  .page-head .row > .field,
  .page-head .row > select {
    flex: 1 1 150px;
  }

  /* Rows: name on top, stats underneath, so nothing truncates to nothing. */
  .player-row {
    grid-template-columns: 42px minmax(0, 1fr);
    row-gap: 7px;
    padding: 10px;
  }
  .p-stats {
    grid-column: 2 / -1;
    justify-content: flex-start;
    gap: 16px;
    flex-wrap: wrap;
  }
  .stat {
    min-width: 0;
    text-align: left;
  }
  .p-actions {
    margin-left: auto;
  }

  /* Comfortable hit areas. */
  .btn {
    padding: 10px 15px;
    min-height: 40px;
  }
  .btn.sm {
    padding: 7px 11px;
    min-height: 34px;
  }
  .icon-btn {
    width: 38px;
    height: 38px;
  }
  .tab {
    padding: 11px 13px;
    font-size: 14px;
  }
  select,
  input[type="text"],
  input[type="number"],
  input[type="search"],
  input[type="password"],
  textarea {
    /* 16px keeps iOS Safari from zooming in when a field takes focus. */
    font-size: 16px;
    padding: 10px 12px;
  }

  .kv {
    grid-template-columns: 1fr;
  }
  .kv > dt {
    padding-bottom: 0;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
  }
  .kv > dd {
    padding-top: 2px;
  }

  .grid-leagues {
    grid-template-columns: 1fr;
  }
  .grid-2 {
    grid-template-columns: 1fr;
  }

  .matchup {
    grid-template-columns: 1fr auto 1fr;
    gap: 8px;
    padding: 10px;
  }
  .mu-detail-grid {
    grid-template-columns: 1fr;
  }
  .mu-col .player-row {
    grid-template-columns: 42px minmax(0, 1fr);
    padding: 10px;
  }
  .mu-logo {
    width: 24px;
    height: 24px;
  }
  .mu-name {
    font-size: 12px;
  }
  .mu-score {
    font-size: 15px;
  }

  .modal-host {
    padding: 12px calc(12px + var(--sar)) 12px calc(12px + var(--sal));
    align-items: flex-end;
  }
  .modal {
    max-height: calc(100vh - var(--sat) - var(--sab) - 24px);
  }
  .bd-totals {
    gap: 8px;
  }
  .bd-total .v {
    font-size: 17px;
  }
  .bd-abbr {
    min-width: 38px;
  }
  .modal-foot {
    padding-bottom: calc(13px + var(--sab));
  }
  .toast-host {
    left: 12px;
    right: 12px;
    bottom: calc(var(--tabbar-h) + var(--sab) + 12px);
    max-width: none;
  }
  .scoring-grid {
    grid-template-columns: 1fr;
  }
}

/* Very narrow phones: drop the least essential stat column. */
@media (max-width: 380px) {
  .p-stats .stat:nth-child(3) {
    display: none;
  }
}

/* Roster occupancy on league cards and the league header */
.roster-pill {
  display: inline-block;
  margin-top: 4px;
  font-size: 12px;
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
}
.roster-pill.full {
  color: var(--warn);
  font-weight: 600;
}
.roster-pill.bad {
  color: var(--bad);
  font-weight: 600;
}
.lc-record .roster-pill {
  display: block;
  margin-top: 3px;
}
