:root {
  color-scheme: dark;
  --bg: #0f1514;
  --panel: #141c1a;
  --panel-2: #19231f;
  --line: #27332e;
  --line-2: #34433c;
  --text: #eef1e8;
  --muted: #a4b0a7;
  --quiet: #7d8c82;
  --lime: #d5ed82;
  --lime-ink: #16210f;
  --blue: #5aa8f2;
  --coral: #ff8d5e;
  --heading: "Space Grotesk", "DM Sans", "PingFang SC", "Microsoft YaHei UI", sans-serif;
  --body: "DM Sans", "PingFang SC", "Microsoft YaHei UI", "Noto Sans SC", system-ui, sans-serif;
  --serif: "Instrument Serif", Georgia, serif;
  --radius: 22px;
  font-family: var(--body);
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  font-synthesis: none;
}
* {
  box-sizing: border-box;
}
html,
body {
  margin: 0;
  min-height: 100%;
}
body {
  min-width: 300px;
  background:
    radial-gradient(ellipse at 80% -10%, #a7d27a12, transparent 50%),
    radial-gradient(ellipse at 0% 60%, #6fb38a0a, transparent 45%),
    var(--bg);
}
button,
input {
  font: inherit;
  color: inherit;
}
button {
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
a {
  color: inherit;
  text-decoration: none;
}
:focus-visible {
  outline: 2px solid var(--lime);
  outline-offset: 3px;
}
[hidden] {
  display: none !important;
}

/* ---------- Top bar: the site's <tipo-bar> (/tipo/tipo.css) in the club's colours ---------- */
/* As tall as the bar it replaced, so the court keeps the height it is sized for. */
tipo-bar {
  --tipo-fg: var(--text);
  --tipo-muted: var(--quiet);
  --tipo-line: var(--line-2);
  --tipo-accent: var(--lime);
  --tipo-accent-bg: #d5ed821f;
  padding-top: 8px;
  padding-bottom: 8px;
}
.top-actions {
  margin-left: auto;
  display: flex;
  gap: 8px;
}
.icon-btn {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 1px solid var(--line-2);
  border-radius: 12px;
  background: #ffffff06;
  transition: background 0.2s, border-color 0.2s;
}
.icon-btn:hover {
  background: #ffffff10;
  border-color: #4a5a52;
}
.icon-btn svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.i-speaker {
  fill: currentColor;
}
#soundBtn .i-mute,
#soundBtn[aria-pressed="false"] .i-wave {
  display: none;
}
#soundBtn[aria-pressed="false"] .i-mute {
  display: inline;
}
#soundBtn[aria-pressed="false"] {
  color: var(--quiet);
}
#helpBtn .i-dot {
  stroke-width: 2.6;
}

/* ---------- Layout: the court takes the window ---------- */
.layout {
  max-width: 1680px;
  margin: 0 auto;
  padding: 0 24px 18px;
}
.stage {
  min-width: 0;
}
.arena {
  position: relative;
  width: 100%;
  height: calc(100vh - 82px);
  height: calc(100dvh - 82px);
  min-height: 520px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #0b1312;
  box-shadow: 0 40px 80px -50px #000, inset 0 1px #ffffff08;
  isolation: isolate;
}
canvas {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  outline: none;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

/* ---------- HUD ---------- */
.hud {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 2;
}
.scorebug {
  position: absolute;
  top: 14px;
  left: 14px;
  min-width: 240px;
  overflow: hidden;
  border: 1px solid #ffffff1c;
  border-radius: 12px;
  background: linear-gradient(180deg, #13201dee, #0a1110e6);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: 0 18px 38px -20px #000, inset 0 1px #ffffff14;
  font-variant-numeric: tabular-nums;
}
.sb-row {
  display: grid;
  grid-template-columns: 4px minmax(0, 1fr) auto 16px 46px;
  align-items: center;
  gap: 10px;
  height: 40px;
  padding: 0;
}
.sb-row + .sb-row {
  border-top: 1px solid #ffffff0d;
}
/* Each side's colour runs down the left edge like a broadcast score bug. */
.sb-dot {
  align-self: stretch;
  width: 4px;
  background: linear-gradient(180deg, #9fd0ff, var(--blue));
  box-shadow: 0 0 12px #5aa8f2a0;
}
.sb-row.side1 .sb-dot {
  background: linear-gradient(180deg, #ffbf9f, var(--coral));
  box-shadow: 0 0 12px #ff8d5ea0;
}
.sb-name {
  overflow: hidden;
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.sb-name small {
  margin-left: 6px;
  padding: 1px 6px;
  border-radius: 6px;
  background: #d5ed8222;
  color: var(--lime);
  font-size: 11px;
  font-weight: 700;
}
.sb-games {
  display: flex;
  gap: 3px;
}
.sb-games i {
  width: 7px;
  height: 7px;
  border: 1px solid #ffffff40;
  border-radius: 2px;
}
.sb-games i.won {
  border-color: var(--lime);
  background: var(--lime);
}
.sb-serve {
  width: 14px;
  height: 14px;
  opacity: 0;
  background: no-repeat center / contain url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M3 13 9.5 6.5M5.5 15.2 13.7 7a3.6 3.6 0 0 0-5.2-5L.6 10.1z' fill='%23d5ed82' fill-opacity='.25' stroke='%23d5ed82' stroke-width='1.3'/%3E%3Ccircle cx='3.2' cy='12.8' r='2.4' fill='%23d5ed82'/%3E%3C/svg%3E");
  transition: opacity 0.2s;
}
.sb-row.serving .sb-serve {
  opacity: 1;
}
.sb-pts {
  align-self: stretch;
  display: grid;
  place-items: center;
  border-left: 1px solid #ffffff10;
  background: #ffffff09;
  font: 700 24px/1 var(--heading);
  letter-spacing: -0.5px;
  transition: color 0.3s, background 0.3s, text-shadow 0.3s;
}
.sb-row.serving .sb-pts {
  background: linear-gradient(180deg, #d5ed8224, #d5ed820c);
}
.sb-row .sb-pts.bump {
  color: var(--lime);
  background: #d5ed8233;
  text-shadow: 0 0 16px #d5ed82b0;
}
.sb-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px 7px 14px;
  border-top: 1px solid #ffffff0d;
  background: linear-gradient(90deg, #d5ed8214, #ffffff05 65%);
  color: var(--quiet);
  font-size: 11.5px;
  letter-spacing: 0.02em;
}
.sb-flag {
  margin-left: auto;
  padding: 1px 8px;
  border-radius: 999px;
  background: var(--lime);
  color: var(--lime-ink);
  font-weight: 700;
  animation: flag 1.2s ease-in-out infinite;
}
@keyframes flag {
  50% {
    opacity: 0.65;
  }
}
.hud-actions {
  position: absolute;
  top: 14px;
  right: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.hud-btn {
  pointer-events: auto;
  background: #0a1110c4;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
.net-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 32px;
  padding: 0 12px;
  border: 1px solid #ffffff14;
  border-radius: 999px;
  background: #0a1110c4;
  color: var(--muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}
.net-chip::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #7dd99a;
  box-shadow: 0 0 0 3px #7dd99a2a;
}
.net-chip.warn::before {
  background: #ffc46b;
  box-shadow: 0 0 0 3px #ffc46b2a;
}
.net-chip.bad::before {
  background: #ff7b6b;
  box-shadow: 0 0 0 3px #ff7b6b2a;
}
.toast {
  position: absolute;
  top: 16px;
  left: 50%;
  max-width: min(80%, 460px);
  padding: 10px 18px;
  border: 1px solid #ffffff17;
  border-radius: 999px;
  background: #0a1110e0;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: 0 18px 40px -22px #000;
  font-size: 15px;
  font-weight: 600;
  text-align: center;
  /* Long enough to wrap (on a phone, or in English), it wraps in balanced lines rather than running out of the pill. */
  width: max-content;
  text-wrap: balance;
  opacity: 0;
  transform: translate(-50%, -12px);
  transition: opacity 0.25s, transform 0.25s;
}
.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}
.toast.good {
  border-color: #d5ed8266;
  color: var(--lime);
}
.toast.bad {
  border-color: #ff8d5e55;
  color: #ffc2a8;
}
.toast.big {
  top: 38%;
  padding: 16px 28px;
  font: 700 26px var(--heading);
}
.rally {
  position: absolute;
  bottom: 16px;
  left: 16px;
  padding: 6px 12px;
  border-radius: 999px;
  background: #0a1110c4;
  color: var(--muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}
.rally b {
  margin-left: 4px;
  color: var(--text);
  font: 700 15px var(--heading);
}
.hint {
  position: absolute;
  bottom: 16px;
  left: 50%;
  max-width: calc(100% - 32px);
  overflow: hidden;
  text-overflow: ellipsis;
  padding: 8px 14px;
  border-radius: 999px;
  background: #0a1110b8;
  color: #d9e3d2;
  font-size: 13px;
  text-align: center;
  white-space: nowrap;
  opacity: 0;
  transform: translateX(-50%);
  transition: opacity 0.3s;
}
.hint.show {
  opacity: 1;
}
.hint kbd {
  margin: 0 2px;
}

/* ---------- Overlays ---------- */
.overlay {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: grid;
  place-items: center;
  padding: 24px;
  animation: fade 0.35s ease;
}
@keyframes fade {
  from {
    opacity: 0;
  }
}
.menu {
  place-items: center start;
  padding: 20px clamp(20px, 4%, 56px);
  background: linear-gradient(90deg, #0a1110e0 0%, #0a1110a6 30%, #0a111022 58%, #0a111000 80%);
}
.menu-card {
  width: min(100%, 432px);
  max-height: 100%;
  overflow: auto;
  padding: 24px 24px 18px;
  border: 1px solid #ffffff12;
  border-radius: 22px;
  background: linear-gradient(165deg, #16201ddb, #0f1716e8);
  box-shadow: 0 40px 80px -40px #000;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  scrollbar-width: thin;
}
.eyebrow {
  display: inline-block;
  color: var(--lime);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.24em;
}
.menu h1 {
  margin: 10px 0 8px;
  font: 600 clamp(32px, 3.4vw, 44px) / 1.06 var(--heading);
  letter-spacing: -0.05em;
}
.menu h1 em {
  color: var(--lime);
  font: italic 400 1.08em/1.02 var(--serif);
  letter-spacing: -0.01em;
}
.lead {
  margin: 0 0 4px;
  color: #c1ccbf;
  font-size: 13.5px;
  line-height: 1.7;
}
.menu-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 14px;
}
.menu-actions .btn.lg {
  min-height: 50px;
  padding: 12px 22px;
}
.menu-actions #startBtn,
.menu-actions #createBtn {
  flex: 1;
}
.card-overlay {
  background: radial-gradient(ellipse at center, #0a1110b8, #0a1110e6);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
}
.card-overlay.soft {
  background: radial-gradient(ellipse at center, #0a11109c, #0a111055);
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  pointer-events: none;
}
.card {
  width: min(100%, 430px);
  padding: 28px;
  border: 1px solid #ffffff14;
  border-radius: 22px;
  background: linear-gradient(160deg, #18231fef, #101816f2);
  box-shadow: 0 40px 80px -40px #000;
  animation: rise 0.35s cubic-bezier(0.2, 0.9, 0.3, 1.2);
}
@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(14px) scale(0.98);
  }
}
.card.narrow {
  width: min(100%, 340px);
}
.card.center {
  text-align: center;
}
.card h2 {
  margin: 10px 0 10px;
  font: 600 28px/1.2 var(--heading);
  letter-spacing: -0.03em;
}
.card .row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 20px;
}
.card .row .btn {
  flex: 1;
}
.stack {
  display: grid;
  gap: 10px;
  margin-top: 22px;
}
.code-inline {
  color: var(--lime);
  letter-spacing: 0.12em;
}
.room-code {
  margin: 18px 0 6px;
  padding: 16px;
  border: 1px dashed #d5ed8266;
  border-radius: 16px;
  background: #d5ed820d;
  color: var(--lime);
  font: 700 40px/1 var(--heading);
  letter-spacing: 0.16em;
  text-align: center;
}
.room-status {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 18px 0 6px;
  color: var(--muted);
  font-size: 14px;
}
.pulse {
  width: 9px;
  height: 9px;
  flex: none;
  border-radius: 50%;
  background: var(--lime);
  animation: pulse 1.4s ease-out infinite;
}
.room-status.error .pulse {
  background: #ff8d6b;
  animation: none;
}
@keyframes pulse {
  0% {
    box-shadow: 0 0 0 0 #d5ed8288;
  }
  100% {
    box-shadow: 0 0 0 12px #d5ed8200;
  }
}
.break-score {
  margin: 4px 0 6px;
  font: 700 46px/1.1 var(--heading);
  letter-spacing: 0.02em;
  font-variant-numeric: tabular-nums;
}
.break-score span {
  color: var(--quiet);
  font-weight: 500;
}
.result-card h2 {
  font-size: 34px;
}
.result-card.win h2 {
  color: var(--lime);
}
.result-games {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 6px 0 18px;
}
.result-games span {
  padding: 5px 11px;
  border: 1px solid var(--line-2);
  border-radius: 999px;
  color: var(--muted);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}
.result-games span b {
  color: var(--text);
}
.stats {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
  font-variant-numeric: tabular-nums;
}
.stats th,
.stats td {
  padding: 8px 4px;
  border-bottom: 1px solid #ffffff0c;
}
.stats th {
  color: var(--quiet);
  font-weight: 500;
  text-align: center;
}
.stats th:first-child,
.stats td:first-child {
  text-align: left;
}
.stats td {
  text-align: center;
  font-weight: 600;
}
.stats td.best {
  color: var(--lime);
}
.stats .who {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 500;
  color: var(--muted);
}
.stats .who i {
  width: 8px;
  height: 8px;
  border-radius: 2px;
  background: var(--blue);
}
.stats .who.side1 i {
  background: var(--coral);
}

/* ---------- Buttons & fields ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 46px;
  padding: 11px 18px;
  border: 1px solid transparent;
  border-radius: 13px;
  font-size: 15px;
  font-weight: 650;
  letter-spacing: 0.01em;
  transition: background 0.18s, border-color 0.18s, transform 0.12s, box-shadow 0.18s, opacity 0.18s;
}
.btn:active {
  transform: scale(0.97);
}
.btn:disabled {
  opacity: 0.45;
  cursor: wait;
}
.btn.primary {
  background: var(--lime);
  color: var(--lime-ink);
  box-shadow: 0 12px 30px -14px #d5ed82aa, inset 0 1px #ffffff66;
}
.btn.primary:hover {
  background: #e3f6a6;
}
.btn.ghost {
  border-color: var(--line-2);
  background: #ffffff08;
}
.btn.ghost:hover {
  border-color: #52625a;
  background: #ffffff10;
}
.btn.quiet {
  background: none;
  color: var(--muted);
}
.btn.quiet:hover {
  color: var(--text);
}
.btn.lg {
  min-height: 54px;
  padding: 14px 28px;
  font-size: 16px;
  border-radius: 15px;
}
.btn.wide {
  width: 100%;
}
.btn.pulse-cta {
  animation: cta 1.2s ease-in-out infinite;
}
@keyframes cta {
  50% {
    box-shadow: 0 0 0 6px #d5ed8233, inset 0 1px #ffffff66;
  }
}
.field {
  display: grid;
  gap: 8px;
  margin-top: 16px;
}
.field span {
  color: var(--muted);
  font-size: 13px;
}
input:not([type="checkbox"]) {
  width: 100%;
  min-width: 0;
  height: 46px;
  padding: 0 14px;
  border: 1px solid var(--line-2);
  border-radius: 12px;
  background: #0d1413;
  font-size: 16px;
  transition: border-color 0.2s;
}
input:not([type="checkbox"]):focus {
  border-color: #d5ed8299;
  outline: none;
}
input::placeholder {
  color: #7b8b81;
}

/* ---------- Menu controls ---------- */
.tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  margin: 14px 0 12px;
  padding: 4px;
  border-radius: 13px;
  background: #0b1110cc;
}
.tabs button {
  height: 36px;
  border: 0;
  border-radius: 9px;
  background: none;
  color: var(--muted);
  font-size: 13.5px;
  font-weight: 600;
  transition: background 0.2s, color 0.2s;
}
.tabs button[aria-selected="true"] {
  background: #233029;
  color: var(--text);
  box-shadow: inset 0 0 0 1px #384a40;
}
.opts {
  display: grid;
  gap: 8px;
}
.setting {
  display: grid;
  grid-template-columns: 40px 1fr;
  align-items: center;
  gap: 10px;
}
.setting-label {
  color: var(--muted);
  font-size: 12.5px;
}
.seg {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 5px;
}
.seg button {
  height: 34px;
  border: 1px solid var(--line-2);
  border-radius: 9px;
  background: #ffffff05;
  color: #c9d3c6;
  font-size: 13px;
  font-weight: 600;
  transition: all 0.18s;
}
.seg button:hover {
  border-color: #4d5e55;
}
.seg button[aria-checked="true"] {
  border-color: #d5ed8299;
  background: #d5ed8218;
  color: var(--lime);
}
.seg button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.record {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 12px;
  margin-top: 12px;
  color: var(--quiet);
  font-size: 11.5px;
}
.record b {
  color: #cfd8cb;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
/* The way to the badminton tools (/badminton/tools): a quiet line at the foot of the menu, and one in the guide. */
.tools-link {
  color: var(--quiet);
  font-size: 12px;
  text-decoration: underline;
  text-decoration-color: #ffffff2b;
  text-underline-offset: 3px;
  transition: color 0.18s, text-decoration-color 0.18s;
}
.tools-link:hover {
  color: var(--lime);
  text-decoration-color: currentColor;
}
.menu-card > .tools-link {
  display: block;
  width: fit-content;
  margin: 10px 0 0 auto;
}
.help-tools {
  margin: 12px 0 0;
}
.help-tools .tools-link {
  font-size: 12.5px;
}
#onlinePanel > .muted {
  margin-bottom: 10px;
}
.join {
  display: flex;
  flex: 1 1 180px;
  gap: 8px;
}
.join input {
  height: 50px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.join input::placeholder {
  text-transform: none;
  letter-spacing: 0;
}
.join .btn {
  flex: none;
  min-height: 50px;
}
.net-msg {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}
.net-msg:empty {
  display: none;
}
.net-msg.error {
  color: #ffb39b;
}
details.more {
  margin-top: 14px;
  padding-top: 10px;
  border-top: 1px solid #ffffff10;
}
details.more summary {
  color: #c9d3c6;
  font-size: 13px;
}
.field.inline {
  grid-template-columns: 40px 1fr;
  align-items: center;
  gap: 10px;
  margin-top: 12px;
}
.field.inline input {
  height: 38px;
  font-size: 14px;
}
.toggles {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}
.toggles-slot:empty {
  display: none;
}
#pauseToggles .toggles {
  margin: 14px 0 0;
  padding: 14px 0 0;
  border-top: 1px solid var(--line);
}
.help-card {
  width: min(100%, 620px);
  max-height: 100%;
  overflow: auto;
  scrollbar-width: thin;
}
.help-card .keys {
  margin-top: 14px;
}
.help-card .keys li {
  grid-template-columns: 132px 1fr;
}
.toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #c9d3c6;
  font-size: 13.5px;
  cursor: pointer;
}
.toggle input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}
.switch {
  position: relative;
  width: 36px;
  height: 21px;
  flex: none;
  border-radius: 999px;
  background: #2c3a33;
  transition: background 0.2s;
}
.switch::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 15px;
  height: 15px;
  border-radius: 50%;
  background: #cfd8cc;
  transition: transform 0.2s;
}
.toggle input:checked + .switch {
  background: var(--lime);
}
.toggle input:checked + .switch::after {
  background: var(--lime-ink);
  transform: translateX(15px);
}
.toggle input:focus-visible + .switch {
  outline: 2px solid var(--lime);
  outline-offset: 2px;
}
.muted {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.7;
}
.small {
  font-size: 12.5px;
}
.keys {
  display: grid;
  gap: 10px;
  margin: 0 0 16px;
  padding: 0;
  list-style: none;
}
.keys li {
  display: grid;
  grid-template-columns: 118px 1fr;
  align-items: center;
  gap: 10px;
  color: #c3cdc0;
  font-size: 13px;
}
.keycaps {
  display: flex;
  gap: 4px;
}
/* On a touch screen the guide leads with the stick and the Swing button, and leaves out the mouse and the keys. */
.touch-keys {
  display: none;
}
@media (pointer: coarse) {
  .touch-keys {
    display: grid;
  }
  .help-card .touch-keys li {
    grid-template-columns: 108px 1fr;
  }
  .mouse-keys,
  .help-phone {
    display: none;
  }
}
kbd {
  display: inline-grid;
  place-items: center;
  min-width: 24px;
  height: 24px;
  padding: 0 6px;
  border: 1px solid #44544b;
  border-bottom-width: 2px;
  border-radius: 6px;
  background: #1b2622;
  color: #e3eadc;
  font: 600 11px var(--heading);
}
kbd.wide {
  min-width: 40px;
}
.shots {
  display: grid;
  gap: 8px;
  margin-bottom: 14px;
}
.shots div {
  display: grid;
  grid-template-columns: 38px 1fr;
  gap: 8px;
  color: #b9c4b7;
  font-size: 12.5px;
  line-height: 1.6;
}
.shots b {
  color: var(--lime);
  font-weight: 600;
}
details {
  margin-top: 12px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.75;
}
summary {
  cursor: pointer;
  color: #d6dfd2;
  font-weight: 600;
}
details p {
  margin: 10px 0 0;
}
.nowrap {
  white-space: nowrap;
}
.foot {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 8px 24px;
  max-width: 1680px;
  margin: 0 auto;
  padding: 2px 28px 24px;
  color: #7b8b81;
  font-size: 11px;
  letter-spacing: 0.06em;
}

/* ---------- Touch controls ---------- */
.touch {
  display: none;
}
.stick-zone {
  position: relative;
  flex: 1;
  height: 100%;
  touch-action: none;
}
.stick {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 118px;
  height: 118px;
  margin: -59px 0 0 -59px;
  border: 1px solid #ffffff22;
  border-radius: 50%;
  background: radial-gradient(circle, #ffffff0a, #ffffff04 70%);
  pointer-events: none;
  transition: opacity 0.2s;
}
.knob {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 52px;
  height: 52px;
  margin: -26px 0 0 -26px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #f2f6ec, #b9c5b4);
  box-shadow: 0 6px 16px -4px #000a;
}
.touch-label {
  position: absolute;
  left: 50%;
  bottom: 6px;
  transform: translateX(-50%);
  color: #ffffff4d;
  font-size: 11px;
  letter-spacing: 0.2em;
  pointer-events: none;
}
.touch-btns {
  display: flex;
  align-items: center;
  gap: 14px;
  padding-right: 6px;
}
.t-btn {
  display: grid;
  place-items: center;
  align-content: center;
  gap: 2px;
  border: 1px solid #ffffff1f;
  border-radius: 50%;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  transition: transform 0.08s, filter 0.08s;
}
.t-btn b {
  font-size: 16px;
}
.t-btn small {
  font-size: 10px;
  opacity: 0.7;
}
.t-btn.down {
  transform: scale(0.92);
  filter: brightness(1.15);
}
.t-hit {
  position: relative;
  width: 112px;
  height: 112px;
  background: var(--lime);
  color: var(--lime-ink);
  box-shadow: 0 10px 30px -10px #d5ed82aa;
  transition: transform 0.08s, filter 0.08s, box-shadow 0.15s, background 0.15s;
}
.t-hit b {
  position: relative;
  font-size: 19px;
  pointer-events: none;
}
.t-hit small {
  position: relative;
  max-width: 96px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  pointer-events: none;
}
/* The swing button doubles as a small aiming stick while held. */
.hit-knob {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 44px;
  height: 44px;
  margin: -22px 0 0 -22px;
  border: 2px solid transparent;
  border-radius: 50%;
  pointer-events: none;
}
.t-hit.aiming {
  background: #c6e26a;
}
.t-hit.aiming .hit-knob {
  border-color: #16210f8c;
  background: #16210f1f;
}
.t-hit.hot {
  box-shadow: 0 0 0 7px #d5ed8259, 0 10px 30px -10px #d5ed82aa;
}
body.playing .arena canvas {
  cursor: crosshair;
}
.shots em.hot {
  color: var(--lime);
  font-style: normal;
  font-weight: 600;
}

/* Playing on a phone or tablet: the court takes the whole screen. */
body.playing.touch-mode {
  overflow: hidden;
  overscroll-behavior: none;
}
body.playing.touch-mode .stage {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  flex-direction: column;
  height: 100dvh;
  background: #0b1312;
}
body.playing.touch-mode .arena {
  flex: 1;
  min-height: 0;
  max-height: none;
  aspect-ratio: auto;
  border: 0;
  border-radius: 0;
}
body.playing.touch-mode .touch {
  display: flex;
  align-items: center;
  flex: none;
  height: calc(176px + env(safe-area-inset-bottom));
  padding: 0 18px env(safe-area-inset-bottom) 8px;
  background: linear-gradient(#0b1312, #0e1716);
  border-top: 1px solid #ffffff0c;
}
@media (orientation: landscape) {
  body.playing.touch-mode .touch {
    position: absolute;
    inset: auto 0 0 0;
    height: 100%;
    padding: 70px max(18px, env(safe-area-inset-right)) max(12px, env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left));
    align-items: flex-end;
    background: none;
    border: 0;
    pointer-events: none;
  }
  body.playing.touch-mode .stick-zone {
    flex: 0 0 34%;
    height: 70%;
    pointer-events: auto;
  }
  body.playing.touch-mode .touch-btns {
    margin-left: auto;
    pointer-events: auto;
  }
}

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
  .layout {
    padding: 0 16px 16px;
  }
  tipo-bar {
    padding: 6px 16px;
  }
}
@media (max-width: 860px) {
  .arena {
    height: calc(100vh - 70px);
    height: calc(100svh - 70px);
  }
  .menu {
    place-items: end center;
    padding: 14px;
    background: linear-gradient(0deg, #0a1110f2 0%, #0a1110c4 45%, #0a111033 75%, #0a111000 90%);
  }
}
@media (max-width: 640px) {
  tipo-bar {
    padding: max(8px, env(safe-area-inset-top)) 12px 8px;
  }
  .layout {
    padding: 0 8px 12px;
  }
  .arena {
    min-height: 480px;
    border-radius: 18px;
  }
  .menu {
    padding: 10px;
  }
  .menu-card {
    padding: 18px 16px 14px;
  }
  .menu h1 {
    margin: 6px 0 6px;
    font-size: 30px;
  }
  .lead {
    font-size: 12.5px;
    line-height: 1.6;
  }
  .tabs {
    margin: 10px 0 10px;
  }
  .menu-actions .btn {
    flex: 1;
  }
  .scorebug {
    top: 10px;
    left: 10px;
    min-width: 0;
    width: min(212px, calc(100% - 70px));
  }
  .sb-row {
    height: 32px;
    grid-template-columns: 3px minmax(0, 1fr) auto 14px 36px;
    gap: 8px;
    padding: 0;
  }
  .sb-pts {
    font-size: 19px;
  }
  .hud-actions {
    top: 10px;
    right: 10px;
  }
  .net-chip {
    display: none !important;
  }
  .toast {
    top: auto;
    bottom: 14px;
    font-size: 13.5px;
  }
  .toast.big {
    top: 40%;
    bottom: auto;
    font-size: 21px;
  }
  .hint {
    display: none;
  }
  .rally {
    top: 112px;
    bottom: auto;
    left: 10px;
  }
  .card {
    padding: 22px;
  }
  .card h2 {
    font-size: 24px;
  }
  .room-code {
    font-size: 32px;
  }
  .foot {
    padding: 4px 16px 24px;
  }
}
@media (max-height: 520px) and (orientation: landscape) {
  .arena {
    height: calc(100vh - 62px);
    height: calc(100svh - 62px);
    min-height: 300px;
  }
  .menu {
    place-items: center;
    padding: 8px;
    background: #0a1110b3;
  }
  .menu-card {
    width: min(100%, 560px);
    padding: 14px 18px 10px;
  }
  .menu .eyebrow,
  .menu .lead {
    display: none;
  }
  .menu h1 {
    margin: 0 0 4px;
    font-size: 24px;
  }
  .tabs {
    margin: 6px 0 8px;
  }
  .tabs button,
  .seg button {
    height: 30px;
  }
  .opts {
    gap: 6px;
  }
  .menu-actions {
    margin-top: 10px;
  }
  .menu-actions .btn.lg,
  .join input,
  .join .btn {
    min-height: 42px;
    height: 42px;
    padding-top: 8px;
    padding-bottom: 8px;
  }
  .record,
  .menu-card > .tools-link {
    display: none;
  }
  .toast {
    top: auto;
    bottom: 12px;
    font-size: 13.5px;
  }
  .toast.big {
    top: 40%;
    bottom: auto;
  }
  .hint {
    display: none;
  }
  .scorebug {
    top: 8px;
    left: 8px;
    min-width: 0;
    width: 200px;
  }
  .sb-row {
    height: 30px;
    grid-template-columns: 3px minmax(0, 1fr) auto 14px 34px;
    gap: 8px;
    padding: 0;
  }
  .sb-pts {
    font-size: 18px;
  }
  .sb-meta {
    padding: 4px 10px 5px;
  }
  .hud-actions {
    top: 8px;
    right: 8px;
  }
}
/* ---------- English ---------- */
/* Eyebrows are capitals in either language; a label of a word or two needs more room than two characters. */
html[lang="en"] .eyebrow {
  text-transform: uppercase;
}
html[lang="en"] .setting,
html[lang="en"] .field.inline {
  grid-template-columns: 50px 1fr;
}
html[lang="en"] .shots div {
  grid-template-columns: 64px 1fr;
}
html[lang="en"] .lead {
  line-height: 1.6;
}
/* Under the score, the flag drops to a line of its own when a phone has no room for both; the computer's name and
   level (Computer · Normal) need a little more width than 电脑 · 标准. */
html[lang="en"] .sb-meta {
  flex-wrap: wrap;
  row-gap: 3px;
}
@media (max-width: 640px) {
  html[lang="en"] .scorebug {
    width: min(236px, calc(100% - 70px));
  }
  /* Start match and How to play keep to one line each, as the Chinese labels do, so the court above keeps its room. */
  html[lang="en"] .menu-actions .btn.lg {
    padding-left: 12px;
    padding-right: 12px;
  }
}
@media (max-height: 520px) and (orientation: landscape) {
  html[lang="en"] .scorebug {
    width: 224px;
  }
}
/* One screen and no more: the bar, the court and the footnote under it share it, so the page never scrolls. */
body {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100svh;
}
.layout,
.foot {
  width: 100%;
}
.layout {
  flex: 1;
  min-height: 0;
}
.stage,
.arena {
  height: 100%;
}
.arena {
  min-height: 0;
}
/* With no page to scroll, a card taller than the court (a short window, a phone held sideways) scrolls inside it, as
   the menu and the guide already do, so its buttons stay within reach. */
.card {
  max-height: 100%;
  overflow: auto;
  scrollbar-width: thin;
}
/* Format and record fold under one button, but only on a phone. */
.opts-more {
  display: none;
}
@media (max-width: 640px) {
  /* Folded away on a phone, so the court shows above the menu: the eyebrow, and the format and the record. */
  .menu .eyebrow {
    display: none;
  }
  .opts-more {
    display: flex;
    align-items: center;
    gap: 6px;
    min-height: 32px;
    padding: 0;
    border: 0;
    background: none;
    color: var(--muted);
    font-size: 13px;
  }
  .opts-more::after {
    content: "▾";
  }
  .menu-card.more-open .opts-more::after {
    content: "▴";
  }
  .menu-card:not(.more-open) :is(.opt-extra, .record, .tools-link) {
    display: none;
  }
}

/* ---------- Casual play ---------- */
/* Two styles, casual and pro, side by side. */
.styleSeg {
  grid-template-columns: repeat(2, 1fr);
}
/* The guide leads with the swipes in casual play; pro play's lists, notes and assist switches step aside. */
.casual-keys,
.casual-note {
  display: none;
}
body.casual .casual-keys {
  display: grid;
}
body.casual .casual-note {
  display: block;
  margin: -4px 0 14px;
}
body.casual :is(.touch-keys, .mouse-keys, .shots, .help-phone, .pro-only) {
  display: none;
}
.help-card .casual-keys li {
  grid-template-columns: 70px 1fr;
}
/* On a touch screen the stick and the Swing button give way to one pad to swipe on (the court takes swipes too). */
.swipe-pad {
  position: relative;
  display: none;
  place-items: center;
  flex: 1;
  align-self: stretch;
  margin: 12px 0 12px 10px;
  border: 1px dashed #ffffff2e;
  border-radius: 22px;
  background: radial-gradient(ellipse at center, #ffffff0d, #ffffff03 70%);
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
}
body.casual.playing.touch-mode :is(.stick-zone, .touch-btns) {
  display: none;
}
body.casual.playing.touch-mode .swipe-pad {
  display: grid;
}
.pad-dir {
  position: absolute;
  color: #ffffff6b;
  font-size: 20px;
  font-weight: 700;
  line-height: 1;
  pointer-events: none;
}
.pad-dir small {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
}
.pad-dir.up {
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
}
.pad-dir.down {
  bottom: 12px;
  left: 50%;
  transform: translateX(-50%);
}
.pad-dir.left {
  top: 50%;
  left: 18px;
  transform: translateY(-50%);
}
.pad-dir.right {
  top: 50%;
  right: 18px;
  transform: translateY(-50%);
}
#padLabel {
  max-width: 64%;
  overflow: hidden;
  color: #cfd8cb;
  font-size: 15px;
  text-overflow: ellipsis;
  white-space: nowrap;
  pointer-events: none;
}
/* A shuttle on its way that no swipe has answered yet: the pad calls for one. */
.swipe-pad.waiting {
  border-color: #d5ed82b3;
  animation: pad-call 0.9s ease-in-out infinite alternate;
}
@keyframes pad-call {
  to {
    box-shadow: 0 0 0 6px #d5ed8226;
    background: radial-gradient(ellipse at center, #d5ed821f, #ffffff03 70%);
  }
}
/* The shot is chosen: the pad names it. */
.swipe-pad.set {
  border-style: solid;
  border-color: #d5ed8280;
}
.swipe-pad.set #padLabel {
  color: var(--lime);
  font-weight: 700;
}
@media (orientation: landscape) {
  /* Held sideways the pad sits small in the corner, over the boards rather than the court (which takes swipes too). */
  body.casual.playing.touch-mode .swipe-pad {
    flex: 0 0 auto;
    width: min(200px, 24%);
    height: 56%;
    margin: auto 0 0 auto;
    background-color: #0a1110a6;
    pointer-events: auto;
  }
  body.casual.playing.touch-mode .pad-dir.left {
    left: 10px;
  }
  body.casual.playing.touch-mode .pad-dir.right {
    right: 10px;
  }
  body.casual.playing.touch-mode #padLabel {
    max-width: 58%;
    font-size: 13px;
    white-space: normal;
    text-align: center;
  }
}

/* ---------- Tutorial ---------- */
/* A slim card at the top of the court, clear of the coach: the swipe to make (a fingertip running along an arrow), its
   name and how to do it on this device, with the three steps as dashes. */
.coach {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding-top: 12px;
  pointer-events: none;
}
.coach[hidden] {
  display: none;
}
.coach-card {
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: calc(100% - 120px);
  padding: 8px 18px 8px 10px;
  border: 1px solid #d5ed8240;
  border-radius: 18px;
  background: #0a1210e0;
  box-shadow: 0 18px 40px -18px #000c;
  transition: transform 0.2s, border-color 0.2s, box-shadow 0.2s;
}
.coach-text {
  display: grid;
  justify-items: start;
  gap: 3px;
  min-width: 0;
}
.coach-card b {
  color: var(--text);
  font: 700 18px var(--heading);
  white-space: nowrap;
}
.coach-card small {
  color: var(--muted);
  font-size: 12px;
}
.coach-steps {
  display: flex;
  gap: 5px;
}
.coach-steps i {
  width: 16px;
  height: 3px;
  border-radius: 2px;
  background: #ffffff26;
}
.coach-steps i.on {
  background: var(--lime);
}
.coach-steps i.done {
  background: #d5ed8280;
}
.coach-swipe {
  position: relative;
  display: grid;
  flex: none;
  place-items: center;
  width: 50px;
  height: 56px;
  color: var(--lime);
  font-size: 30px;
  font-weight: 800;
  line-height: 1;
}
.coach[data-dir="up"] .coach-swipe::before {
  content: "↑";
}
.coach[data-dir="down"] .coach-swipe::before {
  content: "↓";
}
.coach[data-dir="side"] .coach-swipe::before {
  content: "↔";
}
.coach-swipe i {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 18px;
  height: 18px;
  margin: -9px;
  border-radius: 50%;
  background: #ffffffd9;
  box-shadow: 0 0 0 5px #ffffff2e;
  animation: coach-up 1.1s ease-in-out infinite;
}
.coach[data-dir="down"] .coach-swipe i {
  animation-name: coach-down;
}
.coach[data-dir="side"] .coach-swipe i {
  animation: coach-side 0.9s ease-in-out infinite alternate;
}
@keyframes coach-up {
  0% {
    opacity: 0;
    transform: translateY(20px);
  }
  20%,
  75% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: translateY(-20px);
  }
}
@keyframes coach-down {
  0% {
    opacity: 0;
    transform: translateY(-20px);
  }
  20%,
  75% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: translateY(20px);
  }
}
@keyframes coach-side {
  from {
    transform: translateX(-20px);
  }
  to {
    transform: translateX(20px);
  }
}
/* Time stands still: the card calls for the swipe. */
.coach.now .coach-card {
  border-color: #d5ed82cc;
  box-shadow: 0 0 0 6px #d5ed8233, 0 18px 40px -18px #000c;
  transform: scale(1.08);
}
/* A swipe the step doesn't teach: a shake. */
.coach.nope .coach-card {
  animation: coach-nope 0.36s;
}
@keyframes coach-nope {
  20% {
    transform: translateX(-8px);
  }
  40% {
    transform: translateX(7px);
  }
  60% {
    transform: translateX(-5px);
  }
  80% {
    transform: translateX(3px);
  }
}
/* Skip sits under the pause button, clear of the coach (who serves from the other side at 0–0). */
.coach-skip {
  position: absolute;
  top: 64px;
  right: 12px;
  padding: 6px 12px;
  border: 0;
  border-radius: 999px;
  background: #0a1210b3;
  color: var(--muted);
  font-size: 12px;
  text-decoration: underline;
  text-underline-offset: 3px;
  pointer-events: auto;
}
.coach-skip:hover {
  color: var(--text);
}
/* No score to keep in the tutorial. The score bug keeps its room, though: on a tall screen the camera leaves room for it,
   and a camera that moved at the start of the match would paint the whole hall again. */
body.lesson .scorebug {
  visibility: hidden;
}
body.lesson .rally {
  display: none;
}
/* On a phone the card keeps clear of the pause button. */
@media (max-width: 640px) {
  .coach-card {
    gap: 8px;
    padding: 6px 14px 6px 6px;
  }
  .coach-card b {
    font-size: 16px;
  }
  .coach.now .coach-card {
    transform: scale(1.03);
  }
}
/* A phone held sideways has the far court at the top in the middle, so the card moves to the free top-left corner. */
@media (max-height: 520px) and (orientation: landscape) {
  .coach {
    align-items: flex-start;
    padding: 10px 0 0 10px;
  }
  .coach-card {
    max-width: min(300px, 34%);
    padding: 6px 12px 6px 6px;
    transform-origin: left top;
  }
  .coach-card b {
    font-size: 15px;
    white-space: normal;
  }
  .coach-swipe {
    width: 40px;
    height: 46px;
    font-size: 26px;
  }
}
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
