/*
 * MultiplayerTest web platform.
 *
 * Design rule: the interface is a pitch at night, drawn in chalk. Only the two teams get
 * colour (blue and orange); actions and text are chalk white on dark turf.
 */

@font-face {
  font-family: 'Hanken Grotesk';
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url('/fonts/hanken-grotesk-latin-ext.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

@font-face {
  font-family: 'Hanken Grotesk';
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url('/fonts/hanken-grotesk-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
  font-family: 'Big Shoulders Display';
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url('/fonts/big-shoulders-display-latin-ext.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

@font-face {
  font-family: 'Big Shoulders Display';
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url('/fonts/big-shoulders-display-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  /* Turf at night, from the deepest shade up */
  --turf-900: #0c1410;
  --turf-800: #121d17;
  --turf-700: #19271f;
  --turf-600: #22342a;
  --line: #2c4034;

  /* Chalk */
  --chalk: #eef3ea;
  --chalk-dim: #9db0a4;
  --chalk-mark: rgb(238 243 234 / 0.26);

  /* The two teams: the only saturated colours in the product */
  --blue: #5b97ff;
  --blue-wash: rgb(91 151 255 / 0.13);
  --orange: #ff8f33;
  --orange-wash: rgb(255 143 51 / 0.13);

  /* Rating movement */
  --up: #8fe3ab;
  --down: #ff8a80;

  --font-text: 'Hanken Grotesk', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-display: 'Big Shoulders Display', 'Hanken Grotesk', system-ui, sans-serif;

  --radius-s: 6px;
  --radius-m: 10px;
  --radius-l: 18px;
  --page: 1120px;
  --gutter: clamp(16px, 4vw, 32px);

  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--turf-900);
  color: var(--chalk);
  font: 400 1rem/1.5 var(--font-text);
  font-variant-numeric: tabular-nums;
}

h1, h2, h3, p, ul, ol, dl, dd, figure { margin: 0; }
ul, ol { padding: 0; list-style: none; }
img { display: block; max-width: 100%; }
a { color: inherit; }
button, input, select { font: inherit; color: inherit; }
table { border-collapse: collapse; width: 100%; }

:focus-visible {
  outline: 2px solid var(--chalk);
  outline-offset: 3px;
  border-radius: 4px;
}

main:focus { outline: none; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.skip-link {
  position: absolute;
  left: var(--gutter);
  top: -100px;
  z-index: 20;
  padding: 10px 16px;
  background: var(--chalk);
  color: var(--turf-900);
  border-radius: var(--radius-s);
  font-weight: 600;
}

.skip-link:focus { top: 12px; }

.noscript { padding: 24px var(--gutter); }

.muted { color: var(--chalk-dim); }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.text-link { text-underline-offset: 3px; }
.text-link:hover { text-decoration-thickness: 2px; }

/* Top bar ------------------------------------------------------------------------------ */

.topbar { border-bottom: 1px solid var(--line); background: var(--turf-800); }

.topbar-inner {
  display: flex;
  align-items: center;
  gap: 8px 28px;
  flex-wrap: wrap;
  max-width: var(--page);
  min-height: 64px;
  margin: 0 auto;
  padding: 10px var(--gutter);
}

.brand { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; }

/* The centre circle of a pitch with the halfway line through it */
.brand-mark {
  position: relative;
  width: 26px;
  height: 26px;
  border: 2px solid var(--chalk);
  border-radius: 50%;
}

.brand-mark::before {
  content: '';
  position: absolute;
  left: 50%;
  top: -7px;
  bottom: -7px;
  width: 2px;
  margin-left: -1px;
  background: var(--chalk);
}

.brand-name { font: 800 1.5rem/1 var(--font-display); letter-spacing: 0.01em; }

.nav { display: flex; gap: 4px; }

.nav-link {
  padding: 8px 12px;
  border-radius: var(--radius-s);
  color: var(--chalk-dim);
  font-weight: 500;
  text-decoration: none;
}

.nav-link:hover { color: var(--chalk); background: var(--turf-700); }
.nav-link[aria-current='page'] { color: var(--chalk); box-shadow: inset 0 -2px 0 var(--chalk); border-radius: var(--radius-s) var(--radius-s) 0 0; }

.account { display: flex; align-items: center; gap: 12px; margin-left: auto; min-height: 40px; }

.me {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 4px 10px 4px 4px;
  border-radius: 999px;
  background: var(--turf-700);
  text-decoration: none;
}

.me:hover { background: var(--turf-600); }
.me-name { max-width: 14ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }

.pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 0.875rem;
  font-weight: 600;
  text-decoration: none;
}

.pill:hover { border-color: var(--chalk-dim); }

.pulse {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--chalk);
  animation: pulse 1.4s ease-in-out infinite;
}

@keyframes pulse {
  50% { opacity: 0.25; }
}

/* Page ---------------------------------------------------------------------------------- */

.page {
  max-width: var(--page);
  margin: 0 auto;
  padding: clamp(24px, 5vw, 44px) var(--gutter) 72px;
}

.page-title {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  font: 800 clamp(2rem, 5vw, 2.75rem)/1.05 var(--font-display);
  letter-spacing: 0.005em;
}

.page-lead { margin-top: 6px; }
.page > .page-title + * { margin-top: 20px; }
.page > .page-title + .page-lead { margin-top: 6px; }
.page > .page-lead + * { margin-top: 20px; }

.panel {
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius-m);
  background: var(--turf-800);
}

.panel-flush { padding: 0; overflow: hidden; }
.panel > * + * { margin-top: 14px; }

.panel-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1.0625rem;
  font-weight: 650;
  line-height: 1.3;
}

.label { color: var(--chalk-dim); font-size: 0.8125rem; font-weight: 500; }
.hint { color: var(--chalk-dim); font-size: 0.8125rem; }

/* Controls ------------------------------------------------------------------------------ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 40px;
  padding: 8px 16px;
  border: 1px solid var(--chalk-dim);
  border-radius: var(--radius-s);
  background: transparent;
  color: var(--chalk);
  font-weight: 600;
  line-height: 1.2;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color 120ms, border-color 120ms;
}

.btn:hover { background: var(--turf-600); border-color: var(--chalk); }
.btn:active { transform: translateY(1px); }
.btn[aria-busy='true'] { opacity: 0.6; cursor: progress; }
.btn:disabled { opacity: 0.4; cursor: not-allowed; background: transparent; border-color: var(--chalk-dim); transform: none; }

.btn-primary { background: var(--chalk); border-color: var(--chalk); color: var(--turf-900); }
.btn-primary:hover { background: #fff; border-color: #fff; }
.btn-primary:disabled { background: var(--chalk); border-color: var(--chalk); }

.btn-quiet { border-color: transparent; color: var(--chalk-dim); }
.btn-quiet:hover { color: var(--chalk); border-color: transparent; }
.btn-quiet:disabled { border-color: transparent; }

.btn-sm { min-height: 34px; padding: 6px 12px; font-size: 0.875rem; }
.btn-lg { min-height: 52px; padding: 12px 24px; font-size: 1.0625rem; }

.input {
  min-height: 40px;
  min-width: 0;
  flex: 1;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-s);
  background: var(--turf-900);
}

.input::placeholder { color: #71857a; }
.input:hover { border-color: var(--chalk-dim); }
.input-code { font-weight: 600; letter-spacing: 0.12em; text-transform: uppercase; }
.input-code::placeholder { letter-spacing: 0; text-transform: none; font-weight: 400; }

.field-row { display: flex; gap: 8px; margin-top: 6px; }

.input[aria-invalid='true'] { border-color: var(--down); }

/* A drawn arrow, because the native one ignores the theme */
select.input {
  appearance: none;
  padding-right: 32px;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--chalk-dim) 50%),
    linear-gradient(135deg, var(--chalk-dim) 50%, transparent 50%);
  background-position: right 17px center, right 12px center;
  background-size: 5px 5px;
  background-repeat: no-repeat;
  cursor: pointer;
}

.field { display: grid; gap: 6px; min-width: 0; }
.field .input { width: 100%; }

/* The hint under a field, which turns into its error. Two lines are kept free for it, so
   that an error never pushes the page down. */
.field-note { min-height: 3em; margin-top: 8px; }
.field-note.is-error { color: var(--down); font-weight: 600; }

.tag {
  display: inline-block;
  padding: 2px 8px;
  border: 1px solid var(--line);
  border-radius: 4px;
  color: var(--chalk-dim);
  font: 600 0.75rem/1.4 var(--font-text);
  letter-spacing: 0;
  white-space: nowrap;
}

.tag-rated { border-color: var(--chalk-dim); color: var(--chalk); }

/* Player bits --------------------------------------------------------------------------- */

.avatar {
  flex: none;
  display: inline-grid;
  place-items: center;
  border-radius: 50%;
  background: var(--turf-600);
  color: var(--chalk);
  font-weight: 700;
  object-fit: cover;
}

.avatar-sm { width: 28px; height: 28px; font-size: 0.6875rem; }
.avatar-md { width: 40px; height: 40px; font-size: 0.875rem; }
.avatar-xl { width: 88px; height: 88px; font-size: 1.75rem; }

/* Level, in the manner of a shirt number */
.level {
  flex: none;
  display: inline-grid;
  place-items: center;
  min-width: 22px;
  height: 22px;
  padding: 0 5px;
  border: 1.5px solid var(--chalk-dim);
  border-radius: 5px;
  color: var(--chalk-dim);
  font: 800 0.9375rem/1 var(--font-display);
}

.level-mid { border-color: var(--chalk); color: var(--chalk); }
.level-top { border-color: var(--chalk); background: var(--chalk); color: var(--turf-900); }

.elo-inline { color: var(--chalk-dim); font-size: 0.875rem; font-weight: 500; }
.elo-strong { font-weight: 700; }

.player-link { font-weight: 600; text-decoration: none; }
.player-link:hover { text-decoration: underline; text-underline-offset: 3px; }

.player-cell { display: flex; align-items: center; gap: 8px; min-width: 0; }
.player-cell .team-dot { flex: none; margin-right: 0; }
.player-cell .player-link { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.delta { font-weight: 700; white-space: nowrap; }
.delta-up { color: var(--up); }
.delta-down { color: var(--down); }
.delta-none { color: var(--chalk-dim); font-weight: 500; }

.team-chip { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; }
.team-chip::before, .team-dot { content: ''; display: inline-block; width: 9px; height: 9px; border-radius: 2px; background: var(--chalk-dim); }
.team-dot { margin-right: 8px; }
.team-blue.team-chip::before, .team-dot.team-blue { background: var(--blue); }
.team-orange.team-chip::before, .team-dot.team-orange { background: var(--orange); }

/* Tables -------------------------------------------------------------------------------- */

.table-wrap { overflow-x: auto; }

.table th, .table td { padding: 12px 14px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
.table th, .table td { white-space: nowrap; }
.table thead th { color: var(--chalk-dim); font-size: 0.8125rem; font-weight: 500; }
.table tbody th { font-weight: 400; }
.table tbody tr:last-child > * { border-bottom: 0; }
.table .num { text-align: right; white-space: nowrap; }
/* The one column that gives way: it takes the spare width and truncates instead of pushing the others out. */
.table .col-grow { width: 100%; max-width: 0; }
.truncate-line { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.table tbody tr:hover { background: var(--turf-700); }
.table .is-me { background: var(--turf-700); box-shadow: inset 3px 0 0 var(--chalk); }

.panel > .table-wrap { margin-left: -20px; margin-right: -20px; padding: 0 6px; }

.table-rank .rank { width: 4ch; font: 800 1.375rem/1 var(--font-display); color: var(--chalk-dim); }
.table-rank tbody tr:nth-child(-n + 3) .rank { color: var(--chalk); }

.result { font-weight: 700; }
.result-win { color: var(--up); }
.result-loss { color: var(--down); }
.score-cell a { font: 800 1.25rem/1 var(--font-display); text-decoration: none; }
.score-cell a:hover { text-decoration: underline; text-underline-offset: 3px; }

/* States -------------------------------------------------------------------------------- */

.loading { display: flex; align-items: center; gap: 10px; padding: 28px 0; color: var(--chalk-dim); }

.spinner {
  flex: none;
  width: 16px;
  height: 16px;
  border: 2px solid var(--line);
  border-top-color: var(--chalk);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.empty { padding: 36px 20px; text-align: center; }
.empty > * + * { margin-top: 12px; }
.empty-title { font-weight: 650; font-size: 1.0625rem; }
.empty-hint { color: var(--chalk-dim); }

.toasts {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 30;
  display: grid;
  gap: 8px;
  width: min(92vw, 420px);
  transform: translateX(-50%);
  pointer-events: none;
}

.toast {
  padding: 12px 16px;
  border-radius: var(--radius-s);
  background: var(--chalk);
  color: var(--turf-900);
  font-weight: 600;
  box-shadow: 0 12px 32px rgb(0 0 0 / 0.45);
  animation: toast-in 160ms ease-out;
  transition: opacity 300ms;
}

.toast-error { background: #ffd9d4; color: #4a0d07; }
.toast-leaving { opacity: 0; }

@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

/* Pitch scoreboard ---------------------------------------------------------------------- */

.pitch {
  --circle: clamp(132px, 24vw, 232px);
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) var(--circle) minmax(0, 1fr);
  align-items: center;
  min-height: calc(var(--circle) + 72px);
  padding: 24px clamp(14px, 3vw, 40px);
  border: 2px solid var(--chalk-mark);
  border-radius: var(--radius-l);
  overflow: hidden;
  background:
    linear-gradient(90deg, var(--blue-wash), transparent 46%, transparent 54%, var(--orange-wash)),
    repeating-linear-gradient(90deg, #14231b 0 72px, #111e17 72px 144px);
}

/* Halfway line and centre circle */
.pitch::before {
  content: '';
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 2px;
  margin-left: -1px;
  background: var(--chalk-mark);
}

.pitch::after {
  content: '';
  position: absolute;
  left: 50%;
  top: 50%;
  width: var(--circle);
  height: var(--circle);
  border: 2px solid var(--chalk-mark);
  border-radius: 50%;
  transform: translate(-50%, -50%);
}

/* Goal areas at both ends */
.pitch-box {
  position: absolute;
  top: 27%;
  bottom: 27%;
  width: clamp(10px, 2.4vw, 30px);
  border: 2px solid var(--chalk-mark);
}

.pitch-box-left { left: -2px; border-left: 0; }
.pitch-box-right { right: -2px; border-right: 0; }

.pitch-half { position: relative; z-index: 1; min-width: 0; padding: 0 clamp(8px, 2vw, 28px); }
.pitch-orange { text-align: right; }

.pitch-team {
  display: flex;
  align-items: baseline;
  gap: 10px;
  font: 800 clamp(1.5rem, 3.6vw, 2.25rem)/1 var(--font-display);
}

.pitch-blue .pitch-team { color: var(--blue); }
.pitch-orange .pitch-team { color: var(--orange); flex-direction: row-reverse; }
.pitch-won { color: var(--chalk); font: 600 0.8125rem/1 var(--font-text); }

.pitch-players { display: grid; gap: 10px; margin-top: 14px; }
.pitch-player { display: flex; align-items: center; gap: 10px; min-width: 0; }
.pitch-orange .pitch-player { flex-direction: row-reverse; }
.pitch-player-text { display: grid; gap: 2px; min-width: 0; }
.pitch-player-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pitch-player-meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.pitch-orange .pitch-player-meta { flex-direction: row-reverse; }

.pitch-score {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: 1fr 1fr;
  justify-items: center;
  align-items: center;
}

.score { font: 900 clamp(3.25rem, 10vw, 6.5rem)/1 var(--font-display); }
.score:first-child { color: var(--blue); }
.score:last-child { color: var(--orange); }
.score-lost { opacity: 0.42; }
.score-idle { opacity: 0.28; }

.pitch-compact { --circle: clamp(112px, 16vw, 150px); padding: 18px clamp(12px, 2vw, 22px); }
.pitch-compact .score { font-size: clamp(2.75rem, 6vw, 4rem); }
.pitch-compact .pitch-team { font-size: 1.375rem; }
.pitch-compact .pitch-half { padding: 0 8px; }
.pitch-compact .avatar { display: none; }

.pitch-link { display: block; border-radius: var(--radius-l); text-decoration: none; }
.pitch-link:hover .pitch { border-color: var(--chalk-dim); }

/* Match lists --------------------------------------------------------------------------- */

.match-row {
  display: flex;
  align-items: center;
  gap: 8px 20px;
  flex-wrap: wrap;
  padding: 12px 20px;
  border-bottom: 1px solid var(--line);
}

.match-row:last-child { border-bottom: 0; }
.match-row:hover { background: var(--turf-700); }
/* Fixed width, so the scores of all rows line up under each other */
.match-row-meta { display: flex; justify-content: flex-end; gap: 16px; flex: 0 0 15rem; margin-left: auto; font-size: 0.875rem; white-space: nowrap; }

.match-line {
  flex: 1 1 320px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  gap: 16px;
  text-decoration: none;
}

.match-line-team { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--chalk-dim); }
.match-line-team.is-winner { color: var(--chalk); font-weight: 650; }
.match-line-blue { text-align: right; }
.match-line-blue::after, .match-line-orange::before { content: ''; display: inline-block; width: 9px; height: 9px; border-radius: 2px; }
.match-line-blue::after { margin-left: 10px; background: var(--blue); }
.match-line-orange::before { margin-right: 10px; background: var(--orange); }
.match-line-score { display: inline-flex; gap: 6px; font: 800 1.5rem/1 var(--font-display); }
.match-line-score .is-loser { opacity: 0.45; }
.match-line-dash { color: var(--chalk-dim); }

.match-list-plain .match-row { padding: 10px 4px; }

/* Landing ------------------------------------------------------------------------------- */

.landing-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(0, 0.95fr);
  gap: clamp(28px, 5vw, 64px);
  align-items: start;
  padding-top: clamp(8px, 4vw, 40px);
}

.display {
  font: 900 clamp(2.75rem, 7.4vw, 5.25rem)/0.96 var(--font-display);
  letter-spacing: 0.002em;
  text-wrap: balance;
}

.lead { max-width: 46ch; margin-top: 20px; color: var(--chalk-dim); font-size: 1.125rem; }
.signin { display: grid; gap: 24px; justify-items: start; margin-top: 32px; }
.dev-login { width: min(100%, 380px); }
.dev-form .hint { margin-top: 8px; }
.landing-results > * + * { margin-top: 14px; }

/* Play ---------------------------------------------------------------------------------- */

.play-banner:empty { display: none; }
.game-download { margin-top: 16px; }
.play .game-download { margin: 0 0 16px; }

.banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px 20px;
  flex-wrap: wrap;
  padding: 14px 20px;
  border: 1px solid var(--chalk-dim);
  border-radius: var(--radius-m);
  background: var(--turf-700);
  text-decoration: none;
}

.banner:hover { border-color: var(--chalk); }
.banner-action { font-weight: 700; text-decoration: underline; text-underline-offset: 3px; }

.play-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(280px, 1fr);
  gap: 20px;
  align-items: start;
  margin-top: 20px;
}

.queue-list { margin: 0 -20px; }

.queue {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto 150px;
  align-items: center;
  gap: 8px 20px;
  min-height: 84px;
  padding: 14px 20px;
  border-top: 1px solid var(--line);
}

.queue.is-active { background: var(--turf-700); box-shadow: inset 3px 0 0 var(--chalk); }
.queue .btn { width: 100%; }
.queue-name { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; font: 800 1.625rem/1.1 var(--font-display); }
.queue-meta { margin-top: 2px; color: var(--chalk-dim); font-size: 0.875rem; }
.queue-meta.is-blocked { color: var(--chalk); }
.queue-status { display: inline-flex; align-items: center; gap: 8px; color: var(--chalk-dim); font-size: 0.875rem; white-space: nowrap; }
.queue-status.is-searching { color: var(--chalk); font-weight: 600; }
.queue-elapsed { min-width: 4ch; }
.queue-note { min-height: 1.5em; padding-top: 14px; border-top: 1px solid var(--line); margin: 0 -20px; padding-left: 20px; padding-right: 20px; color: var(--chalk-dim); font-size: 0.875rem; box-sizing: content-box; }

.party > * + * { margin-top: 16px; }
.party-join { padding-top: 16px; border-top: 1px solid var(--line); }

.invite { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.invite-code { font: 800 2.25rem/1 var(--font-display); letter-spacing: 0.12em; user-select: all; }

.member-list { display: grid; gap: 12px; padding: 16px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.member { display: flex; align-items: center; gap: 10px; min-width: 0; }
.member-text { display: grid; gap: 2px; min-width: 0; margin-right: auto; }
.member-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.member-meta { display: flex; align-items: center; gap: 8px; }

/* Match room ---------------------------------------------------------------------------- */

.match > * + * { margin-top: 20px; }
.match > :empty { display: none; }
.match-title-row { display: flex; align-items: center; justify-content: space-between; gap: 8px 20px; flex-wrap: wrap; }
.match-head .muted { margin-top: 4px; }

.status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-weight: 600;
  white-space: nowrap;
}

.status-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--chalk-dim); }
.status-allocating .status-dot, .status-ready .status-dot, .status-live .status-dot { background: var(--chalk); animation: pulse 1.4s ease-in-out infinite; }
.status-live { border-color: var(--chalk); }
.status-cancelled { color: var(--chalk-dim); }

.connect { border-color: var(--chalk-dim); }
.connect-command { display: flex; gap: 10px; align-items: stretch; flex-wrap: wrap; }

.command {
  flex: 1 1 280px;
  min-width: 0;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-s);
  background: var(--turf-900);
  font: 500 0.9375rem/1.4 ui-monospace, 'Cascadia Mono', Consolas, monospace;
  overflow-x: auto;
  white-space: nowrap;
  user-select: all;
}

.connect-facts { display: flex; gap: 12px 40px; flex-wrap: wrap; }
.connect-facts > div { min-width: 0; }
.connect-facts dt { color: var(--chalk-dim); font-size: 0.8125rem; }
.connect-facts dd { max-width: 28ch; font-weight: 600; }

.timeline { margin: 0 -20px; }

.tl {
  display: grid;
  grid-template-columns: 5ch minmax(0, 1fr) auto;
  align-items: baseline;
  gap: 14px;
  padding: 9px 20px;
  border-left: 3px solid transparent;
}

.tl-time { color: var(--chalk-dim); font-size: 0.875rem; text-align: right; }
.tl-minor, .tl-kicks { color: var(--chalk-dim); font-size: 0.875rem; }
.tl-mark { margin: 4px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.tl-goal { background: var(--turf-700); font-size: 1.0625rem; }
.tl-goal.team-blue { border-left-color: var(--blue); }
.tl-goal.team-orange { border-left-color: var(--orange); }
.tl-score { font: 800 1.5rem/1 var(--font-display); }
.tl-kicks details { grid-column: 2 / -1; }
.tl-kicks summary { display: inline-block; cursor: pointer; text-decoration: underline dotted; text-underline-offset: 3px; list-style: none; }
.tl-kicks summary::-webkit-details-marker { display: none; }
.tl-kicks summary:hover { color: var(--chalk); }
.tl-kick-list { display: grid; gap: 4px; padding: 8px 0 4px; }
.tl-kick-list li { display: flex; align-items: center; gap: 0; }
.tl-kick-list .tl-time { width: 5ch; margin-right: 12px; }

/* Profile ------------------------------------------------------------------------------- */

.profile > * + * { margin-top: 24px; }
.profile-head { display: flex; align-items: center; gap: 20px; flex-wrap: wrap; }
.profile-id { min-width: 0; margin-right: auto; }
.profile-rank { display: flex; align-items: center; gap: 10px; margin-top: 8px; color: var(--chalk-dim); }
.profile-elo { display: grid; justify-items: end; }
.profile-elo-value { font: 900 clamp(3rem, 9vw, 4.75rem)/0.9 var(--font-display); }
.profile-elo-label { color: var(--chalk-dim); font-size: 0.875rem; }

.facts {
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.fact { padding: 14px 12px 14px 0; }
.fact dt { color: var(--chalk-dim); font-size: 0.8125rem; }
.fact dd { font: 800 1.75rem/1.1 var(--font-display); }

/* Device link --------------------------------------------------------------------------- */

.page.page-narrow { max-width: 640px; }

.link-panel { padding: clamp(20px, 5vw, 32px); }
.link-panel > * + * { margin-top: 22px; }
.link-panel > .loading { padding: 8px 0; }
.link-panel .signin { margin-top: 0; }
.link-panel .signin:not(:first-child) { margin-top: 22px; padding-top: 22px; border-top: 1px solid var(--line); }

.link-message > * + * { margin-top: 8px; }
.link-form .field-note { min-height: 1.5em; }
.link-question { font-size: 1.25rem; }
.link-headline { font: 800 clamp(1.875rem, 7vw, 2.5rem)/1.05 var(--font-display); letter-spacing: 0.005em; }
.link-question:focus, .link-headline:focus { outline: none; }

.link-code {
  margin-top: 2px;
  font: 900 clamp(2.75rem, 14vw, 4.75rem)/1 var(--font-display);
  letter-spacing: 0.08em;
  white-space: nowrap;
  user-select: all;
}

.link-expiry { margin-top: 8px; font-size: 0.875rem; }
.link-who .member { margin-top: 8px; }

.link-warning {
  padding: 14px 16px;
  border-radius: var(--radius-s);
  background: var(--turf-700);
  box-shadow: inset 3px 0 0 var(--chalk);
  color: var(--chalk-dim);
  font-size: 0.9375rem;
}

.link-warning strong { color: var(--chalk); font-weight: 650; }

.link-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.link-actions .btn-lg { flex: 1 1 130px; }
.link-actions .btn-primary.btn-lg { flex: 2 1 200px; }

/* Communities --------------------------------------------------------------------------- */

.community-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(280px, 1fr);
  gap: 20px;
  align-items: start;
}

.community-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px 20px;
  flex-wrap: wrap;
  min-height: 68px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--line);
  text-decoration: none;
}

li:last-child > .community-row { border-bottom: 0; }
.community-row:hover { background: var(--turf-700); }
.community-row:focus-visible { outline-offset: -3px; }
.community-row-name { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; min-width: 0; font: 800 1.625rem/1.1 var(--font-display); overflow-wrap: anywhere; }
.community-row-members { color: var(--chalk-dim); font-size: 0.875rem; white-space: nowrap; }
.community-start > * + * { margin-top: 14px; }

.community > * + * { margin-top: 20px; }
.community-head > * + * { margin-top: 6px; }
.community-title-row { display: flex; align-items: center; justify-content: space-between; gap: 8px 20px; flex-wrap: wrap; }
.community-title-row .page-title { min-width: 0; overflow-wrap: anywhere; }
/* As tall as the button it may hold, so joining does not move the page */
.community-membership { display: flex; align-items: center; min-height: 40px; }

.community-head > .community-rule {
  margin-top: 16px;
  padding: 12px 16px;
  border-radius: var(--radius-s);
  background: var(--turf-700);
  box-shadow: inset 3px 0 0 var(--chalk);
  color: var(--chalk-dim);
}

.community-rule strong { color: var(--chalk); font-weight: 650; }

.community-detail {
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr);
  /* The second row takes what a long standings table needs, so the queues stay compact */
  grid-template-rows: auto 1fr;
  grid-template-areas: 'queues standings' 'matches standings';
}

.community-queues { grid-area: queues; }
.community-standings { grid-area: standings; container-type: inline-size; }
.community-matches { grid-area: matches; }

/* Where "Find match" would be, for someone who is not a member. Same height as the button. */
.queue-locked { display: grid; place-items: center; min-height: 40px; color: var(--chalk-dim); font-size: 0.875rem; font-weight: 600; white-space: nowrap; }

.queue-form-box:empty { display: none; }
.queue-form { margin: 0 -20px; padding: 16px 20px 0; border-top: 1px solid var(--line); }
.queue-form-title { font-size: 0.9375rem; font-weight: 650; }
.queue-form-fields { display: grid; grid-template-columns: minmax(0, 1fr) 6.5rem 7rem auto; gap: 8px 10px; align-items: end; margin-top: 10px; }

.community-standings .table-wrap { margin: 0 -20px -12px; padding: 0 6px; }
.table-standings .tag { flex: none; }

/* In a narrow column the name needs the room more than the avatar does */
@container (max-width: 420px) {
  .table-standings .avatar { display: none; }
  .table-standings th, .table-standings td { padding-left: 10px; padding-right: 10px; }
}

.community-matches .match-list { margin: 0 -20px -20px; border-top: 1px solid var(--line); }
.community-matches .match-row:last-child { border-radius: 0 0 var(--radius-m) var(--radius-m); }

.community-foot { display: flex; align-items: center; gap: 4px 24px; flex-wrap: wrap; font-size: 0.875rem; }
.community-foot .btn { margin-left: -12px; }
.community-foot:empty { display: none; }

/* Small screens ------------------------------------------------------------------------- */

@media (max-width: 1040px) {
  .community-detail { grid-template-columns: minmax(0, 1fr); grid-template-rows: none; grid-template-areas: 'queues' 'standings' 'matches'; }
}

/* Four navigation items and a signed-in account share one row down to about 870 px */
@media (max-width: 960px) {
  .topbar-inner { gap: 8px 16px; }
  .nav-link { padding: 8px 10px; }
  .me .elo-inline { display: none; }
}

@media (max-width: 860px) {
  .landing-grid, .play-grid, .community-grid { grid-template-columns: minmax(0, 1fr); }
  .facts { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

@media (max-width: 640px) {
  .topbar-inner { gap: 6px 12px; }
  /* Four items fit a 390 px phone with this padding. Narrower, they shrink a little (below) and wrap if they must. */
  .nav { order: 3; width: 100%; margin: 0 -8px; gap: 2px; flex-wrap: wrap; }
  .nav-link { padding: 8px; }
  .me-name, .me .elo-inline { display: none; }
  .me { padding: 4px 8px 4px 4px; }
  .hide-sm { display: none; }

  .queue { grid-template-columns: minmax(0, 1fr); gap: 8px; }
  .queue-locked { justify-items: start; }
  .queue-form-fields { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .queue-form-fields .field-name, .queue-form-fields .btn { grid-column: 1 / -1; }

  .pitch { padding: 18px 6px; }
  .pitch-half { padding: 0 6px; }
  .pitch .avatar { display: none; }
  .pitch-won { display: none; }
  .pitch-player-meta { gap: 6px; }
  .pitch-player-meta .elo-inline { display: none; }

  .table th, .table td { padding: 10px 10px; }
  .match-row { padding: 12px 14px; }
  .match-row-meta { flex: 1 1 100%; margin-left: 0; justify-content: space-between; }
  .match-line { gap: 10px; }
  .tl { grid-template-columns: 4ch minmax(0, 1fr) auto; gap: 10px; }
  .profile-elo { justify-items: start; }
}

@media (max-width: 380px) {
  .nav-link { padding: 8px 6px; font-size: 0.9375rem; }
}

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