/* Sideline. The brand green (#0b5d3b) is the same green the invite emails use.
   Every color is a token so light and dark stay in sync — nothing below this block
   should hardcode a color. Light is the default; dark follows the device unless the
   person picked a theme on their profile (html[data-theme]). */
:root {
  color-scheme: light;
  --bg: #f4f5f7;
  --bg-2: #ffffff;
  --bg-3: #eceef1;
  --bg-3-hover: #e0e4ea;
  --line: #e3e6ea;
  --text: #1d2330;
  --muted: #5f6b7a;
  --accent: #0b5d3b;
  --accent-soft: rgba(11, 93, 59, 0.08);
  --primary: #0b5d3b;
  --primary-hover: #084a2f;
  --on-primary: #ffffff;
  /* Gold reads as the player color. As text it has to be darker than the fill to stay legible. */
  --gold: #9a6200;
  --gold-fill: #ffb545;
  --gold-soft-bg: #fdf3e2;
  --gold-soft-line: #e6cb9b;
  --ok: #15734a;
  --err: #c62828;
  --err-soft: rgba(198, 40, 40, 0.1);
  --ok-soft: rgba(21, 115, 74, 0.1);
  --gold-msg-soft: rgba(154, 98, 0, 0.12);
  --topbar: #0b5d3b;
  --topbar-text: #ffffff;
  --topbar-muted: rgba(255, 255, 255, 0.82);
  --topbar-hover: rgba(255, 255, 255, 0.14);
  --topbar-line: rgba(255, 255, 255, 0.3);
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.06);
}
/* Dark has to lighten the green: #0b5d3b on a dark page is only 2.4:1, too dim to read. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0e1411;
    --bg-2: #151d19;
    --bg-3: #1d2722;
    --bg-3-hover: #26332c;
    --line: #2a3630;
    --text: #e8ede9;
    --muted: #93a19a;
    --accent: #4cc38a;
    --accent-soft: rgba(76, 195, 138, 0.12);
    --primary: #147a4c;
    --primary-hover: #1a8f5a;
    --gold: #ffb545;
    --gold-soft-bg: #2b2313;
    --gold-soft-line: #6b5320;
    --ok: #3ccf7a;
    --err: #ff6b6b;
    --err-soft: rgba(255, 107, 107, 0.12);
    --ok-soft: rgba(60, 207, 122, 0.12);
    --gold-msg-soft: rgba(255, 181, 69, 0.12);
    --shadow: none;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0e1411;
  --bg-2: #151d19;
  --bg-3: #1d2722;
  --bg-3-hover: #26332c;
  --line: #2a3630;
  --text: #e8ede9;
  --muted: #93a19a;
  --accent: #4cc38a;
  --accent-soft: rgba(76, 195, 138, 0.12);
  --primary: #147a4c;
  --primary-hover: #1a8f5a;
  --gold: #ffb545;
  --gold-soft-bg: #2b2313;
  --gold-soft-line: #6b5320;
  --ok: #3ccf7a;
  --err: #ff6b6b;
  --err-soft: rgba(255, 107, 107, 0.12);
  --ok-soft: rgba(60, 207, 122, 0.12);
  --gold-msg-soft: rgba(255, 181, 69, 0.12);
  --shadow: none;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; }
/* The full-width player is 100vw, which is wider than the page when a classic scrollbar takes
   up room. `clip` trims that overhang without making a scroll container, which `hidden` would
   do — and that would break the sticky top bar. */
html { overflow-x: clip; }
/* Phones have no hover, so body links carry their underline all the time. */
a { color: var(--accent); text-decoration: underline; text-underline-offset: 2px; text-decoration-thickness: 1px; }
a:hover { text-decoration-thickness: 2px; }
a.danger { color: var(--err); }
button { font: inherit; color: var(--text); background: var(--bg-3); border: 1px solid var(--line); border-radius: 8px; padding: 8px 14px; cursor: pointer; }
button:hover { background: var(--bg-3-hover); }
button.primary { background: var(--primary); border-color: var(--primary); color: var(--on-primary); font-weight: 600; }
button.primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
button.ghost { background: transparent; }
button.ghost:hover { background: var(--bg-3); }
button.small { padding: 5px 10px; font-size: 13px; }
button.danger { color: var(--err); }
button.danger:hover { background: var(--err-soft); }
button:disabled { opacity: 0.5; cursor: default; }
a.primary { display: inline-block; background: var(--primary); color: var(--on-primary); border-radius: 8px; padding: 8px 14px; font-weight: 600; text-decoration: none; }
a.primary:hover { background: var(--primary-hover); }
a.small { display: inline-block; font: inherit; background: var(--bg-3); border: 1px solid var(--line); border-radius: 8px; padding: 5px 10px; font-size: 13px; color: var(--text); text-decoration: none; }
a.small:hover { background: var(--bg-3-hover); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
input, select, textarea { font: inherit; color: var(--text); background: var(--bg-2); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: transparent; }
input:disabled, select:disabled { color: var(--muted); background: var(--bg-3); cursor: default; }
select.mini { padding: 3px 6px; font-size: 12px; }
.muted { color: var(--muted); }
.spacer { flex: 1; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

.topbar {
  display: flex; align-items: center; gap: 18px; background: var(--topbar); color: var(--topbar-text);
  padding: 10px max(20px, env(safe-area-inset-right)) 10px max(20px, env(safe-area-inset-left));
  position: sticky; top: 0; z-index: 10;
}
.brand { font-weight: 800; letter-spacing: 0.08em; color: var(--topbar-text); font-size: 18px; text-decoration: none; text-transform: uppercase; white-space: nowrap; }
.brand:hover { text-decoration: none; }
/* The bar stays exactly one row tall at every width: when the links stop fitting they scroll
   sideways instead of wrapping and pushing the page down. */
#nav { display: flex; gap: 2px; flex-wrap: nowrap; align-items: center; min-width: 0; overflow-x: auto; scrollbar-width: none; }
#nav::-webkit-scrollbar { display: none; }
#nav a { white-space: nowrap; flex: 0 0 auto; }
#who, #btn-signout { flex: 0 0 auto; white-space: nowrap; }
#nav a, #who a { color: var(--topbar-muted); padding: 6px 10px; border-radius: 6px 6px 0 0; border-bottom: 3px solid transparent; text-decoration: none; }
#nav a:hover, #who a:hover { color: var(--topbar-text); background: var(--topbar-hover); text-decoration: none; }
#nav a.active, #who a.active { color: var(--topbar-text); font-weight: 600; border-bottom-color: var(--topbar-text); }
#nav a.team-switch { color: var(--topbar-text); font-weight: 700; }
#nav .caret { font-size: 11px; margin-left: 2px; opacity: 0.8; }
.nav-sep { width: 1px; height: 18px; background: var(--topbar-line); margin: 0 6px; }
#who a { display: inline-block; max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; vertical-align: middle; }
#btn-signout { background: transparent; color: var(--topbar-text); border-color: var(--topbar-line); }
#btn-signout:hover { background: var(--topbar-hover); }

.profile { display: flex; flex-direction: column; gap: 12px; max-width: 420px; }
.profile label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
.profile input { font-size: 15px; }
.profile .hint { font-size: 11px; color: var(--muted); opacity: 0.8; }
.my-players + .my-players { margin-top: 10px; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg button { border: 0; border-radius: 0; background: var(--bg-2); padding: 7px 14px; font-size: 14px; }
.seg button + button { border-left: 1px solid var(--line); }
.seg button.on { background: var(--primary); color: var(--on-primary); font-weight: 600; }

.members table { width: 100%; border-collapse: collapse; font-size: 14px; }
.members th, .members td { padding: 8px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.members th { color: var(--muted); font-weight: 600; font-size: 12px; }
.status { display: inline-block; font-size: 12px; font-weight: 600; border-radius: 999px; padding: 2px 8px; margin-right: 4px; }
.status.active { color: var(--ok); background: var(--ok-soft); }
.status.invited { color: var(--gold); background: var(--gold-msg-soft); }
.status.off { color: var(--err); background: var(--err-soft); }

.app { max-width: 1200px; margin: 0 auto; padding: 20px 20px calc(60px + env(safe-area-inset-bottom)); }
h1 { font-size: 24px; margin: 0 0 4px; }
h2 { font-size: 18px; margin: 24px 0 10px; }
.sub { color: var(--muted); margin-bottom: 20px; }
.card { background: var(--bg-2); border: 1px solid var(--line); border-radius: 12px; padding: 16px; box-shadow: var(--shadow); }
.card + .card { margin-top: 12px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.center { text-align: center; padding: 60px 20px; }
.center h1 { font-size: 34px; }
.center p { color: var(--muted); max-width: 480px; margin: 10px auto 24px; }

.game-card { display: block; color: var(--text); text-decoration: none; }
.game-card:hover { text-decoration: none; border-color: var(--accent); }
.game-card .t { font-weight: 700; font-size: 16px; }
.game-card .m { color: var(--muted); font-size: 13px; margin-top: 4px; }

.clip { background: var(--bg-2); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; display: flex; flex-direction: column; box-shadow: var(--shadow); }
.clip video { width: 100%; aspect-ratio: 16 / 9; background: #000; display: block; }
.clip .body { padding: 10px 12px 12px; display: flex; flex-direction: column; gap: 8px; }
.clip .title { font-weight: 700; display: flex; align-items: center; gap: 8px; }
.clip .title input { flex: 1; padding: 4px 8px; }
.photo { background: var(--bg-2); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; display: flex; flex-direction: column; box-shadow: var(--shadow); }
.photo img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; background: #000; display: block; }
.photo .body { padding: 10px 12px 12px; display: flex; flex-direction: column; gap: 6px; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tag { display: inline-flex; align-items: center; gap: 4px; background: var(--bg-3); border: 1px solid var(--line); border-radius: 999px; padding: 3px 10px 3px 8px; font-size: 13px; }
.tag .num { font-weight: 800; color: var(--gold); }
.tag .x { color: var(--muted); cursor: pointer; margin-left: 2px; }
.tag .x:hover { color: var(--err); }
.tag.award { border-color: var(--gold-soft-line); background: var(--gold-soft-bg); }
.playtype { display: inline-block; background: var(--accent-soft); border: 1px solid var(--accent); color: var(--accent); border-radius: 999px; padding: 1px 10px; font-size: 12px; font-weight: 700; }
.tagger { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; padding-top: 6px; border-top: 1px dashed var(--line); }
.tagger select { padding: 4px 8px; font-size: 13px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { border: 1px solid var(--line); background: var(--bg-3); border-radius: 6px; padding: 4px 10px; font-size: 13px; cursor: pointer; font-weight: 700; color: var(--text); }
.chip:hover { background: var(--bg-3-hover); }
.chip.on { background: var(--gold-fill); color: #000; border-color: var(--gold-fill); }

.roster table, .awards table { width: 100%; border-collapse: collapse; }
.roster td, .roster th, .awards td, .awards th { padding: 6px 8px; border-bottom: 1px solid var(--line); text-align: left; }
.roster input { width: 100%; }
.awards th.n { text-align: center; }
.awards td.n { text-align: center; font-variant-numeric: tabular-nums; }
.awards td.n.hot { color: var(--gold); font-weight: 800; }

.drop { border: 2px dashed var(--line); border-radius: 12px; padding: 40px 20px; text-align: center; color: var(--muted); cursor: pointer; }
.drop.over { border-color: var(--accent); color: var(--text); background: var(--accent-soft); }
.uploads { margin-top: 12px; display: flex; flex-direction: column; gap: 6px; }
.upload { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; font-size: 13px; }
.upload .bar { grid-column: 1 / -1; height: 5px; background: var(--bg-3); border-radius: 3px; overflow: hidden; }
.upload .bar > div { height: 100%; background: var(--primary); width: 0; transition: width 0.2s; }
.upload .ok { color: var(--ok); }
.upload .err { color: var(--err); }

/* Film always sits on black, in either theme, and gets the whole window width — a play is
   easier to read big. The height cap leaves room for the two control rows underneath, so
   Prev/Next and the zoom row never fall below the fold while you're working through a game. */
.player-wrap {
  background: #000; overflow: hidden; position: relative;
  width: 100vw; margin-left: calc(50% - 50vw); border-radius: 0;
}
.game-bar { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px; margin: 0 0 10px; font-size: 14px; }
.game-bar h1 { font-size: 18px; margin: 0; }

/* Clip film: the marks bar under the player is the whole game at a glance. */
.marks { position: relative; height: 26px; background: var(--bg-3); border: 1px solid var(--line); border-radius: 6px; margin: 10px 0; cursor: pointer; overflow: hidden; }
.marks .mark { position: absolute; top: 0; bottom: 0; background: var(--accent); opacity: 0.55; border-radius: 2px; }
.marks .mark.on { opacity: 1; background: var(--gold-fill); }
.marks .playhead { position: absolute; top: -2px; bottom: -2px; width: 2px; background: var(--text); left: 0; }
input.mini { width: 56px; padding: 2px 6px; font-size: 13px; }
/* Explicit color: inside a primary button `inherit` would be white on the white key cap. */
kbd { font: 11px ui-monospace, SFMono-Regular, Menlo, monospace; background: var(--bg); border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 4px; padding: 1px 5px; margin-left: 6px; color: var(--text); }
#film-pick { margin-bottom: 12px; }
.card.warn { border-color: var(--gold-soft-line); background: var(--gold-soft-bg); margin-bottom: 12px; font-size: 14px; }
.player-zoom { transform-origin: center center; transition: transform 0.1s ease-out; }
/* Safari/WebKit has a long-standing bug where a hardware-decoded <video> renders black once a
   CSS transform is applied to it or an ancestor, unless the video is forced onto its own GPU
   compositing layer first. translateZ(0) + backface-visibility is the standard workaround. */
.player-wrap video {
  width: 100%; max-height: max(260px, calc(100vh - 215px)); display: block; background: #000;
  transform: translateZ(0); -webkit-transform: translateZ(0);
  backface-visibility: hidden; -webkit-backface-visibility: hidden;
}
.player-wrap.zoomed video { cursor: crosshair; }
.player-nav { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 10px 0; }
.zoom-nav { display: flex; align-items: center; gap: 8px; margin-bottom: 14px; flex-wrap: wrap; }
.zoom-nav #zoom-level { min-width: 44px; text-align: center; font-variant-numeric: tabular-nums; }
.zoom-nav .nav-gap { width: 1px; height: 20px; background: var(--line); margin: 0 4px; }
.zoom-nav select.small { padding: 4px 8px; font-size: 13px; }
.clip-panel .title { font-weight: 700; display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.clip-panel .title input { flex: 1; padding: 4px 8px; }
.clip-list { margin-top: 12px; display: flex; flex-direction: column; gap: 6px; max-height: 60vh; overflow-y: auto; }
.clip-row { display: flex; align-items: flex-start; gap: 10px; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg-2); cursor: pointer; }
.clip-row:hover { border-color: var(--accent); }
.clip-row.active { border-color: var(--accent); background: var(--accent-soft); }
.clip-row .idx { width: 22px; flex-shrink: 0; font-variant-numeric: tabular-nums; padding-top: 2px; }
.clip-row .rt { flex: 1; min-width: 0; }
.clip-row .rt .title { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.clip-row .rt .tags { margin-top: 4px; }

.player-head { display: flex; align-items: baseline; gap: 12px; }
.player-head .num { font-size: 40px; font-weight: 900; color: var(--gold); }
.badges { display: flex; gap: 8px; flex-wrap: wrap; margin: 10px 0 20px; }
.badge { background: var(--gold-soft-bg); border: 1px solid var(--gold-soft-line); border-radius: 10px; padding: 8px 12px; font-size: 14px; }
.badge b { color: var(--gold); }

.viewas { background: var(--gold-fill); color: #000; padding: 8px 20px; display: flex; gap: 12px; align-items: center; font-weight: 600; }
.viewas button { background: #000; color: var(--gold-fill); border-color: #000; padding: 4px 10px; }

.admin table { width: 100%; border-collapse: collapse; font-size: 14px; }
.admin th, .admin td { padding: 8px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.admin td.actions { white-space: nowrap; }
.admin td.actions button { margin: 0 2px 4px 0; }
.admin .teamtags { display: flex; flex-wrap: wrap; gap: 4px; }
.admin .teamtags .tag { cursor: default; }
.admin .status-off { color: var(--err); }
.secret { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; background: var(--bg); border: 1px solid var(--gold-soft-line); border-radius: 8px; padding: 10px 12px; margin-top: 8px; user-select: all; }

.toast {
  position: fixed; left: 50%; bottom: calc(30px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: var(--bg-2); color: var(--text); border: 1px solid var(--line); border-radius: 8px;
  padding: 10px 16px; z-index: 40; box-shadow: 0 6px 20px rgba(0, 0, 0, 0.18); max-width: calc(100vw - 32px);
}
.toast.ok { border-color: var(--ok); }
.toast.err { border-color: var(--err); }

/* Fingers, not cursors: 44px is the smallest reliable tap target, and tagging a clip or a photo
   is mostly done one-handed on a phone at the field. */
@media (pointer: coarse) {
  button, a.small, a.primary { min-height: 44px; }
  button.small, a.small { padding: 8px 12px; }
  .chip { min-height: 40px; display: inline-flex; align-items: center; padding: 6px 12px; }
  .tag { padding: 6px 12px; }
  .admin td.actions button { min-height: 38px; }
}

@media (max-width: 700px) {
  .app { padding: 14px 14px calc(60px + env(safe-area-inset-bottom)); }
  .topbar { gap: 10px; padding: 8px max(14px, env(safe-area-inset-right)) 0 max(14px, env(safe-area-inset-left)); flex-wrap: wrap; }
  /* Phones get the links on their own swipeable row under the brand, so the name and Sign out
     keep their space instead of squeezing the nav to nothing. */
  #nav { order: 3; width: 100%; -webkit-overflow-scrolling: touch; }
  #who a { max-width: 130px; }
  .nav-sep { display: none; }
  /* iOS zooms the whole page in whenever a focused field is under 16px. */
  input, select, textarea, .tagger select, .zoom-nav select.small, .clip .title input, .clip-panel .title input, .mini { font-size: 16px; }
  .profile input { font-size: 16px; }
  .center { padding: 40px 10px; }
  .center h1 { font-size: 28px; }
}
.no-preview { width: 100%; aspect-ratio: 4 / 3; display: flex; align-items: center; justify-content: center; padding: 16px; text-align: center; font-size: 13px; color: var(--muted); background: var(--bg); }
