/* Padel Buddy: phone-first styles. No framework, no internet needed. */
/* Heebo, Hebrew letters only (SIL OFL, static/fonts/Heebo-OFL.txt): the display fonts below have no Hebrew, so the phone fell back to a serif. First in every stack; Latin and digits keep today's fonts. */
@font-face { font-family: "Heebo"; font-style: normal; font-weight: 400 800; font-display: swap; src: url("/fonts/heebo-hebrew.woff2") format("woff2"); unicode-range: U+0307-0308, U+0590-05FF, U+200C-2010, U+20AA, U+25CC, U+FB1D-FB4F; }
:root {
  color-scheme: dark;
  --bg: #0c1315;
  --bg-2: #111a1d;
  --surface: #152024;
  --surface-2: #1d2b30;
  --hover: #26383e;
  --line: #2a3c42;
  --text: #f4f2ea;          /* chalk white, a little warm */
  --muted: #b3bdb8;
  --faint: #929e99;
  --accent: #d9f24a;        /* ball yellow */
  --accent-ink: #141a05;
  --accent-strong: #2b62e0; /* court blue */
  --good: #3ddc97;
  --good-strong: #138a5f;
  --bad: #ff8a7a;
  --warn: #ffd24a;
  --ball: #c4f25b;
  --me: #4da3ff;
  --partner: #2dd4bf;
  --opp: #a3b1cc;
  --topbar: 48px;
  --radius: 14px;
  /* Sporty condensed face for titles and numbers: Bahnschrift on Windows, Avenir Next Condensed on iPhone,
     Roboto Condensed on Android. Body text stays the phone's own font. */
  --display: Heebo, Bahnschrift, "Avenir Next Condensed", "Roboto Condensed", "sans-serif-condensed", "Arial Narrow", system-ui, sans-serif;
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(900px 460px at 10% -10%, rgba(43, 98, 224, 0.22) 0%, transparent 65%),
    radial-gradient(700px 420px at 105% 110%, rgba(217, 242, 74, 0.06) 0%, transparent 60%),
    var(--bg);
  background-attachment: fixed;
  color: var(--text);
  font: 16px/1.45 Heebo, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-tap-highlight-color: transparent;
}
/* Faint court lines behind everything, like chalk on the floor. */
body::before {
  content: ""; position: fixed; z-index: -1; pointer-events: none;
  right: -14vw; bottom: -12vh; width: min(72vw, 520px); aspect-ratio: 1 / 2;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 200' fill='none' stroke='white' stroke-width='0.8'%3E%3Crect x='1' y='1' width='98' height='198'/%3E%3Cline x1='1' y1='100' x2='99' y2='100' stroke-width='1.8'/%3E%3Cline x1='1' y1='31' x2='99' y2='31'/%3E%3Cline x1='1' y1='169' x2='99' y2='169'/%3E%3Cline x1='50' y1='31' x2='50' y2='169'/%3E%3C/svg%3E") no-repeat center / contain;
  opacity: 0.06; transform: rotate(-14deg);
}
.hidden { display: none !important; }

/* Icons (icons.js): line drawings that take the colour of the text around them. */
.ico {
  width: 1.15em; height: 1.15em; flex: none; display: inline-block; vertical-align: -0.2em;
  fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
}
.ico .solid, .ico.solid { fill: currentColor; }
.ico.solid { stroke-width: 1.5; }
[data-icon] { display: inline-flex; align-items: center; justify-content: center; }
.btn .ico { margin-inline-end: -2px; }
.btn:has(> .ico:only-child), .btn:has(> [data-icon]:only-child) { gap: 0; }
.btn .ico:only-child { margin: 0; }
[dir="rtl"] .arrow [data-icon="arrow-left"], [dir="rtl"] .arrow [data-icon="arrow-right"] { transform: none; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 8px; }
h1, h2, h3, p { margin: 0; }
button { font: inherit; color: inherit; }
/* No zoom on the iPhone (docs/players_sheet_report.md): Safari zooms into a focused field whose text is under 16 px,
   so every text field, drop-down and text box is 16 px+ on touch screens (a field that wants bigger type sets
   --field-size). Pinch zoom stays on (accessibility); "manipulation" only drops double-tap zoom, so fast taps never zoom. */
html, body, button, a, label, summary, [role="button"], input, select, textarea { touch-action: manipulation; }
input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="color"]):not([type="file"]), select, textarea {
  font-size: max(16px, var(--field-size, 1rem));
}
@media (pointer: coarse) {
  input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="color"]):not([type="file"]), select, textarea {
    font-size: max(16px, var(--field-size, 1rem)) !important;
  }
}

.wrap {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 max(12px, env(safe-area-inset-right)) 32px max(12px, env(safe-area-inset-left));
}

/* ------------------------------------------------ top bar */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  min-height: var(--topbar);
  padding-top: env(safe-area-inset-top);
}
.brand {
  display: flex; align-items: center; gap: 10px;
  font: italic 700 1.3rem/1 var(--display); letter-spacing: 0.01em; text-transform: uppercase;
}
/* A padel ball drawn in CSS: yellow felt with two white seams. */
.brand-mark {
  position: relative; overflow: hidden; flex: none;
  width: 28px; height: 28px; border-radius: 50%;
  background: radial-gradient(circle at 34% 30%, #f6ff9e 0%, var(--accent) 45%, #a9c21c 100%);
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.35), 0 0 18px rgba(217, 242, 74, 0.25);
  transition: transform 0.5s var(--ease);
}
.brand-mark::before, .brand-mark::after {
  content: ""; position: absolute; top: -2px; width: 100%; height: 100%;
  border: 2px solid rgba(255, 255, 255, 0.85); border-radius: 50%;
}
.brand-mark::before { left: -64%; }
.brand-mark::after { left: 64%; }
.brand:hover .brand-mark { transform: rotate(200deg); }

/* ------------------------------------------------ buttons, chips, cards */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 0 16px;
  border-radius: 11px; border: 1px solid var(--line);
  background: var(--surface-2); color: var(--text);
  font-weight: 650; font-size: 0.95rem; line-height: 1.1; cursor: pointer;
  touch-action: manipulation;
  transition: transform 0.12s var(--ease), background-color 0.15s, box-shadow 0.12s, border-color 0.15s;
}
.btn:hover { background: var(--hover); }
.btn:active:not(:disabled) { transform: translateY(1px) scale(0.98); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
/* The main buttons sit on a small ledge and press down into it. */
.btn-primary { background: var(--accent); border-color: transparent; color: var(--accent-ink); font-weight: 750; box-shadow: 0 3px 0 #8ea31a; }
.btn-primary:hover { background: #e6ff63; }
.btn-primary:active:not(:disabled) { transform: translateY(2px); box-shadow: 0 1px 0 #8ea31a; }
.btn-good { background: var(--good-strong); border-color: transparent; color: #fff; font-weight: 750; box-shadow: 0 3px 0 #0a5a3e; }
.btn-good:hover { background: #17a06f; }
.btn-good:active:not(:disabled) { transform: translateY(2px); box-shadow: 0 1px 0 #0a5a3e; }
.btn-good:disabled { background: var(--line); color: var(--muted); box-shadow: none; }
.btn-sm { min-height: 40px; padding: 0 12px; font-size: 0.85rem; border-radius: 10px; }
.btn-block { width: 100%; }
.btn-danger { background: transparent; border-color: #8a3a48; color: var(--bad); }
.btn-danger:hover { background: #3a1a22; }

/* ------------------------------------------------ my clips (home) */
.library-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 4px 0 2px; }
.library-head .card-title { font-size: 1.9rem; text-transform: uppercase; font-style: italic; letter-spacing: 0.01em; }
#librarySummary { margin: 0 0 12px; min-height: 1.2em; }
.clip-list { display: grid; gap: 10px; }
@media (min-width: 760px) { .clip-list { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (min-width: 1150px) { .clip-list { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.clip-groups { display: grid; gap: 14px; }
.court-head {
  display: flex; align-items: center; justify-content: space-between; gap: 10px; width: 100%;
  min-height: 44px; padding: 8px 14px; color: var(--text); font: 750 1rem Heebo, system-ui, sans-serif; text-align: start;
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px; cursor: pointer; touch-action: manipulation;
}
.court-head .court-count { color: var(--muted); font-weight: 600; font-size: 0.85rem; white-space: nowrap; }
.court-head::after { content: "▾"; color: var(--muted); }
.court-group.is-folded .court-head::after { content: "▸"; }
[dir="rtl"] .court-group.is-folded .court-head::after { content: "◂"; }
.court-head span:first-child { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.court-group.is-folded .clip-list { display: none; }
.court-group .clip-list { margin-top: 10px; }
.month-divider { grid-column: 1 / -1; margin: 6px 2px 0; color: var(--muted); font-size: 0.8rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; }
.clip-search {
  width: 100%; min-height: 44px; padding: 0 12px; margin: 0 0 8px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--bg); color: var(--text); font: 500 1rem Heebo, system-ui, sans-serif; color-scheme: dark;
}
#searchCount { margin: 0 0 10px; min-height: 1.2em; }
/* ------------------------------------------------ select many clips */
.library-actions { display: flex; align-items: center; gap: 8px; }
.select-tools {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 8px; margin: 0 0 8px; padding: 6px 0;
  background: var(--bg); border-bottom: 1px solid var(--line);
}
.select-tools .select-count { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.select-close {
  flex: none; width: 44px; height: 44px; border-radius: 10px; border: 0; background: transparent; color: var(--text);
  font-size: 1.3rem; cursor: pointer; touch-action: manipulation;
}
.select-close:disabled { opacity: 0.4; }
#libraryNote { margin: 0 0 8px; min-height: 1.2em; }
#libraryStep.is-selecting { padding-bottom: calc(100px + env(safe-area-inset-bottom)); }
#libraryStep.is-selecting .clip-row { animation: none; }
.clip-row.is-pressable { -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; }
.clip-row.is-selectable { grid-template-columns: 24px 112px minmax(0, 1fr) auto; }
@media (max-width: 380px) { .clip-row.is-selectable { grid-template-columns: 24px 88px minmax(0, 1fr) auto; } }
.clip-pick {
  flex: none; width: 24px; height: 24px; border-radius: 7px; border: 2px solid var(--muted);
  display: grid; place-items: center; color: var(--accent-ink); font-weight: 900; font-size: 0.95rem; line-height: 1;
}
.clip-row.is-selected, .court-head.is-selected { border-color: var(--accent); background: #1d2a1a; }
.clip-row.is-selected .clip-pick, .court-head.is-selected .clip-pick, .court-head.is-partial .clip-pick { background: var(--accent); border-color: var(--accent); }
.clip-row.is-selected .clip-pick::after, .court-head.is-selected .clip-pick::after { content: "✓"; }
.court-head.is-partial .clip-pick::after { content: "–"; }
.court-head.is-selectable::after { content: none; }
.court-head .clip-pick:first-child { flex: none; width: 24px; }
.court-head.is-selectable span:nth-child(2) { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.select-bar {
  position: fixed; inset-inline: 0; bottom: 0; z-index: 30; display: grid; gap: 8px;
  padding: 10px 16px calc(10px + env(safe-area-inset-bottom)); background: var(--surface); border-top: 1px solid var(--line);
  box-shadow: 0 -8px 24px rgba(0, 0, 0, 0.45);
}
.select-count { font-weight: 750; }
.select-buttons { display: flex; flex-wrap: wrap; gap: 8px; }
.select-buttons .btn { flex: 1 1 90px; }
.select-bar .select-buttons { flex-wrap: nowrap; }
.select-bar .btn:disabled { opacity: 0.45; box-shadow: none; }
@media (orientation: landscape) and (max-height: 500px) {
  .select-bar { padding-block: 6px; }
  .select-bar .btn { min-height: 40px; }
  #libraryStep.is-selecting { padding-bottom: 72px; }
}
.sheet-backdrop { position: fixed; inset: 0; z-index: 40; display: grid; place-items: center; padding: 16px; background: rgba(0, 0, 0, 0.6); }
.sheet { width: min(420px, 100%); max-height: 100%; overflow: auto; display: grid; gap: 10px; padding: 16px; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; }
.sheet-names { margin: 0; padding-inline-start: 20px; display: grid; gap: 4px; overflow-wrap: anywhere; }

/* Court picker (court_picker.js): club / court drop-downs, "isn't listed" forms, the AI notice, the HD note. */
.place-sheet { width: min(460px, 100%); grid-template-columns: minmax(0, 1fr); }
.place-sheet .field, .place-sheet .field select, .place-sheet .field input { min-width: 0; width: 100%; }
.place-sort { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; }
.place-sort .faint { flex: 1 1 180px; }
.field select {
  min-height: 44px; padding: 0 10px; border-radius: 12px; border: 1px solid var(--line); max-width: 100%;
  background: var(--bg); color: var(--text); font: 500 1rem Heebo, system-ui, sans-serif; color-scheme: dark;
}
.field select:disabled { opacity: 0.55; }
.place-add { display: grid; gap: 8px; padding: 10px; border: 1px dashed var(--line); border-radius: 12px; }
.place-add .btn { justify-self: start; }
.link-button {
  justify-self: start; background: none; border: 0; padding: 6px 0; min-height: 32px; color: var(--accent);
  font: inherit; font-weight: 650; text-decoration: underline; text-underline-offset: 3px; cursor: pointer;
}
.place-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; margin: 0 0 4px; font-weight: 650; }
.place-bar .link-button { padding: 2px 0; }
.clip-court-line { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; margin: 0 0 6px; }
.clip-court-line.hidden, .place-bar.hidden { display: none; }
.ai-notice { display: grid; gap: 8px; margin: 6px 0 10px; padding: 12px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--accent-strong); }
.ai-notice p { margin: 0; }
.hd-note { display: flex; align-items: flex-start; gap: 10px; margin: 12px 0 4px; padding: 10px 12px; border-radius: 12px; background: rgba(217, 242, 74, 0.08); border: 1px solid rgba(217, 242, 74, 0.35); }
.hd-note p { margin: 0; color: var(--muted); }
.hd-note strong { color: var(--text); display: block; margin-bottom: 2px; }
.hd-badge { flex: none; padding: 2px 7px; border-radius: 6px; background: var(--accent); color: var(--accent-ink); font: 800 0.8rem var(--display); letter-spacing: 0.04em; }
.undo-toast {
  position: fixed; inset-inline: 12px; bottom: calc(12px + env(safe-area-inset-bottom)); z-index: 50; display: flex; align-items: center;
  justify-content: space-between; gap: 12px; max-width: 460px; margin-inline: auto; padding: 8px 8px 8px 16px;
  background: var(--surface); border: 1px solid var(--accent); border-radius: 12px; box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
}
.trash-list { display: grid; gap: 8px; margin-top: 8px; }
.trash-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.trash-text { min-width: 0; }
.clip-downloads { margin-top: 10px; }
.clip-downloads .btn { flex: 1 1 200px; }
.clip-row {
  display: grid; grid-template-columns: 112px minmax(0, 1fr) auto; gap: 12px; align-items: center;
  width: 100%; padding: 8px; text-align: start; color: var(--text); cursor: pointer;
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
  font: inherit; touch-action: manipulation;
  transition: transform 0.18s var(--ease), border-color 0.18s, background-color 0.18s;
}
@media (hover: hover) { .clip-row:hover { border-color: #46616a; background: #182529; transform: translateY(-2px); } }
.clip-row:active { transform: scale(0.99); }
.clip-thumb { width: 112px; aspect-ratio: 16 / 9; object-fit: cover; border-radius: 9px; background: #000; display: block; }
.clip-text { min-width: 0; display: grid; gap: 3px; }
.clip-name { font-weight: 750; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.clip-meta { font-size: 0.8rem; color: var(--faint); display: flex; flex-wrap: wrap; gap: 4px 8px; align-items: center; }
.clip-mistake { font-size: 0.8rem; color: var(--muted); overflow: hidden; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; }
/* The rating looks like a little scoreboard tile. */
.clip-rating {
  min-width: 3.1ch; padding: 6px 8px; text-align: center;
  font: italic 700 1.5rem/1 var(--display); font-variant-numeric: tabular-nums; color: var(--accent);
  background: var(--bg); border: 1px solid var(--line); border-radius: 9px;
}
.badge-saved { color: var(--good); font-weight: 700; }
.badge-unsaved { color: var(--warn); font-weight: 700; }
/* A marking clip (someone else's game, kept for hand marks): a small pill, rating dimmed. */
.badge-marking { color: var(--muted); font-weight: 700; white-space: nowrap; padding: 1px 7px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface-2); }
.clip-row.is-marking .clip-rating { opacity: 0.45; }
.notify-button { margin-top: 12px; }
/* Several videos at once: which clip is being set up, the queue screen, and the line on My clips. */
.batch-note { margin: 0 0 10px; padding: 8px 12px; border-radius: 10px; background: var(--surface-2); font-weight: 700; font-size: 0.9rem; overflow-wrap: anywhere; }
.queue-list { display: grid; gap: 8px; margin-top: 12px; }
.queue-row {
  display: grid; grid-template-columns: 96px minmax(0, 1fr); gap: 12px; align-items: center; width: 100%;
  padding: 8px; border-radius: 12px; border: 1px solid var(--line); background: var(--bg-2); color: var(--text);
  text-align: start; font: inherit; min-height: 64px;
}
.queue-row[data-state="done"] { cursor: pointer; border-color: rgba(61, 220, 151, 0.5); }
.queue-row[data-state="done"]:hover { background: var(--surface-2); }
.queue-row[data-state="error"] { border-color: rgba(255, 138, 122, 0.6); }
.queue-row:disabled { opacity: 1; }
.queue-thumb { width: 96px; aspect-ratio: 16 / 9; object-fit: cover; border-radius: 8px; background: var(--surface-2); }
.queue-text { display: grid; gap: 3px; min-width: 0; }
.queue-name { font-weight: 700; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow-wrap: anywhere; }   /* two lines: the date at the end stays readable (friend journey 2026-11-24) */
.queue-state { font-size: 0.85rem; color: var(--muted); overflow-wrap: anywhere; }
.queue-row[data-state="done"] .queue-state { color: var(--good); font-weight: 700; }
.queue-row[data-state="error"] .queue-state { color: var(--bad); }
.queue-bar { display: block; height: 6px; border-radius: 99px; background: var(--surface-2); overflow: hidden; }
.queue-bar i { display: block; height: 100%; background: var(--accent); transition: width 0.4s linear; }
/* Set up while uploading (upload_setup.js): the picked videos on the upload screen, clips not queued yet on the queue screen */
.up-list { display: grid; gap: 8px; width: 100%; margin: 8px 0 4px; text-align: start; }
.up-row { display: grid; grid-template-columns: 72px minmax(0, 1fr); gap: 10px; align-items: center; padding: 6px;
  border-radius: 12px; border: 1px solid var(--line); background: var(--bg-2); }
.up-row[data-state="failed"] { border-color: rgba(255, 138, 122, 0.6); }
.up-thumb { width: 72px; aspect-ratio: 16 / 9; object-fit: cover; border-radius: 8px; background: var(--surface-2); }
.up-thumb.is-empty, .queue-thumb.is-empty { visibility: hidden; }
.up-text { display: grid; gap: 3px; min-width: 0; }
.up-name { font-weight: 700; font-size: 0.9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.up-state { font-size: 0.8rem; color: var(--muted); overflow-wrap: anywhere; }
#queuePending { margin-bottom: 10px; }
.pend-row { grid-template-columns: minmax(0, 1fr) 44px; padding: 0; gap: 0; }
.pend-row[data-state="answer"] { border-color: rgba(217, 242, 74, 0.45); }
.pend-open { display: grid; grid-template-columns: 96px minmax(0, 1fr); gap: 12px; align-items: center; padding: 8px;
  background: none; border: 0; color: inherit; font: inherit; text-align: start; min-height: 64px; cursor: pointer; }
.pend-open:disabled { cursor: default; color: inherit; opacity: 1; }
.pend-row[data-state="answer"] .queue-state { color: var(--accent); font-weight: 700; }
.pend-remove { align-self: stretch; min-width: 44px; background: none; border: 0; border-inline-start: 1px solid var(--line);
  color: var(--muted); font: inherit; font-size: 1.1rem; cursor: pointer; }
.job-row:not([data-state="error"]) { grid-template-columns: minmax(0, 1fr); }
.job-row[data-state="done"] .pend-open { cursor: pointer; }
#sameCourtButton { margin: 0 0 8px; }
.queue-banner {
  display: block; width: 100%; margin: 10px 0 0; padding: 10px 12px; min-height: 44px; border-radius: 12px;
  border: 1px solid rgba(217, 242, 74, 0.35); background: rgba(217, 242, 74, 0.08); color: var(--accent);
  font: 700 0.9rem Heebo, system-ui, sans-serif; text-align: start; cursor: pointer;
}
/* "Install Padel Buddy" card on My clips (pwa.js). */
.install-card { display: flex; align-items: center; gap: 12px; padding: 12px; margin: 10px 0 0; border-color: rgba(217, 242, 74, 0.35); }
.install-icon { flex: none; width: 44px; height: 44px; border-radius: 10px; }
.install-text { flex: 1; min-width: 0; display: grid; gap: 2px; }
.install-title { font-weight: 750; }
.install-text b { color: var(--text); }
.install-actions { flex: none; display: flex; align-items: center; gap: 6px; }
.library-empty { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 8px; padding: 32px 16px; }
@media (max-width: 380px) { .clip-row { grid-template-columns: 88px minmax(0, 1fr) auto; } .clip-thumb { width: 88px; } }

/* ------------------------------------------------ home (numbers, latest and best clips) */
.home-cols { display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; max-width: 980px; margin-inline: auto; }
.home-col { min-width: 0; display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px; align-content: start; }
.home-col .queue-banner { margin: 0; }
.home-col .wiki-entry { margin-bottom: 0; }
.home-col .install-card { margin: 0; }
.home-add { min-height: 56px; font-size: 1.15rem; }
#homeStatus { margin: 0; min-height: 0; }
#homeStatus:empty { display: none; }
.home-tiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.tile, .home-best {
  min-width: 0; padding: 10px 12px; display: grid; gap: 2px; align-content: start;
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}
.tile-label { font: 700 0.78rem/1.2 var(--display); letter-spacing: 0.04em; text-transform: uppercase; color: var(--muted); }
.tile-value { font: italic 700 1.9rem/1.1 var(--display); font-variant-numeric: tabular-nums; color: var(--accent); overflow-wrap: anywhere; }
.tile-sample { font-size: 0.75rem; line-height: 1.3; color: var(--faint); overflow-wrap: anywhere; margin: 0; }
.home-best { width: 100%; text-align: start; color: var(--text); font: inherit; cursor: pointer; touch-action: manipulation; }
.home-best:disabled { cursor: default; }
.home-best .clip-name { white-space: normal; }
.home-heading { margin: 6px 0 8px; }
.home-all { margin-top: 10px; }
.best-strip { display: flex; gap: 10px; overflow-x: auto; scroll-snap-type: x proximity; padding-bottom: 6px; max-width: 100%; }
.best-item {
  flex: none; width: 150px; display: grid; gap: 4px; padding: 6px; scroll-snap-align: start; text-align: start;
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px; color: var(--text); font: inherit; cursor: pointer;
}
.best-item .clip-thumb { width: 100%; }
.best-item .clip-name { font-size: 0.85rem; }
.best-hits { font: italic 700 1.1rem/1 var(--display); color: var(--accent); }
@media (min-width: 760px), (orientation: landscape) and (min-width: 700px) {
  .home-cols { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
  .home-col .clip-list { grid-template-columns: minmax(0, 1fr); }
}

/* ------------------------------------------------ this clip (results screen) */
.clip-card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 6px; }
.clip-title-line { margin: 0 0 6px; font-weight: 700; overflow-wrap: anywhere; }
.clip-card .pill.is-saved { background: var(--good-strong); color: #fff; }
.clip-card .pill.is-unsaved { background: #5a4a14; color: #ffe9a6; }
.clip-fields { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; margin: 10px 0; }
@media (max-width: 420px) { .clip-fields { grid-template-columns: 1fr; } }
.field { display: grid; gap: 4px; font-size: 0.8rem; color: var(--muted); font-weight: 650; }
.field input {
  min-height: 44px; padding: 0 12px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--bg); color: var(--text); font: 500 1rem Heebo, system-ui, sans-serif; color-scheme: dark;
}
.clip-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.clip-actions .btn-good { flex: 1 1 200px; }
#clipStatus { margin: 8px 0 0; min-height: 1.2em; }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04), 0 10px 30px -18px rgba(0, 0, 0, 0.6);
  padding: 16px;
}
.card + .card { margin-top: 12px; }
.card-title { font: 700 1.4rem/1.15 var(--display); letter-spacing: 0.005em; }
.eyebrow { font: 700 0.88rem/1.2 var(--display); letter-spacing: 0.04em; text-transform: uppercase; color: var(--muted); }
.eyebrow::before {
  content: ""; display: inline-block; flex: none; width: 3px; height: 0.95em; border-radius: 2px;
  background: var(--accent); margin-inline-end: 8px; vertical-align: -0.12em;
}
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.small { font-size: 0.85rem; }

.error {
  margin: 4px 0 12px; padding: 12px 14px; border-radius: 12px;
  background: #4a1f28; border: 1px solid #b94a5a; color: #ffe3e7;
}

/* ------------------------------------------------ steps (upload, calibrate, progress) */
.batch-note { display: flex; align-items: center; gap: 10px; }
.batch-note.hidden { display: none; }
.batch-thumb { width: 56px; height: 32px; object-fit: cover; border-radius: 6px; flex: none; }
.step-head { display: flex; align-items: center; gap: 10px; margin-bottom: 4px; }
.step-num {
  display: grid; place-items: center; width: 28px; height: 28px; border-radius: 50%;
  background: var(--accent); color: var(--accent-ink); font: italic 700 1rem/1 var(--display); flex: none;
}
/* The drop area looks like a strip of court turf. */
.upload-drop {
  display: flex; flex-direction: column; align-items: center; text-align: center; gap: 12px;
  padding: 28px 16px; margin-top: 14px;
  border: 2px dashed rgba(217, 242, 74, 0.35); border-radius: var(--radius);
  background:
    repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.025) 0 26px, transparent 26px 52px),
    rgba(43, 98, 224, 0.12);
}
.upload-icon { font-size: 2.6rem; line-height: 1; color: var(--accent); animation: float 3s ease-in-out infinite; }
.upload-icon .ico { stroke-width: 1.5; }
@keyframes float { 50% { transform: translateY(-6px) rotate(-4deg); } }
.file-btn { position: relative; cursor: pointer; }
.file-btn:focus-within { outline: 3px solid var(--accent); outline-offset: 2px; }

.howto { list-style: none; padding: 0; margin: 12px 0; display: grid; gap: 10px; }
.howto li { display: grid; grid-template-columns: 28px 1fr; gap: 10px; align-items: start; }
.howto .step-num { background: var(--surface-2); color: var(--text); border: 1px solid var(--line); }
.howto b { color: var(--text); }
.swatch { display: inline-block; width: 12px; height: 12px; border-radius: 50%; vertical-align: -1px; margin-right: 2px; }

.calibrate-grid { display: grid; gap: 14px; align-items: start; }
.calibrate-main { min-width: 0; }

/* Magnifier for placing a court dot: fixed on the screen, away from the finger (at the top, or at the bottom
   when the dot is high up on the screen). */
.loupe {
  position: fixed; left: 50%; transform: translateX(-50%); top: calc(64px + env(safe-area-inset-top));
  width: 168px; height: 168px; z-index: 30; pointer-events: none;
  border: 3px solid #fff; border-radius: 50%; box-shadow: 0 8px 30px rgba(0, 0, 0, 0.6); background: var(--bg);
}
.loupe.at-bottom { top: auto; bottom: calc(96px + env(safe-area-inset-bottom)); }

.adjust-pad { display: grid; grid-template-columns: 1fr auto; gap: 12px; align-items: center; margin-top: 10px; padding: 10px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); }
.chips-row { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0; }
.handle-chip { min-height: 40px; padding: 0 12px; font: 650 0.85rem Heebo, system-ui, sans-serif; }
.handle-chip.is-picked { background: var(--accent-strong); border-color: transparent; color: #fff; }
.arrow-pad { display: grid; grid-template-columns: repeat(3, 52px); grid-auto-rows: 52px; gap: 6px; }
.arrow { padding: 0; min-height: 52px; font-size: 1.3rem; touch-action: none; user-select: none; }
@media (max-width: 420px) { .adjust-pad { grid-template-columns: 1fr; } .arrow-pad { justify-self: center; } }
.calibrate-main .toolbar { margin: 10px 0 4px; }
details.how { margin-top: 6px; }
details.court-adjust { margin-top: 8px; }
details.court-adjust > summary { cursor: pointer; min-height: 44px; display: flex; align-items: center; color: var(--text); font-weight: 650; font-size: 0.95rem; }
details.how summary { cursor: pointer; min-height: 40px; display: flex; align-items: center; color: var(--muted); font-weight: 650; font-size: 0.9rem; }
#calibrationCanvas { display: block; width: 100%; height: auto; border-radius: 14px; background: #000; touch-action: none; cursor: crosshair; }

.corner-panel {
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  border: 2px solid var(--accent); background: rgba(217, 242, 74, 0.06);
  border-radius: var(--radius); padding: 12px; justify-self: center; width: 100%; max-width: 280px;
}
.corner-panel.is-set { border-color: var(--good); background: rgba(61, 220, 151, 0.08); }
.corner-panel:not(.is-set) { animation: glow 1.6s ease-in-out infinite; }
#cornerTitle { font: 700 1.2rem/1.2 var(--display); color: var(--accent); text-align: center; }
.corner-panel.is-set #cornerTitle { color: var(--good); }
/* The court map is the whole screen of step 3: as tall as the screen allows, keeping its shape. */
#cornerCanvas { display: block; width: auto; max-width: 100%; height: min(50vh, 420px); height: min(50dvh, 420px); border-radius: 12px; cursor: pointer; touch-action: manipulation; }
#sideStep .corner-panel { max-width: 420px; margin: 12px auto 0; }
.frame-corners { display: block; width: 100%; height: auto; border-radius: 12px; cursor: pointer; touch-action: manipulation; background: #000; }
/* Phone on its side: little height. Hide the steps bar, put the words beside the map and fit the map in. */
@media (orientation: landscape) and (max-height: 500px) {
  .stepper { display: none; }
  #sideStep .corner-panel {
    max-width: 640px; display: grid; grid-template-columns: 1fr auto; grid-template-rows: auto auto auto auto 1fr;
    column-gap: 16px; align-items: center; margin-top: 6px; padding: 8px 12px;
  }
  #sideStep #cornerTitle, #sideStep #cornerSubtitle, #sideStep #cornerHint, #sideStep .frame-corners { grid-column: 1; }
  #sideStep .frame-corners { width: auto; max-width: 100%; max-height: 190px; justify-self: center; }
  #sideStep .corner-panel > p.faint:not(#cornerSubtitle):not(#cornerHint) { display: none; }
  #sideStep #cornerCanvas { grid-column: 2; grid-row: 1 / span 5; height: calc(100vh - 200px); height: calc(100dvh - 200px); min-height: 150px; }
  #sideStep .step-actions { margin-top: 8px; }
}
@keyframes glow {
  0%, 100% { box-shadow: 0 0 0 0 rgba(217, 242, 74, 0.5); }
  50% { box-shadow: 0 0 0 10px rgba(217, 242, 74, 0); }
}

.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin: 12px 0; }
.lens { display: flex; align-items: center; gap: 10px; flex: 1 1 240px; min-width: 200px; font-size: 0.9rem; color: var(--muted); }
.lens input[type="range"] { flex: 1; min-width: 120px; height: 32px; accent-color: var(--accent); }
.prompt { padding: 8px 12px; border-radius: 12px; background: var(--surface-2); font-weight: 700; font-size: 0.9rem; text-align: center; }
.sticky-actions {
  position: sticky; bottom: 0; z-index: 5; margin: 14px -4px 0; padding: 10px 4px calc(10px + env(safe-area-inset-bottom));
  background: linear-gradient(180deg, transparent, var(--bg-2) 35%);
}

.step-actions.two { display: grid; grid-template-columns: auto 1fr; gap: 10px; }
.back-button { padding-inline: 18px; }

/* ------------------------------------------------ the set-up steps bar */
.stepper { margin: 2px 0 12px; }
.stepper ol { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.stepper li {
  display: flex; flex-direction: column; align-items: center; gap: 4px; position: relative;
  font-size: 0.75rem; font-weight: 650; color: var(--faint); text-align: center;
}
.stepper li::before {     /* the line joining the dots */
  content: ""; position: absolute; top: 13px; inset-inline-start: calc(-50% + 16px); width: calc(100% - 32px);
  height: 2px; background: var(--line);
}
.stepper li:first-child::before { display: none; }
.stepper .dot {
  display: grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; position: relative; z-index: 1;
  background: var(--surface-2); border: 1px solid var(--line); font: italic 700 0.9rem/1 var(--display);
  transition: background-color 0.25s, box-shadow 0.25s, transform 0.25s var(--ease);
}
.stepper li.is-done { color: var(--muted); }
.stepper li.is-done .dot { background: var(--good-strong); border-color: transparent; color: #fff; }
.stepper li.is-done::before, .stepper li.is-current::before { background: var(--good-strong); }
.stepper li.is-current { color: var(--text); }
.stepper li.is-current .dot { background: var(--accent); border-color: transparent; color: var(--accent-ink); box-shadow: 0 0 0 4px rgba(217, 242, 74, 0.2); transform: scale(1.08); }

.upload-preview { width: 100%; max-width: 360px; border-radius: 12px; border: 1px solid var(--line); }

/* ------------------------------------------------ analysing */
.progress-message {
  min-height: 3em; margin: 14px 0 0; font-size: 1.1rem; font-weight: 700; color: var(--text);
  transition: opacity 0.35s ease;
}
.progress-message.is-fading { opacity: 0; }
@media (prefers-reduced-motion: reduce) { .progress-message { transition: none; } }
.progress-info { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-bottom: 10px; }
.progress-percent { font: italic 700 1.6rem/1 var(--display); font-variant-numeric: tabular-nums; color: var(--accent); }
#progressEta { font-variant-numeric: tabular-nums; }

.progress {
  height: 14px; border-radius: 999px; background: var(--surface-2); overflow: hidden; margin: 14px 0 8px;
}
/* Ball-yellow bar with stripes that keep rolling, so it never looks frozen between updates. */
.progress > div {
  height: 100%; width: 0; border-radius: 999px; transition: width 0.3s;
  background: repeating-linear-gradient(-45deg, transparent 0 10px, rgba(0, 0, 0, 0.14) 10px 20px), var(--accent);
  background-size: 28.28px 28.28px, auto;
  animation: stripes 0.9s linear infinite;
}
@keyframes stripes { to { background-position: 28.28px 0, 0 0; } }
/* A ball bouncing next to "Analysing…". */
#progressStep .step-head::after {
  content: ""; margin-inline-start: auto; width: 14px; height: 14px; border-radius: 50%; flex: none;
  background: radial-gradient(circle at 35% 30%, #f6ff9e, var(--ball) 55%, #9ab814);
  animation: bounce 0.55s cubic-bezier(0.5, 0, 0.5, 1) infinite alternate;
}
@keyframes bounce {
  from { transform: translateY(-12px); }
  90% { transform: translateY(3px) scale(1, 1); }
  to { transform: translateY(4px) scale(1.15, 0.8); }
}

/* ------------------------------------------------ results: the one-screen stage */
.stage {
  display: grid; gap: 10px;
  height: calc(100vh - var(--topbar) - 10px);
  height: calc(100dvh - var(--topbar) - 10px);
  min-height: 540px;
}
.stage-left, .stage-right { display: flex; flex-direction: column; gap: 10px; min-height: 0; min-width: 0; }
@media (max-width: 999px) {
  .stage { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr); }
}
@media (min-width: 1000px) {
  .stage { grid-template-columns: minmax(0, 1fr) minmax(600px, 46%); }
  .stage-left { overflow-y: auto; }
}
/* Phone held sideways (UX audit C1): the video gets the left ~62 % at full height; the map, the speed rows and the tip
   stack in the right column. .stage-left dissolves so its parts can be placed in the one grid. */
@media (max-width: 999px) and (orientation: landscape) {
  .stage { grid-template-columns: minmax(0, 62fr) minmax(0, 38fr); grid-template-rows: repeat(6, auto); column-gap: 10px; row-gap: 6px; height: auto; min-height: 0; }
  .stage-left { display: contents; }
  .stage .video-box { grid-column: 1; grid-row: 1 / span 6; align-self: start; position: sticky; top: 4px; }
  .stage #mapPanel { min-height: 200px; }
  .stage .stage-left > :not(.video-box) { grid-column: 2; }
  .stage #mapPanel, .stage #rallyEdit, .stage #hitEdit { grid-column: 2; grid-row: 1; }
  .stage.is-editing #rallyEdit, .stage.is-editing #hitEdit { overflow: visible; }   /* the page scrolls; the foot row sticks to the screen */
  .stage .legend, .stage .legend-btn { display: none; }
}

.video-box { position: relative; border-radius: 14px; overflow: hidden; background: #000; flex: none; }
.ball-box { position: absolute; left: 0; top: 0; width: 100%; height: 100%; pointer-events: none; }
/* The "Ghost on video" and "Debug" switches sit in the row under the video (nothing covers the picture). */
.overlay-row { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 16px; padding: 0 0 2px; }
.overlay-switch { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; font-size: 0.95rem; font-weight: 700; cursor: pointer; white-space: nowrap; }
.overlay-switch input { width: 22px; height: 22px; margin: 0; accent-color: #ffd24a; }
.debug-switch input { accent-color: #ff6b6b; }
.overlay-switch.hidden { display: none; }
.stage.is-editing .overlay-row { display: none; }
#hitRing { z-index: 2; }
.debug-panel { display: grid; gap: 6px; margin-top: 6px; }
.video-stuck { margin: 6px 0 0; padding: 8px 12px; border-radius: 8px; background: rgba(255, 170, 60, 0.18); color: inherit; font-size: 0.9rem; text-align: center; cursor: pointer; }
.debug-panel p { margin: 0; }
.debug-strip { display: block; width: 100%; height: 40px; border-radius: 8px; touch-action: none; cursor: pointer; direction: ltr; }
.debug-numbers { margin: 0; padding: 6px 10px; border-radius: 10px; background: var(--surface); border: 1px solid var(--line); font-size: 0.74rem; line-height: 1.35; white-space: pre-wrap; direction: ltr; text-align: start; unicode-bidi: isolate; }
.settings-card { display: grid; gap: 8px; }
.settings-section { margin: 0; font-size: 1.05rem; }
.debug-options { display: grid; gap: 2px; }
.debug-option { min-height: 44px; white-space: normal; }
#settingsStep .btn { justify-self: start; }
#video { display: block; width: 100%; max-height: 36vh; max-height: 36dvh; aspect-ratio: 16 / 9; background: #000; object-fit: contain; }
@media (min-width: 1000px), (orientation: landscape) { #video { max-height: 60vh; max-height: 60dvh; } }

.trim { padding: 4px 10px 2px; border-radius: 14px; background: var(--surface); border: 1px solid var(--line); flex: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
.trim-row { display: flex; align-items: center; gap: 8px; }
.switch { display: inline-flex; align-items: center; gap: 8px; font-weight: 700; min-height: 40px; cursor: pointer; white-space: nowrap; }
.switch input { width: 22px; height: 22px; accent-color: var(--good); }
.speed-row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; direction: ltr; padding: 4px 0; }
.speed-btn { min-height: 32px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface-2); color: var(--text); font-weight: 700; font-size: 0.85rem; cursor: pointer; }
.speed-btn[aria-pressed="true"] { background: var(--good); color: #fff; border-color: transparent; }
#cropRange { font-variant-numeric: tabular-nums; color: var(--muted); font-size: 0.78rem; margin-inline-start: auto; text-align: end; direction: ltr; unicode-bidi: isolate; }
html[dir="rtl"] #cropRange { direction: ltr; }   /* times and numbers keep their order, even next to Hebrew words */
.icon-btn {
  flex: none; width: 40px; height: 40px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--surface-2); font-size: 1.1rem; cursor: pointer; display: grid; place-items: center;
}
.icon-btn[aria-expanded="true"] { background: var(--accent-strong); border-color: transparent; }
.scrubber { position: relative; height: 28px; cursor: pointer; touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
.scrubber .track { position: absolute; left: 0; right: 0; top: 10px; height: 8px; border-radius: 99px; background: var(--surface-2); overflow: hidden; }
#cropFill { position: absolute; top: 0; bottom: 0; background: rgba(61, 220, 151, 0.7); }
#cropHead { position: absolute; top: 4px; bottom: 4px; width: 4px; margin-left: -2px; border-radius: 3px; background: #fff; box-shadow: 0 0 0 2px rgba(10, 16, 32, 0.8); }
.adjust { padding: 4px 0 8px; }
.adjust .row { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 6px; }
#cropNote { color: var(--faint); font-size: 0.8rem; }

/* The tip always has the same height (room for three lines), whatever its text. A box that grows and
   shrinks with the text moves everything below it, and the map is redrawn each time: that flickers.
   If a text is too long for three lines, the script makes its letters a little smaller instead. */
.tip {
  flex: none; padding: 8px 12px; border-radius: 14px; border: 1px solid var(--line);
  background: var(--surface); color: var(--muted); font-size: 0.9rem; line-height: 1.25;
  height: 72px; overflow: hidden; contain: layout;
  display: flex; align-items: center; gap: 10px;
}
.tip::before {
  content: ""; flex: none; width: 12px; height: 12px; border-radius: 50%;
  background: var(--ball); box-shadow: 0 0 0 4px rgba(196, 242, 91, 0.14);
}
#tipText { flex: 1; min-width: 0; max-height: 3.75em; overflow: hidden; overflow-wrap: anywhere; }
.tip { border-inline-start: 3px solid var(--ball); transition: background-color 0.3s, border-color 0.3s; }
.tip.is-ghost { border-color: var(--warn); background: rgba(255, 210, 74, 0.1); color: #fff2bd; font-weight: 600; }
.tip.is-ghost::before { background: var(--warn); animation: ping 1.1s ease-out infinite; }
.tip.is-idle { color: var(--faint); border-inline-start-color: var(--line); }
.tip.is-idle::before { background: var(--faint); box-shadow: none; }
/* A tip with a guide page: the whole box opens it; the chip says so. */
.tip.is-link { cursor: pointer; }
@media (hover: hover) { .tip.is-link:hover { background: rgba(255, 210, 74, 0.16); } }
.tip-learn {
  flex: none; align-self: center; min-height: 36px; padding: 0 12px; border-radius: 99px; cursor: pointer;
  border: 1px solid rgba(255, 210, 74, 0.5); background: rgba(255, 210, 74, 0.12); color: var(--warn);
  font: 700 0.82rem/1 Heebo, system-ui, sans-serif; white-space: nowrap; touch-action: manipulation;
}
.tip-learn:active { transform: scale(0.96); }
@keyframes ping {
  0% { box-shadow: 0 0 0 0 rgba(255, 210, 74, 0.6); }
  100% { box-shadow: 0 0 0 9px rgba(255, 210, 74, 0); }
}

.map-panel {
  display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 12px;
  flex: 1; min-height: 0; padding: 10px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
}
@media (max-width: 999px) { .stage-right { display: contents; } }
.map-wrap { display: flex; align-items: center; justify-content: center; min-height: 0; }
#radarCanvas { display: block; border-radius: 12px; background: #0f181b; }
.map-side { display: flex; flex-direction: column; gap: 12px; min-width: 0; overflow-y: auto; }
.sync { font: italic 700 2.8rem/1 var(--display); font-variant-numeric: tabular-nums; }
#tetherState {
  display: inline-flex; align-items: center; gap: 6px; align-self: flex-start;
  padding: 6px 12px; border-radius: 999px; font-weight: 750; font-size: 0.9rem; color: #0a1210; background: var(--muted); white-space: nowrap;
  transition: background-color 0.35s;
}
#ghostMode { color: var(--faint); font-size: 0.8rem; }
.legend { display: grid; gap: 6px; font-size: 0.82rem; color: var(--muted); }
.legend span { display: flex; align-items: center; gap: 8px; }
.dot { flex: none; display: inline-block; width: 12px; height: 12px; border-radius: 50%; }
.dot.ring { background: transparent; border: 3px solid; width: 14px; height: 14px; }
@media (max-width: 999px) {
  .map-side { gap: 8px; overflow-y: auto; scrollbar-width: none; }
  .map-side::-webkit-scrollbar { display: none; }
  .sync { font-size: 2.3rem; }
  .legend { font-size: 0.76rem; gap: 4px; }
  .map-panel { padding: 8px; gap: 10px; }
}

.more-hint { text-align: center; color: var(--faint); font-size: 0.8rem; padding: 6px 0 2px; }

/* ------------------------------------------------ below the stage: log + report */
.below { margin-top: 14px; display: grid; gap: 12px; }
.log { display: flex; flex-direction: column; gap: 8px; max-height: 26rem; overflow-y: auto; overflow-x: hidden; min-width: 0; }
.card { min-width: 0; overflow-wrap: anywhere; }
.log-item {
  display: block; width: 100%; min-width: 0; max-width: 100%; height: auto; margin: 0;
  text-align: start; font: inherit; color: inherit; white-space: normal; overflow-wrap: anywhere;
  padding: 10px 12px; border-radius: 12px; -webkit-appearance: none; appearance: none;
  border: 1px solid var(--line); background: var(--bg-2); cursor: pointer; min-height: 56px;
  transition: background-color 0.15s, border-color 0.15s, transform 0.12s var(--ease);
}
.log-item > * { min-width: 0; overflow-wrap: anywhere; }
.log-item:hover { background: var(--surface-2); }
.log-item:active { transform: scale(0.99); }
.log-item.is-active { border-color: var(--warn); background: rgba(255, 210, 74, 0.1); }
.log-item.is-faded { opacity: 0.65; }
.log-row { display: flex; gap: 6px; min-width: 0; }
.log-row .log-item { flex: 1; }
.learn-btn { flex: none; align-self: stretch; height: auto; padding: 0 12px; color: var(--accent); }
/* "Read in the guide ›" under a top mistake or a drill. */
.link-btn {
  display: inline-flex; align-items: center; min-height: 40px; margin-top: 6px; padding: 0; border: 0; background: none;
  color: var(--accent); font: 700 0.85rem Heebo, system-ui, sans-serif; cursor: pointer; touch-action: manipulation;
}
.link-btn:hover { text-decoration: underline; }
.log-time { font: 700 0.82rem/1.2 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; color: var(--warn); }
.log-time .rest { color: var(--muted); font-weight: 500; }
.log-text { margin-top: 2px; color: var(--text); }
.badge { margin-inline-start: 6px; display: inline-block; padding: 2px 8px; border-radius: 99px; background: #2e4248; color: #e2ebe7; font: 600 0.7rem/1.4 Heebo, system-ui, sans-serif; }

.report-grid { display: grid; gap: 12px; grid-template-columns: 1fr; }
@media (min-width: 700px) { .report-grid { grid-template-columns: 1fr 1fr; } }
@media (min-width: 1100px) { .report-grid { grid-template-columns: repeat(4, 1fr); } }
.report-grid .card + .card { margin-top: 0; }
.rating-number { font: italic 700 3.6rem/1 var(--display); color: var(--accent); text-shadow: 0 0 24px rgba(217, 242, 74, 0.2); }
.rating-row { display: flex; align-items: baseline; gap: 8px; margin-top: 4px; }
.rating-row .pill { margin-inline-start: auto; }
.topbar-actions { display: flex; align-items: center; gap: 8px; }
.pill { padding: 2px 10px; border-radius: 99px; background: #2e4248; font-size: 0.72rem; color: #e2ebe7; }
.bar-row .top { display: flex; justify-content: space-between; font-size: 0.85rem; color: var(--text); }
.bar-row .top .val { color: var(--muted); }
.bar-row .track { margin-top: 4px; height: 8px; border-radius: 99px; background: var(--surface-2); overflow: hidden; }
.bar-row .fill { height: 100%; border-radius: 99px; transform-origin: left; animation: grow 0.7s var(--ease) both; }
@keyframes grow { from { transform: scaleX(0); } }
.stack { display: grid; gap: 8px; }
.item { padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--bg-2); }
.item-title { font-weight: 700; color: var(--warn); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; max-height: 9rem; overflow-y: auto; }
.chip {
  min-height: 36px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface-2);
  color: var(--text); cursor: pointer; font: 600 0.78rem ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
.strip { margin-top: 8px; height: 5px; border-radius: 99px; background: var(--surface-2); overflow: hidden; }
.strip > div { height: 100%; }
/* You vs pros: the pros' band (p10-p90), their median tick and a dot for you. */
.pos-row .top { display: flex; justify-content: space-between; gap: 8px; font-size: 0.85rem; color: var(--text); }
.pos-verdict { flex: none; color: var(--muted); font-size: 0.8rem; text-align: end; }
.pos-verdict.is-in { color: var(--accent); }
.pos-verdict.is-edge { color: var(--warn); }
.pos-verdict.is-hi, .pos-verdict.is-lo { color: #f87171; }
.pos-track { position: relative; margin: 8px 6px 4px; height: 8px; border-radius: 99px; background: var(--surface-2); }
.pos-band { position: absolute; top: 0; bottom: 0; border-radius: 99px; background: rgba(148, 163, 184, 0.45); }
.pos-mid { position: absolute; top: -3px; bottom: -3px; width: 2px; margin-left: -1px; background: var(--muted); }
.pos-dot { position: absolute; top: 50%; width: 14px; height: 14px; margin: -7px 0 0 -7px; border-radius: 50%; border: 2px solid var(--bg); background: var(--accent); }
.pos-dot.is-edge { background: var(--warn); }
.pos-dot.is-hi, .pos-dot.is-lo { background: #f87171; }
.pos-tip { font-size: 0.92rem; line-height: 1.4; }
.home-pros { margin-top: 12px; }
.pos-more summary { cursor: pointer; min-height: 40px; display: flex; align-items: center; color: var(--muted); font-weight: 650; font-size: 0.9rem; margin-top: 8px; }

/* ------------------------------------------------ debug overlay (?debug=1) */
#debugBox {
  position: fixed; left: 8px; bottom: 8px; z-index: 50; margin: 0; padding: 6px 8px; border-radius: 8px;
  background: rgba(0, 0, 0, 0.8); color: #b6ffb0; font: 11px/1.3 ui-monospace, Menlo, Consolas, monospace; pointer-events: none;
  max-width: 92vw; white-space: pre-wrap;
}

/* Before the analysis (upload, court set-up, progress) nothing should get "selected" by a long press or a drag:
   no text highlight, no image/callout menu. The magnifier and the buttons must never be selectable either. */
#uploadStep, #calibrateStep, #progressStep, #loupe {
  -webkit-user-select: none; user-select: none;
  -webkit-touch-callout: none;
}
#uploadStep img, #calibrateStep img, #calibrateStep canvas, #loupe { -webkit-user-drag: none; user-drag: none; }

/* Hebrew reads right to left. The page text flips; the picture does not (the court, the video and the
   progress bars keep their direction: a map and a timeline are not text). */
html[dir="rtl"] .stage, html[dir="rtl"] .map-wrap, html[dir="rtl"] .video-box { direction: ltr; }
html[dir="rtl"] .tip, html[dir="rtl"] .map-side, html[dir="rtl"] .trim-row, html[dir="rtl"] .adjust { direction: rtl; }
.scrubber, .progress, .bar-row .track, .strip, .legend .dot { direction: ltr; }

/* A phone held sideways has very little height: keep the video, the trim bar and the tip all in view.
   (Kept at the end so it wins over the general video rules above.) */
@media (max-width: 999px) and (orientation: landscape) {
  #video { max-height: calc(100vh - var(--topbar) - 10px); max-height: calc(100dvh - var(--topbar) - 10px); }
  .tip { height: 52px; padding: 5px 10px; font-size: 0.85rem; }
  #tipText { max-height: 2.5em; }
  .switch { min-height: 36px; }
  .scrubber { height: 24px; }
  .scrubber .track { top: 8px; }
  .icon-btn { width: 36px; height: 36px; }
}

/* Small movements so the screens feel alive: each screen slides in, clip cards arrive one after another. */
main > section:not(.hidden), #wikiPage:not(.hidden), #wikiList:not(.hidden) { animation: rise 0.38s var(--ease) both; }
.clip-row, .wiki-row { animation: rise 0.42s var(--ease) both; }
.clip-row:nth-child(2), .wiki-row:nth-child(2) { animation-delay: 40ms; }
.clip-row:nth-child(3), .wiki-row:nth-child(3) { animation-delay: 80ms; }
.clip-row:nth-child(4), .wiki-row:nth-child(4) { animation-delay: 120ms; }
.clip-row:nth-child(5), .wiki-row:nth-child(5) { animation-delay: 160ms; }
.clip-row:nth-child(6), .wiki-row:nth-child(6) { animation-delay: 200ms; }
.clip-row:nth-child(n+7), .wiki-row:nth-child(n+7) { animation-delay: 240ms; }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

/* Hebrew has no real italic: keep its letters upright. */
html[dir="rtl"], html[dir="rtl"] * { font-style: normal; }   /* Heebo would be slanted by force */

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

/* ---------- Ball labelling page (label.html) ---------- */
html:has(.lb-body), .lb-body { height: 100%; }
.lb-body { -webkit-user-select: none; user-select: none; overflow: hidden; min-height: 0; }
.lb-wrap {
  height: 100%;
  display: flex; flex-direction: column;
  padding: max(8px, env(safe-area-inset-top)) max(10px, env(safe-area-inset-right)) max(8px, env(safe-area-inset-bottom)) max(10px, env(safe-area-inset-left));
  gap: 6px;
}
.lb-top { display: flex; align-items: center; gap: 10px; }
.lb-title { font-weight: 700; font-size: 17px; }
.lb-count { margin-inline-start: auto; color: var(--muted); font-variant-numeric: tabular-nums; }
.lb-hint { margin: 0; color: var(--muted); font-size: 14px; min-height: 1.4em; }
.lb-main { flex: 1; min-height: 0; display: flex; flex-direction: column; gap: 8px; }
.lb-stage {
  flex: 1; min-height: 0; position: relative;
  display: flex; align-items: center; justify-content: center;
}
.lb-canvas { display: block; touch-action: manipulation; border-radius: 10px; background: #000; cursor: crosshair; }
.lb-message { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; text-align: center; color: var(--muted); padding: 16px; }
.lb-controls { display: flex; flex-direction: column; gap: 8px; }
.lb-row { display: flex; gap: 8px; }
.lb-row .btn { flex: 1; min-height: 48px; padding-inline: 8px; touch-action: manipulation; }
.lb-toggle[aria-pressed="true"] { background: var(--accent-strong); border-color: transparent; color: #fff; }
.lb-help { color: var(--muted); font-size: 14px; }
.lb-help summary, .pt-help summary { cursor: pointer; padding: 4px 0; min-height: 44px; display: flex; align-items: center; }
.lb-help p { margin: 4px 0 0; }

/* Hit marking page (hits.html): the rally video with marks drawn on it, and a timeline below. */
.hm-left { flex: 1; min-height: 0; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.hm-left .lb-stage { overflow: hidden; touch-action: none; }   /* zoomed video is cut at the edges; no pinch */
/* The video stays at the top: when the buttons below change (placing a hit) it must not slide. */
.hm-left .lb-stage { align-items: flex-start; }
.hm-body { touch-action: pan-x pan-y; }   /* the hit page zooms itself: no pinch zoom (iPhone ignores the viewport tag) */
.hm-body .lb-hint { min-height: 2.8em; }   /* always two lines: the video must not move when the hint changes */        /* the hit page zooms itself: no pinch zoom (iPhone ignores the viewport tag) */
.hm-frame { position: relative; flex: none; }
.hm-video { display: block; width: 100%; height: 100%; border-radius: 10px; background: #000; }
.hm-overlay { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; cursor: crosshair; }
.hm-timeline {
  position: relative; height: 38px; flex: none; border-radius: 8px; cursor: pointer;
  background: var(--surface-2, rgba(255, 255, 255, 0.08)); touch-action: none;
}
.hm-tick { position: absolute; top: 4px; bottom: 4px; width: 3px; margin-left: -1.5px; border-radius: 2px; background: #3ee08f; pointer-events: none; }
.hm-span {
  position: absolute; top: 0; bottom: 0; pointer-events: none;
  background: rgba(255, 210, 63, 0.18); border-inline: 3px solid #ffd23f; box-sizing: border-box;
}
.hm-span-open-start { border-left-style: none; }
.hm-span-open-end { border-right-style: none; }
.lb-set { border-color: #ffd23f; }
.hm-tick-lob { background: #5ab4ff; top: 0; bottom: 0; }
.hm-playhead { position: absolute; top: 0; bottom: 0; width: 2px; margin-left: -1px; background: #fff; pointer-events: none; }
/* The handle you drag (the whole bar reacts, the handle shows where you are). */
.hm-playhead::after {
  content: ""; position: absolute; top: 50%; left: 50%; width: 18px; height: 18px; margin: -9px 0 0 -9px;
  border-radius: 50%; background: #fff; box-shadow: 0 1px 4px rgba(0, 0, 0, 0.5);
}

/* Phone on its side: picture on the left, buttons in a column on the right. */
@media (orientation: landscape) and (max-height: 560px) {
  .lb-hint { display: none; }
  .lb-top { gap: 8px; }
  .lb-title { font-size: 15px; }
  .lb-main { flex-direction: row; }
  .lb-controls { width: 168px; flex: none; overflow-y: auto; }
  .lb-row { flex-direction: column; gap: 6px; }
  .lb-row .btn { min-height: 40px; }
  .lb-help { display: none; }
  /* Marking pages with many buttons: two per row. */
  .lb-two .lb-controls { width: 210px; }
  .lb-two .lb-row { flex-direction: row; flex-wrap: wrap; }
  .lb-two .lb-row .btn { flex: 1 1 calc(50% - 6px); font-size: 14px; }
}

/* ------------------------------------------------ padel guide (wiki.js) */
.wiki-entry, .wiki-row {
  display: grid; grid-template-columns: 44px minmax(0, 1fr) auto; gap: 12px; align-items: center;
  width: 100%; padding: 10px 12px; text-align: start; color: var(--text); cursor: pointer; font: inherit;
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px;
  touch-action: manipulation;
  transition: transform 0.18s var(--ease), border-color 0.18s, background-color 0.18s;
}
.wiki-entry { margin-bottom: 12px; background: linear-gradient(100deg, rgba(43, 98, 224, 0.28), var(--surface) 70%); }
@media (hover: hover) { .wiki-entry:hover, .wiki-row:hover { border-color: #46616a; transform: translateY(-2px); } }
.wiki-entry:active, .wiki-row:active { transform: scale(0.99); }
.wiki-icon { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; font-size: 22px; background: var(--bg); color: var(--accent); border: 1px solid var(--line); }
.wiki-entry:hover .wiki-chevron, .wiki-row:hover .wiki-chevron { color: var(--accent); }
.wiki-row-text { min-width: 0; display: grid; gap: 2px; }
.wiki-row-title { font-weight: 750; }
.wiki-chevron { font-size: 1.6rem; color: var(--faint); padding-inline: 4px; transition: color 0.18s; }
[dir="rtl"] .wiki-chevron { transform: scaleX(-1); }
.wiki-heading { font-size: 1.35rem; margin: 4px 0 2px; }
#wikiList > p { margin: 0 0 12px; }
.wiki-page-group { margin-top: 14px; }
#wikiSummary { margin-bottom: 12px; }

.wiki-anim { display: grid; gap: 12px; padding: 12px; }
.wiki-anim-court { display: flex; flex-direction: column; align-items: center; gap: 8px; min-width: 0; }
.wiki-top { width: auto; height: min(48vh, 420px); max-width: 100%; display: block; }
.wiki-fp { display: block; width: 100%; height: auto; aspect-ratio: 4 / 3; border-radius: 12px; background: var(--bg); }
.wiki-views { display: inline-flex; padding: 3px; gap: 3px; border-radius: 12px; background: var(--bg); border: 1px solid var(--line); }
.wiki-view {
  min-height: 36px; padding: 0 14px; border: 0; border-radius: 9px; background: transparent; color: var(--muted);
  font: inherit; font-size: 0.85rem; font-weight: 650; cursor: pointer; touch-action: manipulation;
}
.wiki-view.is-on { background: var(--accent-strong); color: #fff; }
.wiki-group { margin: 18px 0 8px; }
.wiki-group:first-child { margin-top: 4px; }
.wiki-row-tags { display: flex; gap: 6px; margin-top: 2px; }
.wiki-tag .ico { width: 0.8em; height: 0.8em; margin-inline-end: 4px; vertical-align: -0.05em; }
.wiki-tag { font-size: 0.7rem; font-weight: 700; color: var(--ball); background: rgba(196, 242, 91, 0.1); border-radius: 6px; padding: 1px 6px; }
.wiki-body ol { margin: 0 0 8px; padding-inline-start: 22px; color: var(--muted); }
.wiki-anim-side { min-width: 0; display: grid; gap: 10px; align-content: start; }
.wiki-anim-controls { display: flex; align-items: center; gap: 8px; }
.wiki-anim-controls .btn { min-width: 44px; padding: 0 10px; }
.wiki-track { position: relative; flex: 1; min-width: 60px; display: flex; align-items: center; height: 40px; }
.wiki-scrub {
  width: 100%; margin: 0; height: 6px; border-radius: 3px; -webkit-appearance: none; appearance: none; cursor: pointer;
  background: linear-gradient(to right, var(--accent) var(--done, 0%), var(--surface-2) var(--done, 0%));
}
[dir="rtl"] .wiki-scrub { background: linear-gradient(to left, var(--accent) var(--done, 0%), var(--surface-2) var(--done, 0%)); }
.wiki-scrub::-webkit-slider-thumb { -webkit-appearance: none; width: 20px; height: 20px; border-radius: 50%; background: #fff; border: 3px solid var(--accent-strong); box-shadow: 0 1px 4px rgba(0,0,0,0.5); }
.wiki-scrub::-moz-range-thumb { width: 16px; height: 16px; border-radius: 50%; background: #fff; border: 3px solid var(--accent-strong); }
.wiki-ticks { position: absolute; inset: 0 10px; pointer-events: none; }
.wiki-tick { position: absolute; top: 50%; width: 3px; height: 14px; margin-top: -7px; margin-inline-start: -1px; border-radius: 2px; background: var(--faint); opacity: 0.8; }
.wiki-step { transition: background-color 0.25s, color 0.25s, border-color 0.25s; }
.wiki-anim { background: radial-gradient(500px 260px at 30% 0%, rgba(43, 98, 224, 0.2) 0%, transparent 70%), var(--surface); }
.wiki-steps { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.wiki-step {
  display: grid; grid-template-columns: 26px minmax(0, 1fr); gap: 10px; align-items: start; width: 100%;
  padding: 8px 10px; text-align: start; font: inherit; font-size: 0.92rem; color: var(--muted); cursor: pointer;
  background: transparent; border: 1px solid transparent; border-radius: 12px; touch-action: manipulation;
}
.wiki-step.is-current { color: var(--text); background: var(--surface-2); border-color: var(--line); }
.wiki-step-num { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; font: italic 700 0.9rem/1 var(--display); background: var(--bg); color: var(--faint); }
.wiki-step.is-current .wiki-step-num { background: var(--accent); color: var(--accent-ink); }

/* Court from above (wiki.js makeTopView). */
.wc-line { stroke: #fff; stroke-width: 0.07; opacity: 0.9; }
.wc-glass { stroke: #a8d4ff; stroke-width: 0.2; stroke-linecap: round; opacity: 0.85; }
.wc-mesh { stroke: #7d8bab; stroke-width: 0.14; stroke-dasharray: 0.12 0.1; opacity: 0.9; }
.wc-net { stroke: #eef3fb; stroke-width: 0.13; stroke-dasharray: 0.08 0.05; }
.wc-ground { stroke: #fff; stroke-width: 0.05; stroke-dasharray: 0.15 0.15; opacity: 0.22; }
.wc-flight { fill: none; stroke: var(--ball); stroke-width: 0.08; stroke-dasharray: 0.22 0.16; stroke-linecap: round; opacity: 0.7; }
.wc-target circle { fill: rgba(196, 242, 91, 0.12); stroke: var(--ball); stroke-width: 0.06; stroke-dasharray: 0.12 0.1; }
.wc-target line { stroke: var(--ball); stroke-width: 0.08; stroke-linecap: round; }
.wc-ripple { fill: none; stroke-width: 0.08; }
.wc-label { fill: #06101f; font: 800 0.44px Heebo, system-ui, sans-serif; text-anchor: middle; }
.wc-ground.hidden, .wc-flight.hidden, .wc-target.hidden, .wc-ripple.hidden { display: none; }
.wiki-top { border-radius: 14px; }
.wiki-fp { box-shadow: inset 0 0 0 1px var(--line); }

.wiki-videos { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.wiki-videos a { text-decoration: none; }
.wiki-body { margin-top: 12px; }
.wiki-body h3 { font-size: 1rem; margin: 16px 0 6px; }
.wiki-body h3:first-child { margin-top: 0; }
.wiki-body p { margin: 0 0 8px; color: var(--muted); }
.wiki-body ul { margin: 0 0 8px; padding-inline-start: 20px; color: var(--muted); }
.wiki-body li { margin: 4px 0; }
.wiki-body strong { color: var(--text); }
.wiki-inapp { margin-top: 12px; color: var(--muted); font-size: 0.9rem; border-color: #5a4a14; }

/* Wide screens and phones held sideways: court on one side, controls and steps beside it. */
@media (min-width: 760px), (orientation: landscape) and (max-height: 520px) {
  .wiki-anim { grid-template-columns: auto minmax(0, 1fr); align-items: start; }
  .wiki-top { height: min(62vh, 520px); }
  .wiki-fp { width: auto; height: min(62vh, 520px); max-width: 62vw; }
}
@media (orientation: landscape) and (max-height: 520px) {
  .wiki-top, .wiki-fp { height: calc(100vh - var(--topbar) - 84px); }
}

/* Share a rally to a story (app.js shareStory) */
.story-bar { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 6px; }
.story-options { display: flex; gap: 18px; flex-wrap: wrap; margin: 4px 0 6px; }
.story-option { display: inline-flex; align-items: center; gap: 8px; min-height: 36px; font-size: 0.9rem; color: var(--muted); cursor: pointer; }
.story-option input { width: 20px; height: 20px; accent-color: var(--accent); }
.story-bg { gap: 10px; cursor: default; }
.story-swatch { position: relative; display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 14px 0 6px; border-radius: 22px; cursor: pointer; border: 2px solid var(--line); box-sizing: border-box; color: var(--text); font-size: 0.9rem; }
.story-swatch input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
.story-swatch:has(input:checked) { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.story-swatch:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 3px; }
.swatch-dot { width: 32px; height: 32px; border-radius: 50%; flex: none; }
.swatch-green .swatch-dot { background: #2f6b4a; }
.swatch-clay .swatch-dot { background: #a8603a; }
.swatch-pink .swatch-dot { background: #cf6a94; }
#storySheet .story-options { flex-direction: column; align-items: stretch; gap: 8px; margin: 8px 0 14px; }
#storySheet .story-bg { flex-wrap: wrap; min-height: 44px; }
#storySheet .story-option { min-height: 44px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.story-status { min-height: 1.2em; margin: 0 0 10px; }
.story-status.is-working::before { content: ""; display: inline-block; width: 0.9em; height: 0.9em; margin-inline-end: 8px; vertical-align: -2px; border: 2px solid var(--muted); border-top-color: var(--accent); border-radius: 50%; animation: story-spin 0.9s linear infinite; }
@keyframes story-spin { to { transform: rotate(360deg); } }

/* The hit pages reuse the id "video": undo the main page's #video height cap (it shrank the video in landscape). */
.hm-body #video { max-height: none; aspect-ratio: auto; }
/* Hit spot check (/hits.html?set=spotcheck): six answers in a 3-column grid. */
.sc-answers { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.sc-answers .btn { min-width: 0; padding-left: 4px; padding-right: 4px; font-size: 0.9rem; }

/* Fix rallies by hand (app.js, "rally editor"): under the video, a strip of the whole clip and the edit buttons. */
.rally-fix-bar { display: flex; align-items: center; gap: 10px; margin: 0 0 10px; flex-wrap: wrap; }
.stage.is-editing #mapPanel { display: none; }
.stage.is-editing .rally-edit { overflow-y: auto; min-height: 0; }
@media (max-width: 999px) and (orientation: portrait) {
  .stage.is-editing { height: auto; min-height: 0; grid-template-rows: auto auto; }
  .stage.is-editing #tipBox, .stage.is-editing .speed-row { display: none; }   /* room: the edit buttons fit under the video */
}
.rally-edit { margin: 0; padding: 12px; align-content: start; grid-auto-rows: max-content; background: var(--surface); border: 1px solid var(--accent); border-radius: 14px; display: grid; gap: 8px; }
.rally-edit-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.rally-edit-time { font-variant-numeric: tabular-nums; font-weight: 700; color: var(--text); }
.rally-strip { position: relative; height: 44px; border-radius: 10px; background: var(--bg); border: 1px solid var(--line); cursor: pointer; touch-action: none; overflow: hidden; }
.rally-strip-spans { position: absolute; inset: 0; }
.rally-span { position: absolute; top: 6px; bottom: 6px; border-radius: 6px; background: var(--good-strong); border: 2px solid transparent; }
.rally-span.is-warmup { background: #4a5559; }
.rally-span.is-selected { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.rally-span.is-pending { background: transparent; border: 2px dashed var(--accent); }
.rally-strip-head { position: absolute; top: 0; bottom: 0; width: 2px; margin-left: -1px; background: var(--text); pointer-events: none; }
.rally-edit-steps { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; }
.rally-edit-steps .btn { min-width: 0; padding: 0 4px; }
.rally-edit-steps .btn[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.rally-edit-sel { margin: 0; min-height: 1.3em; font-weight: 650; }
.rally-edit-actions { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 6px; }
.rally-edit-actions .btn { min-width: 0; }
.rally-edit-foot { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.rally-edit-gap { flex: 1; }

/* Fix hits by hand (hit_fix.js). Same panel as the rally editor; the foot row sticks to the bottom of the screen. */
.stage.is-editing #hitEdit { overflow: visible; }
@media (min-width: 1000px), (orientation: landscape) { .stage.is-editing #hitEdit { overflow-y: auto; } }
.hit-edit .btn { min-height: 44px; }
.hit-edit .rally-edit-steps .btn { font-size: 0.8rem; }
.hit-nav { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; direction: ltr; }
.hit-nav .btn { min-width: 0; font-weight: 700; }
.rally-strip-ticks { position: absolute; inset: 0; }
#hitStripTicks { pointer-events: none; }
.hit-tick { position: absolute; top: 5px; bottom: 5px; width: 4px; margin-left: -2px; border-radius: 2px; }
.hit-tick.is-selected { width: 8px; margin-left: -4px; top: 1px; bottom: 1px; outline: 2px solid var(--text); }
.hit-tick.is-checked { opacity: 0.55; }
.hit-checked-span { position: absolute; top: 0; bottom: 0; background: rgba(61, 220, 151, 0.18); }
.hit-who { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.hit-who .btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-width: 0; }
.hit-who .btn[aria-pressed="true"] { border-width: 3px; font-weight: 800; }
.hit-dot { width: 14px; height: 14px; border-radius: 50%; flex: none; }
.hit-status { margin: 0; min-height: 1.3em; }
.hit-status.is-bad { color: var(--bad, #ff8a8a); }
.hit-status.is-note { color: var(--text); }
.hit-checked { min-height: 44px; }
.hit-edit .link-button { justify-self: start; min-height: 44px; }
.hit-foot { position: sticky; bottom: 0; z-index: 5; display: grid; grid-template-columns: 1fr 1fr 1.4fr; gap: 8px; padding: 8px 0 calc(8px + env(safe-area-inset-bottom, 0px)); margin: 0 -12px -12px; padding-inline: 12px; background: var(--surface); border-top: 1px solid var(--line); border-radius: 0 0 14px 14px; }
.hit-foot .btn { min-width: 0; }
.hit-note { margin: 0 0 10px; padding: 10px 12px; border-radius: 10px; background: var(--surface); border: 1px solid var(--accent); }
#rallyEditStatus { margin: 0; min-height: 1.2em; }
#rallyEditStatus.is-bad { color: var(--bad); }

/* ---------- UX batch 1 (docs/ux_fixes_page_report.md) ---------- */
/* C2: the clip's name and court stay above the rallies; the rest of the card is near the end of the page. */
.clip-headlines { padding: 0 2px; }
.clip-headlines .clip-title-line { margin: 0 0 2px; }
.clip-headlines .clip-court-line { margin: 0; }
/* C20: Delete is a quiet link at the card's end. */
.clip-delete-link { margin-top: 10px; min-height: 44px; color: var(--muted); text-decoration: underline; }
/* C11: three map colours always shown; the "i" opens the rest. */
.legend-btn { justify-self: start; min-width: 44px; min-height: 44px; border-radius: 50%; border: 1px solid var(--line); background: var(--surface-2); color: var(--text); font: italic 700 1rem Georgia, serif; cursor: pointer; }
.legend-btn[aria-expanded="true"] { background: var(--accent-strong); color: #fff; }
.legend-more { display: grid; gap: 6px; }
/* C5 / C7: the rally editor's foot (Undo, Cancel, Save) sticks to the bottom of the screen like the hit editor's; Save is the only primary button. */
#rallyEdit .btn { min-height: 44px; }
#rallyEdit .link-button { justify-self: start; min-height: 44px; }
.redit-foot { position: sticky; bottom: 0; z-index: 5; display: grid; grid-template-columns: 1fr 1fr 1.4fr; gap: 8px; padding: 8px 12px calc(8px + env(safe-area-inset-bottom, 0px)); margin: 0 -12px -12px; background: var(--surface); border-top: 1px solid var(--line); border-radius: 0 0 14px 14px; }
.redit-foot .btn { min-width: 0; }
#rallyEdit .btn:disabled { opacity: 0.45; }
.stage.is-editing #rallyEdit { overflow: visible; }
@media (min-width: 1000px) { .stage.is-editing #rallyEdit { overflow-y: auto; } }

/* ---- sizes and contrast (audit C6 H7 H12 U7 U11 C27) ---- */
.speed-btn { min-height: 44px; }
.speed-btn[aria-pressed="true"] { color: #0c1315; }                       /* dark on green: about 9:1 (was white, 1.8:1) */
@media (max-width: 999px) and (orientation: landscape) { .speed-btn { min-height: 44px; } }
.tile-label { font-size: 0.875rem; }
.tile-sample { font-size: 0.82rem; }
.tile-trend { margin-top: 0.25rem; }
.tile-trend .tile-sample { font-size: 0.7rem; }
.trend-svg { display: block; width: 100%; max-width: 110px; height: 24px; overflow: visible; }
.trend-line { fill: none; stroke: var(--faint); stroke-width: 1; }
.trend-dot { fill: var(--faint); }
.trend-new { fill: var(--accent); }
.clip-meta { font-size: 0.875rem; }
.library-actions .btn-sm, #selectButton { min-height: 44px; }
.chip.handle-chip { min-height: 44px; font: 650 0.9rem Heebo, system-ui, sans-serif; }
.place-sheet .link-button, .clip-court-line .link-button, .place-bar .link-button { min-height: 44px; }
.settings-card .story-option, .settings-card .debug-option { min-height: 44px; }
.settings-debug > summary { cursor: pointer; min-height: 44px; display: flex; align-items: center; font-size: 1.05rem; font-weight: 700; }

/* ---- Hebrew (audit H11 C22 C23 C10) ---- */
html[dir="rtl"] .tile-value, html[dir="rtl"] .home-best .tile-value, html[dir="rtl"] .clip-rating, html[dir="rtl"] .rating-number { font-style: normal; }   /* the display font has no Hebrew: no faux italic on the units */
.speed-btn { direction: ltr; unicode-bidi: isolate; }                      /* "1×" stays "1×" */
html[dir="rtl"] .bar-row .track { direction: rtl; }                        /* amount bars fill from the right; time bars (.strip, .scrubber) stay left to right */
html[dir="rtl"] .bar-row .fill { transform-origin: right; }
html[dir="rtl"] .pos-track { transform: scaleX(-1); }                      /* the pros' band and your dot read from the right too */
html[dir="rtl"] #cropRange { direction: rtl; }

/* Fix clip (fix_clip.js): the merged rally + hit editor, same overflow rules as the two old ones. */
.stage.is-editing #fixClip { overflow: visible; }
@media (min-width: 1000px), (orientation: landscape) { .stage.is-editing #fixClip { overflow-y: auto; min-height: 0; } }
@media (max-width: 999px) and (orientation: landscape) { .stage.is-editing #fixClip { overflow: visible; } }
.fc-steps { grid-template-columns: repeat(4, 1fr); }
.fc-mode { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
#fixClip { min-width: 0; }
#fixClip .hit-checked { min-width: 0; white-space: normal; align-items: flex-start; }
#fixClip .hit-checked span { min-width: 0; overflow-wrap: anywhere; }
.fc-mode.has-bounces { grid-template-columns: repeat(3, 1fr); }
.fc-mode .btn { min-width: 0; padding-inline: 6px; }
.fc-mtick { top: 24px; bottom: 2px; width: 5px; margin-left: -2.5px; }
.fc-mtick.is-selected { top: 20px; bottom: 0; width: 8px; margin-left: -4px; }
.fc-tap { position: absolute; inset: 0; z-index: 6; cursor: crosshair; touch-action: none; pointer-events: none; }
.fc-tap.is-active { pointer-events: auto; background: rgba(255, 210, 74, 0.08); outline: 2px dashed #ffd24a; outline-offset: -2px; }
#fcBounceRows .btn[aria-pressed="true"] { border-width: 3px; font-weight: 800; }
#fcBounceRows { display: grid; gap: 8px; }
.fc-mode .btn[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); border-color: transparent; font-weight: 800; }
/* O1: the one-time "Gold = where to stand" hint over the video. */
.ghost-hint { position: absolute; left: 50%; bottom: 64px; transform: translateX(-50%); max-width: 90%; padding: 8px 14px; border-radius: 10px; background: rgba(20, 16, 4, 0.88); color: #ffd24a; font: 700 0.9rem/1.3 Heebo, system-ui, sans-serif; text-align: center; pointer-events: none; z-index: 3; }

/* Landscape phone: the page scrolls (the video stays put), so the hit editor's foot sticks to the screen like the rally editor's (audit C1). */
@media (max-width: 999px) and (orientation: landscape) {
  .stage.is-editing #hitEdit, .stage.is-editing #rallyEdit { overflow: visible; }
}
/* The foot rows have a -12px bottom margin (they cover the panel's padding): pin them 12px up so the buttons end exactly at the screen's edge. */
@media (max-width: 999px) { .hit-foot, .redit-foot { bottom: 12px; } }

/* ------------------------------------------------ usage log (Settings, usage.js) */
.usage-buttons { flex-wrap: wrap; }
.usage-summary { overflow-x: auto; }
.usage-table { width: 100%; border-collapse: collapse; font-size: 0.82rem; }
.usage-table th, .usage-table td { padding: 4px 6px; border-bottom: 1px solid var(--line); text-align: start; white-space: nowrap; }
.usage-table td:not(:first-child), .usage-table th:not(:first-child) { text-align: end; font-variant-numeric: tabular-nums; }

/* ------------------------------------------------ redesign (idea 48): navigation shell */
.top-back { flex: none; margin-inline-end: 4px; }
[dir="rtl"] .top-back .ico { transform: scaleX(-1); }
.top-title { flex: 1; min-width: 0; margin: 0; font: 750 1.02rem/1.2 Heebo, system-ui, sans-serif; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar { justify-content: flex-start; }
.topbar .topbar-actions { margin-inline-start: auto; }
.queue-chip {
  min-height: 34px; padding: 0 12px; border-radius: 99px; border: 1px solid rgba(217, 242, 74, 0.45);
  background: rgba(217, 242, 74, 0.1); color: var(--accent); font: 700 0.8rem/1 Heebo, system-ui, sans-serif; cursor: pointer; white-space: nowrap;
}
.page-title { font-size: 1.7rem; text-transform: uppercase; font-style: italic; letter-spacing: 0.01em; margin: 4px 0 12px; }
body.has-navbar .wrap { padding-bottom: calc(84px + env(safe-area-inset-bottom)); }
.nav-bar {
  position: fixed; z-index: 30; left: 0; right: 0; bottom: 0;
  display: grid; grid-template-columns: repeat(4, 1fr); align-items: end;
  padding: 6px max(8px, env(safe-area-inset-right)) calc(6px + env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left));
  background: rgba(12, 19, 21, 0.96); border-top: 1px solid var(--line);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
}
.nav-item {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  min-height: 52px; padding: 4px 2px; border: 0; background: none; color: var(--faint);
  font: 650 0.74rem/1.1 Heebo, system-ui, sans-serif; cursor: pointer; touch-action: manipulation;
}
.nav-item .ico { width: 24px; height: 24px; }
.nav-item.is-current { color: var(--accent); }
.nav-add-dot {
  display: grid; place-items: center; width: 54px; height: 54px; margin-top: -22px; border-radius: 50%;
  background: var(--accent); color: var(--accent-ink); box-shadow: 0 3px 0 #8ea31a, 0 6px 18px rgba(0, 0, 0, 0.45);
}
.nav-add-dot .ico { width: 28px; height: 28px; stroke-width: 2.6; }
.nav-add:active .nav-add-dot { transform: translateY(2px); box-shadow: 0 1px 0 #8ea31a; }
@media (orientation: landscape) and (max-height: 500px) {
  .nav-item { min-height: 40px; flex-direction: row; gap: 6px; }
  .nav-add-dot { width: 42px; height: 42px; margin-top: 0; }
  body.has-navbar .wrap { padding-bottom: calc(64px + env(safe-area-inset-bottom)); }
}
/* Desktop: the bar becomes a rail of the four places at the side. */
@media (min-width: 1000px) {
  .nav-bar { top: 0; bottom: 0; right: auto; width: 92px; grid-template-columns: 1fr; grid-auto-rows: min-content; align-content: start; gap: 10px;
    padding-top: calc(70px + env(safe-area-inset-top)); border-top: 0; border-inline-end: 1px solid var(--line); }
  [dir="rtl"] .nav-bar { left: auto; right: 0; }
  .nav-add { order: -1; }
  .nav-add-dot { margin-top: 0; }
  body.has-navbar .wrap { padding-inline-start: 104px; padding-bottom: 32px; }
}
.more-language { cursor: default; }
.more-language .btn { flex: none; }
#moreStep > .wiki-entry, #moreStep > .install-card { margin: 0 0 10px; }
#moreStep > .soon-panel { margin: 0 0 10px; padding: 12px 14px; }
.soon-panel.hidden { display: none; }
.soon-panel p { margin: 0 0 8px; }
.soon-item { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-top: 1px solid var(--border, rgba(255,255,255,0.12)); }
.soon-item:first-child { border-top: 0; }
.soon-item-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.soon-item-title { font-weight: 600; }
.soon-item .btn[aria-pressed="true"] { border-color: var(--accent); color: var(--accent); }
.settings-block { margin-top: 22px; display: grid; gap: 12px; }
.settings-block .btn { justify-self: start; }
.progress-score .rating-row { margin: 6px 0 4px; }
.progress-score .tile-trend { margin: 4px 0 8px; max-width: 220px; }
.progress-score p + p { margin-top: 4px; }
#myProgressStep .home-cols { max-width: 980px; }

/* ------------------------------------------------ redesign: the clip screen (Game | Analysis, action bar, menu) */
.top-menu { flex: none; }
.speed-row { display: none !important; }                 /* one cycling button instead (the four stay for the editors) */
.speed-cycle {
  flex: none; min-width: 52px; min-height: 40px; padding: 0 10px; border-radius: 99px; border: 1px solid var(--line);
  background: var(--surface-2); color: var(--text); font: 750 0.9rem/1 Heebo, system-ui, sans-serif; cursor: pointer; direction: ltr;
}
.speed-cycle.is-slow { background: var(--good); color: #fff; border-color: transparent; }
.clip-unsaved { margin: 0; padding: 6px 12px; border-radius: 10px; background: rgba(255, 210, 74, 0.1); color: var(--warn); font-size: 0.88rem; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.clip-unsaved .link-button { color: var(--accent); font-weight: 750; }
.clip-views { display: flex; align-items: center; gap: 8px; flex: none; }
.view-switch { flex: 1; display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 4px; border-radius: 14px; background: var(--surface); border: 1px solid var(--line); }
.view-seg { min-height: 40px; border: 0; border-radius: 10px; background: none; color: var(--muted); font: 750 0.95rem/1 Heebo, system-ui, sans-serif; cursor: pointer; touch-action: manipulation; }
.view-seg[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); }
.clip-quick { display: none; gap: 6px; }
.quick-btn { width: 44px; height: 44px; border-radius: 50%; border: 1px solid var(--line); background: var(--surface-2); color: var(--text); display: grid; place-items: center; cursor: pointer; }
.quick-btn.is-primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.quick-btn .ico { width: 20px; height: 20px; }

/* Which parts show in which view */
#resultStep.is-game #mapPanel, #resultStep.is-game #tipBox, #resultStep.is-game .overlay-row,
#resultStep.is-game .more-hint, #resultStep.is-game #analysisView { display: none; }
#resultStep.is-analysis #gameView { display: none; }
#resultStep.is-game .stage.is-editing #mapPanel { display: none; }

/* Game view cards */
.game-view, .analysis-view { display: grid; gap: 12px; min-width: 0; }
.story-strip { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.story-strip:not(:has(.story-status:not(:empty))):not(:has(#storyAction:not(.hidden))) { display: none; }
.best-card { display: grid; gap: 8px; }
.best-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.best-head .link-button { font-size: 0.85rem; color: var(--accent); font-weight: 700; }
.best-value { font: italic 700 2.1rem/1.05 var(--display); color: var(--accent); }
.best-value.is-none { font: 650 1rem/1.3 Heebo, system-ui, sans-serif; color: var(--muted); }
.best-actions { display: flex; gap: 8px; }
.counts-card { padding-top: 10px; padding-bottom: 10px; }
.counts-row { display: grid; grid-template-columns: repeat(3, 1fr); text-align: center; }
.count { display: grid; gap: 2px; }
.count + .count { border-inline-start: 1px solid var(--line); }
.count-num { font: italic 700 1.75rem/1 var(--display); color: var(--text); direction: ltr; unicode-bidi: isolate; }
.count-label { font-size: 0.72rem; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.counts-note { margin-top: 6px; text-align: center; }
.counts-note .link-button { color: var(--accent); font-weight: 750; }
#countsNote.is-checked { color: var(--good); }
.tip-card { border-color: rgba(217, 242, 74, 0.35); background: linear-gradient(180deg, rgba(217, 242, 74, 0.07), rgba(217, 242, 74, 0.02)), var(--surface); }
.one-tip-text { margin: 6px 0 8px; font-size: 1.02rem; line-height: 1.35; color: var(--text); }
.one-tip-actions { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.one-tip-actions .link-btn { margin-top: 0; }
#oneTipSeeText { direction: ltr; unicode-bidi: isolate; }

/* Game without dead time + best moments (game_cut.js) */
.gc-card { display: grid; gap: 8px; }
.gc-summary { margin: 0; font-size: 1rem; font-weight: 650; color: var(--text); }
.gc-actions { display: flex; gap: 8px; }
.gc-actions .btn { flex: 1 1 0; min-width: 0; }
.gc-sub { margin: -4px 0 0; }
.gc-status:empty { display: none; }
.gc-progress { height: 6px; border-radius: 3px; background: var(--line); overflow: hidden; }
.gc-bar { height: 100%; width: 0; background: var(--accent); transition: width 0.4s; }
.moments-list { display: grid; gap: 6px; }
.moment-row { display: flex; align-items: center; gap: 10px; padding: 6px 0; }
.moment-row + .moment-row { border-top: 1px solid var(--line); }
.moment-rank { flex: none; width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; font: italic 700 1rem/1 var(--display); color: #111; background: var(--accent); }
.moment-text { flex: 1 1 auto; min-width: 0; }
.moment-main { font-weight: 700; color: var(--text); }
.moment-watch { flex: none; display: inline-flex; align-items: center; gap: 6px; }
.gc-chip { position: absolute; top: 8px; left: 50%; transform: translateX(-50%); display: flex; align-items: center; gap: 6px; max-width: 90%; padding: 4px 4px 4px 12px; border-radius: 999px; background: rgba(10, 14, 10, 0.82); color: var(--accent); font: 700 0.85rem/1.2 Heebo, system-ui, sans-serif; z-index: 4; white-space: nowrap; }
html[dir="rtl"] .gc-chip { padding: 4px 12px 4px 4px; }
.gc-chip-stop { width: 28px; height: 28px; border: 0; border-radius: 50%; background: rgba(255, 255, 255, 0.14); color: #fff; font-size: 0.9rem; cursor: pointer; }

/* The action bar (portrait phone) */
.clip-bar {
  position: fixed; z-index: 30; left: 0; right: 0; bottom: 0;
  display: grid; grid-template-columns: 1fr 1.25fr 1fr 0.8fr; gap: 6px;
  padding: 6px max(8px, env(safe-area-inset-right)) calc(6px + env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left));
  background: rgba(12, 19, 21, 0.96); border-top: 1px solid var(--line);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
}
.clip-bar-btn {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-height: 52px; padding: 2px 4px;
  border-radius: 12px; border: 1px solid var(--line); background: var(--surface-2); color: var(--text);
  font: 700 0.76rem/1.1 Heebo, system-ui, sans-serif; cursor: pointer; touch-action: manipulation; text-align: center;
}
.clip-bar-btn .ico { width: 20px; height: 20px; }
.clip-bar-btn.is-primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; box-shadow: 0 3px 0 #8ea31a; }
body.story-busy #barShare, body.story-busy .quick-btn[data-act="share"] { opacity: 0.7; animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: 0.45; } }
body.has-clipbar .wrap { padding-bottom: calc(80px + env(safe-area-inset-bottom)); }
body.is-fixing .clip-bar { display: none; }

/* The clip menu sheet */
.clip-sheet { place-items: end center; padding: 0; }
.clip-sheet .sheet { width: min(520px, 100%); max-height: 88vh; max-height: 88dvh; border-radius: 18px 18px 0 0; padding-bottom: calc(16px + env(safe-area-inset-bottom)); }
.clip-sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.clip-sheet .clip-headlines { margin: 0; }
.clip-about summary { cursor: pointer; min-height: 40px; display: flex; align-items: center; }

/* Portrait phone */
@media (max-width: 999px) and (orientation: portrait) {
  #resultStep.is-game { display: grid; gap: 10px; }
  #resultStep.is-game .stage, #resultStep.is-game .stage-left { display: contents; }
  /* The video stays at the top while the cards scroll under it (risk R3: only a real iPhone can confirm it). */
  #resultStep.is-game .video-box { position: sticky; top: env(safe-area-inset-top); z-index: 6; box-shadow: 0 6px 16px rgba(0, 0, 0, 0.45); }
  #resultStep.is-game .below { margin-top: 0; }
  #resultStep.is-game .trim { padding-top: 2px; padding-bottom: 0; }
  body.has-clipbar #resultStep.is-analysis .stage { height: auto; min-height: calc(100dvh - var(--topbar) - 84px - env(safe-area-inset-bottom)); }
  body.has-clipbar #resultStep.is-analysis #mapPanel { min-height: 290px; }
  .clip-quick { display: none; }
}
/* Phone held sideways: video on the left at full height, everything else in the right column; no bottom bar. */
@media (max-width: 999px) and (orientation: landscape) {
  :root { --topbar: 40px; }
  #resultStep { display: grid; grid-template-columns: minmax(0, 58fr) minmax(0, 42fr); column-gap: 10px; row-gap: 8px; align-items: start; }
  #resultStep .stage, #resultStep .stage-left { display: contents; }
  #resultStep .video-box { grid-column: 1; grid-row: 1 / span 40; position: sticky; top: 4px; }
  #resultStep > *, #resultStep .stage-left > :not(.video-box), #resultStep .stage-right > * { grid-column: 2; }
  #resultStep #mapPanel { grid-row: auto; height: min(330px, calc(100dvh - 60px)); min-height: 220px; }
  #resultStep .below { margin-top: 0; }
  .clip-bar, body.has-clipbar .clip-bar { display: none; }
  body.has-clipbar .wrap { padding-bottom: 24px; }
  .clip-quick { display: flex; }
  .clip-views { flex-wrap: wrap; }
  .topbar { min-height: 40px; }
}
/* Desktop: Game view = video left, cards right; Analysis view = today's stage (video + map), report below. */
@media (min-width: 1000px) {
  .clip-bar, body.has-clipbar .clip-bar { display: none; }
  body.has-clipbar .wrap { padding-bottom: 32px; }
  .clip-quick { display: flex; }
  #resultStep.is-game { display: grid; grid-template-columns: minmax(0, 1fr) minmax(380px, 40%); column-gap: 16px; align-items: start; }
  #resultStep.is-game .stage, #resultStep.is-game .stage-left { display: contents; }
  #resultStep.is-game .stage-right { display: contents; }
  #resultStep.is-game .video-box { grid-column: 1; grid-row: 1 / span 40; position: sticky; top: 8px; }
  #resultStep.is-game > *, #resultStep.is-game .stage-left > :not(.video-box), #resultStep.is-game .stage-right > * { grid-column: 2; }
  #resultStep.is-game .below { margin-top: 0; }
}

/* ------------------------------------------------ redesign: Home as games */
#homeStep { display: grid; gap: 12px; max-width: 980px; margin-inline: auto; }
#libraryStep { max-width: 980px; margin: 16px auto 0; }
#homeStep:empty { display: none; }
.home-hero { display: grid; gap: 10px; }
.hero-title { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; }
.hero-name { font: 800 1.2rem/1.2 Heebo, system-ui, sans-serif; }
.hero-sub { color: var(--muted); font-size: 0.85rem; }
.hero-frame { position: relative; display: block; width: 100%; padding: 0; border: 0; border-radius: 12px; overflow: hidden; background: #000; aspect-ratio: 16 / 9; cursor: pointer; }
.hero-frame.skeleton { background: linear-gradient(90deg, var(--surface-2), var(--hover), var(--surface-2)); background-size: 200% 100%; animation: shimmer 1.4s linear infinite; cursor: default; }
@keyframes shimmer { to { background-position: -200% 0; } }
.hero-img { display: block; width: 100%; height: 100%; object-fit: cover; }
.hero-play { position: absolute; inset: 0; margin: auto; width: 58px; height: 58px; border-radius: 50%; display: grid; place-items: center;
  background: rgba(0, 0, 0, 0.55); border: 2px solid rgba(255, 255, 255, 0.85); color: #fff; }
.hero-play .ico { width: 26px; height: 26px; margin-inline-start: 3px; }
.hero-tag { position: absolute; top: 10px; inset-inline-start: 10px; padding: 4px 10px; border-radius: 8px; background: rgba(0, 0, 0, 0.72); color: #fff; font: 750 0.78rem/1.2 Heebo, system-ui, sans-serif; }
.hero-best { font: italic 700 2rem/1.05 var(--display); color: var(--accent); }
.hero-others-title { margin-top: 2px; }
.hero-strip { display: flex; gap: 10px; overflow-x: auto; scroll-snap-type: x mandatory; padding-bottom: 4px; scrollbar-width: thin; }
.hero-strip-item { flex: 0 0 132px; scroll-snap-align: start; display: grid; gap: 4px; padding: 0; border: 0; background: none; color: var(--text); text-align: start; cursor: pointer; }
.hero-strip-item .clip-thumb { width: 132px; height: 74px; border-radius: 8px; object-fit: cover; }
.hero-strip-text { display: flex; flex-wrap: wrap; gap: 2px 6px; align-items: baseline; font-size: 0.8rem; font-weight: 650; }
.hero-strip-text .clip-code { font-size: 0.72rem; }
/* friend-group awards (awards.js) */
.awards-card { display: grid; gap: 8px; margin-top: 4px; padding: 12px; border-radius: 12px; background: var(--surface-2); }
.awards-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.award-row { display: flex; align-items: center; gap: 10px; }
.award-icon { flex: 0 0 36px; height: 36px; display: grid; place-items: center; border-radius: 50%; background: var(--hover); font-size: 1.15rem; }
.award-text { display: grid; gap: 1px; min-width: 0; }
.award-name { color: var(--accent); font: 750 0.75rem/1.2 Heebo, system-ui, sans-serif; text-transform: uppercase; letter-spacing: 0.04em; }
.award-who { font: 800 1rem/1.2 Heebo, system-ui, sans-serif; overflow-wrap: anywhere; }
.awards-note { margin: 0; }
.awards-status:empty { display: none; }
@media (orientation: landscape) and (min-width: 600px) {
  .awards-list { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
}
.home-numbers {
  display: flex; align-items: center; justify-content: space-between; gap: 10px; width: 100%; min-height: 52px; padding: 10px 14px;
  border-radius: 14px; border: 1px solid var(--line); background: var(--surface); color: var(--muted); font: 600 0.92rem/1.3 Heebo, system-ui, sans-serif; text-align: start; cursor: pointer;
}
.home-numbers .wiki-chevron { font-size: 1.3rem; }
[dir="rtl"] .home-numbers .wiki-chevron { transform: scaleX(-1); }
.clip-row-code { align-self: center; font: 600 0.78rem ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; color: var(--faint); white-space: nowrap; direction: ltr; }
.day-group .court-head { font-size: 0.95rem; }
#libraryStep .library-head { margin-bottom: 8px; }
.nav-add-dot.is-pulsing { animation: addpulse 1.1s ease-out 2; }
@keyframes addpulse { 0% { box-shadow: 0 3px 0 #8ea31a, 0 0 0 0 rgba(217, 242, 74, 0.7); } 100% { box-shadow: 0 3px 0 #8ea31a, 0 0 0 18px rgba(217, 242, 74, 0); } }
@media (min-width: 1000px) {
  /* Desktop: hero left, games list right (one screen, like the old two columns). */
  body[data-screen="homeStep"] main { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 20px; align-items: start; max-width: 1180px; }
  body[data-screen="homeStep"] #homeStep, body[data-screen="homeStep"] #libraryStep { margin: 0; max-width: none; }
}
.home-hero .story-status:empty { display: none; }
#homeTiles .tile:nth-child(3) { grid-column: 1 / -1; }
.research-links { display: flex; flex-wrap: wrap; gap: 8px; }
.clip-code { direction: ltr; unicode-bidi: isolate; }
html[dir="rtl"] .count-num { direction: rtl; }
@media (orientation: landscape) and (max-height: 500px) {
  .home-hero { grid-template-columns: minmax(0, 46fr) minmax(0, 54fr); column-gap: 14px; align-items: start; }
  .home-hero > * { grid-column: 2; }
  .home-hero > .hero-frame { grid-column: 1; grid-row: 1 / span 8; }
  .home-hero.is-loading > * { grid-column: 1 / -1; }
}
@media (min-width: 1000px) { body[data-screen="homeStep"] #libraryStep .clip-list { grid-template-columns: minmax(0, 1fr); } }
#libraryNote:empty, #searchCount:empty { display: none; }

/* Accounts (profile.js): sign-in card over everything, Profile panel rows, invite links. */
.acct-backdrop { z-index: 100; }
.acct-sheet .field input, .acct-input, .acct-link-text {
  min-height: 44px; padding: 0 10px; border-radius: 12px; border: 1px solid var(--line); min-width: 0;
  background: var(--bg); color: var(--text); font: 500 1rem Heebo, system-ui, sans-serif;
}
.acct-sheet .field input { width: 100%; }
.acct-section { display: grid; gap: 8px; padding: 10px 0; border-top: 1px solid var(--line); }
.acct-section:first-child { border-top: 0; }
.acct-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.acct-row .acct-input { flex: 1 1 160px; }
.acct-link { display: grid; gap: 6px; }
.acct-link-text { width: 100%; font-size: 0.85rem; direction: ltr; }
.acct-hidden { display: none !important; }
.acct-section a.btn { text-decoration: none; }
.acct-google { display: flex; align-items: center; justify-content: center; text-decoration: none; margin: 4px 0 8px; }
.acct-code { display: grid; gap: 8px; }
.acct-code .field input { width: 100%; }
.acct-or { margin: 10px 0 0; }
.acct-ltr { unicode-bidi: plaintext; }
/* Casual game switch + playing-style nicknames (static/casual_style.js) */
.casual-row { display: flex; align-items: flex-start; gap: 10px; margin: 10px 0 4px; cursor: pointer; }
.casual-row input { width: 20px; height: 20px; margin-top: 2px; flex: none; accent-color: var(--accent, #c6f432); }
.casual-words { display: flex; flex-direction: column; gap: 2px; }
.casual-label { font-weight: 700; }
.casual-note { margin: 4px 0 8px; }
.badge-casual { color: var(--muted); font-weight: 700; white-space: nowrap; padding: 1px 7px; border: 1px dashed var(--line); border-radius: 999px; }
.pill-casual { background: transparent; border: 1px dashed var(--line); color: var(--muted); }
.style-line { margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--line); }
.style-title { margin-bottom: 4px; }
.style-me { overflow-wrap: anywhere; }
.style-name { color: var(--accent, #c6f432); }
.style-others { margin-top: 4px; overflow-wrap: anywhere; }
.style-lately { margin-top: 12px; }
.style-lately-name { font-size: 1.5rem; font-weight: 800; color: var(--accent, #c6f432); margin: 4px 0 2px; }
.style-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.style-chip { padding: 2px 10px; border-radius: 999px; border: 1px solid var(--line); font-size: 0.8rem; color: var(--muted); }
.style-chip.is-top { color: var(--text, #fff); border-color: var(--accent, #c6f432); }

/* Special moments card (special_moments.js) */
.sm-buttons { flex: none; display: flex; gap: 6px; }
.sm-badge { width: auto; min-width: 32px; padding: 0 6px; border-radius: 14px; font-style: normal; }
.sm-net_battle { background: var(--accent); }

/* Who is who beside the map (map_people.js): picture / initial / letter in the team colour + name; tap = ring on the dot */
.map-people { display: grid; gap: 2px; }
.map-person {
  display: flex; align-items: center; gap: 8px; min-height: 34px; min-width: 0; padding: 2px 4px; margin: 0 -4px;
  border: 0; border-radius: 10px; background: transparent; color: var(--text); font: 600 0.8rem/1.2 Heebo, system-ui, sans-serif;
  text-align: start; cursor: pointer;
}
.map-person:active, .map-person:focus-visible { background: var(--surface-2); }
.mp-face {
  flex: none; display: inline-flex; align-items: center; justify-content: center; width: 26px; height: 26px; border-radius: 50%;
  border: 3px solid; background: #0c1315; color: #fff; font: 800 0.72rem/1 system-ui, sans-serif; overflow: hidden; box-sizing: border-box;
}
.mp-face img { width: 100%; height: 100%; object-fit: cover; display: block; }
.mp-face.is-plain { color: #0c1315; }
.mp-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.legend.has-people > span:nth-child(-n+2) { display: none; }       /* You / Partner rows: the list above says it */
/* "Players" in the clip's action bar and quick buttons: only for the uploader with accounts on (body.can-tag).
   The bar keeps 4 buttons at 375 px: Players takes Best rally's place (Best rally is the Game view's first card and
   stays a quick button in landscape / desktop). */
.tag-only { display: none !important; }
body.can-tag .clip-quick .tag-only { display: grid !important; }
body.can-tag .clip-bar .tag-only { display: flex !important; }
body.can-tag .clip-bar [data-act="best"] { display: none; }
body.can-tag .clip-bar { grid-template-columns: 1.25fr 1fr 1fr 0.8fr; }
/* Game view: the four players at the top; "+ Tag" on an empty slot (uploader) */
.gp-card { display: grid; gap: 8px; }
.gp-head { display: flex; align-items: center; gap: 8px; }
.gp-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
.gp-chip {
  display: flex; align-items: center; gap: 8px; min-width: 0; min-height: 44px; padding: 4px 10px 4px 6px;
  border: 1px solid var(--line); border-radius: 999px; background: var(--surface-2); color: var(--text);
  font: 600 0.84rem/1.2 Heebo, system-ui, sans-serif; text-align: start;
}
button.gp-chip { cursor: pointer; }
.gp-chip.is-open { border-style: dashed; color: var(--accent, #c6f432); }
.gp-chip .mp-face { width: 30px; height: 30px; }
.gp-nudge { position: relative; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 8px 44px 8px 10px; border-radius: 12px; background: var(--surface-2); font-size: 0.88rem; }
html[dir="rtl"] .gp-nudge { padding: 8px 10px 8px 44px; }
.gp-nudge > span { flex: 1 1 150px; }
.gp-close { position: absolute; top: 0; inset-inline-end: 0; }
.soc-slot.is-focus { outline: 2px solid var(--accent, #c6f432); outline-offset: 2px; border-radius: 12px; }
@media (max-width: 999px) and (orientation: landscape) {
  .map-people { display: flex; flex-wrap: wrap; gap: 4px; }
  .map-person { margin: 0; padding: 2px; min-height: 32px; }
  .map-person .mp-name { display: none; }
}

/* ---- Map card, phone first (docs/map_phone_report.md): one merged key under the map ---- */
.legend.has-people > .lg-who { display: none; }                       /* the people list says it (replaces the old "first 2" rule) */
.legend.has-people > span:nth-child(-n+2) { display: none; }
.legend-btn { min-width: 0; min-height: 44px; padding: 0 8px; border: 0; border-radius: 10px; background: transparent; color: var(--accent); font: 700 0.84rem Heebo, system-ui, sans-serif; display: inline-flex; align-items: center; gap: 6px; justify-self: start; }
.legend-btn .chev { width: 7px; height: 7px; border-inline-end: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: rotate(45deg) translateY(-2px); transition: transform 0.15s; }
.legend-btn[aria-expanded="true"] { background: transparent; color: var(--accent); }
.legend-btn[aria-expanded="true"] .chev { transform: rotate(225deg); }
@media (max-width: 999px) and (orientation: portrait) {
  .map-panel { display: flex; flex-direction: column; align-items: stretch; flex: none; height: auto; min-height: 0; gap: 8px; padding: 10px; }
  body.has-clipbar #resultStep.is-analysis #mapPanel { min-height: 0; }
  .map-wrap { flex: none; }
  .map-side { display: flex; flex-direction: column; gap: 6px; overflow: visible; }
  .map-people { order: 1; display: flex; flex-wrap: wrap; gap: 6px; }
  .map-person { flex: 1 1 calc(50% - 6px); margin: 0; padding: 3px 8px 3px 4px; min-height: 40px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface-2); font-size: 0.82rem; }
  .map-person .mp-name { display: block; }
  .legend { order: 2; display: flex; flex-wrap: wrap; align-items: center; gap: 4px 14px; font-size: 0.8rem; }
  .legend .lg-ghost { flex: 1 1 auto; }
  .legend-more { flex-basis: 100%; grid-template-columns: 1fr 1fr; gap: 6px 12px; padding-bottom: 4px; }
  .legend-more.hidden { display: none; }
  .map-side > div:nth-child(2) { order: 3; display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; }
  #ghostMode { flex: 1 1 100%; }
  .map-side > div:nth-child(1) { order: 4; display: flex; align-items: baseline; gap: 8px; align-self: flex-start; padding: 4px 12px; border-radius: 999px; background: var(--surface-2); }
  .map-side > div:nth-child(1) .eyebrow { font-size: 0.7rem; }
  .map-side > div:nth-child(1) .sync { font-size: 1.15rem; }
  .map-side > div.is-empty { display: none; }
}
/* Warm-up / between points: one slim line, not a tall card */
.tip.is-idle { height: auto; min-height: 40px; padding: 6px 12px; font-size: 0.82rem; }
.log-time { overflow-wrap: anywhere; white-space: normal; unicode-bidi: plaintext; }
@media (max-width: 999px) and (orientation: portrait) {
  .legend > .help-btn { order: 1; margin-inline-start: auto; }
  .legend > .legend-more { order: 9; }
}
/* Friend journey 2026-11-24: with no clips Home shows ONE empty card; the Earlier-games header, Select, search and a second empty card stay away (the analysing banner stays). */
body.lib-none #libraryStep > :not(#queueBanner) { display: none; }


/* A group link (profile.js / group_invite.js): the signed-out start's 401 line never flashes before the group sheet. */
.grp-linking #errorBox { display: none !important; }
