/* ─────────────────────────────────────────────────────────────────────────────
   Court Control theme. Everything tweakable lives in these variables.
   ───────────────────────────────────────────────────────────────────────────── */
:root {
  color-scheme: dark light;

  /* palette */
  --navy: #0d1321;
  --paper: #f5f3f5;
  --orange: #d78521;
  --orange-ink: #9a5a12; /* orange darkened to reach AA (4.9:1) on --paper */
  --red: #de1a1a;
  --blue: #576ca8;
  --white: #ffffff; /* text on red/blue buttons (AA ≥ 4.9:1) */

  /* roles — dark scheme (default) */
  --bg: var(--navy);
  --text: var(--orange); /* body text on --bg, 6.4:1 */
  --text-strong: var(--paper);
  --glass: color-mix(in srgb, var(--navy) 90%, transparent);
  --line: color-mix(in srgb, var(--paper) 20%, transparent);

  --surface: var(--paper);
  --on-surface: var(--navy);
  --on-surface-muted: color-mix(in srgb, var(--navy) 72%, var(--paper));
  --surface-kicker: var(--orange-ink);
  --surface-line: color-mix(in srgb, var(--navy) 18%, transparent);
  --field-bg: var(--white);
  --surface-ok: #3e5390; /* --blue deepened for AA text on --paper (6.7:1) */
  --surface-error: #b81414; /* --red deepened for AA text on --paper (6.0:1) */

  --accent: var(--red);
  --on-accent: var(--white);
  --success: var(--blue);
  --on-success: var(--white);

  --court: var(--orange);
  --court-ink: var(--navy);
  --player: var(--blue);
  --map-filter: brightness(0.62) sepia(0.5) hue-rotate(185deg) saturate(1.8);

  /* type */
  --font-display: "abolition", "Anton", Impact, "Arial Narrow Bold", sans-serif;
  --font-body: "proxima-nova", "Montserrat", system-ui, -apple-system, "Segoe UI", sans-serif;
  --fs-xs: 0.75rem;
  --fs-sm: 0.875rem;
  --fs-md: 1rem;
  --fs-lg: 1.25rem;
  --fs-display-sm: 2rem;
  --fs-display-md: 2.5rem;
  --fs-display-lg: clamp(3.5rem, 14vw, 6rem);

  /* spacing */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;

  /* radii */
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 14px;
  --radius-pill: 999px;

  /* sizes + effects */
  --tap: 44px;
  --sheet-width: 420px;
  --shadow-hard: 4px 4px 0 var(--accent);
  --shadow-soft: 0 10px 30px rgba(0, 0, 0, 0.35);
  --focus-ring: 3px solid var(--accent);
  --speed: 0.22s;

  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: var(--paper);
    --text: var(--orange-ink);
    --text-strong: var(--navy);
    --glass: color-mix(in srgb, var(--paper) 92%, transparent);
    --line: color-mix(in srgb, var(--navy) 20%, transparent);

    --surface: var(--navy);
    --on-surface: var(--paper);
    --on-surface-muted: color-mix(in srgb, var(--paper) 75%, var(--navy));
    --surface-kicker: var(--orange);
    --surface-line: color-mix(in srgb, var(--paper) 20%, transparent);
    --field-bg: color-mix(in srgb, var(--paper) 8%, var(--navy));
    --surface-ok: #9fb0e0; /* --blue lifted for AA text on --navy (8.6:1) */
    --surface-error: #ff8080; /* --red lifted for AA text on --navy (7.6:1) */

    --court-ink: var(--navy);
    --shadow-soft: 0 10px 30px rgba(13, 19, 33, 0.25);
    --stripe-strength: 10%;
    --map-filter: none;
  }
}

/* ── base ─────────────────────────────────────────────────────────────────── */
* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body,
#app,
#map {
  height: 100%;
  margin: 0;
}

body {
  font-family: var(--font-body);
  font-size: var(--fs-md);
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

#app {
  position: relative;
}

#map {
  position: relative;
  z-index: 0; /* keeps Leaflet's own z-indexes (up to 1000) under the HUD */
}

:focus-visible {
  outline: var(--focus-ring);
  outline-offset: 3px;
}

.display {
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 400;
  text-transform: uppercase;
  letter-spacing: 0.01em;
  line-height: 0.92;
  margin: 0;
}

.kicker {
  margin: 0 0 var(--space-1);
  font-size: var(--fs-xs);
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--surface-kicker);
}

.hint,
.meta {
  font-size: var(--fs-sm);
  line-height: 1.45;
  color: var(--on-surface-muted);
  margin: var(--space-2) 0;
}

/* ── floating layers ──────────────────────────────────────────────────────── */
.topbar,
.toasts,
.fab-col,
.bottombar,
.sheet,
.boot {
  position: absolute;
  z-index: 500;
}

.topbar {
  top: calc(var(--safe-top) + var(--space-3));
  left: var(--space-3);
  right: var(--space-3);
  display: flex;
  justify-content: space-between;
  align-items: stretch;
  gap: var(--space-2);
  pointer-events: none;
}

.topbar > * {
  pointer-events: auto;
}

.brand,
.stat,
.fab,
.bottombar {
  background: var(--glass);
  border: 2px solid var(--line);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.brand {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  min-height: var(--tap);
  padding: var(--space-1) var(--space-3) var(--space-1) var(--space-1);
  border-radius: var(--radius-md);
  color: var(--text-strong);
  font: inherit;
  cursor: pointer;
  text-align: left;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: var(--on-accent);
  font-family: var(--font-display);
  font-style: italic;
  font-size: var(--fs-lg);
  transform: skewX(-8deg);
}

.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.05;
}

.brand-name {
  font-family: var(--font-display);
  font-style: italic;
  text-transform: uppercase;
  font-size: var(--fs-lg);
  letter-spacing: 0.02em;
}

.whoami {
  font-size: var(--fs-xs);
  font-weight: 800;
  color: var(--text);
}

.whoami:empty {
  display: none;
}

.stat {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  justify-content: center;
  min-width: 76px;
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-hard);
}

.stat-num {
  font-family: var(--font-display);
  font-style: italic;
  font-size: var(--fs-display-sm);
  line-height: 0.9;
  color: var(--text-strong);
}

.stat-label {
  font-size: var(--fs-xs);
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text);
}

/* ── toasts + pending result cards ────────────────────────────────────────── */
.toasts {
  top: calc(var(--safe-top) + 72px);
  left: var(--space-3);
  right: var(--space-3);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  z-index: 550;
  pointer-events: none;
}

.toasts > * {
  pointer-events: auto;
}

.card,
.toast {
  background: var(--surface);
  color: var(--on-surface);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-soft);
}

.toast {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-1) var(--space-1) var(--space-1) var(--space-4);
  min-height: var(--tap);
  font-size: var(--fs-sm);
  font-weight: 600;
  border-left: 6px solid var(--surface-kicker);
}

.toast span {
  flex: 1;
}

.toast[data-tone="error"],
.toast[data-tone="ping"] {
  border-left-color: var(--accent);
}

.toast[data-tone="ok"] {
  border-left-color: var(--success);
}

.result-card {
  padding: var(--space-4);
  border: 3px solid var(--accent);
  box-shadow: var(--shadow-hard), var(--shadow-soft);
}

.result-text {
  margin: 0;
  font-size: var(--fs-md);
  line-height: 1.35;
}

/* ── buttons ──────────────────────────────────────────────────────────────── */
.btn,
.icon-btn,
.fab,
.ping-toggle {
  font-family: inherit;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: var(--tap);
  padding: var(--space-2) var(--space-4);
  border: 2px solid transparent;
  border-radius: var(--radius-sm);
  font-size: var(--fs-sm);
  font-weight: 800;
  font-style: italic;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  text-decoration: none;
  text-align: center;
  flex: 1;
  transition: transform var(--speed) ease, box-shadow var(--speed) ease;
}

.btn:active:not(:disabled) {
  transform: translate(2px, 2px);
}

.btn.primary {
  background: var(--accent);
  color: var(--on-accent);
  box-shadow: 3px 3px 0 var(--on-surface);
}

.btn.success {
  background: var(--success);
  color: var(--on-success);
  box-shadow: 3px 3px 0 var(--on-surface);
}

.btn.ghost {
  background: transparent;
  color: var(--on-surface);
  border-color: currentColor;
}

.btn.sm {
  flex: 0 0 auto;
  min-height: var(--tap);
  padding: var(--space-1) var(--space-3);
  background: var(--accent);
  color: var(--on-accent);
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  box-shadow: none;
}

.icon-btn {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: var(--tap);
  height: var(--tap);
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: inherit;
  font-size: var(--fs-md);
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin: var(--space-3) 0 var(--space-2);
}

.actions.links .btn {
  font-style: normal;
  text-transform: none;
  letter-spacing: 0;
}

.fab-col {
  right: var(--space-3);
  bottom: calc(var(--safe-bottom) + 96px);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.fab {
  display: grid;
  place-items: center;
  width: var(--tap);
  height: var(--tap);
  border-radius: var(--radius-md);
  color: var(--text-strong);
}

.fab svg {
  width: 20px;
  height: 20px;
  fill: currentColor;
}

/* ── bottom bar + ping toggle ─────────────────────────────────────────────── */
.bottombar {
  left: var(--space-3);
  right: var(--space-3);
  bottom: calc(var(--safe-bottom) + var(--space-3));
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2);
  border-radius: var(--radius-lg);
}

.nearby {
  flex: 1;
  min-width: 0;
  margin: 0 var(--space-1);
  font-size: var(--fs-xs);
  line-height: 1.35;
  color: var(--text);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

@media (min-width: 420px) {
  .nearby {
    font-size: var(--fs-sm);
  }
}

.nearby strong {
  color: var(--text-strong);
}

.nearby-pings {
  font-weight: 800;
  color: var(--text-strong);
  white-space: nowrap;
}

.scout {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  min-height: var(--tap);
  padding: 0 var(--space-2);
  font-size: var(--fs-xs);
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-strong);
  cursor: pointer;
}

.scout input {
  width: 20px;
  height: 20px;
  accent-color: var(--success);
}

.ping-toggle {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  min-height: var(--tap);
  padding: 0 var(--space-3);
  border: 2px solid var(--accent);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-strong);
  font-size: var(--fs-sm);
  font-weight: 800;
  font-style: italic;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  white-space: nowrap;
}

.ping-toggle.is-live {
  background: var(--accent);
  color: var(--on-accent);
  box-shadow: 3px 3px 0 var(--text-strong);
}

.ping-dot {
  position: relative;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
  flex: 0 0 auto;
}

.ping-toggle.is-live .ping-dot {
  background: var(--on-accent);
}

.ping-toggle.is-live .ping-dot::after,
.ping-status .ping-dot::after {
  content: "";
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  border: 2px solid currentColor;
  animation: pulse 1.6s ease-out infinite;
}

.ping-status .ping-dot {
  display: inline-block;
  color: var(--accent);
  margin-right: var(--space-1);
}

.ping-status {
  font-weight: 600;
  margin: var(--space-3) 0 var(--space-1);
}

/* ── bottom sheet ─────────────────────────────────────────────────────────── */
.sheet {
  left: 0;
  right: 0;
  bottom: 0;
  max-height: min(78vh, 680px);
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: var(--space-1) var(--space-5) calc(var(--safe-bottom) + var(--space-5));
  background: var(--surface);
  color: var(--on-surface);
  border-top: 5px solid var(--accent);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  box-shadow: var(--shadow-soft);
  transform: translateY(110%);
  visibility: hidden;
  transition: transform var(--speed) ease, visibility 0s linear var(--speed);
  z-index: 600;
}

.sheet.is-open {
  transform: translateY(0);
  visibility: visible;
  transition: transform var(--speed) ease;
}

.sheet-head {
  position: sticky;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 calc(var(--space-5) * -1) var(--space-1);
  padding: var(--space-1) var(--space-2);
  background: var(--surface);
  z-index: 1;
}

.sheet-head .icon-btn {
  position: absolute;
  right: var(--space-2);
  top: var(--space-1);
}

.sheet-handle {
  width: 44px;
  height: 5px;
  margin: var(--space-3) 0;
  border-radius: var(--radius-pill);
  background: var(--surface-line);
}

.sheet h2.display {
  font-size: var(--fs-display-md);
  outline-offset: 4px;
  margin-bottom: var(--space-3);
}

.section {
  margin: var(--space-5) 0 var(--space-2);
  font-size: var(--fs-xs);
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--surface-kicker);
}

.board,
.list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.board-row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  width: 100%;
  min-height: var(--tap);
  padding: var(--space-2) 0;
  border: 0;
  border-bottom: 1px solid var(--surface-line);
  background: none;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.board li:first-child .rank {
  background: var(--accent);
  color: var(--on-accent);
}

.rank {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: var(--radius-sm);
  background: var(--surface-line);
  font-family: var(--font-display);
  font-style: italic;
  font-size: var(--fs-lg);
  transform: skewX(-8deg);
}

.name {
  flex: 1;
  font-weight: 600;
}

.name em {
  font-style: normal;
  color: var(--on-surface-muted);
}

.wins {
  font-family: var(--font-display);
  font-style: italic;
  font-size: var(--fs-lg);
}

.wins small {
  font-family: var(--font-body);
  font-size: var(--fs-xs);
  font-weight: 800;
  margin-left: 2px;
  color: var(--on-surface-muted);
}

.list li {
  display: flex;
  justify-content: space-between;
  gap: var(--space-3);
  min-height: var(--tap);
  align-items: center;
  border-bottom: 1px solid var(--surface-line);
  font-size: var(--fs-sm);
}

.stat-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-3);
  margin: var(--space-4) 0 var(--space-2);
}

.stat-tile {
  display: flex;
  flex-direction: column;
  padding: var(--space-3) var(--space-4);
  border: 2px solid var(--on-surface);
  border-radius: var(--radius-md);
}

.stat-tile:first-child {
  box-shadow: var(--shadow-hard);
}

.stat-tile .num {
  font-family: var(--font-display);
  font-style: italic;
  font-size: var(--fs-display-md);
  line-height: 0.95;
}

.stat-tile .label {
  font-size: var(--fs-xs);
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--on-surface-muted);
}

.ping-card {
  margin: var(--space-4) 0;
  padding: var(--space-3) var(--space-4);
  border: 2px solid var(--accent);
  box-shadow: none;
}

/* ── forms ────────────────────────────────────────────────────────────────── */
.stack {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.field {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  margin: 0;
  padding: 0;
  border: 0;
  font-size: var(--fs-xs);
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--on-surface-muted);
}

.field legend {
  padding: 0;
  margin-bottom: var(--space-1);
}

.field input,
.field select {
  min-height: var(--tap);
  padding: var(--space-2) var(--space-3);
  border: 2px solid var(--surface-line);
  border-radius: var(--radius-sm);
  background: var(--field-bg);
  color: var(--on-surface);
  font: inherit;
  font-size: var(--fs-md);
  font-weight: 400;
  letter-spacing: 0;
  text-transform: none;
}

.field input:focus-visible {
  outline: var(--focus-ring);
  outline-offset: 0;
  border-color: transparent;
}

.field input::placeholder {
  color: var(--on-surface-muted);
  opacity: 0.8;
}

.segmented {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-2);
}

.segmented legend {
  grid-column: 1 / -1;
}

.seg {
  position: relative;
}

.seg input {
  position: absolute;
  opacity: 0;
  inset: 0;
  margin: 0;
  cursor: pointer;
}

.seg span {
  display: grid;
  place-items: center;
  min-height: var(--tap);
  border: 2px solid var(--on-surface);
  border-radius: var(--radius-sm);
  color: var(--on-surface);
  font-size: var(--fs-sm);
  font-style: italic;
  letter-spacing: 0.04em;
}

.seg input:checked + span {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--on-accent);
}

.seg input:focus-visible + span {
  outline: var(--focus-ring);
  outline-offset: 3px;
}

.combo {
  position: relative;
}

.options {
  list-style: none;
  margin: var(--space-1) 0 0;
  padding: var(--space-1);
  border: 2px solid var(--on-surface);
  border-radius: var(--radius-sm);
  background: var(--field-bg);
  text-transform: none;
  letter-spacing: 0;
}

.options button {
  width: 100%;
  min-height: var(--tap);
  padding: 0 var(--space-3);
  border: 0;
  border-radius: var(--radius-sm);
  background: none;
  color: var(--on-surface);
  font: inherit;
  font-size: var(--fs-md);
  font-weight: 600;
  text-align: left;
  cursor: pointer;
}

.options button:hover,
.options button:focus-visible {
  background: var(--surface-line);
}

.options .empty {
  padding: var(--space-3);
  font-size: var(--fs-sm);
  font-weight: 400;
  color: var(--on-surface-muted);
}

.chosen {
  margin: 0;
  padding: var(--space-3);
  border-left: 5px solid var(--success);
  background: color-mix(in srgb, var(--success) 14%, transparent);
  font-weight: 600;
}

.switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  min-height: 56px;
  padding: var(--space-2) 0;
  border-bottom: 1px solid var(--surface-line);
  cursor: pointer;
}

.switch-row span {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.switch-row small {
  font-size: var(--fs-xs);
  color: var(--on-surface-muted);
  line-height: 1.4;
}

input[role="switch"] {
  appearance: none;
  -webkit-appearance: none;
  position: relative;
  flex: 0 0 auto;
  width: 52px;
  height: 30px;
  margin: 0;
  border: 2px solid var(--on-surface);
  border-radius: var(--radius-pill);
  background: transparent;
  cursor: pointer;
  transition: background var(--speed) ease;
}

input[role="switch"]::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--on-surface);
  transition: transform var(--speed) ease;
}

input[role="switch"]:checked {
  background: var(--success);
  border-color: var(--success);
}

input[role="switch"]:checked::after {
  background: var(--white);
  transform: translateX(22px);
}

input[role="switch"]:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* ── start / login screen ─────────────────────────────────────────────────── */
.boot {
  inset: 0;
  z-index: 900;
  display: flex;
  justify-content: center;
  align-items: flex-end;
  overflow-y: auto;
  padding: calc(var(--safe-top) + var(--space-5)) var(--space-4) calc(var(--safe-bottom) + var(--space-5));
  background:
    radial-gradient(circle at 1px 1px, color-mix(in srgb, var(--text) 22%, transparent) 1.2px, transparent 1.6px) 0 0 / 14px 14px,
    repeating-linear-gradient(-28deg, transparent 0 46px, color-mix(in srgb, var(--accent) var(--stripe-strength, 22%), transparent) 46px 58px, transparent 58px 120px),
    var(--bg);
}

.boot-card {
  width: 100%;
  max-width: 460px;
}

.boot-hero {
  padding: 0 var(--space-2) var(--space-5);
}

.boot-hero .kicker {
  color: var(--text);
}

.boot-title {
  font-size: var(--fs-display-lg);
  color: var(--text-strong);
  text-shadow: 5px 5px 0 var(--accent);
  margin: var(--space-2) 0 var(--space-4);
}

.lede {
  margin: 0;
  max-width: 28rem;
  font-size: var(--fs-md);
  line-height: 1.5;
  color: var(--text);
}

.boot .stack,
.boot .auth-msg {
  background: var(--surface);
  color: var(--on-surface);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-hard);
}

.boot .stack {
  padding: var(--space-5);
}

.step-title {
  margin: 0;
  font-family: var(--font-display);
  font-style: italic;
  text-transform: uppercase;
  font-size: var(--fs-display-sm);
  line-height: 0.95;
}

[data-username-hint][data-tone="ok"] {
  color: var(--surface-ok);
  font-weight: 600;
}

[data-username-hint][data-tone="error"] {
  color: var(--surface-error);
  font-weight: 600;
}

.auth-msg {
  margin: var(--space-3) 0 0;
  padding: var(--space-3) var(--space-4);
  font-size: var(--fs-sm);
  line-height: 1.45;
  border-left: 6px solid var(--surface-kicker);
}

.auth-msg[data-tone="error"] {
  border-left-color: var(--accent);
}

/* ── map + markers ────────────────────────────────────────────────────────── */
.leaflet-container {
  background: var(--bg);
  font-family: var(--font-body);
}

.leaflet-tile-pane {
  filter: var(--map-filter);
}

.leaflet-control-attribution {
  background: var(--glass) !important;
  color: var(--text);
  font-size: 10px;
  max-width: 70vw;
  margin-bottom: calc(var(--safe-bottom) + 76px) !important;
}

.leaflet-control-attribution a {
  color: var(--text-strong);
}

.pin-wrap {
  background: none;
  border: 0;
}

.pin {
  position: relative;
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
}

.pin-court svg {
  width: 28px;
  height: 28px;
  padding: 4px;
  fill: var(--court-ink);
  background: var(--court);
  border: 2px solid var(--court-ink);
  border-radius: var(--radius-sm);
  box-shadow: 2px 2px 0 var(--court-ink);
  transform: rotate(-6deg);
  transition: transform var(--speed) ease;
}

.pin-court.is-selected svg {
  background: var(--paper);
  border-color: var(--accent);
  box-shadow: 3px 3px 0 var(--accent);
  transform: rotate(-6deg) scale(1.25);
}

.court-ring {
  stroke: var(--court);
  stroke-width: 1.5;
  fill: var(--court);
  fill-opacity: 0.08;
}

.court-ring.is-selected {
  stroke-width: 3;
  fill-opacity: 0.2;
}

.pin-ping-core {
  position: relative;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--accent);
  border: 3px solid var(--paper);
  box-shadow: 0 0 0 2px var(--accent);
}

.pin-ping-wave {
  position: absolute;
  inset: 8px;
  border-radius: 50%;
  border: 3px solid var(--accent);
  animation: pulse 1.6s ease-out infinite;
}

.pin-ping-tag {
  position: absolute;
  top: 40px;
  left: 50%;
  transform: translateX(-50%) skewX(-8deg);
  white-space: nowrap;
  padding: 2px var(--space-2);
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: var(--on-accent);
  font-size: var(--fs-xs);
  font-weight: 800;
}

.pin-ping.is-mine .pin-ping-core {
  border-color: var(--orange);
}

.ping-radius {
  stroke: var(--accent);
  stroke-width: 2;
  stroke-dasharray: 6 8;
  fill: var(--accent);
  fill-opacity: 0.06;
}

.pin-player-core {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--player);
  border: 3px solid var(--white);
  box-shadow: 0 0 0 6px color-mix(in srgb, var(--player) 35%, transparent);
}

.player-accuracy {
  stroke: var(--player);
  stroke-width: 1;
  fill: var(--player);
  fill-opacity: 0.08;
}

@keyframes pulse {
  from {
    transform: scale(0.7);
    opacity: 1;
  }
  to {
    transform: scale(2.4);
    opacity: 0;
  }
}

/* ── desktop ──────────────────────────────────────────────────────────────── */
@media (min-width: 960px) {
  .topbar {
    left: var(--space-4);
    right: var(--space-4);
    top: var(--space-4);
  }

  .toasts {
    left: auto;
    right: calc(var(--space-4) + var(--tap) + var(--space-3));
    top: 84px;
    width: 380px;
  }

  .sheet {
    top: 84px;
    bottom: var(--space-4);
    left: var(--space-4);
    right: auto;
    width: var(--sheet-width);
    max-height: none;
    border-top: 0;
    border-left: 5px solid var(--accent);
    border-radius: var(--radius-lg);
    transform: translateX(calc(-100% - var(--space-6)));
  }

  .sheet.is-open {
    transform: translateX(0);
  }

  .sheet-handle {
    visibility: hidden;
  }

  .bottombar {
    left: 50%;
    right: auto;
    width: min(620px, calc(100vw - var(--sheet-width) - 120px));
    transform: translateX(-50%);
    bottom: var(--space-4);
  }

  #app:has(.sheet.is-open) .bottombar {
    left: calc(var(--sheet-width) + var(--space-4) + (100vw - var(--sheet-width) - var(--space-4)) / 2);
  }

  .fab-col {
    bottom: var(--space-4);
    right: var(--space-4);
  }

  .leaflet-control-attribution {
    margin-bottom: 0 !important;
  }

  .boot {
    align-items: center;
  }

  .boot-card {
    max-width: 920px;
    display: grid;
    grid-template-columns: 1.1fr 1fr;
    column-gap: var(--space-6);
  }

  .boot-hero {
    grid-row: 1 / span 2;
    align-self: center;
  }

  .boot-card .stack {
    grid-column: 2;
    align-self: end;
  }

  .boot-card .auth-msg {
    grid-column: 2;
    align-self: start;
  }
}

/* ── motion ───────────────────────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }

  .pin-ping-wave,
  .ping-toggle.is-live .ping-dot::after,
  .ping-status .ping-dot::after {
    animation: none;
    opacity: 0.6;
    transform: scale(1.6);
  }
}
