:root {
  color-scheme: light;
  --bg: #f6f7fb;
  --panel: #ffffff;
  --text: #151922;
  --muted: #667085;
  --line: #d9deea;
  --accent: #0f766e;
  --accent-2: #a855f7;
  --good: #14804a;
  --bad: #b42318;
  --shadow: 0 18px 45px rgba(23, 31, 48, .08);
}

[data-theme="dark"] {
  color-scheme: dark;
  --bg: #101319;
  --panel: #181d26;
  --text: #eef2f7;
  --muted: #a6b0c1;
  --line: #2a3241;
  --accent: #2dd4bf;
  --accent-2: #c084fc;
  --good: #6ee7b7;
  --bad: #fca5a5;
  --shadow: 0 18px 45px rgba(0, 0, 0, .28);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 28px clamp(18px, 4vw, 52px) 18px;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--panel) 88%, transparent);
  position: sticky;
  top: 0;
  z-index: 10;
  backdrop-filter: blur(14px);
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
}

h1, h2, p { margin: 0; }
h1 { font-size: clamp(28px, 4vw, 44px); }
h2 { font-size: 20px; }

main {
  width: min(1480px, 100%);
  margin: 0 auto;
  padding: 22px clamp(16px, 4vw, 52px) 48px;
}

.actions, .tabs, .controls {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

button, select, input {
  font: inherit;
}

button, select {
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  min-height: 40px;
  border-radius: 8px;
}

button {
  cursor: pointer;
  padding: 0 14px;
  font-weight: 750;
}

.primary {
  border-color: transparent;
  background: var(--accent);
  color: #fff;
}

.secondary:hover, .icon-button:hover, .tab:hover {
  border-color: var(--accent);
}

.icon-button {
  width: 42px;
  padding: 0;
  font-size: 21px;
}

.summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.summary div, .board {
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.summary div {
  border-radius: 8px;
  padding: 16px;
}

.summary span {
  display: block;
  font-size: 24px;
  font-weight: 850;
}

.summary p, .board-head p {
  color: var(--muted);
  font-size: 13px;
  margin-top: 3px;
}

.movement {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.movement-card {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
  min-height: 82px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.movement-card p {
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
  text-transform: uppercase;
}

.movement-card strong,
.movement-card span {
  display: block;
}

.movement-card strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 18px;
}

.movement-card span {
  margin-top: 2px;
  color: var(--muted);
  font-size: 13px;
}

.movement-card b {
  min-width: 62px;
  text-align: right;
  font-size: 28px;
  line-height: 1;
}

.movement-up {
  border-color: color-mix(in srgb, var(--good) 46%, var(--line));
}

.movement-down {
  border-color: color-mix(in srgb, var(--bad) 46%, var(--line));
}

.controls {
  justify-content: space-between;
  margin-bottom: 16px;
}

.search {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: min(100%, 380px);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
}

.search input {
  width: 100%;
  min-height: 42px;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
}

.tab {
  min-width: 48px;
  background: transparent;
}

.tab.active {
  background: color-mix(in srgb, var(--accent) 16%, transparent);
  border-color: var(--accent);
  color: var(--accent);
}

.board {
  border-radius: 8px;
  overflow: hidden;
}

.board-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 18px;
  border-bottom: 1px solid var(--line);
}

.board-selectors {
  display: flex;
  align-items: end;
  gap: 10px;
  flex-wrap: wrap;
}

.board-selectors label {
  display: grid;
  gap: 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
  text-transform: uppercase;
}

.notice {
  margin: 14px 18px 0;
  padding: 10px 12px;
  border: 1px solid color-mix(in srgb, var(--accent-2) 45%, var(--line));
  border-radius: 8px;
  background: color-mix(in srgb, var(--accent-2) 10%, transparent);
  color: var(--text);
  font-size: 13px;
}

select {
  padding: 0 36px 0 12px;
}

.table-wrap {
  overflow: auto;
  max-height: calc(100vh - 315px);
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 980px;
}

th, td {
  padding: 11px 12px;
  text-align: left;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}

th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--panel);
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

td {
  font-size: 14px;
}

.rank {
  width: 54px;
  font-weight: 850;
}

.player {  
  align-items: center;
  gap: 6px;
  font-weight: 820;
  max-width: 100%;
}

.player span:last-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

tbody tr {
  cursor: pointer;
}

tbody tr:hover {
  background: color-mix(in srgb, var(--accent) 8%, transparent);
}

.tag-icon {
  display: inline-block;
  flex: 0 0 auto;
  font-family: Arial, sans-serif;
  font-size: 1em;
  font-weight: 900;
  line-height: 1;
  padding-right: 12px;
  text-align: center;
}

.tag-icon-target {
  color: var(--good);
}

.tag-icon-avoid {
  color: var(--bad);
}

.tag-icon-injured {
  color: #b7791f;
}

.chip {
  display: inline-flex;
  align-items: center;
  min-width: 42px;
  justify-content: center;
  padding: 4px 8px;
  border-radius: 999px;
  border: 1px solid rgba(0, 0, 0, .18);
  color: #111827;
  font-size: 12px;
  font-weight: 850;
}

.chip-QB { background: #ff6fb1; }
.chip-RB { background: #39ff88; }
.chip-WR { background: #fff34d; }
.chip-TE { background: #c084fc; }
.chip-K { background: #b88746; color: #fffaf0; }
.chip-DST { background: #38bdf8; }

.up { color: var(--good); }
.down { color: var(--bad); }
.empty { text-align: center; color: var(--muted); padding: 36px; }

.modal[hidden] {
  display: none;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 18px;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(13, 18, 28, .56);
}

.modal-panel {
  position: relative;
  z-index: 1;
  width: min(440px, 100%);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--text);
  box-shadow: var(--shadow);
}

.modal-panel header,
.modal-panel footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px;
}

.modal-panel header {
  border-bottom: 1px solid var(--line);
}

.modal-panel footer {
  border-top: 1px solid var(--line);
}

.modal-panel header p {
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
  text-transform: uppercase;
}

.tag-actions {
  display: grid;
  gap: 10px;
  padding: 16px;
}

.tag-option {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 12px;
  min-height: 50px;
}

.tag-target {
  border-color: color-mix(in srgb, var(--good) 46%, var(--line));
}

.tag-avoid {
  border-color: color-mix(in srgb, var(--bad) 46%, var(--line));
}

.tag-injured {
  border-color: color-mix(in srgb, #b7791f 48%, var(--line));
}

@media (max-width: 760px) {
  .topbar, .board-head {
    align-items: stretch;
    flex-direction: column;
  }

  .board-selectors {
    align-items: stretch;
  }

  .board-selectors label,
  .board-selectors select {
    width: 100%;
  }

  .actions button {
    flex: 1;
  }

  .summary {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .movement {
    grid-template-columns: 1fr;
  }

  .movement-card {
    grid-template-columns: 1fr auto;
  }

  .movement-card p {
    grid-column: 1 / -1;
  }

  .table-wrap {
    max-height: none;
  }
}

@media print {
  @page {
    size: landscape;
    margin: .25in;
  }

  body.print-grid-only .topbar,
  body.print-grid-only .summary,
  body.print-grid-only .movement,
  body.print-grid-only .controls,
  body.print-grid-only .board-head,
  body.print-grid-only .notice,
  body.print-grid-only .modal {
    display: none !important;
  }

  body.print-grid-only,
  body.print-grid-only .board {
    background: #fff;
    color: #000;
    box-shadow: none;
    border: 0;
  }

  body.print-grid-only main {
    padding: 0;
    width: 100%;
    max-width: none;
  }

  body.print-grid-only .board {
    overflow: visible;
  }

  body.print-grid-only .table-wrap {
    max-height: none;
    overflow: visible;
  }

  body.print-grid-only table {
    width: 100%;
    min-width: 0;
  }

  body.print-grid-only th,
  body.print-grid-only td {
    padding: 4px 5px;
    font-size: 7px;
  }

  body.print-grid-only th {
    position: static;
  }

  body.print-grid-only .player {
    gap: 2px;
  }

  body.print-grid-only .chip {
    min-width: 24px;
    padding: 2px 4px;
    font-size: 7px;
  }

  body.print-grid-only .tag-icon {
    font-size: 1em;
  }
}
