:root {
  /* Default colour scheme = "Blue cloth". Others in the colour-schemes block below. */
  --bg: #0a1b2e;
  --bg2: #0f2540;
  --card: #14304f;
  --line: #1f4670;
  --text: #f2f6fb;
  --muted: #9db2c9;
  --a: #5eead4;      /* side A accent (mint) */
  --b: #ffb086;      /* side B accent (peach) */
  --ball: #ffd23f;   /* highlight: at the table, banners */
  --on-a: #062a25;   /* text on accent buttons */
  --lime: #ffd23f;   /* landing page button, fixed across schemes */
  --red: #e5392f;    /* red group */
  --yel: #ffd23f;    /* yellow group */
  --felt: #1565b8;   /* cloth colour on the landing page */
  --danger: #ff6b6b;
  --radius: 14px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}
[hidden] { display: none !important; }
.screen { min-height: 100dvh; display: flex; flex-direction: column; padding-top: var(--safe-top); }
.topbar {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px; border-bottom: 1px solid var(--line);
}
.topbar h1 { font-size: 18px; margin: 0; flex: 1; font-weight: 650; }
.topbar.compact { padding: 8px 12px; }
.brand { display: flex; align-items: center; gap: 8px; }
.ball { width: 14px; height: 14px; border-radius: 50%; background: var(--ball); display: inline-block; box-shadow: inset -3px -3px 0 rgba(0,0,0,.25); }
.status { flex: 1; text-align: center; color: var(--muted); font-size: 14px; }
.content { padding: 16px; display: flex; flex-direction: column; gap: 14px; flex: 1; padding-bottom: calc(24px + var(--safe-bottom)); }
.foot { padding: 12px 16px calc(12px + var(--safe-bottom)); font-size: 12px; text-align: center; }
.muted { color: var(--muted); }
.section-title { font-size: 13px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 10px 0 0; }
.row { display: flex; align-items: center; }
.gap { gap: 10px; }
.row > * { flex: 1; }

.btn {
  appearance: none; border: 1px solid var(--line); background: var(--card); color: var(--text);
  border-radius: 12px; padding: 9px 14px; font-size: 15px; font-weight: 650;
  min-height: 42px; cursor: pointer; touch-action: manipulation; user-select: none;
  position: relative; overflow: hidden; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  box-shadow: 0 1px 0 rgba(255,255,255,.05) inset, 0 2px 8px rgba(0,0,0,.12);
  transition: transform .12s ease, box-shadow .2s ease, filter .2s ease;
}
.btn:active { transform: scale(.97); filter: brightness(1.08); }
.btn.primary {
  background: linear-gradient(135deg, color-mix(in srgb, var(--a) 85%, #fff), var(--a) 55%, color-mix(in srgb, var(--a) 80%, #000));
  color: var(--on-a); border-color: transparent;
  box-shadow: 0 6px 18px color-mix(in srgb, var(--a) 35%, transparent), 0 1px 0 rgba(255,255,255,.25) inset;
}
.btn.primary::after { /* soft moving shine */
  content: ''; position: absolute; inset: 0; transform: translateX(-120%);
  background: linear-gradient(110deg, transparent 30%, rgba(255,255,255,.28) 50%, transparent 70%);
  animation: shine 4.5s ease-in-out infinite;
}
@keyframes shine { 0%, 70% { transform: translateX(-120%); } 100% { transform: translateX(120%); } }
.btn.big { min-height: 50px; font-size: 17px; border-radius: 14px; }
.btn.ghost { background: color-mix(in srgb, var(--card) 55%, transparent); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); }
.btn.small { min-height: 34px; font-size: 13px; padding: 6px 10px; border-radius: 10px; }
.btn.danger { color: var(--danger); }
.btn.icon { width: 40px; min-height: 40px; padding: 0; font-size: 20px; line-height: 1; border-radius: 11px; flex: none; }

input[type=text], input:not([type]) {
  width: 100%; background: var(--bg2); color: var(--text); border: 1px solid var(--line);
  border-radius: 10px; padding: 12px; font-size: 16px; min-height: 46px;
}
input:focus { outline: 2px solid var(--a); outline-offset: 0; border-color: transparent; }
fieldset { border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; margin: 0; display: flex; flex-direction: column; gap: 10px; background: var(--card); }
legend { padding: 0 6px; color: var(--muted); font-size: 13px; font-weight: 600; }
.team-card.t0 legend { color: var(--a); }
.team-card.t1 legend { color: var(--b); }
.opt { display: flex; flex-direction: column; gap: 6px; font-size: 14px; color: var(--muted); }
.opt.toggle { flex-direction: row; justify-content: space-between; align-items: center; color: var(--text); min-height: 44px; }
.opt.toggle input { width: 24px; height: 24px; accent-color: var(--a); }
.seg { display: flex; background: var(--bg2); border-radius: 10px; padding: 3px; gap: 3px; }
.seg label { flex: 1; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg span {
  display: block; text-align: center; padding: 10px 6px; border-radius: 8px; color: var(--muted);
  font-size: 14px; font-weight: 600; min-height: 40px; line-height: 20px; cursor: pointer;
}
.seg input:checked + span { background: var(--card); color: var(--text); box-shadow: 0 1px 0 rgba(0,0,0,.3); }

/* history */
.history { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.history li { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; display: flex; flex-direction: column; gap: 4px; cursor: pointer; }
.history .h-top { display: flex; justify-content: space-between; font-size: 13px; color: var(--muted); }
.history .h-row { display: grid; grid-template-columns: 26px 1fr auto; align-items: center; gap: 8px; font-size: 18px; }
.history .h-trophy { font-size: 20px; text-align: center; }
.history .h-team { min-width: 0; line-height: 1.3; overflow-wrap: anywhere; }
.history .h-team .muted { font-size: 16px; }
.history .h-sets { font-variant-numeric: tabular-nums; font-weight: 600; letter-spacing: .02em; white-space: nowrap; }
.history .h-row.won .h-sets { font-weight: 800; }
.history .live { color: var(--ball); }

/* live */
.screen.live { height: 100dvh; min-height: 0; }
.court { flex: 1; display: flex; flex-direction: column; position: relative; min-height: 0; }
.half {
  flex: 1; appearance: none; border: 0; margin: 0; color: var(--text); text-align: left;
  padding: 14px 18px calc(14px); display: grid; cursor: pointer; touch-action: manipulation; user-select: none;
  grid-template-columns: 1fr auto; grid-template-rows: auto 1fr; align-items: center; position: relative;
  background: linear-gradient(180deg, var(--bg2), var(--bg));
  -webkit-user-select: none;
}
.half[data-team="0"] { border-bottom: 2px solid var(--line); }
.half:active { filter: brightness(1.25); }
.half.winner { outline: 3px solid var(--ball); outline-offset: -3px; }
.half .names { grid-column: 1 / -1; display: flex; flex-direction: column; gap: 2px; }
.half .tname { font-size: 28px; font-weight: 800; line-height: 1.15; }
.half[data-team="0"] .tname { color: var(--a); }
.half[data-team="1"] .tname { color: var(--b); }
.half .tplayers { font-size: 19px; color: var(--muted); }
.half .tplayers b { color: var(--text); font-weight: 600; }
.half .pts {
  font-size: clamp(72px, 22vh, 150px); font-weight: 800; line-height: 1; font-variant-numeric: tabular-nums;
  text-align: right; min-width: 2ch; letter-spacing: -.03em;
}
.half .serve { position: absolute; right: 18px; top: 16px; width: 18px; height: 18px; border-radius: 50%; background: var(--ball); opacity: 0; box-shadow: 0 0 0 4px rgba(232,245,74,.2); }
.half.serving .serve { opacity: 1; }
.banner {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); z-index: 2;
  background: var(--ball); color: #1a1f00; font-weight: 800; padding: 8px 16px; border-radius: 999px;
  font-size: 14px; letter-spacing: .06em; text-transform: uppercase; pointer-events: none; box-shadow: 0 6px 20px rgba(0,0,0,.4);
}
.controls {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 10px 12px calc(10px + var(--safe-bottom)); border-top: 1px solid var(--line); background: var(--bg);
}
.controls .btn { min-width: 88px; }
.clock { font-variant-numeric: tabular-nums; color: var(--muted); font-size: 14px; }

/* summary */
.headline { font-size: 24px; font-weight: 700; line-height: 1.3; }
.scoretable, .stats { width: 100%; border-collapse: collapse; background: var(--card); border-radius: var(--radius); overflow: hidden; }
.scoretable td, .scoretable th, .stats td, .stats th { padding: 10px 12px; border-bottom: 1px solid var(--line); text-align: center; font-variant-numeric: tabular-nums; }
.scoretable th:first-child, .scoretable td:first-child { text-align: left; }
.scoretable tr:last-child td, .stats tr:last-child td { border-bottom: 0; }
.scoretable .w { font-weight: 800; }
.stats th { color: var(--muted); font-weight: 500; font-size: 13px; }
.stats td:first-child, .stats td:last-child { font-weight: 700; width: 25%; }
.stats td:nth-child(2) { color: var(--muted); font-size: 13px; }
.c-a { color: var(--a); } .c-b { color: var(--b); }

.toast {
  position: fixed; left: 50%; bottom: calc(24px + var(--safe-bottom)); transform: translateX(-50%);
  background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 999px; font-weight: 600; font-size: 14px; z-index: 10;
  box-shadow: 0 8px 24px rgba(0,0,0,.4);
}

@media (orientation: landscape) and (max-height: 500px) {
  .half[data-team="0"] { border-bottom: 0; }
}
/* Light theme: chosen in the app (data-theme="light"), or following the phone when set to Auto */
:root[data-theme="light"] { --bg: #f2f6fb; --bg2: #e4ecf5; --card: #ffffff; --line: #cfdcea; --text: #0f2135; --muted: #5b6f85; --a: #0f766e; --b: #c2410c; --ball: #e0b400; --on-a: #fff; color-scheme: light; }
:root[data-theme="dark"] { color-scheme: dark; }
@media (prefers-color-scheme: light) {
  :root:not([data-theme]) { --bg: #f2f6fb; --bg2: #e4ecf5; --card: #ffffff; --line: #cfdcea; --text: #0f2135; --muted: #5b6f85; --a: #0f766e; --b: #c2410c; --ball: #e0b400; --on-a: #fff; color-scheme: light; }
}
.brand { flex: 1; }

/* names in the summary table */
.scoretable td:first-child b { font-size: 18px; }
.scoretable td:first-child .muted { font-size: 15px; }

/* celebration */
.celebrate {
  position: fixed; inset: 0; z-index: 20; display: grid; place-items: center; padding: 24px;
  background: radial-gradient(circle at 50% 35%, rgba(232,245,74,.25), rgba(0,0,0,.82) 70%);
  animation: cel-fade .3s ease-out;
}
.cel-card {
  position: relative; z-index: 1; width: min(100%, 380px); text-align: center;
  background: var(--card); border: 2px solid var(--ball); border-radius: 22px; padding: 28px 22px 22px;
  box-shadow: 0 20px 60px rgba(0,0,0,.5); animation: cel-pop .5s cubic-bezier(.2,1.4,.4,1);
}
.cel-trophy { font-size: 84px; line-height: 1; animation: cel-bounce 1.4s ease-in-out infinite; }
.cel-kicker { margin-top: 8px; font-size: 15px; font-weight: 800; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }
.cel-team { margin: 6px 0 4px; font-size: 34px; font-weight: 900; line-height: 1.1; }
.cel-players { font-size: 20px; font-weight: 600; color: var(--text); }
.cel-score { margin: 16px 0 20px; font-size: 30px; font-weight: 800; font-variant-numeric: tabular-nums; letter-spacing: .04em; }
.cel-actions { display: flex; flex-direction: column; gap: 10px; }
.confetti { position: absolute; inset: 0; overflow: hidden; pointer-events: none; }
.confetti i {
  position: absolute; top: -20px; width: 9px; height: 15px; border-radius: 2px; opacity: .95;
  animation-name: cel-fall; animation-timing-function: linear; animation-iteration-count: infinite;
}
@keyframes cel-fall { to { top: 105%; transform: rotate(720deg) translateX(40px); } }
@keyframes cel-pop { from { transform: scale(.6); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@keyframes cel-bounce { 0%, 100% { transform: translateY(0) rotate(-4deg); } 50% { transform: translateY(-10px) rotate(4deg); } }
@keyframes cel-fade { from { opacity: 0; } to { opacity: 1; } }
@media (prefers-reduced-motion: reduce) {
  .celebrate, .cel-card, .cel-trophy { animation: none; }
}

/* colour schemes (Settings → Colour scheme). Blue cloth = the default tokens above. */
:root[data-palette="baize"] { --bg: #0a2117; --bg2: #0e2c1f; --card: #133a29; --line: #1d5540; --a: #7dd3fc; --b: #fda4af; --on-a: #06283a; --felt: #1f7a4d; }
:root[data-palette="baize"][data-theme="light"] { --bg: #f3f7f3; --bg2: #e6efe7; --card: #ffffff; --line: #d3e0d5; --a: #0369a1; --b: #be123c; --on-a: #fff; }
@media (prefers-color-scheme: light) { :root[data-palette="baize"]:not([data-theme]) { --bg: #f3f7f3; --bg2: #e6efe7; --card: #ffffff; --line: #d3e0d5; --a: #0369a1; --b: #be123c; --on-a: #fff; } }
:root[data-palette="burgundy"] { --bg: #210c10; --bg2: #2c1116; --card: #3a181e; --line: #55252d; --a: #7dd3fc; --b: #86efac; --on-a: #06283a; --felt: #8a1c2b; }
:root[data-palette="burgundy"][data-theme="light"] { --bg: #fbf3f4; --bg2: #f4e4e6; --card: #ffffff; --line: #ead0d4; --a: #0369a1; --b: #15803d; --on-a: #fff; }
@media (prefers-color-scheme: light) { :root[data-palette="burgundy"]:not([data-theme]) { --bg: #fbf3f4; --bg2: #f4e4e6; --card: #ffffff; --line: #ead0d4; --a: #0369a1; --b: #15803d; --on-a: #fff; } }
:root[data-palette="mono"] { --bg: #111111; --bg2: #1a1a1a; --card: #222222; --line: #383838; --a: #ffffff; --b: #9ca3af; --on-a: #111111; --felt: #3d3d3d; }
:root[data-palette="mono"][data-theme="light"] { --bg: #f5f5f5; --bg2: #ebebeb; --card: #ffffff; --line: #d9d9d9; --a: #111111; --b: #6b7280; --on-a: #fff; }
@media (prefers-color-scheme: light) { :root[data-palette="mono"]:not([data-theme]) { --bg: #f5f5f5; --bg2: #ebebeb; --card: #ffffff; --line: #d9d9d9; --a: #111111; --b: #6b7280; --on-a: #fff; } }
:root[data-palette="night"] { --bg: #000000; --bg2: #0a0a0a; --card: #141414; --line: #2a2a2a; --a: #5eead4; --b: #ffb086; --on-a: #062a25; --felt: #151515; }
:root[data-palette="night"][data-theme="light"] { --bg: #f3f4f6; --bg2: #e5e7eb; --card: #ffffff; --line: #d1d5db; --a: #0f766e; --b: #c2410c; --on-a: #fff; }
@media (prefers-color-scheme: light) { :root[data-palette="night"]:not([data-theme]) { --bg: #f3f4f6; --bg2: #e5e7eb; --card: #ffffff; --line: #d1d5db; --a: #0f766e; --b: #c2410c; --on-a: #fff; } }

/* settings */
.palettes { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.pal { display: flex; align-items: center; gap: 10px; padding: 12px; border: 2px solid var(--line); border-radius: 12px; background: var(--bg2); cursor: pointer; min-height: 52px; }
.pal.on { border-color: var(--a); }
.pal input { position: absolute; opacity: 0; pointer-events: none; }
.pal-dots { display: flex; }
.pal-dots i { width: 20px; height: 20px; border-radius: 50%; margin-right: -6px; border: 2px solid var(--card); }
.pal-name { margin-left: 8px; font-weight: 700; color: var(--text); font-size: 15px; }
.small-note { font-size: 13px; text-align: center; }

/* share sheet */
.sheet-wrap { position: fixed; inset: 0; z-index: 30; background: rgba(0,0,0,.55); display: flex; align-items: flex-end; justify-content: center; animation: cel-fade .2s ease-out; }
.sheet { width: min(100%, 520px); background: var(--card); border-radius: 22px 22px 0 0; padding: 18px 16px calc(16px + var(--safe-bottom)); display: flex; flex-direction: column; gap: 12px; animation: sheet-up .25s ease-out; }
.sheet-title { margin: 0; font-size: 20px; text-align: center; }
.share-preview { margin: 0; font-size: 14px; color: var(--muted); white-space: pre-line; text-align: center; }
.share-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.share-btn { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 12px 6px; font-size: 14px; min-height: 76px; }
.share-ico { font-size: 24px; line-height: 1; }
.share-btn.wa { background: #25d366; color: #052e16; border-color: transparent; }
.share-btn.fb { background: #1877f2; color: #fff; border-color: transparent; }
.share-btn.ig { background: linear-gradient(45deg, #f58529, #dd2a7b 50%, #8134af); color: #fff; border-color: transparent; }
@keyframes sheet-up { from { transform: translateY(40px); opacity: 0; } to { transform: none; opacity: 1; } }

/* rules & tips */
.guide-tabs { position: sticky; top: 0; z-index: 2; }
.guide-pane { display: flex; flex-direction: column; gap: 10px; }
.guide details { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 0 16px; }
.guide details[open] { border-color: var(--a); }
.guide summary { cursor: pointer; list-style: none; padding: 16px 0; font-size: 18px; font-weight: 700; display: flex; justify-content: space-between; align-items: center; }
.guide summary::-webkit-details-marker { display: none; }
.guide summary::after { content: '+'; font-size: 22px; color: var(--muted); }
.guide details[open] summary::after { content: '–'; }
.guide ul { margin: 0 0 16px; padding-left: 20px; display: flex; flex-direction: column; gap: 8px; }
.guide li, .guide details p { font-size: 16px; line-height: 1.5; }
.guide details p { margin: 0 0 16px; }
.guide b { color: var(--text); }
.guide-src { font-size: 13px; text-align: center; }
.guide-src a { color: var(--a); }

/* player photos */
.players { display: flex; flex-direction: column; gap: 10px; }
.pl { position: relative; display: flex; align-items: center; gap: 10px; }
.pl input[name] { flex: 1; min-width: 0; }
.av-pick { flex: none; padding: 0; color: inherit; width: 52px; height: 52px; border-radius: 50%; border: 2px dashed var(--line); background: var(--bg2); display: grid; place-items: center; cursor: pointer; overflow: hidden; font-size: 22px; }
.av-pick img { width: 100%; height: 100%; object-fit: cover; }
.av-pick:has(img:not([hidden])) { border-style: solid; border-color: var(--a); }
.t1 .av-pick:has(img:not([hidden])) { border-color: var(--b); }
.av-clear { position: absolute; left: 36px; top: -4px; width: 22px; height: 22px; border-radius: 50%; border: none; background: var(--text); color: var(--bg); font-size: 12px; line-height: 22px; padding: 0; cursor: pointer; }
.av { width: 28px; height: 28px; border-radius: 50%; object-fit: cover; vertical-align: middle; margin-right: 6px; border: 2px solid var(--line); }
.av.sm { width: 22px; height: 22px; margin-right: 4px; border-width: 1px; }
.av.lg { width: 64px; height: 64px; margin: 0 0 6px; border: 3px solid var(--ball); }
.half .tplayers .pn { white-space: nowrap; }
.cel-players { display: flex; justify-content: center; gap: 18px; flex-wrap: wrap; }
.cel-pl { display: flex; flex-direction: column; align-items: center; }
.share-img { display: block; width: min(60vw, 220px); aspect-ratio: 1; margin: 0 auto; border-radius: 14px; background: var(--bg2); object-fit: cover; }

/* in-app camera */
.camera { position: fixed; inset: 0; z-index: 40; background: #000; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.cam-video { width: 100%; max-width: 560px; aspect-ratio: 1; object-fit: cover; background: #000; }
.cam-video.mirror { transform: scaleX(-1); }
.cam-guide { position: absolute; width: min(70vw, 360px); aspect-ratio: 1; border-radius: 50%; border: 3px dashed rgba(255,255,255,.8); box-shadow: 0 0 0 100vmax rgba(0,0,0,.35); pointer-events: none; top: 50%; left: 50%; transform: translate(-50%, -50%); }
.cam-bar { position: absolute; left: 0; right: 0; bottom: calc(24px + var(--safe-bottom)); display: flex; align-items: center; justify-content: space-around; }
.cam-btn { color: #fff; border-color: rgba(255,255,255,.4); min-width: 88px; }
.cam-snap { width: 74px; height: 74px; border-radius: 50%; border: 5px solid #fff; background: var(--ball); cursor: pointer; }
.cam-snap:active { transform: scale(.92); }

/* edit names */
.half .tname-row { display: flex; align-items: center; gap: 8px; }
.edit-names { font-size: 18px; line-height: 1; padding: 6px 8px; border-radius: 10px; background: rgba(127,127,127,.18); cursor: pointer; }
.edit-names:active { transform: scale(.92); }
#names-form input { font-size: 18px; }

/* singles / doubles */
.match-type { margin-bottom: 2px; }
#setup-form.singles .pl.p2 { display: none; }

/* who serves first */
.clock-wrap { display: flex; justify-content: center; align-items: center; min-width: 0; }
.serve-btn { font-size: 15px; padding: 10px 12px; border-color: var(--ball); color: var(--text); white-space: nowrap; }
.serve-hint { margin: -4px 0 0; text-align: center; font-size: 14px; }
.serve-choices { display: flex; flex-direction: column; gap: 10px; }
.serve-choice { display: flex; align-items: center; gap: 8px; justify-content: flex-start; text-align: left; }
.serve-choice small { margin-left: auto; color: var(--muted); font-weight: 500; font-size: 13px; }
.serve-choice.c-a { border-left: 5px solid var(--a); }
.serve-choice.c-b { border-left: 5px solid var(--b); }

/* recent players */
.recent { display: flex; flex-direction: column; gap: 8px; }
.recent-title { font-size: 14px; font-weight: 700; }
.recent-title .muted { font-weight: 500; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { display: inline-flex; align-items: center; gap: 4px; padding: 8px 12px; border-radius: 999px; border: 1px solid var(--line); background: var(--card); color: var(--text); font-size: 15px; font-weight: 600; cursor: pointer; }
.chip .av { margin-right: 2px; }
.chip.used { opacity: .4; }

/* settings button on every screen */
.topbar .open-settings { margin-left: auto; }
.topbar.compact .open-settings { margin-left: 0; }

/* ---------- look & feel: court pattern, depth, motion ---------- */
:root { --pat: rgba(255,255,255,.045); --glow-a: color-mix(in srgb, var(--a) 22%, transparent); --glow-b: color-mix(in srgb, var(--b) 18%, transparent); }
:root[data-theme="light"] { --pat: rgba(16,33,26,.05); }
@media (prefers-color-scheme: light) { :root:not([data-theme]) { --pat: rgba(16,33,26,.05); } }
body {
  background-color: var(--bg);
  background-image:
    radial-gradient(60vmax 40vmax at 0% 0%, var(--glow-a), transparent 60%),
    radial-gradient(60vmax 40vmax at 100% 100%, var(--glow-b), transparent 60%),
    linear-gradient(var(--pat) 2px, transparent 2px),
    linear-gradient(90deg, var(--pat) 2px, transparent 2px);
  background-size: 100% 100%, 100% 100%, 140px 180px, 140px 180px;
  background-position: 0 0, 0 0, -1px 89px, 69px -1px;
  background-attachment: fixed;
}
.screen:not(.live) { animation: screen-in .28s ease-out; }
@keyframes screen-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.topbar { backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); background: color-mix(in srgb, var(--bg) 70%, transparent); position: sticky; top: 0; z-index: 5; }
.brand-icon { width: 28px; height: 28px; border-radius: 8px; box-shadow: 0 2px 8px rgba(0,0,0,.3); }

/* ---------- Landing page (Home) ---------- */
.home-top { border-bottom: 0; }
.brand-name { font-weight: 800; letter-spacing: .06em; text-transform: uppercase; font-size: 17px; }
.hero {
  position: relative; overflow: hidden; min-height: 540px; display: flex; align-items: flex-end;
  padding: 28px 20px 96px; color: #fff;
}
.hero-bg { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: 68% 40%; filter: brightness(.6) saturate(.9); }
.hero::before { content: ''; position: absolute; inset: 0; background: linear-gradient(180deg, rgba(5,20,14,.45), rgba(5,20,14,.2) 35%, rgba(5,20,14,.9)); }
.hero-body { position: relative; display: flex; flex-direction: column; gap: 14px; width: 100%; max-width: 440px; }
.hero-badge {
  align-self: flex-start; display: inline-flex; align-items: center; gap: 9px; padding: 9px 14px;
  border: 1px solid rgba(255,255,255,.28); border-radius: 8px; background: rgba(5,20,14,.55);
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  font-size: 12px; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; color: #eef5f0;
}
.hero-badge i { width: 8px; height: 8px; border-radius: 50%; background: var(--lime); }
.hero-h { margin: 4px 0 0; font-size: clamp(44px, 14vw, 68px); line-height: 1.02; font-weight: 800; letter-spacing: -.025em; color: #fff; }
.hero-h span { color: var(--lime); }
.hero-sub { margin: 0 0 6px; font-size: 17px; line-height: 1.5; color: #d7e3dc; }
.btn.lime {
  background: var(--lime); color: #0b1f16; border-color: transparent; border-radius: 8px;
  justify-content: space-between; padding: 0 22px; min-height: 56px; font-size: 18px; font-weight: 750;
  box-shadow: 0 10px 26px color-mix(in srgb, var(--lime) 28%, transparent);
}
.btn.lime::after { content: none; }
.hero-link { appearance: none; background: none; border: 0; color: #fff; font: inherit; font-weight: 700; font-size: 16px; padding: 6px 0; text-align: left; cursor: pointer; display: inline-flex; gap: 8px; align-self: flex-start; }
.scorecard {
  --cols: 3; position: relative; z-index: 1; margin: -76px 16px 0; padding: 16px 18px 6px;
  background: #fff; color: #10211a; border-radius: 16px; box-shadow: 0 18px 44px rgba(0,0,0,.35); cursor: pointer;
}
.scorecard:active { transform: scale(.99); }
.sc-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding-bottom: 12px; border-bottom: 1px solid #e3e9e5; font-size: 12px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: #3c5048; }
.sc-live { display: flex; align-items: center; gap: 8px; white-space: nowrap; flex: none; }
.sc-live i { width: 10px; height: 10px; border-radius: 50%; background: #0b3b2a; }
.sc-live.on i { background: #16a34a; box-shadow: 0 0 0 4px rgba(22,163,74,.2); }
.sc-right { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.sc-row { display: grid; grid-template-columns: minmax(0, 1fr) repeat(var(--cols), minmax(34px, auto)); gap: 8px; align-items: center; padding: 11px 0; border-bottom: 1px solid #e3e9e5; font-size: 22px; font-weight: 700; }
.sc-row:last-child { border-bottom: 0; }
.sc-th { font-size: 11px; letter-spacing: .1em; text-transform: uppercase; color: #5d7068; font-weight: 700; padding: 10px 0 8px; }
.sc-v { text-align: center; font-variant-numeric: tabular-nums; }
.sc-team { display: flex; align-items: center; gap: 8px; min-width: 0; font-size: 17px; }
.sc-team b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sc-team i { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.dot-a { background: #0b3b2a; } .dot-b { background: #2563eb; }
.sc-game { background: var(--lime); color: #0b1f16; border-radius: 8px; padding: 5px 4px; font-size: 20px; }
.sc-empty { margin: 12px 0 10px; color: #5d7068; font-size: 15px; line-height: 1.45; }
.home .content { padding-top: 18px; }
.install { border-color: color-mix(in srgb, var(--a) 60%, var(--line)); }

/* cards get depth */
fieldset, .history li, .guide details, .sheet { box-shadow: 0 6px 20px rgba(0,0,0,.12); }
.history li { transition: transform .15s ease; }
.history li:active { transform: scale(.985); }

/* live screen: court feel + score pop */
.half {
  background:
    radial-gradient(120% 90% at 50% 120%, var(--glow-a), transparent 60%),
    linear-gradient(180deg, var(--bg2), var(--bg));
}
.half[data-team="1"] { background:
    radial-gradient(120% 90% at 50% -20%, var(--glow-b), transparent 60%),
    linear-gradient(180deg, var(--bg2), var(--bg)); }
.half.serving .serve { animation: serve-pulse 1.6s ease-in-out infinite; }
@keyframes serve-pulse { 0%, 100% { box-shadow: 0 0 0 4px rgba(232,245,74,.2); } 50% { box-shadow: 0 0 0 10px rgba(232,245,74,0); } }
.half .pts.pop { animation: pop .28s cubic-bezier(.2,1.6,.4,1); }
@keyframes pop { from { transform: scale(.8); opacity: .5; } to { transform: scale(1); opacity: 1; } }
.controls { background: color-mix(in srgb, var(--bg) 85%, transparent); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); }

/* install help */
.install-icon { width: 64px; height: 64px; border-radius: 16px; margin: 0 auto; display: block; box-shadow: 0 6px 18px rgba(0,0,0,.3); }
.install-steps { margin: 0; padding-left: 22px; display: flex; flex-direction: column; gap: 10px; font-size: 16px; line-height: 1.45; }
.kbd { display: inline-block; padding: 0 6px; border: 1px solid var(--line); border-radius: 6px; background: var(--bg2); }

@media (prefers-reduced-motion: reduce) {
  .btn.primary::after, .half.serving .serve, .half .pts.pop, .screen:not(.live) { animation: none; }
}
/* slimmer form controls to match the smaller buttons */
input[type=text], input:not([type]) { min-height: 42px; padding: 9px 12px; }
.av-pick { width: 44px; height: 44px; font-size: 19px; }
.av-clear { left: 30px; }
.seg span { padding: 8px 6px; min-height: 36px; }

.clock-wrap { flex-direction: column; gap: 4px; }
.clock-wrap .serve-btn { min-height: 32px; padding: 5px 10px; font-size: 13px; }

/* sets: Best of / Race to */
.seg-wrap { flex-wrap: wrap; }
.seg-wrap label { flex: 1 1 30%; }
.sets-hint { font-size: 12px; color: var(--muted); }

/* mirrored score screen: top team's names at the very top, bottom team's names at the
   very bottom, both scores in the middle next to the net */
.court .half .info, .court .half .pts { grid-row: 2; }
.court .half:first-of-type .info, .court .half:first-of-type .pts { align-self: end; }
.court .half ~ .half { grid-template-rows: 1fr auto; }
.court .half ~ .half .names { grid-row: 2; flex-direction: column-reverse; gap: 6px; }
.court .half ~ .half .info, .court .half ~ .half .pts { grid-row: 1; align-self: start; }
.court .half ~ .half .tplayers { margin-top: 0; }
.court .half ~ .half .serve { top: auto; bottom: 16px; }

/* Landing page on wide screens: keep the card readable, let the text breathe */
@media (min-width: 900px) {
  .hero-body { max-width: 560px; }
  .scorecard { max-width: 760px; }
  .home .content { max-width: 792px; }
}
/* Landing page in phone landscape: compact two-column hero so the buttons stay on screen */
@media (orientation: landscape) and (max-height: 560px) {
  .hero { min-height: 0; padding: 16px 20px 44px; }
  .hero-body {
    max-width: none; display: grid; grid-template-columns: 1.15fr 1fr; grid-template-rows: auto auto auto;
    column-gap: 28px; row-gap: 8px; align-items: end;
  }
  .hero-badge { grid-column: 1; grid-row: 1; padding: 6px 10px; font-size: 11px; }
  .hero-h { grid-column: 1; grid-row: 2; font-size: clamp(30px, 6vw, 44px); margin: 0; }
  .hero-sub { grid-column: 1; grid-row: 3; font-size: 14px; margin: 0; }
  #btn-resume { grid-column: 2; grid-row: 2; }
  .btn.lime { min-height: 46px; font-size: 16px; padding: 0 16px; }
  .scorecard { margin-top: -28px; padding: 12px 16px 2px; }
  .sc-row:not(.sc-th) { padding: 7px 0; font-size: 18px; }
  .sc-game { font-size: 17px; padding: 3px 4px; }
}

/* ================= Pool Score ================= */
/* cloth texture instead of court lines */
body {
  background-image:
    radial-gradient(60vmax 40vmax at 0% 0%, var(--glow-a), transparent 60%),
    radial-gradient(60vmax 40vmax at 100% 100%, var(--glow-b), transparent 60%),
    radial-gradient(var(--pat) 1px, transparent 1.5px);
  background-size: 100% 100%, 100% 100%, 7px 7px;
  background-position: 0 0, 0 0, 0 0;
}

/* landing page: photo of a pool table (img/hero.jpg); the felt gradient shows while it loads */
.hero {
  background: radial-gradient(130% 75% at 66% 24%, var(--felt), color-mix(in srgb, var(--felt) 55%, #000) 62%, color-mix(in srgb, var(--felt) 28%, #000));
}
.hero-bg { object-fit: cover; object-position: 62% 50%; filter: none; }
.hero { min-height: 620px; }
@media (orientation: landscape) and (max-height: 560px) { .hero { min-height: 0; } .hero-bg { object-position: 50% 62%; } }
.hero::before { z-index: 1; background: linear-gradient(180deg, rgba(5,6,8,.3), rgba(5,6,8,.08) 26%, rgba(5,6,8,.62) 52%, rgba(5,6,8,.9)); }
.hero-body { z-index: 2; }
.hero-badge { background: rgba(3,10,20,.55); color: #f2f6fb; }
.hero-sub { color: #dbe6f2; }
.btn.lime { color: #1f1a00; }
.scorecard { --cols: 1; color: #0f2135; }
.sc-head, .sc-row { border-color: #e1e8f0; }
.sc-head { color: #3b4f66; }
.sc-th, .sc-empty { color: #5b6f85; }
.sc-live i { background: #0f2135; }
.dot-a { background: #0f766e; } .dot-b { background: #c2410c; }
.sc-row { grid-template-columns: minmax(0, 1fr) repeat(var(--cols), minmax(54px, auto)); }
.sc-game { color: #1f1a00; }
.sc-left { font-size: 18px; white-space: nowrap; }
.sc-brk { font-size: 10px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: #5b6f85; border: 1px solid #cfdcea; border-radius: 999px; padding: 2px 6px; flex: none; }
.foot a { color: inherit; }
.history .h-sets { font-size: 22px; }

/* balls */
.bl {
  display: inline-block; width: 16px; height: 16px; border-radius: 50%; flex: none; vertical-align: middle;
  box-shadow: inset -2px -3px 4px rgba(0,0,0,.35), inset 2px 2px 3px rgba(255,255,255,.4);
}
.bl.red { background: var(--red); }
.bl.yellow { background: var(--yel); }
.bl.black { background: #141414; box-shadow: inset -2px -3px 4px rgba(0,0,0,.6), inset 2px 2px 3px rgba(255,255,255,.35), 0 0 0 1px rgba(255,255,255,.3); }
.bl.gone { background: transparent; box-shadow: inset 0 0 0 2px var(--line); }
.bl.sm { width: 13px; height: 13px; }
.bl.black.on { box-shadow: inset -2px -3px 4px rgba(0,0,0,.6), inset 2px 2px 3px rgba(255,255,255,.35), 0 0 0 3px var(--ball); }

/* live screen */
.live-main { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.court::after { /* the cushion between the two sides */
  content: ''; position: absolute; left: 0; right: 0; top: 50%; height: 3px; transform: translateY(-50%); pointer-events: none; background: var(--line);
}
.half { min-height: 0; overflow: hidden; }
.half .info { display: flex; flex-direction: column; gap: 8px; align-self: center; min-width: 0; }
.half .pts { font-size: clamp(60px, 17vh, 130px); min-width: 1ch; }
.screen.live.frames-only .half .pts { font-size: clamp(72px, 22vh, 150px); }
.half .tplayers { display: block; margin-top: 4px; font-size: 16px; }
.chips-s { display: flex; gap: 6px; flex-wrap: wrap; min-height: 26px; }
.chip-s {
  font-size: 12px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; padding: 4px 9px; border-radius: 999px;
  background: var(--card); border: 1px solid var(--line); color: var(--text); white-space: nowrap;
}
.chip-s.at { background: var(--ball); color: #1f1a00; border-color: transparent; }
.dots { display: flex; gap: 4px; align-items: center; flex-wrap: wrap; }
.dots .bl { width: 18px; height: 18px; }
.dots .bl.black { margin-left: 4px; }
.open-tag { font-size: 14px; color: var(--muted); font-weight: 600; }
.half.serving { box-shadow: inset 0 0 0 3px color-mix(in srgb, var(--ball) 75%, transparent); }
.half .serve { box-shadow: 0 0 0 4px color-mix(in srgb, var(--ball) 25%, transparent); }
.screen.live:not(.frames-only) .half { cursor: default; }
.screen.live:not(.frames-only) .half:active { filter: none; }

.toast { bottom: auto; top: calc(62px + var(--safe-top)); pointer-events: none; text-align: center; max-width: 92vw; }

/* shot buttons (ball by ball) */
.pad {
  padding: 8px 12px; border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: 6px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
}
.pad-hint { font-size: 14px; font-weight: 700; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pad-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.pbtn { flex-direction: column; gap: 1px; min-height: 54px; padding: 6px 4px; line-height: 1.15; min-width: 0; }
.pbtn .pl-t { display: inline-flex; align-items: center; gap: 6px; font-size: 16px; white-space: nowrap; }
.pbtn small { font-size: 11px; font-weight: 600; color: var(--muted); min-height: 13px; white-space: nowrap; }
.pbtn:disabled { opacity: .4; }
.pbtn.foul { color: var(--danger); }
.pbtn.mine { border-color: var(--ball); }
.pbtn.win { background: var(--ball); color: #1f1a00; border-color: transparent; }
.pbtn.win small { color: #4a3d00; }
.controls .serve-btn { min-width: 0; }

/* "More" sheet */
.sheet { max-height: 94dvh; overflow-y: auto; }
.stepper { display: flex; align-items: center; gap: 10px; color: var(--text); font-size: 15px; }
.stepper > span { flex: 1; display: flex; gap: 8px; align-items: center; }
.stepper b { min-width: 24px; text-align: center; font-size: 20px; font-variant-numeric: tabular-nums; }
.opt.toggle > span { display: flex; gap: 8px; align-items: center; }
.ms-outcome { margin: 0; font-size: 14px; min-height: 20px; color: var(--text); font-weight: 600; }

/* summary */
.scoretable td.big { font-size: 26px; font-weight: 700; width: 30%; }
.scoretable td.big.w { font-weight: 900; }
.scoretable.frames td, .scoretable.frames th { font-size: 14px; padding: 8px; }
.scoretable.frames th { color: var(--muted); font-weight: 500; font-size: 13px; }
.scoretable.frames td:nth-child(2), .scoretable.frames th:nth-child(2) { text-align: left; }
.scoretable.frames td:first-child, .scoretable.frames th:first-child { text-align: center; width: 34px; }

/* ---------- score screen in landscape (phone on its side, short viewport) ---------- */
@media (orientation: landscape) and (max-height: 500px) {
  .screen.live .topbar { padding: 4px 12px; }
  .live-main { flex-direction: row; }
  .court { flex-direction: row; min-width: 0; }
  .court::after { left: 50%; right: auto; top: 0; bottom: 0; height: auto; width: 3px; transform: translateX(-50%); }
  /* both halves: names on top, balls + frames in one row below */
  .court .half, .court .half ~ .half {
    padding: 8px 12px 6px; grid-template-columns: 1fr auto; grid-template-rows: auto 1fr; align-items: center; min-width: 0;
  }
  .court .half .names, .court .half ~ .half .names { grid-row: 1; grid-column: 1 / -1; flex-direction: column; gap: 2px; min-width: 0; padding-right: 22px; }
  .court .half .info, .court .half:first-of-type .info, .court .half ~ .half .info { grid-row: 2; grid-column: 1; align-self: center; }
  .screen.live:not(.frames-only) .banner { display: none; }
  .court .half .pts, .court .half:first-of-type .pts, .court .half ~ .half .pts { grid-row: 2; grid-column: 2; align-self: center; font-size: clamp(44px, 26vh, 100px); }
  .court .half .serve, .court .half ~ .half .serve { top: 10px; bottom: auto; right: 12px; width: 14px; height: 14px; }
  .half .tname { font-size: 20px; }
  .half .tplayers { margin-top: 2px; font-size: 14px; }
  .dots { gap: 3px; }
  .dots .bl { width: 15px; height: 15px; }
  .pad { width: 262px; flex: none; border-top: 0; border-left: 1px solid var(--line); justify-content: center; padding: 6px 10px; }
  .pad-grid { gap: 6px; }
  .pbtn { min-height: 48px; }
  .pbtn .pl-t { font-size: 14px; gap: 4px; }
  .pbtn .bl { width: 13px; height: 13px; }
  .controls { padding: 6px 12px calc(6px + var(--safe-bottom)); }
  .controls .btn { min-height: 36px; }
  .clock-wrap { flex-direction: row; gap: 10px; }
}

/* apple (break and finish): button on the live screen, selfie camera, picture sheet */
.apple-fab {
  position: absolute; left: 56%; top: 50%; transform: translate(-50%, -50%); z-index: 3;
  display: flex; align-items: center; gap: 10px; max-width: min(80%, 340px);
  padding: 10px 18px 10px 12px; border-radius: 999px; border: 2px solid #ffd9a8; cursor: pointer;
  background: linear-gradient(135deg, #b3121d, #e3242b); color: #fff; font: inherit; text-align: left;
  box-shadow: 0 8px 24px rgba(0,0,0,.45);
}
.apple-fab[hidden] { display: none; }
.apple-fab .ap-i { font-size: 30px; line-height: 1; }
.apple-fab b { display: block; font-size: 16px; font-weight: 800; overflow-wrap: anywhere; }
.apple-fab small { display: block; font-size: 12px; opacity: .85; }
.apple-fab.on { background: linear-gradient(135deg, #1f7a4d, #2fa866); border-color: #d6f5e0; }
.apple-fab:active { transform: translate(-50%, -50%) scale(.96); }
.apple-btn { background: linear-gradient(135deg, #b3121d, #e3242b); color: #fff; border-color: #ffd9a8; font-weight: 700; }
.apple-wrap { z-index: 35; }
.apple-img { display: block; width: min(64vw, 260px); aspect-ratio: 4 / 5; margin: 0 auto; border-radius: 14px; background: var(--bg2); object-fit: cover; }
.cam-hint { display: none; }
.camera.apple .cam-guide { display: none; }
.camera.apple .cam-video { width: auto; max-width: 100%; height: min(72dvh, 125vw); aspect-ratio: 4 / 5; border: 6px solid #e3242b; border-radius: 22px; }
.camera.apple .cam-hint {
  display: block; position: absolute; top: calc(14px + env(safe-area-inset-top, 0px)); left: 12px; right: 12px;
  text-align: center; color: #fff; font-weight: 700; font-size: 15px; text-shadow: 0 1px 4px rgba(0,0,0,.8);
}
@media (orientation: landscape) and (max-height: 500px) {
  .apple-fab { left: 50%; top: auto; bottom: 8px; transform: translateX(-50%); padding: 6px 14px 6px 10px; }
  .apple-fab:active { transform: translateX(-50%) scale(.96); }
  .apple-fab .ap-i { font-size: 22px; }
  .apple-fab small { display: none; }
  .camera.apple .cam-video { height: min(70dvh, 70vw); }
}

/* v4 home: smaller hero, game tiles, recent matches, players, more */
.hero.hero-sm { min-height: 300px; padding: 20px 20px 26px; }
.hero-sm .hero-h { font-size: clamp(34px, 10vw, 52px); }
.home .scorecard { margin: 14px 16px 0; }
.scorecard[hidden] { display: none; }
.home-content { gap: 12px; }
.section-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.link-btn { appearance: none; background: none; border: 0; color: var(--a); font: inherit; font-weight: 700; font-size: 14px; cursor: pointer; padding: 6px 0; }
.link-btn[hidden] { display: none; }
.tiles { display: grid; gap: 10px; }
.tiles-disc { grid-template-columns: repeat(auto-fit, minmax(96px, 1fr)); }
.tiles-3 { grid-template-columns: repeat(3, 1fr); }
.tile {
  appearance: none; border: 1px solid var(--line); background: var(--card); color: var(--text); border-radius: var(--radius);
  padding: 14px 6px; display: flex; flex-direction: column; align-items: center; gap: 8px;
  font: inherit; font-weight: 700; font-size: 15px; cursor: pointer; box-shadow: 0 6px 20px rgba(0,0,0,.12);
}
.tile:active { transform: scale(.97); }
.tile-ico { font-size: 28px; line-height: 44px; height: 44px; }
.dball {
  --c: #111; width: 44px; height: 44px; border-radius: 50%; display: inline-grid; place-items: center; flex: none;
  background: radial-gradient(circle at 32% 28%, color-mix(in srgb, var(--c) 55%, #fff), var(--c) 58%, color-mix(in srgb, var(--c) 60%, #000));
  box-shadow: 0 2px 6px rgba(0,0,0,.35);
}
.dball b { width: 56%; height: 56%; border-radius: 50%; background: #fff; color: #111; display: grid; place-items: center; font-size: 13px; font-weight: 800; line-height: 1; }
.dball.sm { width: 22px; height: 22px; box-shadow: none; }
.dball.sm b { width: 64%; height: 64%; font-size: 8px; }
.d-blackball { --c: #111; outline: 2px solid var(--ball); outline-offset: 1px; }
.d-8ball { --c: #151515; }
.d-9ball { --c: #e0b400; }
.d-10ball { --c: #1f6fd6; }
.d-ultimate { --c: #d4202c; }
.recent-matches { display: flex; gap: 10px; overflow-x: auto; scroll-snap-type: x proximity; margin: 0 -16px; padding: 0 16px 6px; -webkit-overflow-scrolling: touch; }
.recent-matches[hidden] { display: none; }
.rm-card {
  flex: 0 0 min(66%, 240px); scroll-snap-align: start; appearance: none; text-align: left; font: inherit; color: var(--text);
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px;
  display: flex; flex-direction: column; gap: 6px; cursor: pointer; box-shadow: 0 6px 20px rgba(0,0,0,.12);
}
.rm-top { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); border-bottom: 1px solid var(--line); padding-bottom: 6px; }
.rm-top .live { margin-left: auto; color: var(--ball); }
.rm-row { display: flex; justify-content: space-between; gap: 10px; font-size: 17px; }
.rm-row b { font-variant-numeric: tabular-nums; }
.rm-row.won { font-weight: 800; }
.rm-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.history .h-top .dball { vertical-align: middle; }
.players-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.pl-row {
  width: 100%; appearance: none; font: inherit; color: var(--text); text-align: left; background: var(--card);
  border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; display: flex; align-items: center; gap: 12px; cursor: pointer;
}
.pl-av { width: 48px; height: 48px; margin: 0; flex: none; border-radius: 50%; }
.pl-av.none { display: grid; place-items: center; background: var(--bg2); border: 2px solid var(--line); font-weight: 800; font-size: 20px; color: var(--muted); }
.pl-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.pl-info b { font-size: 17px; overflow-wrap: anywhere; }
.pl-info small { color: var(--muted); font-size: 13px; }
.pl-go { color: var(--muted); font-size: 22px; }
.more-row { justify-content: flex-start; text-align: left; text-decoration: none; }
.more-row[hidden] { display: none; }
#player-sheet .pl input { flex: 1; min-width: 0; }
.guide-tabs.seg-wrap span { font-size: 14px; }

/* v5 score screen (frames only): name bar, shot clock | score in the centre | + and -, middle strip */
.half .pm, .half .sclock, .mid { display: none; }
.screen.live.frames-only .banner, .screen.live.frames-only .court::after, .screen.live.frames-only .half .serve { display: none; }
.screen.live.frames-only .court .half, .screen.live.frames-only .court .half ~ .half {
  display: grid; padding: 0; border: 0; text-align: center; align-items: center; min-width: 0;
  grid-template-columns: minmax(70px, 24%) 1fr minmax(70px, 24%);
  grid-template-rows: auto 1fr; grid-template-areas: "names names names" "clock pts pm";
  background: var(--bg);
}
.screen.live.frames-only .court .half ~ .half { grid-template-rows: 1fr auto; grid-template-areas: "clock pts pm" "names names names"; }
.screen.live.frames-only .court .half .names, .screen.live.frames-only .court .half ~ .half .names {
  grid-area: names; display: flex; flex-direction: column; align-items: center; gap: 2px; min-width: 0;
  padding: 12px 14px; background: color-mix(in srgb, var(--a) 26%, var(--card));
}
.screen.live.frames-only .court .half[data-team="1"] .names { background: color-mix(in srgb, var(--b) 26%, var(--card)); }
.screen.live.frames-only .half .tname-row { justify-content: center; }
.screen.live.frames-only .half .tname { font-size: 26px; overflow-wrap: anywhere; }
.screen.live.frames-only .half .tplayers { margin: 0; }
.screen.live.frames-only .court .half .pts, .screen.live.frames-only .court .half:first-of-type .pts, .screen.live.frames-only .court .half ~ .half .pts {
  grid-area: pts; align-self: center; justify-self: center; text-align: center; min-width: 1ch;
  font-size: clamp(88px, 21vh, 180px);
}
.screen.live.frames-only .court .half .info, .screen.live.frames-only .court .half:first-of-type .info {
  grid-area: pts; align-self: start; justify-self: center; flex-direction: row; padding: 8px 0; z-index: 1;
}
.screen.live.frames-only .court .half ~ .half .info { grid-area: pts; align-self: end; justify-self: center; flex-direction: row; padding: 8px 0; z-index: 1; }
.screen.live.frames-only .half .pm { grid-area: pm; display: flex; flex-direction: column; gap: 10px; align-items: center; justify-self: center; }
.pm button, .sc-btns button {
  appearance: none; border: 0; border-radius: 12px; cursor: pointer; font: inherit; font-weight: 800; color: #fff;
  background: color-mix(in srgb, var(--a) 45%, var(--card)); box-shadow: 0 4px 12px rgba(0,0,0,.3); touch-action: manipulation;
}
.half[data-team="1"] .pm button, .half[data-team="1"] .sc-btns button { background: color-mix(in srgb, var(--b) 45%, var(--card)); }
.pm button { width: 58px; height: 54px; font-size: 34px; line-height: 1; }
.pm button:active, .sc-btns button:active, .sc-face:active { transform: scale(.93); }
.pm button:disabled { opacity: .3; cursor: default; }
.screen.live.frames-only .half .sclock:not([hidden]) { grid-area: clock; display: flex; flex-direction: column; gap: 8px; align-items: center; justify-self: center; }
.sc-face {
  appearance: none; width: 62px; height: 62px; border-radius: 50%; border: 4px solid var(--muted); background: none; color: var(--text);
  font: inherit; font-size: 24px; font-weight: 800; font-variant-numeric: tabular-nums; cursor: pointer;
}
.sclock.run .sc-face { border-color: var(--ball); }
.sclock.warn .sc-face { border-color: #ff5a4f; color: #ff8a80; }
.sclock.out .sc-face { border-color: #ff5a4f; background: #b3121d; color: #fff; }
.sc-btns { display: flex; gap: 6px; }
.sc-btns button { min-width: 34px; height: 32px; padding: 0 6px; font-size: 13px; }
.screen.live.frames-only .mid {
  display: flex; align-items: center; gap: 12px; padding: 10px 14px; min-height: 76px; flex: none;
  background: var(--card); border-block: 1px solid var(--line);
}
.mid-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; text-align: left; }
.mid-text b { font-size: 17px; }
.mid-text small { font-size: 14px; color: var(--muted); }
.mid-text small:empty { display: none; }
.screen.live.frames-only .apple-fab, .screen.live.frames-only .apple-fab:active {
  position: static; transform: none; max-width: 58%; padding: 8px 14px 8px 10px; box-shadow: none; flex: none;
}
.screen.live.frames-only .apple-fab:active { transform: scale(.96); }
.screen.live.frames-only .apple-fab .ap-i { font-size: 26px; }
.screen.live.frames-only .apple-fab b { font-size: 15px; }
@media (orientation: landscape) and (max-height: 500px) {
  .screen.live.frames-only .court .half, .screen.live.frames-only .court .half ~ .half {
    grid-template-rows: auto 1fr; grid-template-areas: "names names names" "clock pts pm"; grid-template-columns: minmax(56px, 22%) 1fr minmax(56px, 22%);
  }
  .screen.live.frames-only .court .half .names, .screen.live.frames-only .court .half ~ .half .names { padding: 6px 10px; }
  .screen.live.frames-only .half .tname { font-size: 19px; }
  .screen.live.frames-only .court .half .pts, .screen.live.frames-only .court .half:first-of-type .pts, .screen.live.frames-only .court .half ~ .half .pts { font-size: clamp(54px, 34vh, 120px); }
  .screen.live.frames-only .court .half .info, .screen.live.frames-only .court .half:first-of-type .info, .screen.live.frames-only .court .half ~ .half .info { align-self: start; padding: 4px 0; }
  .pm button { width: 46px; height: 40px; font-size: 26px; }
  .screen.live.frames-only .half .pm { gap: 6px; }
  .sc-face { width: 46px; height: 46px; font-size: 18px; border-width: 3px; }
  .sc-btns button { min-width: 28px; height: 26px; font-size: 11px; }
  .screen.live.frames-only .mid { flex-direction: column; justify-content: center; width: 118px; min-height: 0; padding: 6px; border-block: 0; border-inline: 1px solid var(--line); gap: 6px; }
  .mid-text { flex: none; text-align: center; }
  .mid-text b { font-size: 13px; }
  .mid-text small { font-size: 12px; }
  .screen.live.frames-only .apple-fab { max-width: 100%; padding: 6px 8px; gap: 4px; }
  .screen.live.frames-only .apple-fab b { font-size: 12px; }
}
