/* Under the Lights: your club's courts at dusk, seen through frosted glass. */

/* Mona Sans (OFL), self-hosted. Its width axis gives scores and codes a broad scoreboard set. */
@font-face {
  font-family: "Mona Sans";
  src: url("/fonts/MonaSans-Variable.woff2") format("woff2");
  font-weight: 200 900;
  font-stretch: 75% 125%;
  font-display: swap;
}

/* ---------- tokens ---------- */

:root {
  /* Brand: navy, cream and ball yellow, sampled from the TierDink logo. */
  --navy-0: #08121f;
  --navy-1: #0c1a2c;
  --navy-2: #0f2137;
  --cream: #fff1d7;
  --court-blue: #1f4e8c;
  --court-blue-hi: #2a5ea3;
  --court-green: #2f6b4f;
  --flood: #fff4dc;
  --ball: #daf340;
  --ball-ink: #0f2137;

  --sans: "Mona Sans", -apple-system, "Segoe UI", system-ui, sans-serif;
  --figures: "Mona Sans", -apple-system, "Segoe UI", system-ui, sans-serif;

  --r-sm: 14px;
  --r-md: 20px;
  --r-lg: 30px;
  --pill: 999px;

  --ease: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-soft: cubic-bezier(0.33, 1, 0.68, 1);

  /* Night: the landing page always, the app in dark mode. */
  --bg: var(--navy-2);
  --ink: #fdf5e6;
  --ink-2: #c3c8cf;
  --ink-3: #939eae;
  --surface: rgba(255, 255, 255, 0.075);
  --surface-2: rgba(255, 255, 255, 0.12);
  --surface-solid: #142338;
  --edge: rgba(255, 255, 255, 0.14);
  --edge-hi: rgba(255, 255, 255, 0.32);
  --link: #9cc4ff;
  --field: rgba(3, 9, 18, 0.35);
  --up-bg: var(--ball);
  --up-ink: var(--ball-ink);
  --down-bg: #ff9a62;
  --down-ink: #2a1105;
  --danger: #ff8a7a;
  --focus: var(--ball);
  --shadow: 0 24px 60px rgba(2, 6, 12, 0.45);
  --shadow-sm: 0 8px 24px rgba(2, 6, 12, 0.35);
  --ground:
    radial-gradient(70% 55% at 15% -10%, rgba(255, 244, 220, 0.16), transparent 60%),
    radial-gradient(60% 50% at 90% -5%, rgba(255, 244, 220, 0.12), transparent 60%),
    linear-gradient(180deg, var(--navy-1), var(--navy-2) 55%, var(--navy-0));
}

/* Daylight: the app in light mode, readable courtside in the sun. */
@media (prefers-color-scheme: light) {
  body.app {
    --bg: #eef3f8;
    --ink: #0d1b2e;
    --ink-2: #44546b;
    --ink-3: #5d6c80;
    --surface: rgba(255, 255, 255, 0.72);
    --surface-2: rgba(255, 255, 255, 0.92);
    --surface-solid: #ffffff;
    --edge: rgba(13, 27, 46, 0.1);
    --edge-hi: rgba(255, 255, 255, 0.95);
    --link: var(--court-blue);
    --field: #ffffff;
    --down-bg: #ffd7bf;
    --down-ink: #7a2a05;
    --danger: #b42318;
    --focus: var(--court-blue);
    --shadow: 0 22px 50px rgba(13, 27, 46, 0.1);
    --shadow-sm: 0 6px 18px rgba(13, 27, 46, 0.08);
    --ground:
      radial-gradient(60% 45% at 12% -10%, rgba(255, 255, 255, 0.95), transparent 60%),
      radial-gradient(55% 45% at 92% -8%, rgba(214, 233, 255, 0.9), transparent 60%),
      linear-gradient(180deg, #e9f1fa, #eef3f8 40%, #e8eef0);
  }
}

/* ---------- base ---------- */

* { box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  background-image: var(--ground);
  background-attachment: fixed;
  color: var(--ink);
  font: 400 16px/1.55 var(--sans);
  -webkit-font-smoothing: antialiased;
  caret-color: var(--ball);
}
body.app { caret-color: var(--focus); }
::selection { background: rgba(217, 242, 74, 0.85); color: var(--ball-ink); }
html { scrollbar-color: rgba(185, 195, 209, 0.35) transparent; }

a { color: var(--link); text-underline-offset: 3px; text-decoration-thickness: 1px; }
h1, h2, h3 { margin: 0; letter-spacing: -0.025em; text-wrap: balance; }
h1 { font-size: clamp(30px, 4vw, 40px); line-height: 1.08; font-weight: 680; }
h2 { font-size: 21px; line-height: 1.25; font-weight: 640; margin: 40px 0 14px; }
h3 { font-size: 18px; line-height: 1.3; font-weight: 640; }
p { margin: 0; }
.muted { color: var(--ink-2); }
small.muted { font-size: 13px; color: var(--ink-3); }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 3px; border-radius: 10px; }
/* Scoreboard figures: expanded width, tabular digits. */
.code, .final-score, form.score input, .demo-row .rec, .steps .post, .mini .score, .code-input { font-stretch: 118%; font-variant-numeric: tabular-nums; }
.code-input { letter-spacing: 0.06em; }
.icon { width: 1em; height: 1em; flex: none; display: inline-block; vertical-align: -0.125em; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- controls ---------- */

button, input, select { font: inherit; color: inherit; }
button {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 10px 20px;
  border-radius: var(--pill); border: 1px solid var(--edge);
  background: var(--surface-2); color: var(--ink);
  font-weight: 600; letter-spacing: -0.01em; cursor: pointer;
  transition: background 200ms var(--ease-soft), border-color 200ms var(--ease-soft), transform 200ms var(--ease-soft), box-shadow 200ms var(--ease-soft);
}
button:hover { border-color: var(--edge-hi); }
button:active { transform: scale(0.97); }
button:disabled { opacity: 0.55; cursor: default; transform: none; }

/* Ball yellow: the one primary action on each screen. */
button.primary {
  background: var(--ball); color: var(--ball-ink); border-color: transparent;
  box-shadow: 0 10px 26px rgba(2, 6, 12, 0.28), inset 0 1px 0 rgba(255, 255, 255, 0.55);
}
button.primary:hover { background: #e3f76a; }
button.quiet { background: transparent; }
button.danger { min-height: 36px; padding: 6px 14px; font-size: 14px; color: var(--danger); background: transparent; }
button.danger:hover { border-color: currentColor; }
button.text {
  min-height: 0; padding: 6px 8px; border: 0; background: none; color: var(--ink-2);
  font-weight: 500; border-radius: 10px;
}
button.text:hover { color: var(--ink); }

input, select {
  width: 100%; min-height: 48px; padding: 11px 16px;
  border-radius: var(--r-sm); border: 1px solid var(--edge);
  background: var(--field); color: var(--ink);
  transition: border-color 200ms var(--ease-soft), box-shadow 200ms var(--ease-soft);
}
input::placeholder { color: var(--ink-3); }
input:focus, select:focus { outline: none; border-color: var(--focus); box-shadow: 0 0 0 4px color-mix(in srgb, var(--focus) 22%, transparent); }
label { display: grid; gap: 6px; font-size: 14px; font-weight: 500; color: var(--ink-2); }

.glass {
  background: var(--surface);
  border: 1px solid var(--edge);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow), inset 0 1px 0 var(--edge-hi);
}
.glass.blur { -webkit-backdrop-filter: blur(28px) saturate(170%); backdrop-filter: blur(28px) saturate(170%); }

.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }

/* ---------- top bar (app) ---------- */

#topbar {
  position: sticky; top: 12px; z-index: 20;
  display: flex; align-items: center; gap: 6px;
  width: min(960px, calc(100% - 24px)); margin: 12px auto 0; padding: 8px 8px 8px 18px;
  border-radius: var(--pill);
  background: color-mix(in srgb, var(--surface-solid) 70%, transparent);
  border: 1px solid var(--edge);
  box-shadow: var(--shadow-sm), inset 0 1px 0 var(--edge-hi);
  -webkit-backdrop-filter: blur(24px) saturate(170%); backdrop-filter: blur(24px) saturate(170%);
}
.brand { display: inline-flex; align-items: center; margin-right: auto; color: var(--ink); text-decoration: none; }
.ball { width: 20px; height: 20px; flex: none; }

/* The logo wordmark: cream letters, each i dotted with a ball. */
.wordmark { font-size: 21px; font-weight: 640; letter-spacing: -0.02em; line-height: 1; color: var(--cream); white-space: nowrap; }
body.app .wordmark { color: var(--ink); }
.wordmark .i { position: relative; display: inline-block; }
.wordmark .i .ball { position: absolute; left: 50%; top: -0.08em; width: 0.42em; height: 0.42em; transform: translateX(-50%); }

/* Avatars: a photo, or initials on a court-blue disc. */
.av {
  width: var(--s); height: var(--s); flex: none; border-radius: 50%; overflow: hidden;
  display: inline-grid; place-items: center;
  background: linear-gradient(160deg, var(--court-blue-hi), var(--court-blue));
  color: #fff; font-weight: 640; font-size: calc(var(--s) * 0.38); letter-spacing: 0;
  box-shadow: 0 0 0 1px var(--edge);
}
.av img { width: 100%; height: 100%; object-fit: cover; display: block; }

#flash {
  width: min(960px, calc(100% - 24px)); margin: 14px auto 0; padding: 12px 18px;
  border-radius: var(--r-md); background: var(--surface-2); border: 1px solid var(--edge);
}
#flash.error { color: var(--danger); }

/* ---------- app layout ---------- */

body.app main { width: min(960px, calc(100% - 32px)); margin: 0 auto; padding: 28px 0 80px; }
.crumbs { font-size: 15px; margin-bottom: 10px; }
.crumbs a { display: inline-flex; align-items: center; gap: 6px; text-decoration: none; font-weight: 500; }
.lede { margin-top: 6px; color: var(--ink-2); }

.list { list-style: none; margin: 0; padding: 6px; }
.list li { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: var(--r-md); min-height: 56px; }
.list li + li { border-top: 1px solid var(--edge); border-radius: 0; }
.list li > :first-child { margin-right: auto; }
.list a { color: var(--ink); font-weight: 600; text-decoration: none; }
.list a:hover { color: var(--link); }
.list .empty { color: var(--ink-2); }
.tag { font-size: 13px; padding: 3px 10px; border-radius: var(--pill); background: var(--surface-2); border: 1px solid var(--edge); color: var(--ink-2); white-space: nowrap; }

.panels { display: grid; gap: 18px; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); margin-top: 22px; }
form.glass, section.glass.pad { padding: 24px; }
form.glass { display: grid; gap: 14px; align-content: start; }
form.glass h2, section.glass.pad h2 { margin: 0; }
.fields { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }

.code-panel { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 18px; margin-top: 22px; padding: 24px 28px; }
.code { font: 600 clamp(28px, 5vw, 38px)/1.1 var(--figures); letter-spacing: 0.06em; margin: 4px 0; }
.label { font-size: 14px; color: var(--ink-2); }

/* ---------- league ---------- */

.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin: 22px 0 6px; }
.rounds { display: inline-flex; gap: 4px; padding: 4px; margin: 18px 0 0; border-radius: var(--pill); background: var(--surface); border: 1px solid var(--edge); flex-wrap: wrap; }
.rounds a { padding: 7px 16px; border-radius: var(--pill); text-decoration: none; color: var(--ink-2); font-size: 15px; font-weight: 500; transition: background 300ms var(--ease), color 300ms var(--ease); }
.rounds a:hover { color: var(--ink); }
.rounds a.current { background: var(--surface-2); color: var(--ink); box-shadow: var(--shadow-sm); }

.round-head { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; margin: 36px 0 6px; }
.round-head h2 { margin: 0; }
.status { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 600; padding: 4px 12px 4px 10px; border-radius: var(--pill); background: var(--surface-2); border: 1px solid var(--edge); }
.status .lamp { width: 8px; height: 8px; border-radius: 50%; background: var(--ink-3); }
.live .status .lamp { background: var(--ball); animation: lamp 2.4s var(--ease-soft) infinite; }
@keyframes lamp { 50% { opacity: 0.45; } }

.boxes { display: grid; gap: 18px; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); margin-top: 18px; }
@media (max-width: 420px) { .boxes { grid-template-columns: 1fr; } }
/* Your box opens wider than the rest: the full row, standings beside your games. */
@media (min-width: 760px) { .box.mine { grid-column: 1 / -1; } }

.box { position: relative; overflow: hidden; border-radius: var(--r-lg); background: var(--surface); border: 1px solid var(--edge); box-shadow: var(--shadow-sm), inset 0 1px 0 var(--edge-hi); scroll-margin-top: 90px; }
/* Lighting tells the round's state: floodlit while live, lights down once final. */
.box::before {
  content: ""; position: absolute; inset: 0 0 auto; height: 160px; pointer-events: none;
  background: radial-gradient(70% 100% at 50% 0%, rgba(255, 244, 220, 0.18), transparent 70%);
  transition: opacity 900ms var(--ease);
}
.final .box::before { opacity: 0; }
.final .box { background: color-mix(in srgb, var(--surface) 70%, transparent); }
.box.mine { border-color: color-mix(in srgb, var(--ball) 70%, transparent); }
body.app .box.mine { border-color: color-mix(in srgb, var(--focus) 60%, transparent); }
.box > header { position: relative; display: flex; justify-content: space-between; align-items: baseline; padding: 18px 20px 10px; }
.box > header span { font-size: 14px; color: var(--ink-2); }
.box { container-type: inline-size; }
.box .inner { position: relative; display: grid; }
/* Any box with room for it shows standings beside its games. */
@container (min-width: 680px) {
  .box .inner { grid-template-columns: 1fr 1fr; }
  .box .matches { border-left: 1px solid var(--edge); border-top: 0; }
}

table.standings { width: 100%; border-collapse: collapse; font-size: 15px; }
.standings th { white-space: nowrap; text-align: left; font-size: 13px; font-weight: 500; color: var(--ink-3); padding: 6px 8px; }
.standings td { padding: 10px 8px; border-top: 1px solid var(--edge); }
.standings th:first-child, .standings td:first-child { padding-left: 20px; width: 34px; color: var(--ink-3); }
.standings th:last-child, .standings td:last-child { padding-right: 20px; }
.standings .num { text-align: right; font-variant-numeric: tabular-nums; width: 42px; }
.standings tr.me td { font-weight: 650; }
.standings tr.me td:first-child { color: var(--ink); }
.move { white-space: nowrap; display: inline-flex; align-items: center; gap: 3px; margin-left: 8px; padding: 2px 8px 2px 6px; border-radius: var(--pill); font-size: 12px; font-weight: 650; vertical-align: 1px; }
.move.up { background: var(--up-bg); color: var(--up-ink); }
.move.down { background: var(--down-bg); color: var(--down-ink); }

.matches { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--edge); }
.matches li { display: grid; gap: 8px; padding: 14px 20px; }
.matches li + li { border-top: 1px solid var(--edge); }
.teams { display: grid; grid-template-columns: 1fr auto 1fr; gap: 10px; align-items: center; font-size: 14px; }
.teams .vs { color: var(--ink-3); font-size: 12px; }
.teams span:last-child { text-align: right; }
.teams .won { font-weight: 650; }
.result { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.final-score { font: 600 22px/1 var(--figures); font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }

.final-score .not-played { font: 500 15px var(--sans); }
form.score { display: flex; align-items: center; gap: 8px; }
form.score input {
  width: 64px; min-height: 52px; padding: 6px; text-align: center;
  font: 600 22px/1 var(--figures); font-variant-numeric: tabular-nums; border-radius: 16px;
  -moz-appearance: textfield;
}
form.score input::-webkit-outer-spin-button, form.score input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
form.score .dash { color: var(--ink-3); }
form.score button { min-height: 52px; padding: 10px 18px; }
/* A score you just saved settles in from depth. */
.fresh .final-score, .fresh form.score input { animation: settle 520ms var(--ease) both; }
@keyframes settle { from { opacity: 0.2; filter: blur(6px); transform: scale(1.18); } }

details.players { margin-top: 40px; }
details.players summary { cursor: pointer; font-weight: 640; font-size: 18px; list-style: none; display: flex; align-items: center; gap: 8px; }
details.players summary::-webkit-details-marker { display: none; }
details.players summary .icon { transition: transform 300ms var(--ease); }
details.players[open] summary .icon { transform: rotate(90deg); }
details.players > p { margin: 8px 0 14px; }
.trail { display: flex; align-items: center; gap: 10px; color: var(--ink-2); font-size: 13px; font-variant-numeric: tabular-nums; }
.trail svg { width: 88px; height: 28px; overflow: visible; }
.trail path { fill: none; stroke: var(--link); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.trail circle { fill: var(--surface-solid); stroke: var(--link); stroke-width: 2; }
.trail circle.now { fill: var(--ball); stroke: var(--ball-ink); stroke-width: 1.5; }

/* ---------- landing ---------- */

body.landing { overflow-x: hidden; }
body.landing main { width: 100%; }

.lnav {
  position: absolute; z-index: 10; top: 22px; left: 50%; transform: translateX(-50%);
  display: flex; align-items: center; gap: 4px; padding: 6px 6px 6px 18px;
  border-radius: var(--pill); white-space: nowrap;
  background: rgba(255, 255, 255, 0.09); border: 1px solid rgba(255, 255, 255, 0.18);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.28), 0 12px 30px rgba(2, 6, 12, 0.3);
  -webkit-backdrop-filter: blur(24px) saturate(170%); backdrop-filter: blur(24px) saturate(170%);
}
.lnav .brand { margin-right: 18px; }
.lnav a.link { padding: 8px 14px; color: var(--ink-2); text-decoration: none; font-size: 15px; border-radius: var(--pill); }
.lnav a.link:hover { color: var(--ink); }
.lnav button { min-height: 38px; padding: 6px 16px; font-size: 15px; }

.stage { position: relative; min-height: max(760px, 100svh); overflow: hidden; isolation: isolate; }
.lights {
  position: absolute; inset: 0; z-index: -1; pointer-events: none;
  background:
    radial-gradient(38% 55% at 22% -6%, rgba(255, 244, 220, 0.62), rgba(255, 244, 220, 0.12) 45%, transparent 70%),
    radial-gradient(34% 50% at 80% -8%, rgba(255, 244, 220, 0.5), rgba(255, 244, 220, 0.08) 45%, transparent 70%);
  animation: lights-up 2400ms var(--ease) both;
}
@keyframes lights-up { from { opacity: 0.35; filter: brightness(0.6); } }
.court-wrap { position: absolute; z-index: -2; left: 50%; bottom: -34%; width: min(1500px, 140vw); transform: translateX(-50%); perspective: 1400px; }
.court { display: block; width: 100%; height: auto; transform: rotateX(54deg); transform-origin: 50% 100%; }
.stage::after { content: ""; position: absolute; inset: auto 0 0; height: 30%; z-index: -1; background: linear-gradient(transparent, var(--navy-0)); }

.hero {
  width: min(1200px, calc(100% - 48px)); margin: 0 auto; padding: 150px 0 80px;
  display: grid; grid-template-columns: 1.05fr 1fr; gap: 56px; align-items: center;
}
.hero h1 { font-size: clamp(44px, 6.4vw, 84px); line-height: 0.98; letter-spacing: -0.04em; font-weight: 700; max-width: 11ch; }
.hero .pitch { margin-top: 24px; font-size: clamp(18px, 1.6vw, 21px); line-height: 1.5; color: var(--ink-2); max-width: 36ch; }
.hero .actions { margin-top: 34px; display: flex; flex-wrap: wrap; align-items: center; gap: 14px; }
.hero .actions .primary { min-height: 56px; padding: 14px 30px; font-size: 18px; }
.hero .actions a { color: var(--ink); font-weight: 500; text-decoration: none; display: inline-flex; align-items: center; gap: 6px; padding: 10px 4px; }
.hero .actions a:hover { text-decoration: underline; }

.signin {
  margin-top: 22px; padding: 22px; max-width: 420px; display: grid; gap: 14px;
  transform-origin: 0 0; animation: open-panel 520ms var(--ease) both;
}
@keyframes open-panel { from { opacity: 0; transform: translateY(-8px) scale(0.98); filter: blur(4px); } }
.signin h2 { margin: 0; font-size: 18px; }
.signin .providers { display: grid; gap: 10px; justify-items: start; }
#appleid-signin { width: 260px; height: 44px; cursor: pointer; }
.signin form { display: grid; grid-template-columns: 1fr auto; gap: 10px; align-items: end; }
.signin .none { color: var(--ink-2); font-size: 14px; }

.demo { position: relative; display: grid; gap: 16px; }
/* Tinted navy glass, so the court colours soften behind it instead of bleeding through. */
.demo-card { padding: 6px 6px 8px; border-radius: var(--r-lg); background: rgba(16, 32, 54, 0.62); transition: box-shadow 900ms var(--ease), background 900ms var(--ease); }
.demo-card header { display: flex; justify-content: space-between; align-items: baseline; padding: 14px 16px 10px; }
.demo-card header span { font-size: 14px; color: var(--ink-2); }
.demo-row {
  display: grid; grid-template-columns: 22px 1fr auto auto; align-items: center; gap: 10px;
  min-height: 50px; padding: 0 14px; border-radius: 16px; font-size: 16px;
  will-change: transform;
}
.demo-row + .demo-row { margin-top: 4px; }
.demo-row .rk { color: var(--ink-3); font-size: 14px; font-variant-numeric: tabular-nums; }
.demo-row .rec { font: 500 14px var(--figures); color: var(--ink-2); font-variant-numeric: tabular-nums; }
.demo-row.mover { background: rgba(255, 255, 255, 0.07); }
.demo.dim .demo-card { background: rgba(8, 17, 29, 0.78); box-shadow: var(--shadow-sm), inset 0 1px 0 rgba(255, 255, 255, 0.1); }
.demo-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 0 6px; }
.demo-foot small { color: var(--ink-2); font-size: 13px; padding: 4px 12px; border-radius: var(--pill); background: rgba(8, 17, 29, 0.7); border: 1px solid var(--edge); }

.section { width: min(1200px, calc(100% - 48px)); margin: 0 auto; padding: 120px 0 0; }
.section > h2 { font-size: clamp(34px, 4.6vw, 60px); line-height: 1.02; letter-spacing: -0.035em; font-weight: 690; margin: 0; max-width: 16ch; }
.section > .intro { margin-top: 18px; font-size: 19px; color: var(--ink-2); max-width: 52ch; }

/* Three stages stepping down a court line, like players moving through boxes. */
.steps { position: relative; list-style: none; margin: 64px 0 0; padding: 0; display: grid; grid-template-columns: repeat(3, 1fr); gap: 28px; }
.steps::before { content: ""; position: absolute; left: 0; right: 0; top: 23px; height: 2px; background: linear-gradient(90deg, rgba(255, 255, 255, 0.85), rgba(255, 255, 255, 0.25)); }
.steps li { position: relative; display: grid; gap: 14px; align-content: start; }
.steps li:nth-child(2) { margin-top: 56px; }
.steps li:nth-child(3) { margin-top: 112px; }
.steps .post { width: 48px; height: 48px; border-radius: 50%; display: grid; place-items: center; background: var(--navy-2); border: 2px solid rgba(255, 255, 255, 0.85); font: 600 17px var(--figures); }
.steps h3 { font-size: 22px; letter-spacing: -0.02em; }
.steps p { color: var(--ink-2); max-width: 34ch; }
.mini { padding: 16px 18px; border-radius: var(--r-md); display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.mini .code { font-size: 24px; margin: 0; }
.mini .score { display: flex; align-items: center; gap: 8px; font: 600 22px var(--figures); }
.mini .score span { display: grid; place-items: center; width: 54px; height: 46px; border-radius: 14px; background: rgba(3, 9, 18, 0.35); border: 1px solid var(--edge); }
.mini .saved { font-size: 13px; color: var(--ink-3); }

.formats { display: grid; grid-template-columns: 1.15fr 1fr; gap: 28px; margin-top: 56px; align-items: start; }
.format { padding: 30px; }
.format h3 { font-size: 24px; }
.format > p { margin-top: 10px; color: var(--ink-2); max-width: 44ch; }
.pairings { margin-top: 22px; display: grid; gap: 8px; }
.pairing { display: grid; grid-template-columns: auto auto 44px auto auto; justify-content: start; align-items: center; gap: 10px; padding: 10px 14px; border-radius: 16px; background: rgba(255, 255, 255, 0.06); font-size: 15px; }
.pairing .vs { color: var(--ink-3); font-size: 13px; text-align: center; }
.chip { display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; font-weight: 650; font-size: 14px; background: rgba(255, 255, 255, 0.14); border: 1px solid rgba(255, 255, 255, 0.22); }
.robin { margin-top: 22px; display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; max-width: 190px; }
.robin span { aspect-ratio: 1; border-radius: 10px; background: rgba(255, 255, 255, 0.07); }
.robin span.on { background: rgba(255, 255, 255, 0.22); }
.settings { margin-top: 18px; display: flex; gap: 8px; flex-wrap: wrap; }

.retire { margin-top: 140px; display: grid; grid-template-columns: 1fr 1fr; gap: 40px; align-items: end; }
.retire h2 { font-size: clamp(40px, 6vw, 76px); line-height: 0.98; letter-spacing: -0.04em; font-weight: 700; margin: 0; }
.retire ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.retire li { display: flex; align-items: center; gap: 14px; padding: 16px 0; border-top: 1px solid var(--edge); font-size: 19px; color: var(--ink-2); }
.retire li .icon { color: var(--ink); font-size: 20px; }

.close { position: relative; margin-top: 140px; padding: 120px 24px 140px; text-align: center; overflow: hidden; isolation: isolate; }
.close::before {
  content: ""; position: absolute; inset: 0; z-index: -1;
  background: radial-gradient(45% 70% at 50% 8%, rgba(255, 244, 220, 0.38), rgba(255, 244, 220, 0.06) 55%, transparent 75%);
  -webkit-mask-image: linear-gradient(transparent, #000 28%);
  mask-image: linear-gradient(transparent, #000 28%);
}
.close h2 { font-size: clamp(40px, 6vw, 80px); line-height: 0.98; letter-spacing: -0.04em; font-weight: 700; margin: 0 auto; max-width: 13ch; }
.close p { margin: 20px auto 0; color: var(--ink-2); font-size: 19px; max-width: 40ch; }
.close button { margin-top: 34px; min-height: 56px; padding: 14px 30px; font-size: 18px; }
.lfoot { width: min(1200px, calc(100% - 48px)); margin: 0 auto; padding: 28px 0 40px; display: flex; justify-content: space-between; align-items: center; border-top: 1px solid var(--edge); color: var(--ink-3); font-size: 14px; }

/* Reveal: content is visible by default; motion only adds the arrival. */
.reveal { transition: opacity 900ms var(--ease), transform 900ms var(--ease), filter 900ms var(--ease); }
.reveal.pending { opacity: 0; transform: translateY(24px); filter: blur(6px); }

@media (max-width: 960px) {
  .hero { grid-template-columns: 1fr; padding-top: 120px; gap: 40px; }
  .formats, .retire { grid-template-columns: 1fr; }
  .steps { grid-template-columns: 1fr; gap: 36px; }
  .steps::before { left: 23px; right: auto; top: 0; bottom: 0; width: 2px; height: auto; background: linear-gradient(180deg, rgba(255, 255, 255, 0.85), rgba(255, 255, 255, 0.25)); }
  .steps li, .steps li:nth-child(2), .steps li:nth-child(3) { margin-top: 0; padding-left: 70px; }
  .steps .post { position: absolute; left: 0; top: 0; }
}
@media (max-width: 640px) {
  .lnav { left: 16px; right: 16px; transform: none; justify-content: space-between; }
  .lnav a.link { display: none; }
  .hero, .section, .lfoot { width: calc(100% - 32px); }
  .section { padding-top: 88px; }
  .court-wrap { width: 220vw; bottom: -4%; }
  .signin form { grid-template-columns: 1fr; }
  .demo-row { grid-template-columns: 18px 1fr auto; }
  .demo-row .rec { display: none; }
  .pairing { grid-template-columns: auto auto 32px auto auto; gap: 6px; padding: 8px 10px; }
  .retire, .close { margin-top: 96px; }
  .standings th:first-child, .standings td:first-child { padding-left: 16px; }
  .matches li { padding: 14px 16px; }
  .box > header { padding: 16px 16px 8px; }
}

/* ---------- app chrome additions ---------- */

.me-link { display: inline-flex; align-items: center; gap: 10px; padding: 3px 14px 3px 3px; border-radius: var(--pill); color: var(--ink); text-decoration: none; font-weight: 500; transition: background 200ms var(--ease-soft); }
.me-link:hover { background: var(--surface-2); }
@media (max-width: 420px) { .me-link span:last-child { display: none; } .me-link { padding: 3px; } }

#appfoot { width: min(960px, calc(100% - 32px)); margin: 0 auto; padding: 22px 0 40px; display: flex; justify-content: space-between; align-items: center; gap: 12px; border-top: 1px solid var(--edge); color: var(--ink-3); font-size: 14px; }
#appfoot nav, .lfoot nav { display: flex; gap: 18px; }
#appfoot a, .lfoot nav a { color: var(--ink-2); text-decoration: none; }
#appfoot a:hover, .lfoot nav a:hover { color: var(--ink); text-decoration: underline; }

textarea {
  width: 100%; padding: 12px 16px; border-radius: var(--r-sm); border: 1px solid var(--edge);
  background: var(--field); color: var(--ink); font: inherit; line-height: 1.5; resize: vertical; min-height: 88px;
  transition: border-color 200ms var(--ease-soft), box-shadow 200ms var(--ease-soft);
}
textarea:focus { outline: none; border-color: var(--focus); box-shadow: 0 0 0 4px color-mix(in srgb, var(--focus) 22%, transparent); }
label .count { float: right; font-weight: 400; color: var(--ink-3); font-variant-numeric: tabular-nums; }

/* Toggle switch built on a real checkbox. */
.switch { display: flex; align-items: center; gap: 14px; font-size: 16px; color: var(--ink); cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch .track { position: relative; flex: none; width: 52px; height: 32px; border-radius: var(--pill); background: var(--surface-2); border: 1px solid var(--edge); transition: background 300ms var(--ease); }
.switch .track::after { content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; box-shadow: 0 2px 6px rgba(2, 6, 12, 0.3); transition: transform 300ms var(--ease); }
.switch input:checked + .track { background: var(--ball); border-color: transparent; }
.switch input:checked + .track::after { transform: translateX(20px); }
.switch input:focus-visible + .track { outline: 2px solid var(--focus); outline-offset: 3px; }
.switch input:disabled + .track { opacity: 0.5; }

/* Profile */
.profile-head { display: flex; align-items: center; gap: 22px; flex-wrap: wrap; margin-top: 6px; }
.av-edit { position: relative; padding: 0; min-height: 0; border: 0; background: none; border-radius: 50%; }
.av-edit .badge { position: absolute; right: 0; bottom: 0; display: grid; place-items: center; width: 32px; height: 32px; border-radius: 50%; background: var(--ball); color: var(--ball-ink); box-shadow: var(--shadow-sm); }
.av-edit:hover .av { box-shadow: 0 0 0 3px var(--focus); }

/* Destructive areas sit apart, outlined in the warning colour, never glass. */
.danger-zone { padding: 22px 24px; border-radius: var(--r-lg); border: 1px solid color-mix(in srgb, var(--danger) 45%, transparent); }
.danger-zone h2 { margin: 0 0 6px; }
.confirm-row { display: grid; grid-template-columns: 1fr auto; gap: 12px; align-items: end; margin-top: 16px; }
@media (max-width: 520px) { .confirm-row { grid-template-columns: 1fr; } }
/* Text takes the page colour, so it contrasts with the warning red in both themes. */
button.danger-solid { background: var(--danger); color: var(--bg); border-color: transparent; }

/* Club page */
.club-hero { position: relative; margin-top: 6px; }
.club-hero .banner {
  height: clamp(120px, 24vw, 220px); border-radius: var(--r-lg); overflow: hidden;
  background:
    radial-gradient(60% 120% at 20% 0%, rgba(255, 244, 220, 0.35), transparent 60%),
    linear-gradient(135deg, var(--court-blue), var(--court-green));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.25);
}
.club-hero .banner img { width: 100%; height: 100%; object-fit: cover; display: block; }
/* The club logo sits half over the banner; the name and description start beside it, below the banner. */
.club-id { position: relative; display: flex; align-items: flex-start; gap: 18px; padding-left: 22px; }
.club-id .av { margin-top: -42px; box-shadow: 0 0 0 4px var(--bg), var(--shadow-sm); }
.club-id > div { padding-top: 14px; min-width: 0; }
@media (max-width: 520px) { .club-id { padding-left: 12px; gap: 12px; } .club-id .av { --s: 68px !important; margin-top: -34px; } }

details.edit-club { margin-top: 18px; padding: 0; }
details.edit-club summary, details.rules summary { cursor: pointer; list-style: none; display: flex; align-items: center; gap: 10px; padding: 18px 22px; font-weight: 600; }
details.edit-club summary::-webkit-details-marker, details.rules summary::-webkit-details-marker { display: none; }
details.edit-club summary .icon { transition: transform 300ms var(--ease); }
details.edit-club[open] summary .icon { transform: rotate(90deg); }
details.edit-club form { display: grid; gap: 14px; padding: 0 22px 22px; }

.members .who { display: grid; margin-right: auto; min-width: 0; }
.members .who .bio { font-size: 14px; color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.members li > .av { margin-right: 0; }
.list li > .av:first-child { margin-right: 0; }
.list li > .av + a, .list li > .av + span { margin-right: auto; }

/* League rules */
details.rules { margin-top: 18px; padding: 0; }
details.rules summary { color: var(--ink); }
details.rules dl { margin: 0; padding: 0 22px 18px; display: grid; gap: 14px; }
details.rules dl > div { display: grid; grid-template-columns: 140px 1fr; gap: 14px; padding-top: 14px; border-top: 1px solid var(--edge); }
details.rules dt { font-weight: 600; }
details.rules dd { margin: 0; color: var(--ink-2); max-width: 62ch; }
@media (max-width: 560px) { details.rules dl > div { grid-template-columns: 1fr; gap: 4px; } }

.player { display: inline-flex; align-items: center; gap: 10px; }
.score-hint { margin: 0; font-size: 14px; color: var(--danger); }

/* Lists and boxes rise in, one after another, when a page opens. */
@keyframes rise { from { opacity: 0; transform: translateY(10px); } }
.stagger > * { animation: rise 520ms var(--ease) both; animation-delay: calc(var(--i, 0) * 45ms); }

/* Page-to-page cross-fade (browsers with view transitions). */
::view-transition-old(root) { animation: 220ms var(--ease-soft) both vt-out; }
::view-transition-new(root) { animation: 420ms var(--ease) both vt-in; }
@keyframes vt-out { to { opacity: 0; filter: blur(4px); } }
@keyframes vt-in { from { opacity: 0; transform: translateY(8px); filter: blur(4px); } }

/* ---------- install sheet ---------- */

.install-sheet {
  position: fixed; z-index: 50; left: 12px; right: 12px; bottom: max(12px, env(safe-area-inset-bottom));
  max-width: 520px; margin: 0 auto; padding: 22px 20px 20px;
  background: color-mix(in srgb, var(--surface-solid) 82%, transparent);
  animation: sheet-in 560ms var(--ease) both;
}
.install-sheet.leaving { animation: sheet-out 320ms var(--ease-soft) both; }
@keyframes sheet-in { from { transform: translateY(110%); opacity: 0; } }
@keyframes sheet-out { to { transform: translateY(110%); opacity: 0; } }
.install-sheet .sheet-close { position: absolute; top: 10px; right: 10px; width: 40px; height: 40px; padding: 0; justify-content: center; }
.install-head { display: flex; gap: 14px; align-items: center; padding-right: 36px; }
.install-head img { border-radius: 14px; box-shadow: var(--shadow-sm); }
.install-head h2 { margin: 0; font-size: 19px; }
.install-sheet > button.primary { width: 100%; margin-top: 18px; min-height: 52px; }
.install-steps { list-style: none; margin: 18px 0 0; padding: 0; display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.install-steps li { display: grid; gap: 8px; align-content: start; animation: rise 520ms var(--ease) both; animation-delay: calc(200ms + var(--i) * 90ms); }
.install-steps .phone-art { width: 100%; height: auto; max-height: 150px; }
.install-steps p { font-size: 13px; line-height: 1.4; color: var(--ink-2); }
.install-steps p b { color: var(--ink); }
.install-steps .n { display: inline-grid; place-items: center; width: 20px; height: 20px; margin-right: 6px; border-radius: 50%; background: var(--ball); color: var(--ball-ink); font-weight: 700; font-size: 12px; }
.install-steps .icon { color: var(--ink); }

/* ---------- landing additions ---------- */

.signin .fine { font-size: 13px; color: var(--ink-3); }
.signin .step { display: grid; gap: 12px; animation: rise 420ms var(--ease) both; }
.signin .step[hidden] { display: none; }
.signin .sent { color: var(--ink-2); font-size: 15px; }
.signin .sent strong { color: var(--ink); word-break: break-all; }
.signin .otp { font-size: 24px; letter-spacing: 0.3em; text-align: center; }
.signin .or { display: flex; align-items: center; gap: 12px; color: var(--ink-3); font-size: 13px; }
.signin .or::before, .signin .or::after { content: ""; flex: 1; height: 1px; background: var(--edge); }
.signin details.dev summary { cursor: pointer; font-size: 13px; color: var(--ink-3); }
.signin details.dev form { display: grid; grid-template-columns: 1fr auto; gap: 10px; align-items: end; margin-top: 10px; }
.club-nights .photos { margin-top: 48px; display: grid; grid-template-columns: 1.45fr 1fr; gap: 20px; align-items: start; }
.photo { margin: 0; border-radius: var(--r-lg); overflow: hidden; box-shadow: var(--shadow), inset 0 1px 0 rgba(255, 255, 255, 0.2); border: 1px solid var(--edge); }
.photo img { display: block; width: 100%; height: 100%; object-fit: cover; aspect-ratio: 4 / 3; }
.photo:nth-child(2) { margin-top: 64px; }
.photo:nth-child(2) img { aspect-ratio: 4 / 5; object-position: 55% 50%; }
.quotes { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 20px; margin-top: 28px; }
.quotes:empty { display: none; }
.quote { margin: 0; padding: 28px; }
.quote blockquote { margin: 0; font-size: 19px; line-height: 1.5; color: var(--ink); }
.quote blockquote::before { content: "“"; display: block; font-size: 48px; line-height: 0.6; color: var(--ball); margin-bottom: 8px; }
.quote figcaption { margin-top: 18px; display: grid; font-size: 15px; }
.quote figcaption span { color: var(--ink-2); }
@media (max-width: 960px) { .club-nights .photos { grid-template-columns: 1fr; } .photo:nth-child(2) { margin-top: 0; } .photo:nth-child(2) img { aspect-ratio: 4 / 3; } }

/* Privacy policy (signed out uses the night page; signed in sits in the app). */
.policy { width: min(760px, calc(100% - 32px)); margin: 0 auto; padding: 40px 0 72px; }
body.app .policy { width: 100%; padding-top: 0; }
.policy h1 { font-size: clamp(34px, 5vw, 52px); letter-spacing: -0.035em; }
.policy h2 { margin-top: 36px; }
.policy p, .policy li { color: var(--ink-2); max-width: 68ch; }
.policy li + li { margin-top: 8px; }
.policy strong { color: var(--ink); }
body.doc .lfoot { margin-top: 0; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
  .reveal.pending { opacity: 1; transform: none; filter: none; }
}
