:root {
  --bg: #eef3f7;
  --card: #ffffff;
  --text: #14212b;
  --muted: #5f6d7a;
  --primary: #145da0;
  --primary-dark: #0d426f;
  --danger: #b3261e;
  --line: #d5dee7;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--text); font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
header { position: sticky; top: 0; z-index: 5; padding: calc(10px + env(safe-area-inset-top)) 12px 10px; background: var(--card); border-bottom: 1px solid var(--line); }
h1 { margin: 0 0 8px; font-size: 20px; }
nav { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
button { border: 1px solid var(--line); background: #f8fafc; color: var(--text); border-radius: 10px; padding: 11px 12px; font-weight: 700; font-size: 15px; touch-action: manipulation; }
button.active, button.primary { background: var(--primary); color: white; border-color: var(--primary); }
button.danger { background: var(--danger); color: white; border-color: var(--danger); }
button:disabled { opacity: .45; }
main { max-width: 980px; margin: 0 auto; padding: 12px; }
.page { display: none; }
.page.active { display: block; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 14px; margin: 0 0 12px; box-shadow: 0 2px 10px rgba(14, 35, 55, .06); }
.card.compact { padding: 10px 12px; }
h2 { margin: 0 0 10px; font-size: 18px; }
h3 { margin: 14px 0 8px; }
p { color: var(--muted); margin: 6px 0 10px; }
label { display: block; font-weight: 700; margin: 0 0 10px; }
input, select { width: 100%; margin-top: 6px; padding: 12px; border-radius: 10px; border: 1px solid var(--line); font-size: 16px; background: white; }
.hidden { display: none !important; }
.topbar { display: flex; justify-content: space-between; gap: 12px; align-items: center; flex-wrap: wrap; }
.button-row { display: flex; flex-wrap: wrap; gap: 8px; }
.canvas-wrap { width: 100%; overflow: hidden; border-radius: 14px; background: #f9fbfd; border: 1px solid var(--line); touch-action: none; }
canvas { display: block; width: 100%; height: auto; touch-action: none; }
.details-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 12px; }
.preview-box { grid-column: 1 / -1; border: 1px solid var(--line); border-radius: 12px; padding: 12px; background: #f8fafc; color: var(--muted); }
.sticky-actions { position: sticky; bottom: 0; background: rgba(255,255,255,.95); padding: 10px 0 0; margin-top: 10px; }
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(135px, 1fr)); gap: 8px; }
.stat { border: 1px solid var(--line); border-radius: 12px; padding: 10px; background: #f8fafc; }
.stat strong { display: block; font-size: 20px; margin-top: 4px; }
.game-item { display: flex; justify-content: space-between; gap: 10px; align-items: center; padding: 10px; border: 1px solid var(--line); border-radius: 12px; margin-bottom: 8px; background: #f8fafc; }
.game-item small { color: var(--muted); }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 760px; }
th, td { border: 1px solid var(--line); padding: 8px; text-align: center; font-size: 13px; }
th { background: var(--primary); color: white; position: sticky; top: 0; }
td:first-child, th:first-child { text-align: left; font-weight: 700; }
@media (max-width: 560px) {
  main { padding: 8px; }
  .details-grid { grid-template-columns: 1fr; }
  .button-row button { flex: 1 1 auto; }
}

.filter-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(145px, 1fr)); gap: 10px; margin: 8px 0 12px; }
.breakdown-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 12px; margin-top: 12px; }
.mini-table { overflow-x: auto; border: 1px solid var(--line); border-radius: 12px; padding: 10px; background: #f8fafc; }
.mini-table h3 { margin: 0 0 8px; font-size: 15px; }
.mini-table table { min-width: 420px; background: white; }
.mini-table th, .mini-table td { padding: 6px; font-size: 12px; }

/* Cloud/login layer */
.auth-gate { max-width: 980px; margin: 16px auto; padding: 0 12px; }
.auth-card { margin-bottom: 14px; }
.auth-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
.auth-message { min-height: 1.3em; color: #1f4e78; font-weight: 600; }
.muted { color: #64748b; }
.notice { padding: 10px 12px; border: 1px solid #f59e0b; background: #fffbeb; border-radius: 10px; margin-bottom: 12px; color: #92400e; }
.cloud-bar { position: static; z-index: 1; display: flex; justify-content: space-between; align-items: center; gap: 12px; max-width: 1100px; margin: 0 auto 12px auto; padding: 10px 14px; border: 1px solid #dbeafe; background: #eff6ff; border-radius: 12px; color: #1e3a8a; }
.cloud-bar span { font-weight: 700; }
hr { border: none; border-top: 1px solid #e5e7eb; margin: 18px 0; }


/* Help pages */
.auth-help-row { margin: 8px 0 12px; }
.help-card h2 { margin-bottom: 8px; }
.help-content { line-height: 1.45; }
.help-content h3 { margin-top: 18px; padding-top: 10px; border-top: 1px solid #e5e7eb; color: #0f4778; }
.help-content h3:first-child { border-top: none; padding-top: 0; }
.help-content ul, .help-content ol { margin: 8px 0 12px 20px; padding: 0; color: var(--text); }
.help-content li { margin: 6px 0; }
.help-content p { color: var(--text); }
.help-content strong { color: #0f4778; }


/* Help quick navigation */
.help-toc { border: 1px solid #dbeafe; background: #eff6ff; border-radius: 14px; padding: 12px; margin: 10px 0 16px; }
.help-toc h3 { margin: 0 0 6px; padding: 0; border-top: none; color: #0f4778; }
.help-toc p { margin: 0 0 10px; color: #334155; }
.help-toc-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 8px; }
.help-toc-grid a { display: block; text-decoration: none; border: 1px solid #bfdbfe; background: #ffffff; color: #0f4778; border-radius: 10px; padding: 9px 10px; font-weight: 700; }
.help-toc-grid a:active, .help-toc-grid a:hover { background: #dbeafe; }
.help-content h3[id] { scroll-margin-top: 95px; }


/* v1.15: when logged in but still on team-access screen, Help opens as a full-page view. */
#publicHelpPanel.fullscreen-help {
  position: fixed;
  inset: 0;
  z-index: 3000;
  display: block;
  overflow-y: auto;
  max-width: none;
  margin: 0;
  border-radius: 0;
  border: none;
  background: #f3f7fb;
  padding: 12px;
  box-shadow: none;
}
#publicHelpPanel.fullscreen-help > .topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: white;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px;
  margin: 0 auto 12px auto;
  max-width: 980px;
}
#publicHelpPanel.fullscreen-help > .help-content {
  max-width: 980px;
  margin: 0 auto 24px auto;
  background: white;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 14px;
  box-shadow: 0 2px 10px rgba(14, 35, 55, .06);
}
body.auth-help-open { overflow: hidden; }

/* v1.16 folders and multi-game overview */
.select-game-line { display: flex; align-items: center; gap: 8px; font-weight: 700; margin-bottom: 8px; color: #0f4778; }
.select-game-line input { width: auto; margin: 0; transform: scale(1.2); }
.folder-move-row { margin-top: 8px; max-width: 360px; }
.folder-move-row label { margin-bottom: 0; font-size: 13px; color: var(--muted); }
.game-item > div:first-child { flex: 1 1 420px; }
.hint { color: var(--muted); }


/* v1.17: folder accordion, game menus, unified analysis and modals */
.selection-toolbar { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; padding: 10px 0 12px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); margin: 10px 0 12px; }
.selection-check { display: flex; align-items: center; gap: 8px; margin: 0; }
.selection-check input, .folder-compare input, .game-select input { width: auto; margin: 0; transform: scale(1.15); }
.selection-count { color: var(--muted); font-weight: 700; margin-right: auto; }
.folder-section { border: 1px solid var(--line); border-radius: 14px; margin-bottom: 10px; overflow: visible; background: #fff; }
.folder-header { display: grid; grid-template-columns: minmax(0,1fr) auto; gap: 10px; align-items: center; padding: 10px; background: #f4f8fb; border-radius: 14px; }
.folder-title-row { display: flex; align-items: center; gap: 8px; min-width: 0; }
.folder-toggle { display: flex; align-items: center; gap: 8px; min-width: 0; flex: 1; border: 0; background: transparent; padding: 6px; text-align: left; }
.folder-toggle strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.folder-chevron { width: 18px; display: inline-block; transition: transform .15s ease; }
.folder-section.collapsed .folder-chevron { transform: rotate(-90deg); }
.folder-count { color: var(--muted); font-size: 13px; font-weight: 700; white-space: nowrap; }
.folder-compare { display: flex; align-items: center; gap: 7px; margin: 0; color: #0f4778; font-size: 13px; }
.folder-games { padding: 8px; border-top: 1px solid var(--line); }
.folder-section.collapsed .folder-games { display: none; }
.folder-empty { padding: 12px; margin: 0; color: var(--muted); }
.game-item { position: relative; align-items: flex-start; }
.game-main { flex: 1 1 420px; min-width: 0; }
.game-title-line { display: flex; align-items: center; gap: 9px; margin-bottom: 4px; }
.game-select { display: flex; align-items: center; margin: 0; }
.game-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 7px; justify-content: flex-end; }
.menu-wrap { position: relative; }
.menu-button { width: 42px; min-width: 42px; padding: 9px 6px; font-size: 22px; line-height: 1; }
.game-menu { position: absolute; right: 0; top: calc(100% + 5px); z-index: 80; min-width: 185px; padding: 6px; background: white; border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 12px 30px rgba(14,35,55,.18); }
.game-menu button { display: block; width: 100%; text-align: left; background: white; border: 0; padding: 10px; }
.game-menu button:hover { background: #eef5fb; }
.game-menu button.danger-text { color: var(--danger); }
.analysis-empty { text-align: center; padding: 24px 14px; }
#analysisWorkspace { scroll-margin-top: 92px; }
.modal-backdrop { position: fixed; inset: 0; z-index: 4000; display: grid; place-items: center; padding: 16px; background: rgba(15,23,42,.55); }
.modal-card { width: min(440px, 100%); background: white; border-radius: 16px; border: 1px solid var(--line); box-shadow: 0 20px 60px rgba(0,0,0,.25); padding: 16px; }
.modal-actions { justify-content: flex-end; }
body.modal-open { overflow: hidden; }
@media (max-width: 650px) {
  .folder-header { grid-template-columns: 1fr; }
  .folder-compare { padding: 0 7px 5px; }
  .game-item { display: block; }
  .game-actions { margin-top: 10px; justify-content: flex-start; }
  .game-actions .review-btn, .game-actions .resume-btn { flex: 1 1 120px; }
  .menu-wrap { margin-left: auto; }
}

/* v1.18 organization/team UX, contextual workspaces, contact and shot editing */
.contact-floating {
  position: static;
  display: block;
  width: max-content;
  margin: max(10px, env(safe-area-inset-top)) 12px 0 auto;
  padding: 9px 13px;
  border-radius: 999px;
  box-shadow: 0 3px 12px rgba(14,35,55,.12);
}
.workspace-heading { display: flex; align-items: center; gap: 12px; min-width: 0; }
.workspace-heading h1 { margin: 0; }
.workspace-subtitle { margin: 2px 0 0; font-size: 13px; }
#backToTeamHomeBtn { white-space: nowrap; }
.team-action-grid { display: grid; grid-template-columns: repeat(auto-fit,minmax(210px,1fr)); gap: 12px; }
.team-action-card {
  min-height: 118px;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 16px;
  text-align: left;
  background: #f8fafc;
  color: var(--text);
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 7px;
}
.team-action-card strong { font-size: 18px; color: #0f4778; }
.team-action-card span { color: var(--muted); line-height: 1.35; }
.team-action-card.primary-card { background: #eff6ff; border-color: #93c5fd; }
.collapsible-card { padding: 0; overflow: hidden; }
.collapsible-card > summary {
  cursor: pointer;
  list-style: none;
  font-weight: 800;
  color: #0f4778;
  padding: 14px 16px;
  background: #f4f8fb;
  border-radius: 16px;
}
.collapsible-card > summary::-webkit-details-marker { display: none; }
.collapsible-card > summary::after { content: '▾'; float: right; }
.collapsible-card:not([open]) > summary::after { transform: rotate(-90deg); }
.collapsible-card[open] > summary { border-bottom: 1px solid var(--line); border-radius: 16px 16px 0 0; }
.collapsible-content { padding: 14px; }
.graph-edit-toolbar { margin-bottom: 8px; }
#editingShotBanner { margin-bottom: 12px; }
.inline-form { display: grid; grid-template-columns: minmax(0,1fr) auto; gap: 8px; align-items: end; }
.inline-form input { margin: 0; }
.fullscreen-modal { align-items: start; overflow-y: auto; }
.wide-modal { width: min(980px,100%); margin: 18px 0; }
.inset-card { box-shadow: none; background: #f8fafc; }
.org-team-directory summary { display: flex; justify-content: space-between; gap: 10px; cursor: pointer; }
.directory-actions { margin: 12px 0; }
.member-line { display: flex; justify-content: space-between; gap: 12px; align-items: center; padding: 9px 0; border-top: 1px solid var(--line); }
.member-line:first-of-type { border-top: 0; }
.member-line small { display: block; color: var(--muted); margin-top: 2px; }
.member-line > span { background: #eaf2f8; color: #0f4778; border-radius: 999px; padding: 5px 9px; font-size: 12px; font-weight: 700; white-space: nowrap; }
textarea { width: 100%; margin-top: 6px; padding: 12px; border-radius: 10px; border: 1px solid var(--line); font: inherit; resize: vertical; }
.honeypot { position: absolute !important; left: -10000px !important; width: 1px !important; height: 1px !important; opacity: 0 !important; }
button:disabled { opacity: .48; cursor: not-allowed; }

@media (max-width: 650px) {
  .contact-floating { margin: 8px 8px 0 auto; padding: 7px 10px; font-size: 13px; }
  .workspace-heading { align-items: flex-start; }
  #backToTeamHomeBtn { flex: 0 0 auto; }
  .inline-form { grid-template-columns: 1fr; }
  .wide-modal { margin: 0; }
  .member-line { align-items: flex-start; }
}

/* v1.19 team management, penalty tracking, and clearer admin UX */
.penalty-button {
  border-color: #d97706;
  background: #fff7ed;
  color: #9a3412;
  font-weight: 700;
}
.penalty-button:hover { background: #ffedd5; }
.member-management-list { display: grid; gap: 10px; margin-top: 16px; }
.member-management-row {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) minmax(130px, 180px) auto auto;
  gap: 10px;
  align-items: center;
  padding: 12px;
  border: 1px solid #dbe4ee;
  border-radius: 12px;
  background: #fff;
}
.member-management-row .member-ident { min-width: 0; }
.member-management-row .member-ident strong,
.member-management-row .member-ident small { display: block; overflow-wrap: anywhere; }
.member-management-row .member-ident small { color: #64748b; margin-top: 3px; }
.member-role-label {
  display: inline-flex;
  align-items: center;
  min-height: 38px;
  padding: 0 10px;
  border-radius: 9px;
  background: #eef2ff;
  color: #3730a3;
  font-weight: 700;
}
.organization-remove-button { margin-left: auto; }
.directory-member-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}
.directory-member-card {
  display: flex;
  gap: 12px;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid #e5e7eb;
}
.directory-member-card:last-child { border-bottom: 0; }
@media (max-width: 760px) {
  .member-management-row { grid-template-columns: 1fr; }
  .directory-member-card { align-items: flex-start; flex-direction: column; }
  .organization-remove-button { margin-left: 0; }
}

/* v1.21 granular permissions, graph filters, and non-sticky home bar */
.member-permissions {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem 1rem;
  align-items: center;
}
.permission-check {
  display: inline-flex;
  align-items: center;
  gap: .45rem;
  font-size: .92rem;
  white-space: nowrap;
}
.permission-check input { width: auto; }
.invite-permissions {
  margin: .75rem 0 .25rem;
  padding: .75rem;
  border: 1px solid #dbe4ee;
  border-radius: .65rem;
  background: #f8fafc;
}
.permission-member-row {
  align-items: center;
}
.permission-member-row .member-permissions {
  min-width: 250px;
}
.live-graph-filter-grid {
  margin-bottom: .65rem;
}
@media (max-width: 760px) {
  .permission-member-row .member-permissions {
    min-width: 100%;
  }
  .permission-check {
    white-space: normal;
  }
}

.permission-box {
  margin: .75rem 0;
  padding: .8rem;
  border: 1px solid #dbe4ee;
  border-radius: .65rem;
  background: #f8fafc;
}
.permission-box > strong { display: block; margin-bottom: .55rem; color: #0f4778; }
.permission-box .hint { margin-top: .55rem; margin-bottom: 0; }

/* v1.25 match clock, quick actions, scoped loading, and organization deletion */
.clock-enable-row{align-self:end;min-height:44px}
.clock-enable-row input{width:auto;margin-right:8px}
.clock-setup{display:grid;grid-template-columns:repeat(2,minmax(150px,1fr));gap:12px;grid-column:1/-1}
.match-clock-panel{display:flex;align-items:center;justify-content:center;gap:14px;padding:8px 12px;border:1px solid #bfdbfe;border-radius:12px;background:#eff6ff;min-width:225px}
.match-clock-panel>div:first-child{display:flex;flex-direction:column;align-items:center;line-height:1.1}
#matchClockHalf{font-size:.78rem;font-weight:700;color:#1e3a8a;text-transform:uppercase;letter-spacing:.04em}
#matchClockDisplay{font-size:1.65rem;font-variant-numeric:tabular-nums;color:#0f172a}
.quick-action-grid{display:grid;grid-template-columns:repeat(2,minmax(190px,1fr));gap:10px}
.quick-action-grid button{min-height:48px;text-align:left}
#blockedShotBtn{border-color:#f59e0b;background:#fffbeb;color:#92400e}
#quickActionPlayerHeader{margin:.6rem 0 .35rem}
#quickActionPlayer{width:100%;box-sizing:border-box}
.action-table-stack{display:grid;gap:16px;margin-top:12px}
.action-table-stack h4{margin:0 0 6px}
.scope-indicator{font-weight:700;color:#1f4e78}
.organization-danger-zone{border:1px solid #fecaca;background:#fff7f7}
.organization-danger-zone h3{color:#991b1b}
@media (max-width:720px){
  .clock-setup,.quick-action-grid{grid-template-columns:1fr}
  .match-clock-panel{width:100%;justify-content:space-between;box-sizing:border-box}
}


/* v1.25 revision 2: start-screen folder scope, court-side match actions, filtered action statistics */
.court-quick-actions {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(90px, 24%) minmax(0, 1fr);
  gap: 8px;
  align-items: end;
  margin: 8px 0 6px;
}
.court-action-home { grid-column: 1; justify-self: end; }
.court-action-goal-space { grid-column: 2; min-height: 1px; }
.court-action-away { grid-column: 3; justify-self: start; }
.court-action-side {
  display: grid;
  gap: 6px;
  width: min(100%, 230px);
}
.court-action-side button {
  min-height: 40px;
  padding: 8px 10px;
  font-size: 13px;
  line-height: 1.15;
}
.court-action-home button { text-align: right; }
.court-action-away button { text-align: left; }
.filtered-action-section {
  margin-top: 18px;
  padding-top: 14px;
  border-top: 2px solid var(--line);
}
.filtered-action-section > h3 { margin-top: 0; }
.filtered-action-section .action-table-stack { margin-top: 12px; }
@media (max-width: 620px) {
  .court-quick-actions { grid-template-columns: minmax(0,1fr) 56px minmax(0,1fr); gap: 5px; }
  .court-action-side button { min-height: 44px; padding: 7px 6px; font-size: 11px; }
}

/* v1.25 revision 3: true folder workspace and match-time filtering */
.filter-grid input[id$="FilterTimeFrom"],
.filter-grid input[id$="FilterTimeTo"] { font-variant-numeric: tabular-nums; }
.action-table-stack > div { overflow-x: auto; }
.action-table-stack table { min-width: 900px; }

/* v1.25 revision 4: nested folders and applied time filters */
.folder-tree-level { margin-left: calc(var(--folder-depth, 0) * 18px); }
.folder-tree-level .folder-children { margin-top: 8px; }
.folder-tree-level .folder-children > .folder-section { border-left-width: 3px; }
.folder-header-actions { display:flex; flex-wrap:wrap; gap:8px; align-items:center; justify-content:flex-end; }
.create-subfolder-btn { white-space:nowrap; }
.time-filter-actions { align-items:center; margin: -2px 0 12px; }
.applied-time-filter { display:inline-flex; align-items:center; min-height:38px; }
@media (max-width: 700px) {
  .folder-tree-level { margin-left: calc(var(--folder-depth, 0) * 10px); }
  .folder-header-actions { justify-content:flex-start; }
}

/* v1.25 revision 4: team-separated attack summaries */
.team-action-summary-host {
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  align-items: stretch;
}
.team-attack-summary-panel {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #f8fbff;
  padding: 14px;
}
.team-attack-summary-panel h4 {
  margin: 0 0 12px;
  color: #0f4778;
  overflow-wrap: anywhere;
}
.team-attack-summary-metrics {
  display: grid;
  grid-template-columns: repeat(2, minmax(110px, 1fr));
  gap: 10px;
}
.team-attack-summary-metrics .stat { min-width: 0; }
@media (max-width: 560px) {
  .team-action-summary-host { grid-template-columns: 1fr; }
  .team-attack-summary-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* v1.25 revision 5: editable match action history */
.action-history-list { display: grid; gap: 10px; margin-top: 14px; }
.action-history-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 12px; align-items: center; border: 1px solid var(--border, #d7dce2); border-radius: 12px; padding: 12px; background: var(--card, #fff); }
.action-history-main { display: grid; gap: 4px; min-width: 0; }
.action-history-main span { color: var(--muted, #5f6873); font-size: .92rem; }
.action-history-buttons { justify-content: flex-end; }
.action-edit-court-wrap { max-width: 520px; margin: 8px auto 0; touch-action: none; }
.action-edit-court-wrap canvas { width: 100%; height: auto; touch-action: none; }
@media (max-width: 720px) {
  .action-history-row { grid-template-columns: 1fr; }
  .action-history-buttons { justify-content: flex-start; }
}

/* v1.25 revision 6: synchronized multi-device tracking */
.tracker-session-panel { border: 1px solid #b9d6ee; background: #f5faff; }
.tracker-session-panel .topbar { gap: 14px; }
.tracker-session-panel p { margin: 4px 0 0; }
.tracker-presence-list { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.tracker-presence-chip { display: inline-flex; align-items: center; min-height: 32px; border: 1px solid #b9d6ee; border-radius: 999px; padding: 5px 10px; background: #fff; font-size: .9rem; overflow-wrap: anywhere; }
.tracker-presence-chip.muted-chip { color: var(--muted); background: #f7f7f7; border-color: var(--line); }
#trackingSetupClockHint { margin-top: 8px; }
#newGameClockControllerRow { align-self: end; }
@media (max-width: 700px) {
  .tracker-session-panel .topbar { align-items: stretch; }
  .tracker-session-panel .button-row { justify-content: flex-start; }
}

/* v1.25 revision 7: home/away statistics tabs, goal shot maps, and on-court lineups */
.team-stat-tabs {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin: 0 0 14px;
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #eef4f9;
}
.team-stat-tab {
  min-height: 42px;
  border: 1px solid transparent;
  background: transparent;
  color: #1f4e78;
  font-weight: 700;
  overflow-wrap: anywhere;
}
.team-stat-tab.active {
  border-color: #1f6aa5;
  background: #fff;
  color: #0f4778;
  box-shadow: 0 1px 4px rgba(15, 71, 120, .14);
}
.goal-map-wrap canvas { width: 100%; height: auto; }

.lineup-setup {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  padding: 14px;
  border: 1px solid #c9dceb;
  border-radius: 12px;
  background: #f7fbff;
}
.lineup-setup > .hint { grid-column: 1 / -1; margin: 0; }
.lineup-setup-team {
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
}
.lineup-setup-team h3 { margin: 0 0 10px; color: #0f4778; }
.lineup-setup-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(72px, 1fr));
  gap: 8px;
}
.lineup-setup-grid label { font-weight: 700; }
.lineup-setup-grid input { text-align: center; font-variant-numeric: tabular-nums; }

.tracking-stage-layout {
  display: grid;
  grid-template-columns: minmax(150px, 210px) minmax(0, 1fr) minmax(150px, 210px);
  gap: 12px;
  align-items: start;
}
.tracking-main-card { min-width: 0; }
.lineup-panel {
  position: sticky;
  top: 12px;
  padding: 12px;
}
.lineup-panel h3 {
  margin: 0;
  color: #0f4778;
  overflow-wrap: anywhere;
}
.lineup-panel .hint { margin: 4px 0 10px; }
.lineup-position-list { display: grid; gap: 8px; }
.lineup-position-btn {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  width: 100%;
  min-height: 48px;
  padding: 7px 9px;
  text-align: left;
  background: #fff;
  border-color: #b9d6ee;
}
.lineup-position-btn .lineup-position {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 30px;
  border-radius: 8px;
  background: #e6f1fa;
  color: #0f4778;
  font-weight: 800;
}
.lineup-position-btn strong {
  font-size: 1.08rem;
  text-align: center;
  overflow-wrap: anywhere;
}
.lineup-position-btn.empty strong { color: var(--muted); font-weight: 600; }

@media (max-width: 1100px) {
  .tracking-stage-layout { grid-template-columns: minmax(125px, 165px) minmax(0, 1fr) minmax(125px, 165px); gap: 8px; }
  .lineup-panel { padding: 9px; }
  .lineup-position-btn { grid-template-columns: 32px minmax(0, 1fr); padding: 6px; }
}
@media (max-width: 820px) {
  .tracking-stage-layout { grid-template-columns: 1fr 1fr; }
  .tracking-main-card { grid-column: 1 / -1; grid-row: 1; }
  #homeLineupPanel { grid-column: 1; grid-row: 2; position: static; }
  #awayLineupPanel { grid-column: 2; grid-row: 2; position: static; }
  .lineup-setup { grid-template-columns: 1fr; }
  .lineup-setup > .hint { grid-column: 1; }
}
@media (max-width: 560px) {
  .team-stat-tabs { grid-template-columns: 1fr; }
  .tracking-stage-layout { grid-template-columns: 1fr; }
  .tracking-main-card, #homeLineupPanel, #awayLineupPanel { grid-column: 1; }
  .tracking-main-card { grid-row: 1; }
  #homeLineupPanel { grid-row: 2; }
  #awayLineupPanel { grid-row: 3; }
  .lineup-setup-grid { grid-template-columns: repeat(2, minmax(72px, 1fr)); }
}

/* -------------------------------------------------------------------------
   Revision 8: score, dedicated review page, timelines and player cards
   ------------------------------------------------------------------------- */
.live-score-board {
  display: grid;
  grid-template-columns: minmax(120px, 1fr) auto minmax(120px, 1fr);
  align-items: center;
  gap: 12px;
  min-width: min(100%, 390px);
  padding: 10px 14px;
  border: 1px solid #b8d3e7;
  border-radius: 14px;
  background: linear-gradient(180deg, #f9fcff, #edf6fc);
  box-shadow: 0 3px 12px rgba(15, 71, 120, .10);
}
.live-score-board.hidden { display: none; }
.score-side { min-width: 0; text-align: center; }
.score-team-name {
  display: block;
  min-height: 2.4em;
  color: #0f4778;
  font-weight: 800;
  line-height: 1.2;
  overflow-wrap: anywhere;
}
.score-control-row {
  display: grid;
  grid-template-columns: 42px minmax(54px, 1fr) 42px;
  gap: 7px;
  align-items: center;
  margin-top: 6px;
}
.score-control-row button {
  min-height: 42px;
  padding: 5px;
  border-radius: 10px;
  font-size: 1.3rem;
  font-weight: 900;
}
.score-control-row strong {
  font-size: clamp(2rem, 5vw, 3.25rem);
  line-height: 1;
  font-variant-numeric: tabular-nums;
  color: #0b3558;
}
.score-separator {
  align-self: end;
  padding-bottom: 9px;
  color: #64748b;
  font-size: 2rem;
  font-weight: 800;
}

.review-section-tabs {
  display: flex;
  gap: 8px;
  position: sticky;
  top: 0;
  z-index: 8;
  background: rgba(255,255,255,.96);
  backdrop-filter: blur(8px);
}
.review-section-tabs button { flex: 1; min-height: 46px; }
.review-section-tabs button.active {
  color: #fff;
  background: #1f6aa5;
  border-color: #1f6aa5;
}
.review-match-overview-card { overflow: hidden; }
.review-score-headline {
  margin: 8px 0 18px;
  color: #0b3558;
  font-size: clamp(1.7rem, 4vw, 3rem);
  font-weight: 900;
  text-align: center;
  overflow-wrap: anywhere;
}
.comparison-stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(175px, 1fr));
  gap: 10px;
  margin-bottom: 18px;
}
.comparison-stat {
  display: grid;
  gap: 5px;
  padding: 12px;
  border: 1px solid #d1e1ed;
  border-radius: 12px;
  background: #f8fbfd;
  text-align: center;
}
.comparison-stat span { color: #475569; font-weight: 700; }
.comparison-stat strong {
  color: #0f4778;
  font-size: 1.35rem;
  font-variant-numeric: tabular-nums;
}
.comparison-stat small { color: #64748b; font-size: .72em; }
.comparison-stat em { color: #64748b; font-size: .78rem; font-style: normal; overflow-wrap: anywhere; }
.score-timeline-wrap {
  margin: 12px 0;
  overflow-x: auto;
  border: 1px solid #d1e1ed;
  border-radius: 12px;
  background: #fff;
}
.score-timeline-canvas {
  display: block;
  width: 100%;
  min-width: 720px;
  height: auto;
}
.score-event-list { display: grid; gap: 6px; }
.score-event-list > div {
  padding: 8px 10px;
  border-left: 4px solid #1f6aa5;
  background: #f4f9fc;
}
.shared-team-tabs { margin-bottom: 0; }
.player-card-basic { margin: 14px 0 0; }
.player-card-basic .stat strong { font-variant-numeric: tabular-nums; }
.score-history-detail {
  display: block;
  margin-top: 4px;
  color: #0f4778;
  font-size: .84rem;
  font-weight: 700;
}
.manual-score-history-row { border-left: 4px solid #7c3aed; }

@media (max-width: 920px) {
  #gamePanel > .topbar { align-items: stretch; }
  .live-score-board { order: 2; width: 100%; }
  #gamePanel > .topbar > .button-row { order: 3; width: 100%; }
}
@media (max-width: 620px) {
  .live-score-board { grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); gap: 6px; padding: 9px; }
  .score-control-row { grid-template-columns: 34px minmax(42px, 1fr) 34px; gap: 4px; }
  .score-control-row button { min-height: 38px; }
  .score-team-name { font-size: .86rem; }
  .comparison-stat-grid { grid-template-columns: 1fr 1fr; }
  .review-section-tabs { top: 0; }
}
