/* =========================================================
   Scoreboard: setup screen, team editor, results, full-screen scorer
   ========================================================= */

/* ---------- Setup screen ---------- */
.sb-card { margin-top: 14px; }
.sb-card:first-of-type { margin-top: 0; }
.sb-card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.sb-card-head h3 { font-size: 15px; letter-spacing: 0.2px; }
.sb-empty { text-align: center; color: var(--muted); padding: 22px 8px; font-size: 13.5px; }
.sb-loading { display: flex; justify-content: center; padding: 30px 0; }

.sb-opts { display: flex; flex-direction: column; gap: 8px; }
.sb-opt {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; text-align: left; width: 100%;
  background: var(--navy); border: 1.5px solid var(--navy-3); border-radius: 14px; padding: 12px 14px; color: var(--white);
  transition: border-color 0.15s var(--ease), background 0.15s var(--ease), transform 0.12s var(--ease);
}
.sb-opt:hover { border-color: var(--navy-4); }
.sb-opt:active { transform: scale(0.99); }
.sb-opt.selected { border-color: var(--ice); background: var(--ice-tint); }
.sb-opt-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.sb-opt-main b { font-size: 14px; font-weight: 600; }
.sb-opt-main small { color: var(--muted); font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sb-opt-meta { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 12px; white-space: nowrap; flex-shrink: 0; }
.sb-pasttoggle { align-self: flex-start; }

.sb-notice {
  background: var(--warn-tint); border: 1px solid rgba(224, 167, 47, 0.35); color: var(--warn);
  border-radius: 12px; padding: 9px 12px; font-size: 13px; margin-bottom: 12px; display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap;
}
.sb-syncbtn { border: none; cursor: pointer; }

/* The one thing you need at the start of a game, right at the top of the page. */
.sb-start {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  background: linear-gradient(135deg, var(--navy-3), var(--navy-2)); border: 1px solid var(--navy-4); border-radius: 18px; padding: 14px 16px;
  box-shadow: 0 18px 40px -22px rgba(0, 0, 0, 0.8);
}
.sb-start.live { border-color: rgba(230, 57, 44, 0.6); box-shadow: 0 0 0 1px rgba(230, 57, 44, 0.2), 0 18px 40px -22px rgba(230, 57, 44, 0.55); }
.sb-start-info { display: flex; flex-direction: column; gap: 3px; flex: 1 1 0; min-width: 0; }
.sb-start-scope { color: var(--muted-2); font-size: 11px; font-weight: 700; letter-spacing: 0.8px; text-transform: uppercase; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sb-start-info b { font-size: 17px; }
.sb-start-teams { color: var(--muted); font-size: 13.5px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.sb-start-teams i { font-style: normal; color: var(--red); font-weight: 700; padding: 0 3px; }
.sb-start-hint { font-style: normal; color: var(--muted-2); font-size: 12px; }
.sb-start-actions { display: flex; flex-direction: column; align-items: stretch; gap: 8px; flex-shrink: 0; }
.sb-go { padding: 15px 24px; font-size: 16px; }

/* ---------- Tabs ---------- */
.sb-tabs { display: flex; background: var(--navy); border: 1px solid var(--navy-3); border-radius: 12px; padding: 3px; gap: 3px; margin-bottom: 12px; }
.sb-tabs button { flex: 1; border: none; background: transparent; color: var(--muted); font-size: 12.5px; font-weight: 600; padding: 8px 6px; border-radius: 9px; transition: all 0.15s var(--ease); }
.sb-tabs button em { font-style: normal; background: var(--navy-3); border-radius: 999px; padding: 1px 7px; font-size: 11px; margin-left: 4px; }
.sb-tabs button.active { background: var(--navy-3); color: var(--ice); }
.sb-seg { display: flex; background: var(--navy); border: 1px solid var(--navy-3); border-radius: 12px; padding: 3px; gap: 3px; }
.sb-seg button { flex: 1; border: none; background: transparent; color: var(--muted); font-weight: 600; padding: 9px; border-radius: 9px; }
.sb-seg button.active { background: var(--ice); color: var(--navy); }

/* ---------- Team editor ---------- */
.sb-editor { display: flex; flex-direction: column; gap: 14px; }
.sb-edit-court { display: grid; grid-template-columns: 1fr auto 1fr; gap: 10px; align-items: stretch; }
.sb-edit-team { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.sb-edit-title { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; font-size: 11px; font-weight: 700; letter-spacing: 1px; text-transform: uppercase; color: var(--muted); }
.sb-edit-title em { font-style: normal; color: var(--ice); text-transform: none; letter-spacing: 0; font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sb-edit-vs { align-self: center; font-family: var(--font-display); color: var(--red); letter-spacing: 2px; }
.sb-bench-list { display: flex; flex-wrap: wrap; gap: 8px; }
.sb-chip {
  display: flex; align-items: center; gap: 8px; width: 100%; text-align: left; min-width: 0;
  background: var(--navy); border: 1.5px solid var(--navy-3); color: var(--white); border-radius: 12px; padding: 8px 10px; font-size: 13.5px;
  transition: border-color 0.15s var(--ease), background 0.15s var(--ease);
}
.sb-bench-list .sb-chip { width: auto; }
.sb-chip .avatar { margin-right: 0; flex-shrink: 0; }
.sb-chip .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.sb-chip:hover { border-color: var(--navy-4); }
.sb-chip.selected { border-color: var(--ice); background: var(--ice-tint); box-shadow: 0 0 0 3px var(--ice-tint); }
.sb-chip.empty { border-style: dashed; color: var(--muted-2); justify-content: center; min-height: 44px; }
.sb-guest { font-style: normal; font-size: 10px; letter-spacing: 0.5px; text-transform: uppercase; color: var(--warn); background: var(--warn-tint); border-radius: 999px; padding: 1px 6px; }
.sb-selbar {
  display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap;
  background: var(--ice-tint); border: 1px solid rgba(143, 217, 212, 0.35); border-radius: 12px; padding: 10px 12px; font-size: 13px;
}
.sb-selbtns { display: flex; gap: 6px; flex-wrap: wrap; }
.sb-edit-actions { display: flex; flex-wrap: wrap; gap: 8px; }
/* Names in the team editor can be dragged (dragdrop.js): onto another name to swap them, a player on court onto the strip at the end of the
   waiting list to bench them. A finger picks a name up by holding it, so a swipe that starts on one still scrolls the sheet. */
.sb-chip { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; transition: border-color 0.15s var(--ease), background 0.15s var(--ease), transform 0.12s var(--ease), opacity 0.12s var(--ease); }
.sb-chip:not(.empty) { cursor: grab; }
.sb-chip.dd-source { opacity: 0.35; border-style: dashed; }
.sb-chip.dd-target, .sb-dropend.dd-target { border-color: var(--ice); background: var(--ice-tint); color: var(--white); transform: scale(1.03); box-shadow: 0 0 0 3px var(--ice-tint); }
.sb-dropend {
  display: none; flex: 1 1 100%; align-items: center; justify-content: center; min-height: 44px; border: 1.5px dashed var(--navy-4); border-radius: 12px;
  color: var(--muted-2); font-size: 13px; font-weight: 600; transition: border-color 0.15s var(--ease), background 0.15s var(--ease), transform 0.12s var(--ease);
}
[data-drag="slot"] .sb-dropend { display: flex; }
/* The copy of a court spot that follows the finger is drawn outside the menu, so it needs the menu's smaller look itself. */
.dd-ghost.sb-chip.compact { padding: 7px 8px; gap: 6px; font-size: 13px; }
.dd-ghost.sb-chip.compact .avatar { width: 26px; height: 26px; font-size: 10px; }
.dd-ghost.sb-chip.compact .sb-guest { display: none; }
.sb-draghint { margin: 8px 2px 0; font-size: 12px; line-height: 1.4; color: var(--muted-2); }
/* In the scoreboard's own Bench tab the two teams stay side by side, so the court and the bench fit on one screen: drag a name onto another
   (or tap a bench player, then the one to swap with). */
.sb-sheet .sb-edit-court { grid-template-columns: 1fr 1fr; gap: 8px; }
.sb-sheet .sb-edit-vs { display: none; }
.sb-sheet .sb-edit-team { gap: 6px; }
.sb-sheet .sb-edit-court .sb-chip { padding: 7px 8px; gap: 6px; font-size: 13px; }
.sb-sheet .sb-edit-court .sb-chip .avatar { width: 26px; height: 26px; font-size: 10px; }
.sb-sheet .sb-edit-court .sb-guest { display: none; }
/* One-tap changes at the top of the bench: a team goes off and the next two come on, or new partners. */
.sb-quickrow { display: grid; grid-template-columns: repeat(auto-fit, minmax(132px, 1fr)); gap: 8px; }
.sb-quick {
  display: flex; flex-direction: column; align-items: flex-start; justify-content: center; gap: 2px; min-height: 52px; padding: 8px 12px; text-align: left;
  background: var(--navy-2); border: 1px solid var(--navy-4); border-radius: 14px; color: var(--white); transition: transform 0.1s var(--ease), background 0.15s var(--ease);
}
.sb-quick b { font-weight: 700; font-size: 13px; line-height: 1.2; max-width: 100%; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow-wrap: anywhere; }
.sb-quick small { font-size: 11px; color: var(--ice); max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sb-quick:active { transform: scale(0.97); background: var(--navy-3); }
.sb-mlist { display: flex; flex-direction: column; gap: 6px; margin-top: 12px; max-height: 42vh; overflow-y: auto; }
.sb-mrow { display: flex; align-items: center; gap: 10px; text-align: left; background: var(--navy); border: 1px solid var(--navy-3); border-radius: 12px; padding: 9px 12px; color: var(--white); font-size: 14px; }
.sb-mrow:hover { border-color: var(--ice); }
.sb-mrow .nm { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-align: left; }
.sb-mrow small { color: var(--muted); font-size: 11.5px; white-space: nowrap; }
.sb-mhead { font-size: 11px; font-weight: 700; letter-spacing: 1px; text-transform: uppercase; color: var(--muted); margin: 10px 2px 2px; }
.sb-mhead:first-child { margin-top: 2px; }
.sb-pe-row { display: flex; gap: 8px; }
.sb-pe-row .input { flex: 1; min-width: 0; }

/* ---------- Rules ---------- */
.sb-rules { display: flex; flex-direction: column; gap: 16px; }
.sb-sec h4 { font-size: 11px; letter-spacing: 1px; text-transform: uppercase; color: var(--muted); margin: 0 0 8px; font-weight: 700; }
.sb-rot { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.sb-rotbtn { display: flex; flex-direction: column; gap: 3px; text-align: left; background: var(--navy); border: 1.5px solid var(--navy-3); color: var(--white); border-radius: 12px; padding: 10px 12px; transition: all 0.15s var(--ease); }
.sb-rotbtn b { font-size: 13.5px; }
.sb-rotbtn small { color: var(--muted); font-size: 11.5px; line-height: 1.3; }
.sb-rotbtn.active { border-color: var(--ice); background: var(--ice-tint); }
.sb-rotbtn.active b { color: var(--ice); }
.sb-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 10px 0; border-top: 1px solid var(--navy-3); }
.sb-row:first-child { border-top: none; }
.sb-row div { display: flex; flex-direction: column; gap: 2px; }
.sb-row b { font-size: 14px; font-weight: 600; }
.sb-row small { color: var(--muted); font-size: 12px; }
.sb-switch { position: relative; width: 46px; height: 26px; flex-shrink: 0; }
.sb-switch input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; z-index: 1; }
.sb-switch span { position: absolute; inset: 0; background: var(--navy-4); border-radius: 26px; transition: background 0.2s var(--ease); }
.sb-switch span::before { content: ''; position: absolute; width: 20px; height: 20px; left: 3px; top: 3px; border-radius: 50%; background: var(--muted); transition: transform 0.2s var(--ease), background 0.2s var(--ease); }
.sb-switch input:checked + span { background: var(--red); }
.sb-switch input:checked + span::before { transform: translateX(20px); background: #fff; }
.sb-stepper { display: flex; align-items: center; gap: 14px; }
.sb-stepper b { font-family: var(--font-display); letter-spacing: 1px; font-size: 20px; min-width: 90px; text-align: center; }
.sb-danger { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- Results & leaderboards ---------- */
.sb-export { margin-top: 6px; }
.sb-game { background: var(--navy); border: 1px solid var(--navy-3); border-radius: 14px; padding: 12px; margin-bottom: 10px; }
.sb-game-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding-bottom: 8px; margin-bottom: 8px; border-bottom: 1px solid var(--navy-3); }
.sb-game-set { font-size: 11px; font-weight: 700; letter-spacing: 1px; text-transform: uppercase; color: var(--muted); }
.sb-game-score { font-family: var(--font-display); font-size: 24px; letter-spacing: 2px; display: inline-flex; gap: 6px; align-items: baseline; }
.sb-game-score i { font-style: normal; color: var(--muted-2); }
.sb-game-score b { font-weight: 400; color: var(--muted); }
.sb-game-score b.win { color: var(--ice); }
.sb-game-meta { color: var(--muted-2); font-size: 12px; margin-left: auto; }
.sb-x { width: 28px; height: 28px; border-radius: 8px; border: 1px solid var(--navy-4); background: transparent; color: var(--muted); font-size: 12px; }
.sb-x:hover { border-color: var(--red); color: var(--red); }
.sb-game-teams { display: grid; grid-template-columns: 1fr auto 1fr; gap: 8px; align-items: start; }
.sb-game-vs { align-self: center; color: var(--muted-2); font-size: 11px; text-transform: uppercase; letter-spacing: 1px; }
.sb-game-team { background: var(--navy-2); border-radius: 10px; padding: 8px 10px; border-left: 3px solid transparent; min-width: 0; }
.sb-game-team.win { border-left-color: var(--ice); }
.sb-game-tname { font-size: 12px; font-weight: 700; letter-spacing: 0.4px; text-transform: uppercase; color: var(--muted); margin-bottom: 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sb-game-team.win .sb-game-tname { color: var(--ice); }
.sb-game-pl { display: flex; justify-content: space-between; gap: 8px; font-size: 13px; padding: 2px 0; }
.sb-game-pl span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sb-game-pl b { color: var(--muted); }
.sb-game-team.win .sb-game-pl b { color: var(--ice); }
.sb-game-by { color: var(--muted-2); font-size: 11.5px; margin-top: 8px; }
.sb-game-err { color: var(--red); font-size: 12px; margin-top: 6px; }
.sb-lb-row { display: flex; align-items: center; gap: 10px; padding: 10px 2px; border-top: 1px solid var(--navy-3); font-size: 13.5px; }
.sb-lb-row:first-child { border-top: none; }
.sb-lb-rank { width: 26px; height: 26px; border-radius: 50%; background: var(--navy-3); color: var(--muted); display: inline-flex; align-items: center; justify-content: center; font-weight: 700; font-size: 12px; flex-shrink: 0; }
.sb-lb-rank.top1 { background: #e0a72f; color: #2a1d00; }
.sb-lb-rank.top2 { background: #c3ccd6; color: #1c2430; }
.sb-lb-rank.top3 { background: #c98a58; color: #2a1706; }
.sb-lb-name { flex: 1; min-width: 0; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sb-lb-wl { white-space: nowrap; color: var(--muted); font-size: 12.5px; }
.sb-lb-wl b.w { color: var(--good); }
.sb-lb-pct { color: var(--ice); font-weight: 700; min-width: 40px; text-align: right; }
.sb-lb-pts { color: var(--muted-2); font-size: 12px; min-width: 52px; text-align: right; white-space: nowrap; }
.sb-rt-num { font-family: var(--font-display); font-size: 17px; letter-spacing: 0.5px; color: var(--ice); min-width: 44px; text-align: right; }
.sb-rt-up, .sb-rt-down, .sb-rt-same { font-size: 11.5px; font-weight: 700; min-width: 44px; text-align: right; white-space: nowrap; }
.sb-rt-up { color: var(--good); }
.sb-rt-down { color: var(--red); }
.sb-rt-same { color: var(--muted-2); }

/* =========================================================
   Full-screen scorer
   ========================================================= */
body.sb-lock { overflow: hidden; }

.sb-court {
  position: fixed; inset: 0; z-index: 90; display: flex; flex-direction: column; color: var(--white);
  background:
    radial-gradient(ellipse 60% 45% at 12% 50%, rgba(143, 217, 212, 0.09), transparent 70%),
    radial-gradient(ellipse 60% 45% at 88% 50%, rgba(230, 57, 44, 0.1), transparent 70%),
    var(--navy);
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  overscroll-behavior: contain; touch-action: manipulation; -webkit-user-select: none; user-select: none;
  animation: sbIn 0.25s var(--ease);
  outline: none;
}
.sb-court::before {
  content: ''; position: absolute; inset: 0; pointer-events: none; opacity: 0.045;
  background: url('/img/logo.png') center 58% / min(72vmin, 620px) no-repeat;
}
.sb-court input { -webkit-user-select: text; user-select: text; }
.sb-main { position: relative; flex: 1; display: flex; flex-direction: column; min-height: 0; }
@keyframes sbIn { from { opacity: 0; transform: scale(0.985); } to { opacity: 1; transform: none; } }

.sb-top { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 8px 10px; align-items: center; padding: 10px 12px 4px; flex-shrink: 0; }
.sb-ibtn {
  width: 42px; height: 42px; border-radius: 12px; border: 1px solid var(--navy-4); background: var(--navy-2); color: var(--white);
  font-size: 18px; display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; transition: background 0.15s var(--ease), transform 0.12s var(--ease);
}
.sb-ibtn:active { transform: scale(0.94); background: var(--navy-3); }
/* The buttons on the right of the top bar: turn-around (only while the board is turned sideways), landscape, menu. */
.sb-topbtns { display: flex; align-items: center; gap: 8px; }
.sb-ibtn svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; pointer-events: none; }
.sb-ibtn.land { color: var(--muted); }
.sb-ibtn.land.on { color: var(--ice); border-color: var(--ice); background: var(--ice-tint); }
/* The lock button, a padlock. While the board is locked only "+", Fault and this button answer a touch (lock.js): the rest is dimmed, and the
   padlock is held for a moment to unlock (it fills with red as you hold; --unlock-ms is set from lock.js). */
/* Narrow phones: six buttons in the top bar (bench, microphone, landscape, lock, menu, and the back arrow) leave the title little room, so the
   buttons and gaps tighten a little and the title never wraps (its second line, the session, is the one that gets cut). */
@media (max-width: 430px) {
  .sb-top { gap: 8px 8px; padding-left: 10px; padding-right: 10px; }
  .sb-top .sb-topbtns { gap: 5px; }
  .sb-top .sb-ibtn { width: 38px; height: 40px; }
  .sb-top .sb-ibtn.bench { width: 44px; }
  .sb-title b { font-size: 18px; white-space: nowrap; }
}
.sb-ibtn.lock { position: relative; overflow: hidden; color: var(--muted); -webkit-touch-callout: none; }
.sb-ibtn.lock.on { color: #fff; border-color: var(--red); background: rgba(230, 57, 44, 0.24); }
.sb-ibtn.lock::after { content: ''; position: absolute; inset: 0; border-radius: inherit; background: rgba(230, 57, 44, 0.6); transform: scaleY(0); transform-origin: 50% 100%; pointer-events: none; }
.sb-ibtn.lock.holding::after { animation: sbLockFill var(--unlock-ms, 700ms) linear forwards; }
@keyframes sbLockFill { to { transform: scaleY(1); } }
.sb-court.locked .sb-act:not(.fault), .sb-court.locked .sb-minus, .sb-court.locked .sb-setserve, .sb-court.locked .sb-turn, .sb-court.locked .sb-tbtn,
.sb-court.locked .sb-foot, .sb-court.locked .sb-ibtn:not(.lock) { opacity: 0.38; }
.sb-court.locked .sb-srv { cursor: default; }
.sb-title { display: flex; flex-direction: column; align-items: center; text-align: center; min-width: 0; overflow: hidden; line-height: 1.15; }
.sb-title b { font-family: var(--font-display); font-weight: 400; letter-spacing: 1.5px; font-size: 20px; text-transform: uppercase; }
.sb-title span { color: var(--muted); font-size: 12px; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sb-strip { grid-column: 1 / -1; display: flex; gap: 10px; align-items: stretch; justify-content: space-between; }
.sb-lbl { font-size: 9.5px; letter-spacing: 2px; text-transform: uppercase; color: var(--muted-2); font-weight: 700; }
.sb-call, .sb-timer { background: var(--navy-2); border: 1px solid var(--navy-3); border-radius: 14px; padding: 6px 12px; display: flex; }
.sb-call { flex-direction: column; justify-content: center; gap: 0; min-width: 118px; flex: 1 1 auto; }
.sb-call b { font-family: var(--font-display); font-weight: 400; font-size: 32px; letter-spacing: 3px; color: var(--ice); line-height: 1.05; white-space: nowrap; text-shadow: 0 0 22px rgba(143, 217, 212, 0.35); }
.sb-call small { color: var(--muted); font-size: 11.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sb-timer { flex-direction: row; align-items: center; gap: 10px; }
.sb-timer .sb-lbl { align-self: flex-start; padding-top: 2px; }
.sb-timer b { font-family: var(--font-display); font-weight: 400; font-size: 30px; letter-spacing: 2px; min-width: 76px; text-align: center; color: var(--white); font-variant-numeric: tabular-nums; }
.sb-timer b.low { color: var(--red); animation: sbPulseText 1s ease-in-out infinite; }
.sb-tbtns { display: flex; gap: 6px; }
.sb-tbtn { width: 34px; height: 34px; border-radius: 10px; border: 1px solid var(--navy-4); background: var(--navy); color: var(--ice); font-size: 13px; display: inline-flex; align-items: center; justify-content: center; }
.sb-tbtn:active { background: var(--navy-3); }

.sb-teams { flex: 1; min-height: 0; display: grid; grid-template-rows: minmax(0, 1fr) auto minmax(0, 1fr); gap: 8px; padding: 6px 12px 8px; }
.sb-team {
  position: relative; min-height: 0; overflow: hidden; display: flex; flex-direction: column; align-items: center; justify-content: space-between; gap: 4px;
  background: linear-gradient(180deg, var(--navy-2), rgba(22, 39, 74, 0.55)); border: 1px solid var(--navy-3); border-radius: 20px; padding: 10px 14px 12px;
  transition: background 0.3s var(--ease), border-color 0.3s var(--ease), box-shadow 0.3s var(--ease);
}
.sb-team.serving {
  border-color: rgba(230, 57, 44, 0.75);
  background: linear-gradient(180deg, rgba(230, 57, 44, 0.17), var(--navy-2) 72%);
  box-shadow: 0 16px 44px -20px rgba(230, 57, 44, 0.65);
}
.sb-team.serving::before { content: ''; position: absolute; left: 0; right: 0; top: 0; height: 4px; background: var(--red); box-shadow: 0 0 20px var(--red); }
.sb-team.won { border-color: var(--ice); box-shadow: 0 0 0 2px rgba(143, 217, 212, 0.35), 0 16px 44px -20px rgba(143, 217, 212, 0.6); }
.sb-ribbon { position: absolute; top: 12px; right: -34px; transform: rotate(35deg); background: var(--ice); color: var(--navy); font-size: 11px; font-weight: 800; letter-spacing: 1px; padding: 3px 40px; text-transform: uppercase; }
.sb-team-head { width: 100%; display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.sb-tname {
  flex: 1; min-width: 0; background: transparent; border: none; border-bottom: 2px solid var(--navy-4); color: var(--white); outline: none; border-radius: 0;
  font-family: var(--font-display); font-size: clamp(16px, 4.4vw, 24px); letter-spacing: 1.5px; text-transform: uppercase; padding: 0 0 2px; transition: border-color 0.2s;
}
.sb-tname:focus { border-color: var(--ice); }
.sb-won { color: var(--muted); font-size: 11px; white-space: nowrap; }
.sb-won b { color: var(--ice); font-size: 13px; }
.sb-serving { display: flex; align-items: center; gap: 8px; font-size: 12px; font-weight: 700; letter-spacing: 1.2px; text-transform: uppercase; color: var(--red); min-height: 26px; }
.sb-serving i { width: 8px; height: 8px; border-radius: 50%; background: var(--red); box-shadow: 0 0 10px var(--red); animation: sbPulseText 1.4s ease-in-out infinite; }
.sb-serving b { background: var(--red); color: #fff; border-radius: 6px; padding: 1px 7px; letter-spacing: 0.5px; }
.sb-setserve { min-height: 26px; border: 1.5px solid var(--navy-4); background: transparent; color: var(--muted); border-radius: 999px; padding: 3px 16px; font-size: 12px; font-weight: 700; letter-spacing: 1px; text-transform: uppercase; }
.sb-setserve:hover, .sb-setserve:active { border-color: var(--red); color: var(--red); }
.sb-score {
  font-family: var(--font-display); font-weight: 400; line-height: 0.95; letter-spacing: 2px; font-variant-numeric: tabular-nums;
  font-size: clamp(64px, 21vmin, 210px); color: rgba(244, 248, 248, 0.6); transition: color 0.2s var(--ease);
}
.sb-team.serving .sb-score { color: #fff; text-shadow: 0 0 44px rgba(230, 57, 44, 0.55); }
/* The number fills whatever height is left in its card, so the +/- and server buttons can never be pushed out of view. */
@supports (container-type: size) {
  .sb-score { flex: 1 1 0; min-height: 0; width: 100%; container-type: size; display: flex; align-items: center; justify-content: center; }
  .sb-score > span { display: block; font-size: min(calc(100cqh / 0.95), 92cqw); line-height: 0.95; }
}
.sb-flash { animation: sbPop 0.28s var(--ease); }
@keyframes sbPop { 0% { transform: scale(0.82); opacity: 0.5; } 60% { transform: scale(1.08); } 100% { transform: scale(1); opacity: 1; } }
.sb-shake { animation: sbShake 0.36s ease; }
@keyframes sbShake { 0%, 100% { transform: translateX(0); } 20% { transform: translateX(-7px); } 40% { transform: translateX(7px); } 60% { transform: translateX(-4px); } 80% { transform: translateX(4px); } }
@keyframes sbPulseText { 0%, 100% { opacity: 1; } 50% { opacity: 0.45; } }
.sb-pm { display: flex; gap: 10px; width: 100%; max-width: 440px; }
.sb-minus { width: 60px; height: 58px; border-radius: 16px; border: 1px solid var(--navy-4); background: var(--navy-3); color: var(--muted); font-size: 30px; line-height: 1; flex-shrink: 0; }
.sb-minus:active { background: var(--navy-4); }
.sb-plus {
  flex: 1; height: 58px; border: none; border-radius: 16px; background: var(--red); color: #fff; font-size: 40px; font-weight: 700; line-height: 1;
  box-shadow: 0 12px 28px -12px rgba(230, 57, 44, 0.9); transition: transform 0.1s var(--ease), background 0.15s var(--ease);
}
.sb-plus:active:not(:disabled) { transform: scale(0.97); background: var(--red-dark); }
.sb-plus.off { background: var(--navy-3); color: var(--muted-2); box-shadow: none; }
.sb-plus:disabled { opacity: 0.3; cursor: not-allowed; }
.sb-servers { display: flex; gap: 8px; width: 100%; max-width: 440px; justify-content: center; }
.sb-srv {
  flex: 1; min-width: 0; display: flex; align-items: center; justify-content: space-between; gap: 6px; background: transparent; border: 1.5px solid var(--navy-4); color: var(--muted);
  border-radius: 12px; padding: 7px 10px; font-size: 13px; font-weight: 600; transition: all 0.15s var(--ease);
}
.sb-srv span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sb-srv small { font-size: 10px; letter-spacing: 1px; opacity: 0.7; }
/* The number on a name is that player's points this game (a point goes to whoever is serving). */
.sb-srv > span:first-child { flex: 1 1 auto; min-width: 0; text-align: left; }
.sb-pts {
  flex-shrink: 0; min-width: 22px; height: 20px; padding: 0 6px; border-radius: 999px; display: inline-flex; align-items: center; justify-content: center;
  background: var(--ice-tint); color: var(--ice); font-size: 12px; font-weight: 700; line-height: 1; font-variant-numeric: tabular-nums;
}
.sb-pts.zero { opacity: 0.45; }
.sb-team.serving .sb-srv.active .sb-pts { background: rgba(230, 57, 44, 0.32); color: #fff; }
.dd-ghost .sb-pts { display: none; } /* the copy that follows a dragging finger carries the name only: points stay with the spot */
/* Names on the court: tap = who is serving, hold = change the player, drag onto another name = swap places (see dragdrop.js).
   touch-action: none lets a finger drag them without the page trying to scroll. */
.sb-srv { touch-action: none; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; cursor: grab; }
.sb-srv.dd-source { opacity: 0.35; border-style: dashed; }
.sb-court .sb-srv.dd-target { border-color: var(--ice) !important; background: rgba(143, 217, 212, 0.18) !important; color: var(--white) !important; transform: scale(1.05); box-shadow: 0 0 0 3px var(--ice-tint); }
.dd-ghost {
  position: fixed; left: 0; top: 0; z-index: 150; margin: 0; pointer-events: none; opacity: 0.96; transition: none; will-change: transform;
  background: var(--navy-2) !important; border-color: var(--ice) !important; color: var(--white) !important;
  box-shadow: 0 16px 34px -8px rgba(0, 0, 0, 0.75), 0 0 0 3px var(--ice-tint);
}
body.dd-dragging, body.dd-dragging * { cursor: grabbing !important; }
.sb-team:not(.serving) .sb-srv.active { border-color: rgba(143, 217, 212, 0.45); background: rgba(143, 217, 212, 0.07); color: var(--white); }
.sb-team.serving .sb-srv.active { border-color: var(--red); background: rgba(230, 57, 44, 0.18); color: #fff; }
/* Turn a pair round (the other player is on the right): a small button after the two names. */
.sb-turn {
  flex: 0 0 34px; width: 34px; align-self: stretch; padding: 0; border-radius: 12px; border: 1.5px solid var(--navy-4); background: transparent; color: var(--muted);
  font-size: 16px; line-height: 1; display: inline-flex; align-items: center; justify-content: center; transition: all 0.15s var(--ease);
}
.sb-turn:active { background: var(--navy-3); color: var(--ice); border-color: var(--ice); }
/* The Bench button: how many are waiting is on it. */
.sb-ibtn.bench { position: relative; color: var(--ice); flex-direction: column; gap: 2px; width: 48px; padding: 0; }
.sb-ibtn.bench svg { width: 19px; height: 19px; }
.sb-ibtn.bench span { font-size: 9.5px; font-weight: 700; letter-spacing: 0.3px; line-height: 1; text-transform: uppercase; }
.sb-badge {
  position: absolute; top: -6px; right: -6px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px; background: var(--red); color: #fff;
  font-size: 11px; font-weight: 800; font-style: normal; line-height: 1; display: inline-flex; align-items: center; justify-content: center; box-shadow: 0 0 0 2px var(--navy);
}

.sb-actions { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.sb-act {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; min-height: 58px; padding: 6px 4px; text-align: center;
  background: var(--navy-2); border: 1px solid var(--navy-4); border-radius: 14px; color: var(--white); font-size: 12px; transition: transform 0.1s var(--ease), background 0.15s var(--ease);
}
.sb-act .ic { font-size: 16px; line-height: 1; color: var(--ice); }
.sb-act b { font-weight: 600; font-size: 12px; }
.sb-act small { font-size: 10px; color: var(--muted); max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sb-act:active:not(:disabled) { transform: scale(0.96); background: var(--navy-3); }
.sb-act:disabled { opacity: 0.38; }
.sb-act.fault { border-color: rgba(224, 167, 47, 0.55); }
.sb-act.fault .ic { color: var(--warn); }
.sb-act.save { background: var(--ice); border-color: var(--ice); color: var(--navy); }
.sb-act.save .ic { color: var(--navy); }
.sb-act.save.pulse { animation: sbGlow 1.3s ease-in-out infinite; }
@keyframes sbGlow { 0%, 100% { box-shadow: 0 0 0 0 rgba(143, 217, 212, 0.6); } 50% { box-shadow: 0 0 0 9px rgba(143, 217, 212, 0); } }

.sb-foot {
  flex-shrink: 0; display: flex; align-items: center; gap: 8px; width: 100%; text-align: left; overflow-x: auto; white-space: nowrap; padding: 9px 14px;
  background: rgba(14, 27, 51, 0.88); border: none; border-top: 1px solid var(--navy-3); color: var(--muted); scrollbar-width: none;
}
.sb-foot::-webkit-scrollbar { display: none; }
.sb-gchip { display: inline-flex; align-items: baseline; gap: 4px; background: var(--navy-2); border: 1px solid var(--navy-3); border-radius: 999px; padding: 3px 10px; font-size: 12.5px; font-variant-numeric: tabular-nums; }
.sb-gchip em { font-style: normal; color: var(--muted-2); font-size: 10.5px; margin-right: 2px; }
.sb-gchip b { font-weight: 600; color: var(--muted); }
.sb-gchip b.w { color: var(--ice); }
.sb-gchip.more { color: var(--muted); }
.sb-none { font-size: 12px; color: var(--muted-2); }
.sb-rule { margin-left: auto; font-size: 11.5px; color: var(--muted-2); padding-left: 12px; }

/* ---------- In-game menu sheet ---------- */
.sb-sheet-host { position: absolute; inset: 0; pointer-events: none; z-index: 5; }
.sb-scrim { position: absolute; inset: 0; background: rgba(5, 10, 20, 0.62); backdrop-filter: blur(2px); pointer-events: auto; animation: sbFade 0.2s var(--ease); }
@keyframes sbFade { from { opacity: 0; } to { opacity: 1; } }
.sb-sheet {
  position: absolute; left: 0; right: 0; bottom: 0; max-height: 90%; pointer-events: auto; display: flex; flex-direction: column;
  background: var(--navy-2); border: 1px solid var(--navy-3); border-bottom: none; border-radius: 22px 22px 0 0; box-shadow: 0 -20px 60px -20px rgba(0, 0, 0, 0.8);
  animation: sbUp 0.26s var(--ease); -webkit-user-select: text; user-select: text;
}
@keyframes sbUp { from { transform: translateY(40px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes sbSide { from { transform: translateX(40px); opacity: 0; } to { transform: none; opacity: 1; } }
.sb-sheet-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px 6px; }
.sb-sheet-head b { font-family: var(--font-display); font-weight: 400; letter-spacing: 1.5px; font-size: 20px; text-transform: uppercase; }
.sb-sheet-tabs { margin: 6px 14px 0; }
.sb-sheet-body { overflow-y: auto; overscroll-behavior: contain; padding: 14px 16px calc(18px + env(safe-area-inset-bottom)); flex: 1; -webkit-overflow-scrolling: touch; }
.sb-help { display: flex; flex-direction: column; gap: 12px; }
.sb-helprow b { font-size: 13.5px; color: var(--ice); }
.sb-helprow p { margin: 3px 0 0; color: var(--muted); font-size: 13px; line-height: 1.5; }

/* ---------- Points this game (in the win / save dialogs) ---------- */
.sb-ptsum { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 12px; }
.sb-ptsum-team { background: var(--navy); border: 1px solid var(--navy-3); border-radius: 12px; padding: 10px 12px; min-width: 0; }
.sb-ptsum-team.win { border-color: var(--ice); background: var(--ice-tint); }
.sb-ptsum-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; padding-bottom: 6px; margin-bottom: 4px; border-bottom: 1px solid var(--navy-3); }
.sb-ptsum-head b { min-width: 0; font-size: 11.5px; letter-spacing: 0.5px; text-transform: uppercase; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sb-ptsum-head span { font-family: var(--font-display); font-size: 24px; line-height: 1; letter-spacing: 1px; }
.sb-ptsum-team.win .sb-ptsum-head b { color: var(--ice); }
.sb-ptsum-row { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; padding: 3px 0; font-size: 14px; }
.sb-ptsum-row span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sb-ptsum-row b { color: var(--ice); font-variant-numeric: tabular-nums; }
.sb-ptsum-row i { font-style: normal; color: var(--warn); }
@media (max-width: 380px) { .sb-ptsum { grid-template-columns: 1fr; } }

/* ---------- Layout: wide / landscape ---------- */
@media (min-aspect-ratio: 5/4) {
  .sb-top { grid-template-columns: auto minmax(0, 1fr) auto auto auto; padding: 8px 12px 2px; }
  .sb-strip { display: contents; }
  .sb-title { align-items: flex-start; text-align: left; }
  .sb-call { order: 3; flex: none; min-width: 150px; padding: 4px 12px; }
  .sb-timer { order: 4; padding: 4px 12px; }
  .sb-topbtns { order: 5; }
  .sb-call b { font-size: 28px; }
  .sb-timer b { font-size: 26px; }
  .sb-teams { grid-template-rows: minmax(0, 1fr); grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); padding: 6px 12px 8px; }
  .sb-actions { grid-template-columns: none; grid-auto-flow: row; grid-auto-rows: minmax(52px, auto); align-content: center; width: clamp(104px, 13vw, 150px); }
  .sb-score { font-size: clamp(64px, 34vmin, 230px); }
  .sb-pm, .sb-servers { max-width: 380px; }
  .sb-minus, .sb-plus { height: 52px; }
  .sb-sheet { left: auto; top: 0; bottom: 0; right: 0; width: min(460px, 94vw); max-height: none; border-radius: 22px 0 0 22px; border: 1px solid var(--navy-3); border-right: none; animation: sbSide 0.26s var(--ease); }
}

/* Short screens (landscape phones): tighten everything so the score stays huge */
@media (max-height: 480px) {
  .sb-top { padding-top: 6px; padding-bottom: 0; }
  .sb-ibtn { width: 38px; height: 38px; }
  .sb-title b { font-size: 17px; }
  .sb-call {
    display: grid; grid-template-columns: auto minmax(0, 1fr); grid-template-areas: 'n l' 'n s'; column-gap: 10px; row-gap: 0;
    align-items: center; min-width: 0; padding: 3px 12px;
  }
  .sb-call .sb-lbl { grid-area: l; align-self: end; }
  .sb-call b { grid-area: n; font-size: 26px; }
  .sb-call small { grid-area: s; align-self: start; }
  .sb-timer b { font-size: 24px; }
  /* the top bar has a lock button now: the redundant "TIMER" label and some padding go, so the title keeps its room */
  .sb-top { gap: 6px; }
  .sb-timer { gap: 6px; padding: 3px 8px; }
  .sb-timer .sb-lbl { display: none; }
  .sb-timer b { min-width: 64px; }
  .sb-team { padding: 6px 12px 8px; gap: 2px; border-radius: 16px; }
  .sb-tname { font-size: 19px; }
  .sb-serving, .sb-setserve { min-height: 20px; font-size: 11px; }
  .sb-score { font-size: clamp(44px, calc((100vh - 260px) / 0.95), 230px); }
  .sb-minus, .sb-plus { height: 44px; font-size: 32px; }
  .sb-minus { width: 52px; }
  .sb-srv { padding: 4px 8px; font-size: 12px; }
  .sb-pts { height: 17px; min-width: 19px; padding: 0 5px; font-size: 11px; }
  .sb-foot { padding: 5px 12px; }
  .sb-act { min-height: 44px; }
  .sb-act small { display: none; }
  .sb-won { display: none; }
}
@supports (height: 100dvh) {
  @media (max-height: 480px) {
    .sb-score { font-size: clamp(44px, calc((100dvh - 260px) / 0.95), 230px); }
  }
}

/* The portrait rules below are for a screen that really is upright. While the board is turned sideways (the landscape button on a
   phone that can't turn the screen itself; body[data-turn], see the end of this section) the landscape rules are used instead. */

/* Narrow portrait phones: keep the call and the timer on one line */
@media (max-width: 380px) and (orientation: portrait) {
  body:not([data-turn]) .sb-call { min-width: 104px; }
  body:not([data-turn]) .sb-call b { font-size: 28px; }
  body:not([data-turn]) .sb-timer .sb-lbl { display: none; }
  body:not([data-turn]) .sb-timer b { font-size: 24px; min-width: 64px; }
  body:not([data-turn]) .sb-tbtn { width: 30px; height: 30px; }
  body:not([data-turn]) .sb-timer { gap: 6px; padding: 6px 8px; }
  body:not([data-turn]) .sb-act b { font-size: 11px; }
}
@media (max-width: 340px) and (orientation: portrait) {
  body:not([data-turn]) .sb-tbtn { width: 28px; height: 28px; }
  body:not([data-turn]) .sb-timer b { font-size: 22px; min-width: 56px; }
}

/* Portrait: minus, score and plus share one row so the score can be as big as the card allows */
@media (max-aspect-ratio: 99/80) {
  body:not([data-turn]) .sb-team {
    display: grid; grid-template-columns: minmax(76px, 22%) minmax(0, 1fr) minmax(76px, 22%); grid-template-rows: auto auto minmax(0, 1fr) auto;
    grid-template-areas: 'head head head' 'badge badge badge' 'minus score plus' 'srv srv srv';
    align-items: center; justify-content: stretch; column-gap: 8px; row-gap: 4px; padding: 10px 12px 12px;
  }
  body:not([data-turn]) .sb-team-head { grid-area: head; }
  body:not([data-turn]) .sb-serving, body:not([data-turn]) .sb-setserve { grid-area: badge; justify-self: center; }
  body:not([data-turn]) .sb-score { grid-area: score; align-self: stretch; min-width: 0; font-size: clamp(48px, calc((50vh - 215px) / 0.95), 150px); }
  body:not([data-turn]) .sb-pm { display: contents; }
  body:not([data-turn]) .sb-minus { grid-area: minus; width: 100%; height: clamp(52px, 100%, 88px); }
  body:not([data-turn]) .sb-plus { grid-area: plus; width: 100%; height: clamp(52px, 100%, 88px); }
  body:not([data-turn]) .sb-servers { grid-area: srv; max-width: none; }
}
/* ...and when there isn't much height either (most phones while the browser toolbars are showing), tighten the chrome */
@media (max-aspect-ratio: 99/80) and (max-height: 799px) {
  body:not([data-turn]) .sb-top { padding: 8px 12px 0; gap: 6px 10px; }
  body:not([data-turn]) .sb-strip { gap: 8px; }
  body:not([data-turn]) .sb-call { flex: 1 1 auto; min-width: 104px; padding: 3px 10px; }
  body:not([data-turn]) .sb-call .sb-lbl, body:not([data-turn]) .sb-timer .sb-lbl { display: none; }
  body:not([data-turn]) .sb-call b { font-size: 26px; }
  body:not([data-turn]) .sb-timer { padding: 4px 8px; gap: 8px; }
  body:not([data-turn]) .sb-teams { gap: 6px; padding: 6px 12px; }
  body:not([data-turn]) .sb-team { padding: 8px 12px 10px; }
  body:not([data-turn]) .sb-serving, body:not([data-turn]) .sb-setserve { min-height: 22px; }
  body:not([data-turn]) .sb-srv { padding: 5px 9px; }
  body:not([data-turn]) .sb-act { min-height: 52px; padding: 4px; }
  body:not([data-turn]) .sb-foot { padding: 6px 14px; }
}
/* ...and squeeze a little more out of very short screens (an iPhone SE with Safari's bars showing) */
@media (max-aspect-ratio: 99/80) and (max-height: 620px) {
  body:not([data-turn]) .sb-title span, body:not([data-turn]) .sb-call small, body:not([data-turn]) .sb-act small { display: none; }
  body:not([data-turn]) .sb-top { padding-top: 6px; }
  body:not([data-turn]) .sb-ibtn { width: 38px; height: 38px; }
  body:not([data-turn]) .sb-call b { font-size: 24px; }
  body:not([data-turn]) .sb-team { padding: 6px 12px 8px; row-gap: 2px; }
  body:not([data-turn]) .sb-tname { font-size: 18px; }
  body:not([data-turn]) .sb-serving, body:not([data-turn]) .sb-setserve { min-height: 20px; font-size: 11px; }
  body:not([data-turn]) .sb-srv { padding: 3px 9px; font-size: 12px; }
  body:not([data-turn]) .sb-pts { height: 17px; min-width: 19px; padding: 0 5px; font-size: 11px; }
  body:not([data-turn]) .sb-minus, body:not([data-turn]) .sb-plus { height: clamp(44px, 100%, 88px); }
  body:not([data-turn]) .sb-act { min-height: 44px; }
  body:not([data-turn]) .sb-foot { padding: 4px 14px; }
}

/* ---------- Turned sideways: the landscape button on a phone that can't turn the screen itself ----------
   js/scoreboard/orient.js sets body[data-turn] ("cw": the board turned a quarter clockwise, for a phone held with its top edge to the left;
   "ccw": the other way) and --turn-w / --turn-h (the frame the board is laid out in: as wide as the screen is tall and as tall as it is
   wide), and only while the screen is held upright. The court, the dialogs and the toasts are each laid out in that frame and turned into
   place, so everything the player sees is sideways together. The layout inside is the landscape one: the two blocks after the turning
   rules repeat the wide and the short-screen blocks above, with the screen's width standing in for the frame's height. Keep them in step. */
body[data-turn] .sb-court,
body[data-turn] #modal-root,
body[data-turn] .toast-root { position: fixed; top: 0; left: 0; right: auto; bottom: auto; width: var(--turn-w); height: var(--turn-h); transform-origin: 0 0; }
body[data-turn="cw"] .sb-court, body[data-turn="cw"] #modal-root, body[data-turn="cw"] .toast-root { transform: translateX(var(--turn-h)) rotate(90deg); }
body[data-turn="ccw"] .sb-court, body[data-turn="ccw"] #modal-root, body[data-turn="ccw"] .toast-root { transform: translateY(var(--turn-w)) rotate(-90deg); }
body[data-turn] .sb-court { animation: none; }
/* the notch and the home bar belong to the phone's own edges, which are not the board's edges any more */
body[data-turn="cw"] .sb-court { padding: env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left) env(safe-area-inset-top); }
body[data-turn="ccw"] .sb-court { padding: env(safe-area-inset-left) env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom); }
body[data-turn] #modal-root { z-index: 100; pointer-events: none; }
body[data-turn] #modal-root .modal-backdrop { pointer-events: auto; }
body[data-turn] .modal-card { max-height: calc(var(--turn-h) * 0.88); }
body[data-turn] .toast-root { box-sizing: border-box; justify-content: flex-end; padding: 0 16px 24px; }

/* the wide layout (see "wide / landscape" above) */
body[data-turn] .sb-top { grid-template-columns: auto minmax(0, 1fr) auto auto auto; padding: 8px 12px 2px; }
body[data-turn] .sb-strip { display: contents; }
body[data-turn] .sb-title { align-items: flex-start; text-align: left; }
body[data-turn] .sb-call { order: 3; flex: none; min-width: 150px; padding: 4px 12px; }
body[data-turn] .sb-timer { order: 4; padding: 4px 12px; }
body[data-turn] .sb-topbtns { order: 5; }
body[data-turn] .sb-call b { font-size: 28px; }
body[data-turn] .sb-timer b { font-size: 26px; }
body[data-turn] .sb-teams { grid-template-rows: minmax(0, 1fr); grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); padding: 6px 12px 8px; }
body[data-turn] .sb-actions { grid-template-columns: none; grid-auto-flow: row; grid-auto-rows: minmax(52px, auto); align-content: center; width: clamp(104px, 13vw, 150px); }
body[data-turn] .sb-score { font-size: clamp(64px, 34vmin, 230px); }
body[data-turn] .sb-pm, body[data-turn] .sb-servers { max-width: 380px; }
body[data-turn] .sb-minus, body[data-turn] .sb-plus { height: 52px; }
body[data-turn] .sb-sheet { left: auto; top: 0; bottom: 0; right: 0; width: min(460px, 94vw); max-height: none; border-radius: 22px 0 0 22px; border: 1px solid var(--navy-3); border-right: none; animation: sbSide 0.26s var(--ease); }

/* the short-screen layout (see "Short screens" above): the frame is short when the screen is narrow */
@media (max-width: 480px) {
  body[data-turn] .sb-top { padding-top: 6px; padding-bottom: 0; }
  body[data-turn] .sb-ibtn { width: 38px; height: 38px; }
  body[data-turn] .sb-title b { font-size: 17px; }
  body[data-turn] .sb-call {
    display: grid; grid-template-columns: auto minmax(0, 1fr); grid-template-areas: 'n l' 'n s'; column-gap: 10px; row-gap: 0;
    align-items: center; min-width: 0; padding: 3px 12px;
  }
  body[data-turn] .sb-call .sb-lbl { grid-area: l; align-self: end; }
  body[data-turn] .sb-call b { grid-area: n; font-size: 26px; }
  body[data-turn] .sb-call small { grid-area: s; align-self: start; }
  body[data-turn] .sb-timer b { font-size: 24px; }
  body[data-turn] .sb-top { gap: 6px; }
  body[data-turn] .sb-timer { gap: 6px; padding: 3px 8px; }
  body[data-turn] .sb-timer .sb-lbl { display: none; }
  body[data-turn] .sb-timer b { min-width: 64px; }
  body[data-turn] .sb-team { padding: 6px 12px 8px; gap: 2px; border-radius: 16px; }
  body[data-turn] .sb-tname { font-size: 19px; }
  body[data-turn] .sb-serving, body[data-turn] .sb-setserve { min-height: 20px; font-size: 11px; }
  body[data-turn] .sb-score { font-size: clamp(44px, calc((100vw - 260px) / 0.95), 230px); }
  body[data-turn] .sb-minus, body[data-turn] .sb-plus { height: 44px; font-size: 32px; }
  body[data-turn] .sb-minus { width: 52px; }
  body[data-turn] .sb-srv { padding: 4px 8px; font-size: 12px; }
  body[data-turn] .sb-pts { height: 17px; min-width: 19px; padding: 0 5px; font-size: 11px; }
  body[data-turn] .sb-foot { padding: 5px 12px; }
  body[data-turn] .sb-act { min-height: 44px; }
  body[data-turn] .sb-act small { display: none; }
  body[data-turn] .sb-won { display: none; }
}

@media (max-width: 860px) {
  .sb-opt-meta { flex-direction: column; align-items: flex-end; gap: 4px; }
  .sb-edit-court { grid-template-columns: 1fr; }
  .sb-edit-vs { display: none; }
}
@media (max-width: 520px) {
  .sb-start { flex-direction: column; align-items: stretch; gap: 12px; }
  .sb-start-actions { flex-direction: row; align-items: center; }
  .sb-start-actions .sb-go { flex: 1; }
  .sb-game-teams { grid-template-columns: 1fr; }
  .sb-game-vs { display: none; }
  .sb-rot { grid-template-columns: 1fr; }
  .sb-go { padding: 13px 16px; }
}

@media (prefers-reduced-motion: reduce) {
  .sb-court, .sb-sheet, .sb-scrim, .sb-flash, .sb-shake, .sb-serving i, .sb-timer b.low, .sb-act.save.pulse { animation: none; }
}

/* A small link at the end of a leaderboard row (the DUPR tab's "DUPR ↗"), and in its footnotes. */
.sb-lb-link { color: var(--ice); font-size: 12px; font-weight: 600; white-space: nowrap; text-decoration: none; }
.sb-lb-link:hover { text-decoration: underline; }

/* "Won't be sent to DUPR" notes: in the save dialogs, and under the teams on the Start card. They only inform. */
.sb-dupr-warn { margin-top: 12px; font-size: 12.5px; line-height: 1.45; color: var(--warn); background: var(--warn-tint); border: 1px solid rgba(224, 167, 47, 0.35); border-radius: var(--radius-sm); padding: 9px 11px; }
.sb-start-hint.warn { color: var(--warn); }

/* =========================================================
   Hands-free: the microphone button, the little overlay, the Voice tab (js/scoreboard/handsfree.js)
   ========================================================= */
.sb-ibtn.hf { color: var(--muted); position: relative; }
.sb-ibtn.hf.on { color: var(--ice); border-color: var(--ice); background: var(--ice-tint); }
.sb-ibtn.hf.on::after { content: ''; position: absolute; top: 6px; right: 6px; width: 8px; height: 8px; border-radius: 50%; background: var(--good); animation: sbHfPulse 1.4s ease-in-out infinite; }
.sb-ibtn.hf.wait { color: var(--warn); border-color: var(--warn); }
.sb-ibtn.hf.err { color: var(--red); border-color: var(--red); }
.sb-ibtn.hf.remote:not(.on):not(.err):not(.wait) { color: var(--ice-dim); border-color: var(--ice-dim); }
@keyframes sbHfPulse { 50% { opacity: 0.35; transform: scale(0.8); } }

.sb-hf-hud { position: absolute; left: 0; right: 0; bottom: 74px; z-index: 40; display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 0 12px; pointer-events: none; }
.sb-hf-pill { background: rgba(14, 27, 51, 0.92); border: 1px solid var(--navy-4); color: var(--muted); border-radius: 999px; padding: 6px 12px; font-size: 12.5px; display: inline-flex; align-items: center; gap: 8px; max-width: 100%; }
.sb-hf-pill i { width: 8px; height: 8px; border-radius: 50%; background: var(--good); animation: sbHfPulse 1.4s ease-in-out infinite; flex-shrink: 0; }
.sb-hf-pill i.wait { background: var(--warn); }
.sb-hf-pill i.err { background: var(--red); animation: none; }
.sb-hf-pill.err { color: var(--red); border-color: rgba(230, 57, 44, 0.5); }
.sb-hf-tag { background: var(--ice-tint); color: var(--ice); border-radius: 999px; padding: 1px 8px; font-size: 11px; font-weight: 600; }
.sb-hf-msg { pointer-events: auto; display: inline-flex; align-items: center; gap: 12px; background: var(--navy-3); border: 1px solid var(--navy-4); border-left: 4px solid var(--ice); color: var(--white); border-radius: 14px; padding: 10px 14px; font-size: 16px; font-weight: 600; box-shadow: var(--shadow); max-width: 100%; animation: sbIn 0.18s var(--ease); }
.sb-hf-msg.ok { border-left-color: var(--good); }
.sb-hf-msg.warn { border-left-color: var(--warn); }
.sb-hf-msg button { border: 1px solid var(--navy-4); background: var(--navy-2); color: var(--ice); border-radius: 10px; padding: 7px 14px; font-weight: 700; font-size: 14px; }
.sb-hf-msg[hidden], .sb-hf-pill[hidden] { display: none; }

.sb-hf .sb-sec { margin-bottom: 20px; }
.sb-hf-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 8px; }
.sb-hf-state { font-size: 15px; }
.sb-hf-state.listening { color: var(--good); }
.sb-hf-state.starting { color: var(--warn); }
.sb-hf-state.error { color: var(--red); }
.sb-hf-say { background: var(--navy); border: 1px solid var(--navy-3); border-radius: 12px; padding: 4px 12px; margin-bottom: 8px; }
.sb-hf-say p { margin: 8px 0; font-size: 13.5px; line-height: 1.45; color: var(--muted); }
.sb-hf-say b { color: var(--white); }
.sb-hf .check-field { margin: 8px 0; }
.sb-hf .hint { margin: 6px 0 0; line-height: 1.45; }
.sb-hf .hint.warn { color: var(--warn); }
.sb-hf em { font-style: normal; color: var(--ice); font-size: 11px; font-weight: 700; letter-spacing: 0.4px; text-transform: uppercase; }
.sb-hf-log { max-height: 240px; overflow-y: auto; margin-bottom: 10px; border: 1px solid var(--navy-3); border-radius: 12px; }
.sb-hf-log > div { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 2px 10px; padding: 7px 10px; border-bottom: 1px solid var(--navy-3); font-size: 12.5px; }
.sb-hf-log > div:last-child { border-bottom: none; }
.sb-hf-log > div.dim { opacity: 0.55; }
/* The Buttons section of the Voice tab: which key of a Bluetooth remote does what. */
.sb-hf-btn { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 10px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--navy-3); }
.sb-hf-btn b { font-size: 13.5px; font-weight: 600; color: var(--white); grid-column: 1; }
.sb-hf-keys { grid-column: 1; display: flex; flex-wrap: wrap; gap: 6px; min-height: 22px; align-items: center; }
.sb-hf-keys kbd { background: var(--navy-3); border: 1px solid var(--navy-4); border-radius: 8px; padding: 1px 8px; font: inherit; font-size: 12px; color: var(--ice); }
.sb-hf-keys i { font-style: normal; color: var(--muted-2); font-size: 12px; }
.sb-hf-btnacts { grid-column: 2; grid-row: 1 / span 2; display: flex; gap: 6px; }
.sb-hf-log time { color: var(--muted-2); grid-row: span 2; font-variant-numeric: tabular-nums; }
.sb-hf-log span { color: var(--white); overflow-wrap: anywhere; }
.sb-hf-log em { color: var(--muted); font-size: 12px; font-weight: 400; letter-spacing: 0; text-transform: none; }

@media (prefers-reduced-motion: reduce) {
  .sb-ibtn.hf.on::after, .sb-hf-pill i, .sb-hf-msg { animation: none; }
}
