:root {
  --bg: #111316;
  --panel: #191c21;
  --panel-2: #1f232a;
  --line: rgba(255, 255, 255, 0.08);
  --line-2: rgba(255, 255, 255, 0.14);
  --text: #e9eaec;
  --dim: #8d939c;
  --scarlet: #e0281e;
  --scarlet-dim: rgba(224, 40, 30, 0.18);
  --pos: #4fd17c;
  --neg: #ff6b6b;
  --run: #d69a2f;
  --pass: #4a8dff;
  --fg: #a98bff;
  --pen: #7c8390;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.4 var(--sans); }
a { color: var(--dim); }
a:hover { color: var(--text); }
.hidden { display: none !important; }
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; font-size: 0.95em; }
.pos { color: var(--pos); }
.neg { color: var(--neg); }
.dim { color: var(--dim); }
button { font: inherit; color: var(--text); background: var(--panel-2); border: 1px solid var(--line-2); border-radius: 6px; padding: 6px 12px; cursor: pointer; }
button:hover { border-color: rgba(255, 255, 255, 0.3); }
button.primary { background: var(--scarlet); border-color: var(--scarlet); color: #fff; font-weight: 600; min-width: 84px; }
button.ghost { background: transparent; }
select, input[type="search"] { font: inherit; color: var(--text); background: var(--panel-2); border: 1px solid var(--line-2); border-radius: 6px; padding: 5px 8px; }
input[type="search"] { min-width: 220px; }

/* ---- top bar ---- */
.topbar { display: flex; align-items: center; gap: 24px; padding: 12px 24px; border-bottom: 1px solid var(--line); background: var(--panel); position: sticky; top: 0; z-index: 5; }
.brand { font-weight: 700; font-size: 17px; letter-spacing: 0.01em; white-space: nowrap; }
.brand span { color: var(--scarlet); }
.brand small { color: var(--dim); font-weight: 400; font-size: 12px; margin-left: 8px; text-transform: uppercase; letter-spacing: 0.08em; }
.side-toggle { display: inline-flex; border: 1px solid var(--line-2); border-radius: 6px; overflow: hidden; flex: 0 0 auto; }
.side-toggle button { border: 0; border-radius: 0; background: transparent; padding: 6px 14px; color: var(--dim); font-weight: 600; }
.side-toggle button + button { border-left: 1px solid var(--line-2); }
.side-toggle button.on { background: var(--scarlet); color: #fff; }
.side-toggle button.on[data-side="defense"] { background: #5a6270; }
.side-toggle button.on[data-side="all"] { background: var(--panel-2); color: var(--text); }
.side-tag { display: inline-block; margin-right: 6px; padding: 1px 5px; border-radius: 3px; font: 700 9.5px/1.4 var(--mono); letter-spacing: 0.06em; color: #fff; background: var(--scarlet); vertical-align: 2px; }
.side-tag.def { background: #5a6270; }
.dp-who .opp, .c-players .opp { color: var(--dim); }
.dp-who small, .c-players small { font: 700 9.5px/1 var(--mono); color: var(--pos); text-transform: uppercase; letter-spacing: 0.06em; margin-left: 1px; }
.players b.opp { color: var(--dim); font-weight: 500; }
.games { display: flex; gap: 4px; flex: 1; }
.games button { display: flex; flex-direction: column; align-items: flex-start; gap: 1px; background: transparent; border-color: transparent; padding: 4px 12px; line-height: 1.25; }
.games button small { color: var(--dim); font-family: var(--mono); font-size: 11px; }
.games button.on { background: var(--panel-2); border-color: var(--line-2); box-shadow: inset 0 -2px 0 var(--scarlet); }
.count { color: var(--dim); font-family: var(--mono); font-size: 12px; white-space: nowrap; }

/* ---- filters ---- */
.filters { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; padding: 10px 24px; border-bottom: 1px solid var(--line); }
.filters label { display: flex; align-items: center; gap: 6px; color: var(--dim); font-size: 12px; text-transform: uppercase; letter-spacing: 0.06em; }
.filters label select { text-transform: none; letter-spacing: 0; font-size: 13px; }
.filters label.check { text-transform: none; letter-spacing: 0; font-size: 13px; color: var(--text); }
.filters label.check small { color: var(--dim); }
.filters .search { margin-left: auto; }

/* ---- stage: player + drive panel ---- */
.stage { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 20px; padding: 20px 24px 8px; align-items: start; }
.screen { position: relative; aspect-ratio: 16 / 9; background: #000; border-radius: 8px; overflow: hidden; border: 1px solid var(--line); }
.screen video { width: 100%; height: 100%; display: block; background: #000; }
.noclip { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: var(--dim); font-size: 15px; background: repeating-linear-gradient(135deg, #14161a 0 12px, #101216 12px 24px); }

.playhead { padding: 14px 4px 4px; }
.ph-top { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.situation { font-size: 17px; font-weight: 600; }
.yards { font-size: 17px; font-weight: 600; }
.badge { display: inline-block; padding: 2px 8px; border-radius: 4px; font-size: 11px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; line-height: 1.5; border: 1px solid transparent; }
.badge.type.run { color: var(--run); border-color: var(--run); }
.badge.type.pass { color: var(--pass); border-color: var(--pass); }
.badge.type.fg { color: var(--fg); border-color: var(--fg); }
.badge.type.penalty { color: var(--pen); border-color: var(--pen); }
.badge.result { background: var(--panel-2); color: var(--dim); }
.badge.result.good { background: rgba(79, 209, 124, 0.15); color: var(--pos); }
.badge.result.bad { background: rgba(255, 107, 107, 0.15); color: var(--neg); }
.badge.result.td { background: var(--scarlet); color: #fff; }
.players { display: flex; gap: 22px; flex-wrap: wrap; margin-top: 10px; }
.players .role { display: block; color: var(--dim); font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.08em; }
.players b { font-weight: 600; font-size: 15px; }
.desc { margin-top: 10px; color: #c5c9cf; font-size: 13px; }
.ph-foot { margin-top: 8px; color: var(--dim); font-size: 12px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.ph-foot .sep { opacity: 0.5; }
.conf { color: var(--run); }

.transport { display: flex; align-items: center; gap: 8px; margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line); flex-wrap: wrap; }
.transport .spacer { flex: 1; }
.toggle { display: flex; align-items: center; gap: 5px; color: var(--dim); font-size: 12px; }
.speed button { padding: 5px 9px; border-radius: 0; margin-left: -1px; font-family: var(--mono); font-size: 12px; }
.speed button:first-child { border-radius: 6px 0 0 6px; margin-left: 0; }
.speed button:last-child { border-radius: 0 6px 6px 0; }
.speed button.on { background: var(--text); color: var(--bg); border-color: var(--text); }
.hint { color: var(--dim); font-size: 11px; margin-left: 6px; }
#share { margin-left: 6px; min-width: 118px; }

.drive-panel { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; display: flex; flex-direction: column; max-height: calc((100vw - 48px - 20px - 340px) * 9 / 16 + 190px); }
.dp-head { padding: 12px 14px; border-bottom: 1px solid var(--line); }
.dp-game { color: var(--dim); font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; }
.dp-drive { font-weight: 600; margin-top: 2px; }
.dp-list { list-style: none; margin: 0; padding: 0; overflow-y: auto; }
.dp-list li { display: grid; grid-template-columns: 22px 72px 1fr; gap: 10px; padding: 8px 12px; border-bottom: 1px solid var(--line); cursor: pointer; align-items: center; border-left: 3px solid transparent; }
.dp-list li:hover { background: var(--panel-2); }
.dp-list li.sel { background: var(--scarlet-dim); border-left-color: var(--scarlet); }
.dp-n { color: var(--dim); font-size: 12px; text-align: right; }
.dp-list img, .dp-nothumb { width: 72px; height: 40px; object-fit: cover; border-radius: 3px; background: #000; display: block; }
.dp-body { font-size: 12px; line-height: 1.5; min-width: 0; }
.dp-body .badge { font-size: 9.5px; padding: 0 5px; }
.dp-res { color: var(--dim); }
.dp-res.good { color: var(--pos); }
.dp-res.bad { color: var(--neg); }
.dp-res.td { color: var(--scarlet); font-weight: 700; }
.dp-who { color: var(--dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---- filmstrip ---- */
.filmstrip-wrap { padding: 12px 24px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); margin-top: 12px; background: var(--panel); }
.filmstrip { display: flex; gap: 8px; overflow-x: auto; scroll-behavior: smooth; padding-bottom: 6px; scrollbar-width: thin; }
.fs-item { flex: 0 0 auto; width: 148px; padding: 0; background: transparent; border: 2px solid transparent; border-radius: 6px; overflow: hidden; text-align: left; }
.fs-item img, .fs-noclip { width: 100%; height: 83px; object-fit: cover; display: block; background: #000; }
.fs-noclip { display: flex; align-items: center; justify-content: center; color: var(--dim); font-size: 11px; }
.fs-item:hover { border-color: var(--line-2); }
.fs-item.sel { border-color: var(--scarlet); }
.fs-cap { display: flex; flex-direction: column; gap: 1px; padding: 3px 6px; font-size: 10.5px; color: var(--dim); background: var(--panel-2); white-space: nowrap; }
.fs-cap .mono { font-size: 10.5px; }
.fs-r { font-weight: 600; text-transform: uppercase; }
.fs-r.good { color: var(--pos); }
.fs-r.bad { color: var(--neg); }
.fs-r.td { color: var(--scarlet); }

/* ---- table ---- */
.table-wrap { padding: 8px 24px 40px; }
table { width: 100%; border-collapse: collapse; }
thead th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--dim); font-weight: 600; padding: 10px 10px; border-bottom: 1px solid var(--line-2); position: sticky; top: 61px; background: var(--bg); z-index: 2; }
th.num, td.num { text-align: right; }
th.c-sort { cursor: pointer; user-select: none; }
th.c-sort:hover { color: var(--text); }
th.c-sort.on { color: var(--text); }
th .arrow { font-size: 9px; }
td { padding: 5px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; white-space: nowrap; }
.game-row td { padding: 26px 10px 8px; border-bottom: 1px solid var(--line-2); white-space: normal; }
.game-row .g-date { color: var(--dim); font-size: 12px; margin-right: 10px; }
.game-row .g-title { font-size: 18px; font-weight: 700; margin-right: 12px; }
.game-row .g-final { color: var(--dim); font-size: 13px; }
.game-row .g-note { display: block; color: var(--dim); font-size: 12px; margin-top: 4px; }
.drive-row td { padding: 12px 10px 6px; color: var(--dim); font-size: 12px; text-transform: uppercase; letter-spacing: 0.06em; border-bottom: 1px solid var(--line-2); }
.play-row { cursor: pointer; }
.play-row:hover td { background: var(--panel); }
.play-row.sel td { background: var(--scarlet-dim); }
.play-row.sel td:first-child { box-shadow: inset 3px 0 0 var(--scarlet); }
.play-row.noclip-row td { color: var(--dim); }
td.c-num { color: var(--dim); width: 44px; }
td.c-players { width: 22%; }
td.c-thumb { width: 72px; }
td.c-thumb img { width: 64px; height: 36px; object-fit: cover; border-radius: 3px; display: block; background: #000; }
.nothumb { display: inline-block; width: 64px; height: 36px; line-height: 36px; text-align: center; font-size: 10px; color: var(--dim); border: 1px dashed var(--line-2); border-radius: 3px; }
td.c-players { color: #c5c9cf; }
.flag { color: var(--run); margin-left: 6px; font-size: 12px; }
.empty { padding: 40px; text-align: center; color: var(--dim); }
.filter-toggle { display: none; }

@media (max-width: 1100px) {
  .stage { grid-template-columns: 1fr; }
  .drive-panel { max-height: 360px; }
  .filters .search { margin-left: 0; }
}

/* Touch layouts. Desktop rules above remain untouched. */
@media (max-width: 900px) {
  html, body { max-width: 100%; overflow-x: clip; }
  button, .games button, .toggle { min-height: 44px; touch-action: manipulation; }
  select, input[type="search"] { min-height: 44px; font-size: 16px !important; }
  .topbar { position: relative; display: block; padding: 10px 12px 8px; }
  .brand { font-size: 16px; padding: 0 4px 8px; }
  .brand small { float: right; margin-top: 3px; }
  .games { overflow-x: auto; gap: 5px; padding-bottom: 3px; scrollbar-width: none; scroll-snap-type: x proximity; -webkit-overflow-scrolling: touch; }
  .games::-webkit-scrollbar { display: none; }
  .games button { flex: 0 0 auto; align-items: center; min-width: 108px; padding: 5px 10px; scroll-snap-align: start; }
  .count { position: absolute; right: 16px; top: 15px; font-size: 11px; }
  .brand small { display: none; }
  .side-toggle { display: flex; width: 100%; margin: 0 0 8px; }
  .side-toggle button { flex: 1; min-height: 40px; }

  .filter-toggle { display: flex; align-items: center; justify-content: center; gap: 7px; width: calc(100% - 24px); margin: 8px 12px; background: var(--panel); }
  .filter-count { min-width: 20px; height: 20px; line-height: 20px; border-radius: 10px; background: var(--scarlet); font: 700 11px/20px var(--mono); }
  .filters { display: none; padding: 4px 12px 14px; gap: 10px; background: var(--panel); }
  .filters.mobile-open { display: grid; grid-template-columns: 1fr 1fr; }
  .filters label { display: grid; gap: 3px; }
  .filters label select, .filters .search, .filters .search input { width: 100%; min-width: 0; }
  .filters .search { grid-column: 1 / -1; }
  .filters label.check { display: flex; }

  .stage { padding: 0; gap: 0; }
  .player { min-width: 0; width: 100%; overflow: hidden; }
  .screen { border-radius: 0; border-width: 1px 0; }
  .noclip { padding: 24px; text-align: center; }
  .playhead { padding: 11px 12px 4px; }
  .ph-top { gap: 7px; }
  .situation, .yards { font-size: 14px; }
  .players { margin-top: 7px; gap: 16px; }
  .players b { font-size: 13px; }
  .desc { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 7px; }
  .ph-foot { white-space: nowrap; overflow: hidden; flex-wrap: nowrap; }
  .ph-foot #ph-drive { overflow: hidden; text-overflow: ellipsis; }
  .ph-foot #ph-yt, .ph-foot #ph-conf, .ph-foot .sep:last-of-type { display: none; }
  .transport { width: auto; margin: 8px 12px 0; padding: 8px 0 10px; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.35fr) minmax(0, 1fr); gap: 7px; }
  .transport > button { min-height: 46px; padding: 7px; }
  .transport .spacer, .hint { display: none; }
  #share { grid-column: 1 / -1; margin-left: 0; min-height: 42px; }
  .transport .toggle { justify-self: center; font-size: 11px; min-height: 36px; }
  .speed { justify-self: end; white-space: nowrap; }
  .speed button { width: 34px; min-height: 36px; padding: 4px 2px; }
  .drive-panel { display: none; }
  .filmstrip-wrap { display: none; }

  .table-wrap { padding: 4px 8px 32px; }
  table, tbody { display: block; width: 100%; }
  thead { display: none; }
  tbody { display: grid; gap: 8px; }
  tr.play-row { display: grid; grid-template-columns: 120px 60px 58px minmax(0, 1fr); grid-template-rows: 22px 26px 20px; align-items: center; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
  tr.play-row td { display: block; padding: 0 6px; border: 0; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 13px; }
  tr.play-row td.c-thumb { grid-column: 1; grid-row: 1 / 4; width: auto; padding: 0; }
  tr.play-row td.c-thumb img, tr.play-row .nothumb { width: 120px; height: 68px; min-height: 0; border-radius: 0; object-fit: cover; line-height: 68px; }
  tr.play-row td.c-num { display: none; }
  tr.play-row td:nth-child(3) { grid-column: 2; grid-row: 1; color: var(--dim); }
  tr.play-row td:nth-child(4) { grid-column: 3; grid-row: 1; }
  tr.play-row td:nth-child(5) { grid-column: 4; grid-row: 1; font-weight: 600; }
  tr.play-row td:nth-child(6) { display: none; }
  tr.play-row td:nth-child(7) { grid-column: 2 / 3; grid-row: 2; }
  tr.play-row td:nth-child(8) { grid-column: 3; grid-row: 2; text-align: left; font-size: 14px; font-weight: 600; }
  tr.play-row td:nth-child(9) { grid-column: 4; grid-row: 2; }
  tr.play-row td:nth-child(9) .badge { font-size: 9px; letter-spacing: 0.02em; padding: 2px 5px; }
  tr.play-row td.c-players { grid-column: 2 / 5; grid-row: 3; width: auto; color: var(--dim); font-size: 12px; }
  /* All mode: the 60px type cell can't fit "OFF RUN", so pin the side chip over the thumbnail instead. */
  tr.play-row { position: relative; }
  tr.play-row .side-tag { position: absolute; left: 4px; top: 4px; margin: 0; z-index: 1; box-shadow: 0 1px 3px rgba(0,0,0,.6); }
  .game-row, .drive-row { display: block; }
  .game-row td, .drive-row td { display: block; }
  .game-row td { padding: 18px 6px 6px; }
  .game-row .g-title { font-size: 16px; }
  .drive-row { position: sticky; top: 0; z-index: 3; }
  .drive-row td { padding: 9px 8px; background: rgba(17, 19, 22, 0.96); border-bottom-color: var(--scarlet); }
  .play-row.sel { border-color: rgba(224,40,30,.65); box-shadow: inset 3px 0 var(--scarlet); }
}

@media (max-width: 600px) and (orientation: portrait) {
  .stage, .player { display: contents; }
  .screen { position: sticky; top: 0; z-index: 4; box-shadow: 0 6px 18px rgba(0,0,0,.45); }
}

@media (max-width: 900px) and (orientation: landscape) and (max-height: 520px) {
  .topbar { display: flex; height: 52px; padding: 5px 10px; gap: 12px; }
  .brand { padding: 0; flex: 0 0 auto; }
  .games { flex: 1; }
  .games button { min-height: 40px; min-width: 100px; }
  .side-toggle { width: auto; margin: 0; }
  .side-toggle button { flex: 0 0 auto; padding: 0 10px; }
  .count, .filter-toggle, .filters { display: none !important; }
  .stage { display: grid; grid-template-columns: 58% 42%; height: calc(100vh - 52px); align-items: stretch; }
  .player { min-width: 0; overflow-y: auto; }
  .screen { border-radius: 0; }
  .playhead { padding: 7px 10px 2px; }
  .players, .desc, .ph-foot { display: none; }
  .transport { margin: 5px 8px; padding: 5px 0; }
  .transport .toggle, .transport .speed { display: none; }
  .drive-panel { display: flex; border-radius: 0; border-width: 0 0 0 1px; max-height: none; height: 100%; }
  .dp-head { padding: 8px 10px; }
  .dp-list li { min-height: 72px; grid-template-columns: 18px 82px 1fr; padding: 6px 8px; }
  .dp-list img, .dp-nothumb { width: 82px; height: 46px; }
  .table-wrap { padding-top: 10px; }
}
