/* WrestleSmart — dark, high-contrast UI for gyms and tournament halls. */
:root {
  --bg: #0d141c;
  --surface: #141e29;
  --surface-2: #1b2734;
  --surface-3: #22303f;
  --line: #273546;
  --line-strong: #36475b;
  --text: #e9eff5;
  --muted: #8d9db0;
  --us: #3d95e3;
  --us-ink: #9cc8f2;
  --us-bg: rgba(61, 149, 227, 0.14);
  --opp: #e8665e;
  --opp-ink: #f3a7a2;
  --opp-bg: rgba(232, 102, 94, 0.14);
  --clock: #f2b43a;
  --ok: #3fbf8a;
  --warn: #f2b43a;
  --danger: #e8665e;
  --focus: #9cc8f2;
  --radius: 10px;
  --radius-sm: 6px;
  --font: 'Barlow', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --font-cond: 'Barlow Condensed', 'Arial Narrow', system-ui, sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
a { color: var(--us-ink); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { font-family: var(--font-cond); font-weight: 600; letter-spacing: 0.01em; margin: 0 0 0.5rem; line-height: 1.15; }
h1 { font-size: 2rem; }
h2 { font-size: 1.3rem; }
h3 { font-size: 1.05rem; margin-top: 1rem; }
p { margin: 0 0 0.75rem; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.muted { color: var(--muted); }
.small { font-size: 0.875rem; }
.strong { font-weight: 600; }
.danger { color: var(--danger) !important; }
[hidden] { display: none !important; }
.icon { flex: none; }

/* ------------------------------------------------ layout */
#app { min-height: 100%; }
.layout-shell { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.layout-full { min-height: 100vh; }
.layout-auth { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.main { padding: 28px 32px 64px; max-width: 1280px; width: 100%; outline: none; }

.sidebar {
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column; gap: 20px;
  padding: 20px 14px; border-right: 1px solid var(--line); background: var(--surface);
}
.brand { display: flex; align-items: center; gap: 10px; padding: 0 6px; }
.brand-mark { width: 36px; height: 36px; flex: none; display: block; }
.brand-mark svg { display: block; }
.brand-lg .brand-mark { width: 52px; height: 52px; }
.brand-name { font-family: var(--font-cond); font-size: 1.35rem; font-weight: 700; letter-spacing: 0.02em; }
.brand-lg .brand-name { font-size: 1.9rem; }
.team-name, .team-switch { font-size: 0.85rem; color: var(--muted); }
.team-switch { background: transparent; border: 0; padding: 0; width: auto; min-height: 0; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-item { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: var(--radius-sm); color: var(--muted); font-weight: 500; }
.nav-item:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.nav-item.active { background: var(--surface-3); color: var(--text); box-shadow: inset 3px 0 0 var(--us); }
.sidebar-foot { margin-top: auto; display: flex; flex-direction: column; gap: 6px; padding: 0 6px; }
.whoami { font-size: 0.85rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.sync, .live-sync { display: inline-flex; align-items: center; gap: 6px; font-size: 0.85rem; padding: 4px 8px; border-radius: 999px; background: var(--surface-2); width: fit-content; }
.sync-ok { color: var(--ok); }
.sync-pending { color: var(--warn); }
.sync-error { color: var(--danger); }
.sync-local { color: var(--muted); }

@media (max-width: 860px) {
  .layout-shell { grid-template-columns: 1fr; }
  .main { padding: 18px 16px 96px; }
  .sidebar {
    position: fixed; top: auto; bottom: 0; left: 0; right: 0; height: auto; z-index: 20;
    flex-direction: row; padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); border-right: 0; border-top: 1px solid var(--line);
  }
  .brand, .sidebar-foot .whoami { display: none; }
  .nav { flex-direction: row; flex: 1; justify-content: space-around; }
  .nav-item { flex-direction: column; gap: 2px; padding: 6px 4px; font-size: 0.68rem; flex: 1; align-items: center; text-align: center; }
  .nav-item.active { box-shadow: inset 0 3px 0 var(--us); }
  .sidebar-foot { position: fixed; top: 8px; right: 10px; margin: 0; padding: 0; }
  h1 { font-size: 1.6rem; }
}

/* ------------------------------------------------ page parts */
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px 24px; margin-bottom: 20px; }
.page-sub { margin: 0; max-width: 70ch; }
.page-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.back { display: inline-flex; align-items: center; gap: 4px; color: var(--muted); margin-bottom: 8px; font-size: 0.9rem; }
.section-title { display: flex; gap: 8px; align-items: baseline; }

.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; min-width: 0; }
.panel-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 8px; flex-wrap: wrap; }
.panel-head h2 { margin: 0; }
.panel-live { border-color: var(--clock); margin-bottom: 16px; }
.dash-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; margin-top: 16px; }
.settings-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.span-2 { grid-column: 1 / -1; }
@media (max-width: 960px) { .dash-grid, .settings-grid { grid-template-columns: 1fr; } }

.tiles { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.tile { background: var(--surface); padding: 16px 18px; }
.tile-value { font-family: var(--font-cond); font-size: 2.1rem; font-weight: 600; line-height: 1.1; font-variant-numeric: tabular-nums; }
.tile-label { color: var(--text); font-weight: 500; }
.tile-sub { font-size: 0.82rem; }
@media (max-width: 700px) { .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); } .tile-value { font-size: 1.7rem; } }

.list { display: flex; flex-direction: column; }
.list-row { display: flex; align-items: center; gap: 12px; padding: 10px 4px; border-top: 1px solid var(--line); color: var(--text); min-height: 48px; }
.list-row:first-child { border-top: 0; }
a.list-row:hover { background: var(--surface-2); text-decoration: none; }
.list-date { color: var(--muted); width: 56px; flex: none; font-size: 0.9rem; font-variant-numeric: tabular-nums; }
.list-main { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.tp { white-space: nowrap; }

.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.table th { text-align: left; color: var(--muted); font-weight: 500; font-size: 0.85rem; padding: 8px; border-bottom: 1px solid var(--line-strong); white-space: nowrap; }
.table td { padding: 10px 8px; border-bottom: 1px solid var(--line); }
.table .num { text-align: right; }
.table-hover tbody tr { cursor: pointer; }
.table-hover tbody tr:hover { background: var(--surface-2); }
.table-compact td { padding: 6px 8px; }

.chip { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 999px; background: var(--surface-3); font-size: 0.82rem; white-space: nowrap; border: 1px solid transparent; color: var(--text); }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip-win { background: var(--us-bg); border-color: var(--us); color: var(--us-ink); }
.chip-loss { background: var(--opp-bg); border-color: var(--opp); color: var(--opp-ink); }
.chip-draw, .chip-muted { color: var(--muted); }
.chip-live { color: var(--clock); border-color: var(--clock); background: transparent; }
.chip-ok { color: var(--ok); }
.chip-flag { color: var(--clock); }
.chip-time { cursor: pointer; font-variant-numeric: tabular-nums; border-color: var(--line-strong); font: inherit; font-size: 0.82rem; }
.chip-time:hover { border-color: var(--us); }

.state { padding: 24px 8px; text-align: center; }
.state-title { font-weight: 600; margin-bottom: 4px; }
.state-loading { display: flex; gap: 10px; justify-content: center; align-items: center; color: var(--muted); }
.spinner { width: 18px; height: 18px; border: 2px solid var(--line-strong); border-top-color: var(--us); border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 3s; } }

.callout { background: var(--surface-2); border-left: 3px solid var(--clock); padding: 10px 12px; border-radius: var(--radius-sm); margin: 0 0 12px; font-size: 0.92rem; }
.banner { padding: 8px 12px; border-radius: var(--radius-sm); }
.banner-warn { background: rgba(242, 180, 58, 0.14); color: var(--clock); }

/* ------------------------------------------------ controls */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 42px; padding: 8px 14px; border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong); background: var(--surface-2); color: var(--text);
  font: inherit; font-weight: 500; cursor: pointer; text-decoration: none; white-space: nowrap;
}
.btn:hover { background: var(--surface-3); text-decoration: none; }
.btn:disabled { opacity: 0.5; cursor: default; }
.btn-primary { background: var(--us); border-color: var(--us); color: #06121f; font-weight: 600; }
.btn-primary:hover { background: #5aa7ea; }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #1f0806; font-weight: 600; }
.btn-danger-ghost { color: var(--opp-ink); }
.btn-sm { min-height: 34px; padding: 4px 10px; font-size: 0.9rem; }
.btn-lg { min-height: 52px; padding: 10px 18px; font-size: 1.05rem; }
.btn-link { background: none; border: 0; color: var(--us-ink); padding: 4px 0; font: inherit; cursor: pointer; }
.btn-link:hover { text-decoration: underline; }
.btn-icon { display: inline-grid; place-items: center; width: 42px; height: 42px; border-radius: var(--radius-sm); background: transparent; border: 0; color: var(--text); cursor: pointer; }
.btn-icon:hover { background: var(--surface-2); }

input, select, textarea {
  width: 100%; min-height: 42px; padding: 8px 10px; border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong); background: var(--bg); color: var(--text); font: inherit;
}
textarea { resize: vertical; min-height: 60px; }
input[type=checkbox] { width: 20px; height: 20px; min-height: 0; accent-color: var(--us); }
input[type=date] { min-width: 0; }
.input-sm { max-width: 110px; }
.field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.field-label { font-size: 0.88rem; color: var(--muted); font-weight: 500; }
.field-hint { font-size: 0.8rem; color: var(--muted); }
.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 16px; }
.form-grid > .form-msg, .form-grid > .fieldset { grid-column: 1 / -1; }
.fieldset { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 12px; display: flex; flex-direction: column; gap: 12px; margin: 0; }
.fieldset legend { color: var(--muted); padding: 0 6px; font-size: 0.88rem; }
@media (max-width: 640px) { .form-grid { grid-template-columns: 1fr; } }
.form-msg { color: var(--opp-ink); min-height: 0; margin: 0; }
.form-msg:empty { display: none; }
.form-msg.ok { color: var(--ok); }
.row { display: flex; gap: 10px; align-items: flex-end; }
.row.wrap { flex-wrap: wrap; }
.row > .field { flex: 1; }
.row-end { display: flex; gap: 10px; justify-content: flex-end; align-items: center; flex-wrap: wrap; margin-top: 8px; }
.row-between { display: flex; gap: 10px; justify-content: space-between; align-items: center; }
.filters { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.filters > * { width: auto; flex: 0 1 180px; }
.filters input[type=search] { flex: 1 1 200px; }
ul.plain { list-style: none; padding: 0; margin: 0 0 12px; display: flex; flex-direction: column; gap: 6px; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 14px; overflow-x: auto; }
.tab { background: none; border: 0; color: var(--muted); padding: 10px 14px; font: inherit; cursor: pointer; border-bottom: 2px solid transparent; white-space: nowrap; }
.tab.active { color: var(--text); border-bottom-color: var(--us); }
details summary { cursor: pointer; color: var(--muted); padding: 6px 0; }
.danger-zone { margin-top: 12px; border-top: 1px solid var(--line); padding-top: 8px; }
.invite-code { display: flex; gap: 10px; align-items: center; margin: 10px 0; }
.invite-code code { font-size: 1.6rem; letter-spacing: 0.14em; background: var(--bg); padding: 6px 12px; border-radius: var(--radius-sm); border: 1px dashed var(--line-strong); }

/* ------------------------------------------------ auth */
.auth-card { width: min(440px, 100%); background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 28px; display: flex; flex-direction: column; gap: 14px; }
.auth-wide { width: min(760px, 100%); }
.onboard-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.onboard-grid .panel { display: flex; flex-direction: column; gap: 12px; background: var(--bg); }
@media (max-width: 640px) { .onboard-grid { grid-template-columns: 1fr; } }

/* ------------------------------------------------ dialogs & toasts */
.modal { border: 1px solid var(--line-strong); border-radius: 14px; background: var(--surface); color: var(--text); padding: 0; width: min(520px, calc(100vw - 24px)); max-height: calc(100vh - 32px); }
.modal-wide { width: min(780px, calc(100vw - 24px)); }
.modal::backdrop { background: rgba(4, 8, 12, 0.7); }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 14px 16px 0 20px; }
.modal-head h2 { margin: 0; }
.modal-body { padding: 12px 20px 20px; }
.choice-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.choice-grid .btn { flex-direction: column; gap: 2px; white-space: normal; }
.choice-grid small { color: var(--muted); font-weight: 400; }
.btn-primary small { color: #0b2340; }
#toasts { position: fixed; z-index: 100; left: 50%; transform: translateX(-50%); bottom: calc(84px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 8px; width: min(480px, calc(100vw - 24px)); pointer-events: none; }
.toast { display: flex; gap: 10px; align-items: flex-start; background: var(--surface-3); border: 1px solid var(--line-strong); padding: 10px 14px; border-radius: var(--radius-sm); box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4); pointer-events: auto; }
.toast-ok .icon { color: var(--ok); }
.toast-error { border-color: var(--danger); }
.toast-error .icon { color: var(--danger); }
.uploads { position: fixed; z-index: 90; right: 16px; bottom: calc(84px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 8px; width: min(380px, calc(100vw - 32px)); }
.uploads:empty { display: none; }
.upload { background: var(--surface-3); border: 1px solid var(--line-strong); border-radius: var(--radius-sm); padding: 10px 12px; display: flex; flex-direction: column; gap: 6px; font-size: 0.9rem; }
.upload-row { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.upload progress { width: 100%; accent-color: var(--us); }

/* ------------------------------------------------ profile, match, notes */
.profile-head { display: flex; gap: 20px; align-items: center; flex-wrap: wrap; margin-bottom: 20px; }
.profile-id { flex: 1; min-width: 200px; }
.profile-id h1 { margin-bottom: 6px; }
.avatar { width: 48px; height: 48px; border-radius: 50%; background: var(--surface-3); display: grid; place-items: center; font-family: var(--font-cond); font-weight: 600; object-fit: cover; }
.avatar-lg { width: 84px; height: 84px; font-size: 1.8rem; }
.match-summary { margin-bottom: 0; }
.summary-score { display: grid; grid-template-columns: 1fr auto 1fr; gap: 16px; align-items: center; margin-bottom: 12px; }
.side { display: flex; flex-direction: column; gap: 2px; }
.side-opp { text-align: right; align-items: flex-end; }
.side-name { font-weight: 600; }
.side-us .side-name { color: var(--us-ink); }
.side-opp .side-name { color: var(--opp-ink); }
.side-score { font-family: var(--font-cond); font-size: 3rem; font-weight: 700; line-height: 1; font-variant-numeric: tabular-nums; }
.summary-mid { text-align: center; display: flex; flex-direction: column; gap: 4px; align-items: center; }
.log { list-style: none; margin: 0 0 12px; padding: 0; display: flex; flex-direction: column; }
.log li { display: flex; gap: 10px; align-items: center; padding: 7px 0; border-top: 1px solid var(--line); font-size: 0.95rem; }
.log li:first-child { border-top: 0; }
.log-time { color: var(--muted); font-variant-numeric: tabular-nums; width: 72px; flex: none; font-size: 0.85rem; }
.log-text { flex: 1; min-width: 0; }
.log-text.is-us::before, .log-text.is-opp::before { content: ''; display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 8px; vertical-align: 1px; }
.log-text.is-us::before { background: var(--us); }
.log-text.is-opp::before { background: var(--opp); }
.log-by { font-size: 0.82rem; }
.log-void .log-text { text-decoration: line-through; color: var(--muted); }
.log-void .log-text::before { opacity: 0.4; }
.log-video li { align-items: flex-start; }
.tl-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.tl-meta { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.log-video li.is-override .chip-time { border-color: var(--clock); }
.history { padding-left: 18px; display: flex; flex-direction: column; gap: 6px; }
.notes { display: flex; flex-direction: column; gap: 10px; margin-top: 12px; }
.note { border-left: 3px solid var(--line-strong); padding: 4px 0 4px 12px; }
.note-flag { border-left-color: var(--clock); }
.note-meta { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 4px; }
.note-body { white-space: pre-wrap; margin: 0; }
.note-actions { display: flex; gap: 14px; font-size: 0.85rem; }
.note-form { display: flex; flex-direction: column; gap: 8px; }
.note-form .row { align-items: center; flex-wrap: wrap; }
.note-form .row input:not([type=checkbox]) { flex: 1 1 140px; width: auto; }

/* ------------------------------------------------ film */
.film-layout { display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(300px, 1fr); gap: 16px; align-items: start; }
.film-main { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.film-side { position: sticky; top: 16px; max-height: calc(100vh - 32px); overflow-y: auto; }
.film-score { font-family: var(--font-cond); font-size: 1.4rem; margin-bottom: 8px; }
@media (max-width: 960px) { .film-layout { grid-template-columns: 1fr; } .film-side { position: static; max-height: none; } }
.player-wrap { background: #000; border-radius: var(--radius); overflow: hidden; aspect-ratio: 16 / 9; display: grid; place-items: center; }
.player { width: 100%; height: 100%; display: block; background: #000; }
.player-missing { padding: 24px; text-align: center; }
.player-controls { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.player-controls select { width: auto; min-height: 34px; }
.sync-note { display: flex; gap: 10px; align-items: center; justify-content: space-between; font-size: 0.88rem; color: var(--muted); padding: 8px 0 12px; flex-wrap: wrap; }
.sync-note.warn { color: var(--clock); }
.video-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; }
.video-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; color: var(--text); display: flex; flex-direction: column; }
.video-card:hover { border-color: var(--line-strong); text-decoration: none; }
.video-thumb { aspect-ratio: 16 / 9; background: var(--surface-2); display: grid; place-items: center; color: var(--muted); position: relative; }
.video-dur { position: absolute; right: 8px; bottom: 6px; font-size: 0.8rem; background: rgba(0, 0, 0, 0.6); padding: 1px 6px; border-radius: 4px; font-variant-numeric: tabular-nums; }
.video-meta { padding: 10px 12px; display: flex; flex-direction: column; gap: 4px; }

/* ------------------------------------------------ charts */
.chart { margin: 0; position: relative; }
.chart figcaption { font-weight: 500; margin-bottom: 8px; }
.chart-svg { width: 100%; height: 190px; display: block; overflow: visible; }
.chart .grid { stroke: var(--line); stroke-width: 1; }
.chart .axis { stroke: var(--line-strong); stroke-width: 1; }
.chart .tick { fill: var(--muted); font-size: 11px; font-family: var(--font); }
.chart .fill-us, .legend .fill-us { fill: var(--us); background: var(--us); }
.chart .fill-opp, .legend .fill-opp { fill: var(--opp); background: var(--opp); }
.chart .fill-muted { fill: var(--line-strong); }
.chart .hit { fill: transparent; cursor: default; }
.chart .bar:hover path, .chart .bar:hover rect:not(.hit) { opacity: 0.85; }
.chart-tip { position: absolute; transform: translateX(-50%); background: var(--surface-3); border: 1px solid var(--line-strong); padding: 4px 8px; border-radius: 4px; font-size: 0.82rem; pointer-events: none; white-space: nowrap; z-index: 2; }
.legend { display: flex; gap: 14px; font-size: 0.85rem; color: var(--muted); margin-bottom: 4px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.swatch { width: 10px; height: 10px; border-radius: 2px; display: inline-block; }

/* ------------------------------------------------ live scorer */
.live-root { padding: 0 !important; max-width: none !important; }
.live {
  --green: #2e9e5b; --green-ink: #8fe0b0; --red: #d9433b; --red-ink: #f6a39d;
  height: 100vh; height: 100dvh; display: grid; grid-template-rows: auto minmax(0, 1fr) auto auto;
  background: #0a0f14; overflow: hidden;
}
.live[data-us-band="green"] { --us-band: var(--green); --us-ink: var(--green-ink); --opp-band: var(--red); --opp-ink: var(--red-ink); }
.live[data-us-band="red"] { --us-band: var(--red); --us-ink: var(--red-ink); --opp-band: var(--green); --opp-ink: var(--green-ink); }

/* top bar */
.live-top { display: flex; align-items: center; gap: 12px; padding: 6px 12px; padding-top: max(6px, env(safe-area-inset-top)); background: #0f161e; border-bottom: 1px solid var(--line); min-height: 48px; }
.top-link { display: inline-flex; align-items: center; gap: 2px; color: var(--clock); font: inherit; font-weight: 600; background: none; border: 0; cursor: pointer; padding: 6px 4px; min-height: 40px; }
.top-link:hover { text-decoration: none; filter: brightness(1.15); }
.live-meta { flex: 1; min-width: 0; display: flex; justify-content: center; gap: 18px; color: var(--muted); font-size: 0.92rem; overflow: hidden; white-space: nowrap; }
.live-meta span { overflow: hidden; text-overflow: ellipsis; }
.live-meta span + span::before { content: ''; display: inline-block; width: 4px; height: 4px; border-radius: 50%; background: var(--line-strong); margin-right: 18px; vertical-align: middle; }

/* camera stage */
.stage { position: relative; background: #000; min-height: 0; overflow: hidden; }
.stage-video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.stage-empty { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; color: var(--muted); text-align: center; padding: 16px;
  background: radial-gradient(circle at 50% 55%, transparent 0 60px, rgba(242, 180, 58, 0.08) 61px 64px, transparent 65px 150px, rgba(217, 67, 59, 0.10) 151px 156px, transparent 157px), #070b0f; }
.stage-title { color: var(--text); font-weight: 600; margin: 4px 0 0; }
.rec-badge { position: absolute; top: 12px; left: 14px; display: flex; align-items: center; gap: 6px; background: rgba(0, 0, 0, 0.55); color: #fff; font-weight: 700; font-size: 0.8rem; letter-spacing: 0.06em; padding: 3px 10px 3px 8px; border-radius: 999px; }
.rec-dot { width: 9px; height: 9px; border-radius: 50%; background: #ff3b30; animation: blink 1.2s steps(2, start) infinite; }
@keyframes blink { to { visibility: hidden; } }
@media (prefers-reduced-motion: reduce) { .rec-dot { animation: none; } }
.stage-banner { position: absolute; top: 12px; left: 50%; transform: translateX(-50%); display: flex; gap: 10px; align-items: center; background: rgba(15, 22, 30, 0.92); border: 1px solid var(--clock); color: var(--clock); padding: 6px 8px 6px 14px; border-radius: 999px; font-weight: 600; white-space: nowrap; }
.mark-btn { position: absolute; left: 14px; bottom: 14px; display: inline-flex; align-items: center; gap: 8px; background: rgba(10, 15, 20, 0.82); color: #fff; border: 1px solid rgba(255, 255, 255, 0.18); border-radius: 10px; padding: 10px 16px; font: inherit; font-weight: 600; cursor: pointer; min-height: 46px; }
.mark-btn:disabled { opacity: 0.35; cursor: default; }
.rec-btn { position: absolute; right: 18px; bottom: 14px; width: 72px; height: 72px; border-radius: 50%; border: 4px solid rgba(255, 255, 255, 0.92); background: rgba(0, 0, 0, 0.25); display: grid; place-items: center; cursor: pointer; padding: 0; }
.rec-btn:disabled { opacity: 0.3; cursor: default; }
.rec-inner { width: 52px; height: 52px; border-radius: 50%; background: #ff3b30; transition: all 0.15s; }
.rec-btn.recording .rec-inner { width: 28px; height: 28px; border-radius: 6px; }
@media (prefers-reduced-motion: reduce) { .rec-inner { transition: none; } }

/* scoring from an uploaded video */
.stage-player { object-fit: contain; background: #000; }
.vid-ctrls { position: absolute; top: 12px; left: 14px; display: flex; gap: 6px; }
.vid-btn { background: rgba(10, 15, 20, 0.82); color: #fff; border: 1px solid rgba(255, 255, 255, 0.18); border-radius: 8px; min-width: 52px; min-height: 40px; padding: 6px 10px; font: inherit; font-weight: 600; cursor: pointer; }
.vid-select { width: auto; min-height: 40px; background: rgba(10, 15, 20, 0.82); color: #fff; border: 1px solid rgba(255, 255, 255, 0.18); border-radius: 8px; padding: 6px 10px; font-weight: 600; }
.vid-btn:disabled { opacity: 0.5; }
.mark-btn.mark-top { top: 12px; bottom: auto; left: auto; right: 14px; }
.meta-video { color: var(--clock) !important; font-weight: 600; }

/* scorebug */
.bug { display: grid; grid-template-columns: minmax(150px, 220px) minmax(0, 1fr) 150px; background: #121a23; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.bug-names { display: grid; grid-template-rows: 1fr 1fr; padding: 4px 0; border-right: 1px solid var(--line); }
.bug-name { display: flex; align-items: center; gap: 10px; padding: 0 14px; min-height: 34px; min-width: 0; }
.bug-who { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.band { width: 13px; height: 13px; border-radius: 3px; flex: none; }
.band-green { background: var(--green); }
.band-red { background: var(--red); }
.bug-periods { display: flex; overflow-x: auto; scrollbar-width: none; }
.bug-col { display: grid; grid-template-columns: auto 1fr; grid-template-rows: 1fr 1fr; column-gap: 8px; align-items: center; padding: 4px 12px 4px 10px; border-right: 1px solid var(--line); min-width: 150px; }
.bug-col.current { background: rgba(242, 180, 58, 0.05); }
.bug-col-label { grid-row: 1 / span 2; align-self: center; font-size: 0.78rem; font-weight: 700; color: #c9d3de; background: #2a3644; padding: 2px 7px; border-radius: 4px; }
.bug-col.current .bug-col-label { background: var(--clock); color: #1d1405; }
.bug-row { display: flex; gap: 6px; align-items: center; min-height: 30px; flex-wrap: nowrap; }
.chip-act { font: inherit; font-size: 0.82rem; font-weight: 800; letter-spacing: 0.02em; padding: 3px 8px; border-radius: 4px; border: 0; color: #fff; cursor: pointer; line-height: 1.2; }
.chip-green { background: var(--green); }
.chip-red { background: var(--red); }
.chip-call { background: transparent; color: var(--text); box-shadow: inset 0 0 0 1.5px var(--line-strong); }
.chip-pos { background: #2a3644; color: #c9d3de; }
.bug-ctrl { border-left: 1px solid var(--line); display: grid; grid-template-rows: 1fr 1fr; }
.bug-period { display: grid; grid-template-columns: 44px 1fr 44px; align-items: stretch; border-bottom: 1px solid var(--line); }
.bug-step { background: none; border: 0; color: var(--clock); font-size: 1.5rem; font-weight: 600; cursor: pointer; }
.bug-period-label { display: grid; place-items: center; font-weight: 700; font-size: 0.95rem; }
.bug-pos { background: none; border: 0; color: var(--muted); font: inherit; font-size: 0.85rem; cursor: pointer; padding: 0 8px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bug-pos:hover { color: var(--text); }

/* controls */
.controls { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); gap: 12px; padding: 12px 14px; padding-bottom: max(12px, env(safe-area-inset-bottom)); background: #0d141b; }
.ctrl-half { display: flex; align-items: stretch; gap: 12px; min-width: 0; }
.ctrl-opp { justify-content: flex-end; }
.side-ctrl { display: flex; flex-direction: column; gap: 8px; flex: 1; min-width: 0; }
.side-ctrl.side-opp { align-items: stretch; text-align: left; }
.side-opp .act-row { justify-content: flex-end; }
.act-row { display: flex; gap: 8px; flex-wrap: wrap; }
.act-row-score { flex-wrap: nowrap; }
.act {
  min-height: 48px; min-width: 84px; padding: 6px 12px; border-radius: 6px; border: 0; cursor: pointer; font: inherit; color: #fff;
  display: inline-flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1.1; touch-action: manipulation; user-select: none; -webkit-user-select: none;
}
.act:active { transform: scale(0.96); }
.act-label { font-weight: 700; font-size: 1rem; }
.act-sub { font-size: 0.68rem; opacity: 0.85; margin-top: 2px; white-space: nowrap; }
.side-us .act-call, .side-us .act-score { background: var(--us-band); }
.side-opp .act-call, .side-opp .act-score { background: var(--opp-band); }
.act-call { filter: saturate(0.85) brightness(0.92); }
.act-score { min-width: 72px; flex: 0 1 96px; }
.act-ghost { flex: 0 1 84px; min-width: 0; }
.act-score .act-label { font-size: 1.35rem; font-family: var(--font-cond); letter-spacing: 0.02em; }
.act-wide { min-width: 132px; }
.act-ghost { background: transparent; box-shadow: inset 0 0 0 2px var(--line-strong); color: var(--text); }
.side-us .act-fall { box-shadow: inset 0 0 0 2px var(--us-band); color: var(--us-ink); }
.side-opp .act-fall { box-shadow: inset 0 0 0 2px var(--opp-band); color: var(--opp-ink); }
.act-more { background: #1d2733; min-width: 52px; color: var(--muted); }
.ctrl-score { font-family: var(--font-cond); font-weight: 700; font-size: clamp(2.8rem, 6vw, 4.2rem); line-height: 1; min-width: 72px; display: grid; place-items: center; font-variant-numeric: tabular-nums; }
.ctrl-center { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; min-width: 150px; padding: 0 6px; border-left: 1px solid var(--line); border-right: 1px solid var(--line); }
.pill-btn { display: inline-flex; align-items: center; gap: 6px; background: #1d2733; color: var(--text); border: 0; border-radius: 999px; padding: 8px 14px; font: inherit; font-size: 0.9rem; cursor: pointer; min-height: 40px; max-width: 220px; }
.pill-btn:disabled { opacity: 0.45; cursor: default; }
.undo-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.timer-pill { background: rgba(242, 180, 58, 0.18); color: #b98a2e; font-weight: 700; font-variant-numeric: tabular-nums; padding: 8px 16px; border-radius: 8px; font-size: 1.05rem; letter-spacing: 0.03em; }
.timer-pill.is-recording { background: var(--clock); color: #1d1405; }

.live-flash { position: fixed; left: 50%; top: 60px; transform: translate(-50%, -8px); background: var(--surface-3); border: 1px solid var(--line-strong); padding: 8px 14px; border-radius: 999px; opacity: 0; pointer-events: none; transition: opacity 0.15s, transform 0.15s; z-index: 30; font-weight: 500; max-width: calc(100vw - 32px); }
.live-flash.show { opacity: 1; transform: translate(-50%, 0); }
.live-flash.warn { border-color: var(--clock); color: var(--clock); }
@media (prefers-reduced-motion: reduce) { .live-flash { transition: none; } }
.live-sync { display: inline-flex; align-items: center; gap: 5px; font-size: 0.8rem; padding: 3px 8px; border-radius: 999px; background: #1d2733; white-space: nowrap; }
.end-panel { position: fixed; inset: 0; background: rgba(4, 8, 12, 0.72); display: grid; place-items: center; z-index: 40; padding: 16px; }
.end-card { background: var(--surface); border: 1px solid var(--line-strong); border-radius: 14px; padding: 24px; width: min(560px, 100%); }
.end-win { border-color: var(--us); }
.end-loss { border-color: var(--opp); }
.end-score { font-family: var(--font-cond); font-size: 3rem; font-weight: 700; margin: 0; line-height: 1.1; }

/* Phone portrait */
@media (max-width: 760px) {
  .live { grid-template-rows: auto minmax(150px, 34vh) auto minmax(0, 1fr); }
  .live-meta { display: none; }
  .live-top { justify-content: space-between; }
  .live-top .live-sync { margin-left: auto; }
  .rec-btn { width: 58px; height: 58px; right: 12px; bottom: 10px; }
  .rec-inner { width: 40px; height: 40px; }
  .mark-btn { left: 10px; bottom: 10px; padding: 8px 12px; min-height: 40px; }
  .stage-empty .muted { display: none; }
  .bug { grid-template-columns: 112px minmax(0, 1fr) 92px; font-size: 0.85rem; }
  .bug-name { padding: 0 8px; gap: 6px; }
  .bug-col { min-width: 108px; padding: 4px 8px; column-gap: 6px; }
  .bug-period { grid-template-columns: 30px 1fr 30px; }
  .controls { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); grid-template-areas: "center center" "us opp"; overflow-y: auto; gap: 8px; padding: 8px; }
  .ctrl-us { grid-area: us; }
  .ctrl-opp { grid-area: opp; }
  .ctrl-center { grid-area: center; flex-direction: row; border: 0; min-width: 0; justify-content: space-between; }
  .ctrl-center .pill-btn { padding: 6px 10px; min-height: 36px; font-size: 0.82rem; max-width: 150px; }
  .timer-pill { padding: 6px 10px; font-size: 0.9rem; }
  .ctrl-half { flex-direction: column; gap: 6px; }
  .ctrl-us .ctrl-score { order: -1; }
  .ctrl-half > .side-ctrl { align-self: stretch; width: 100%; flex: none; }
  .ctrl-opp { justify-content: flex-start; }
  .ctrl-score { font-size: 2.6rem; }
  .side-opp .act-row { justify-content: flex-start; }
  .act-row { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
  .act { min-width: 0; min-height: 50px; padding: 4px 6px; }
  .act-row-score .act:only-child, .act-wide { grid-column: 1 / -1; }
  .act-label { font-size: 0.92rem; }
}

/* storage meter */
.meter-wrap { display: flex; flex-direction: column; gap: 4px; margin-bottom: 14px; max-width: 520px; }
.meter { height: 8px; background: var(--surface-3); border-radius: 999px; overflow: hidden; }
.meter span { display: block; height: 100%; background: var(--us); border-radius: 999px; }
.meter-warn span { background: var(--clock); }
.meter-full span { background: var(--opp); }

/* On the scoring screen, messages appear at the top so they never cover the buttons. */
body:has(.live) #toasts { bottom: auto; top: calc(56px + env(safe-area-inset-top)); }
body:has(.live) .uploads { bottom: auto; top: calc(56px + env(safe-area-inset-top)); }

/* team branding */
.brand-team { align-items: center; }
.team-logo { width: 42px; height: 42px; object-fit: contain; border-radius: 8px; background: var(--surface-2); flex: none; }
.team-logo-lg { width: 76px; height: 76px; border-radius: 12px; background: rgba(13, 20, 28, 0.6); padding: 4px; }
.brand-team-name { font-size: 1.12rem; line-height: 1.15; }
.brand-sub { font-size: 0.78rem; color: var(--muted); }
.team-banner { position: relative; height: 210px; border-radius: var(--radius); overflow: hidden; margin-bottom: 18px; background: var(--surface-2); }
.team-banner > img { width: 100%; height: 100%; object-fit: cover; display: block; }
.team-banner::after { content: ''; position: absolute; inset: 0; background: linear-gradient(180deg, rgba(13, 20, 28, 0) 35%, rgba(13, 20, 28, 0.88) 100%); }
.team-banner-text { position: absolute; left: 22px; right: 22px; bottom: 18px; display: flex; align-items: flex-end; gap: 16px; z-index: 1; }
.team-banner-text h1 { margin: 0; text-shadow: 0 2px 12px rgba(0, 0, 0, 0.5); }
.team-banner-text p { margin: 2px 0 0; color: #d5dde6; }
@media (max-width: 700px) { .team-banner { height: 150px; } .team-logo-lg { width: 56px; height: 56px; } }
.brand-slots { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.6fr); gap: 20px; }
@media (max-width: 760px) { .brand-slots { grid-template-columns: 1fr; } }
.brand-slot { display: flex; gap: 14px; align-items: flex-start; }
.brand-slot p { margin: 4px 0 8px; }
.brand-preview { flex: none; display: grid; place-items: center; background: var(--surface-2); border: 1px dashed var(--line-strong); border-radius: 10px; overflow: hidden; }
.brand-slot-logo .brand-preview { width: 104px; height: 104px; }
.brand-slot-banner .brand-preview { width: 216px; height: 72px; }
.brand-preview img { width: 100%; height: 100%; object-fit: contain; }
.brand-slot-banner .brand-preview img { object-fit: cover; }
@media (max-width: 760px) { .brand-slot-banner { flex-direction: column; } .brand-slot-banner .brand-preview { width: 100%; height: auto; aspect-ratio: 3 / 1; } }
.row.wrap > input, .row.wrap > select { flex: 1 1 150px; width: auto; }
.row.wrap > .input-sm { flex: 0 1 110px; }

/* on-device video shrinking */
.shrink-box { display: flex; justify-content: center; background: #000; border-radius: 8px; margin-bottom: 12px; min-height: 60px; }
.shrink-preview { max-width: 100%; max-height: 200px; display: block; }
.modal-body progress { width: 100%; }

/* score sheet */
.sheet-result { font-size: 1.4rem; font-weight: 700; margin-bottom: 8px; }
.sheet-film .player { width: 100%; max-height: 62vh; background: #000; border-radius: 8px; }
.sheet-film .row { margin-top: 8px; }
.sheet-film [aria-pressed="true"] { background: var(--accent, #3b82f6); color: #fff; border-color: transparent; }
.sheet-actions a.chip-time, .sheet-actions button.chip-time { text-decoration: none; cursor: pointer; }
.time-pair { display: inline-flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.od-test { font-size: 0.8rem; white-space: nowrap; }

/* archived films */
.chip-archived { display: inline-flex; align-items: center; gap: 6px; }
.od-badge { font-size: 0.68rem; font-weight: 700; letter-spacing: 0.02em; padding: 1px 6px; border-radius: 999px; background: #0364b8; color: #fff; }
.player-archived { gap: 10px; }
.player-archived .state-title { display: inline-flex; align-items: center; gap: 6px; }

/* Cloudflare film storage */
.cf-settings { margin-top: 1rem; border-top: 1px solid var(--line, #e5e7eb); padding-top: .75rem; }
.cf-settings h3 { margin: 0 0 .35rem; font-size: 1rem; }
.cf-form { display: grid; gap: .5rem; }
.cf-form input { width: 100%; }
.cf-meter { margin: .25rem 0 .5rem; }
.move-panel { margin: .5rem 0; }
.move-panel .row-between { gap: 1rem; align-items: center; flex-wrap: wrap; }
.move-panel p { margin: 0; }
.rec-size { font-weight: 500; letter-spacing: 0; opacity: .9; }

/* Dual meet lineup */
.lineup-table td { vertical-align: middle; }
.lineup-table select, .lineup-table .lineup-opp { width: 100%; min-width: 150px; }
.lineup-actions { white-space: nowrap; text-align: right; }
.lineup-actions .btn { margin-left: 4px; }
.lineup-done td { opacity: .92; }
@media (max-width: 720px) {
  .lineup-table thead { display: none; }
  .lineup-table tr { display: grid; grid-template-columns: 52px 1fr; gap: 4px 8px; padding: 8px 0; border-bottom: 1px solid var(--line); }
  .lineup-table td { border: 0; padding: 0; }
  .lineup-table td:first-child { grid-row: span 4; }
  .lineup-actions { text-align: left; }
  .lineup-actions .btn { margin: 0 4px 0 0; }
}

/* Pause filming (injury / blood time) */
.pause-btn { position: absolute; right: 14px; bottom: 98px; display: inline-flex; align-items: center; gap: 6px; background: rgba(10, 15, 20, 0.82); color: #fff; border: 1px solid rgba(255, 255, 255, 0.18); border-radius: 10px; padding: 8px 14px; font: inherit; font-weight: 600; cursor: pointer; min-height: 44px; }
.pause-btn.is-paused { background: #f5a623; color: #111; border-color: #f5a623; }
.pause-btn .pause-ico { display: inline-flex; }
.pause-btn.is-paused .pause-ico { color: #d0021b; }
.rec-badge.paused { background: rgba(245, 166, 35, 0.9); color: #111; }
.rec-badge.paused .rec-dot { background: #111; animation: none; }
@media (max-width: 720px) { .pause-btn { right: 8px; bottom: 76px; padding: 6px 10px; min-height: 38px; } }

/* Film Room: one card per match */
.video-card-main { color: inherit; display: flex; flex-direction: column; flex: 1; }
.video-card-main:hover { text-decoration: none; }
.video-clips { display: flex; flex-wrap: wrap; gap: 4px 12px; padding: 0 12px 10px; font-size: 0.82rem; }
.video-clips a { color: var(--muted); }
.video-clips a:hover { color: var(--text); }

/* Differentials */
td.pos { color: var(--ok, #2fbf71); }
td.neg { color: var(--opp-ink, #e5484d); }

/* Sign-up: Team / Individual / Family */
.kind-cards { display: grid; gap: 8px; margin-bottom: 12px; }
.kind-card { display: grid; grid-template-columns: auto 1fr; gap: 2px 10px; align-items: start; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--radius); cursor: pointer; }
.kind-card input { grid-row: span 2; margin-top: 3px; }
.kind-card .kind-title { font-weight: 700; }
.kind-card.selected { border-color: var(--us); background: var(--us-bg); }
.onboard-details { display: grid; gap: 8px; }
/* Trial banner */
.trial-banner { display: flex; gap: 10px; align-items: center; justify-content: space-between; flex-wrap: wrap; padding: 8px 14px; margin: 0 0 14px; border-radius: var(--radius); background: var(--us-bg); color: var(--us-ink); font-size: 0.9rem; }
.trial-banner.ending { background: rgba(245, 166, 35, 0.15); color: #f5c26b; }
