/* WikiRace: styled as an extension of Wikipedia (Vector 2022 skin, Wikimedia Codex controls). */

:root {
  --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Lato, Helvetica, Arial, sans-serif;
  --font-serif: 'Linux Libertine', Georgia, Times, 'Source Serif 4', serif;
  --font-mono: Menlo, Consolas, 'Liberation Mono', 'Courier New', monospace;

  --radius: 2px;
  --hud-h: 44px;
  --rail-w: 280px;
  --page-w: 1280px;
  --gutter: 44px;
  --shadow-menu: 0 2px 2px 0 rgb(0 0 0 / 20%);
}

:root,
:root[data-theme='light'] {
  color-scheme: light;
  --bg: #ffffff;
  --bg-subtle: #f8f9fa;
  --bg-neutral: #eaecf0;
  --bg-pressed: #dadde3;
  --bg-progressive-subtle: #eaf3ff;
  --bg-disabled: #c8ccd1;
  --ink: #202122;
  --ink-subtle: #54595d;
  --ink-placeholder: #72777d;
  --ink-on-disabled: #ffffff;
  --border: #a2a9b1;
  --border-subtle: #c8ccd1;
  --border-muted: #eaecf0;
  --border-input: #72777d;
  --link: #3366cc;
  --link-hover: #447ff5;
  --link-active: #2a4b8d;
  --progressive: #3366cc;
  --progressive-hover: #447ff5;
  --progressive-active: #2a4b8d;
  --destructive: #dd3333;
  --destructive-hover: #ff4242;
  --destructive-active: #b32424;
  --destructive-subtle: #ffe9e5;
  --success: #14866d;
  --success-subtle: #dff2eb;
  --warning: #ab7f2a;
  --warning-icon: #edab00;
  --warning-subtle: #fdf2d5;
  --redlink: #ba0000;
  --navbox-title: #ccccff;
  --navbox-group: #ddddff;
  --navbox-list: #fdfdfd;
  --scrim: rgb(255 255 255 / 65%);
}

:root[data-theme='dark'] {
  color-scheme: dark;
  --bg: #101418;
  --bg-subtle: #202122;
  --bg-neutral: #27292d;
  --bg-pressed: #404244;
  --bg-progressive-subtle: #233566;
  --bg-disabled: #404244;
  --ink: #eaecf0;
  --ink-subtle: #a2a9b1;
  --ink-placeholder: #8b9198;
  --ink-on-disabled: #101418;
  --border: #72777d;
  --border-subtle: #54595d;
  --border-muted: #404244;
  --border-input: #a2a9b1;
  --link: #6d8af2;
  --link-hover: #88a3e8;
  --link-active: #b0c1f0;
  --progressive: #3366cc;
  --progressive-hover: #447ff5;
  --progressive-active: #2a4b8d;
  --destructive: #fd7865;
  --destructive-hover: #fea898;
  --destructive-active: #ffc8bd;
  --destructive-subtle: #612419;
  --success: #2cb491;
  --success-subtle: #153d36;
  --warning: #ca982e;
  --warning-icon: #edab00;
  --warning-subtle: #453217;
  --redlink: #fd7865;
  --navbox-title: #2d3166;
  --navbox-group: #242850;
  --navbox-list: #16191e;
  --scrim: rgb(0 0 0 / 65%);
  --shadow-menu: 0 2px 2px 0 rgb(0 0 0 / 60%);
}

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

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 14px/1.5714 var(--font-sans);
  min-height: 100vh;
}

[hidden] {
  display: none !important;
}

.sprite {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

.ic,
.brand-mark svg {
  width: 16px;
  height: 16px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.ic .fill,
symbol .fill {
  fill: currentColor;
  stroke: none;
}

a {
  color: var(--link);
  text-decoration: none;
}

a:hover {
  color: var(--link-hover);
  text-decoration: underline;
}

a:active {
  color: var(--link-active);
}

button,
input {
  font: inherit;
  color: inherit;
}

:focus-visible {
  outline: 2px solid var(--progressive);
  outline-offset: 1px;
}

.mono {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

/* ---------- Buttons (Codex) ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 32px;
  padding: 4px 11px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-subtle);
  color: var(--ink);
  font-weight: 700;
  font-size: 14px;
  line-height: 1.4;
  cursor: pointer;
  white-space: nowrap;
}

.btn:not(:disabled):hover {
  background: var(--bg-neutral);
}

.btn:not(:disabled):active {
  background: var(--bg-pressed);
  border-color: var(--border-input);
}

.btn:focus-visible {
  outline: 0;
  border-color: var(--progressive);
  box-shadow: inset 0 0 0 1px var(--progressive);
}

.btn:disabled {
  background: var(--bg-disabled);
  border-color: var(--bg-disabled);
  color: var(--ink-on-disabled);
  cursor: default;
}

.btn-lg {
  min-height: 40px;
  padding: 6px 20px;
  font-size: 15px;
}

.btn-primary {
  background: var(--progressive);
  border-color: var(--progressive);
  color: #ffffff;
}

.btn-primary .ic {
  fill: currentColor;
}

.btn-primary:not(:disabled):hover {
  background: var(--progressive-hover);
  border-color: var(--progressive-hover);
}

.btn-primary:not(:disabled):active {
  background: var(--progressive-active);
  border-color: var(--progressive-active);
}

.btn-primary:focus-visible {
  box-shadow: inset 0 0 0 1px var(--progressive), inset 0 0 0 2px #ffffff;
}

.btn-quiet,
.btn-quiet-danger {
  background: transparent;
  border-color: transparent;
}

.btn-quiet:disabled,
.btn-quiet-danger:disabled {
  background: transparent;
  border-color: transparent;
  color: var(--border);
}

.btn-quiet-danger {
  color: var(--destructive);
}

.btn-quiet-danger:not(:disabled):hover {
  background: var(--destructive-subtle);
}

.btn-quiet-danger.is-armed,
.btn-quiet-danger.is-armed:not(:disabled):hover {
  background: #dd3333;
  border-color: #dd3333;
  color: #ffffff;
}

/* Inline copy confirmation ("Copied!") instead of a toast over the page. */
.btn.is-copied,
.btn.is-copied:not(:disabled):hover {
  border-color: var(--success);
  color: var(--success);
  background: var(--success-subtle);
}

.btn.is-copy-failed,
.btn.is-copy-failed:not(:disabled):hover {
  border-color: var(--warning);
  color: var(--warning);
}

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  flex: none;
}

.icon-btn .ic {
  width: 18px;
  height: 18px;
}

.icon-btn:not(:disabled):hover {
  background: var(--bg-neutral);
}

.icon-btn.is-bordered {
  border-color: var(--border);
  background: var(--bg-subtle);
}

.icon-btn:disabled {
  color: var(--border);
  cursor: default;
}

.icon-btn.is-bordered:disabled {
  background: var(--bg-disabled);
  border-color: var(--bg-disabled);
  color: var(--ink-on-disabled);
}

.link-btn {
  padding: 0;
  border: 0;
  background: none;
  color: var(--link);
  font-size: 12px;
  cursor: pointer;
}

.link-btn:hover {
  color: var(--link-hover);
  text-decoration: underline;
}

.theme-toggle .ic-moon {
  display: none;
}

:root[data-theme='dark'] .theme-toggle .ic-sun {
  display: none;
}

:root[data-theme='dark'] .theme-toggle .ic-moon {
  display: block;
}

.tag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--ink-subtle);
  font: 400 13px/1.4 var(--font-sans);
  white-space: nowrap;
}

.tag:empty {
  display: none;
}

.tag .ic {
  width: 14px;
  height: 14px;
}

.hint {
  margin: 0;
  color: var(--ink-subtle);
  font-size: 13px;
}

/* ---------- Site header ---------- */

.topbar {
  display: flex;
  align-items: center;
  gap: 16px 28px;
  min-height: 56px;
  padding: 8px max(var(--gutter), calc((100% - var(--page-w)) / 2));
  background: var(--bg);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--ink);
  flex: none;
}

.brand:hover {
  color: var(--ink);
  text-decoration: none;
}

.brand-mark {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
}

.brand-mark svg {
  width: 30px;
  height: 30px;
  stroke-width: 1.5;
}

.brand-text {
  display: grid;
  gap: 3px;
}

/* Small-caps serif wordmark, in the manner of the Wikipedia wordmark. */
.brand-word {
  font: 400 25px/1 var(--font-serif);
  font-variant-caps: small-caps;
  letter-spacing: 0.01em;
}

.brand-tag {
  font: 400 11.5px/1 var(--font-serif);
  letter-spacing: 0.02em;
}

/* Room code and copy button, joined like the search field and its button. */
.topbar-room {
  display: flex;
  align-items: stretch;
  min-width: 0;
}

.room-field {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  min-height: 32px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-right: 0;
  border-radius: var(--radius) 0 0 var(--radius);
  background: var(--bg);
}

.room-label {
  color: var(--ink-subtle);
}

.room-code {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 34vw;
  font: 14px var(--font-mono);
}

.topbar-room .btn {
  border-radius: 0 var(--radius) var(--radius) 0;
}

.topbar-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 12px;
}

.net-status {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--ink-subtle);
  font-size: 13px;
}

.net-status .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--success);
}

.net-status[data-level='warn'] .dot {
  background: var(--warning-icon);
}

/* ---------- Page chrome shared by the lobby and results ---------- */

.view {
  width: min(var(--page-w), 100% - 2 * var(--gutter));
  margin: 0 auto;
}

.view-lobby,
.view-results {
  padding: 8px 0 0;
}

.page-title {
  margin: 0;
  padding: 0 0 3px;
  border-bottom: 1px solid var(--border);
  font: 400 28.8px/1.375 var(--font-serif);
  overflow-wrap: anywhere;
}

.page-toolbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  min-height: 38px;
  border-bottom: 1px solid var(--border-subtle);
}

/* The one selected namespace tab of a special page. */
.page-tab {
  margin-bottom: -1px;
  padding: 12px 0 6px;
  border-bottom: 2px solid var(--ink);
  line-height: 1.4;
}

.page-toolbar .tag,
.res-status {
  padding-bottom: 8px;
  color: var(--ink-subtle);
  font-size: 13px;
  line-height: 1.4;
}

.site-sub {
  margin: 8px 0 0;
  font-size: 13px;
}

.sec-h {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin: 26px 0 12px;
  padding: 0 0 2px;
  border-bottom: 1px solid var(--border);
  font: 400 24px/1.375 var(--font-serif);
}

/* Heading annotation, set like a section's [edit] link. */
.sec-h .tag::before {
  content: '[';
  margin-right: -3px;
}

.sec-h .tag::after {
  content: ']';
  margin-left: -3px;
}

.sub-h {
  margin: 20px 0 8px;
  font: 700 16.8px/1.4 var(--font-sans);
}

/* Sidebar headings, like the pinned Appearance and Tools menus. */
.pin-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border-subtle);
}

.pin-head h2 {
  margin: 0;
  font: 700 14px/1.5714 var(--font-sans);
}

.pin-sub {
  margin: 0 0 4px;
  color: var(--ink-subtle);
  font: 400 13px/1.5 var(--font-sans);
}

.site-foot {
  margin: 40px 0 0;
  padding: 14px 0 28px;
  border-top: 1px solid var(--border-subtle);
  color: var(--ink-subtle);
  font-size: 12.6px;
}

/* ---------- Lobby ---------- */

.lobby-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) var(--rail-w);
  gap: 0 var(--gutter);
  align-items: start;
}

.lobby-main {
  min-width: 0;
}

.lobby-main > section:first-child .sec-h {
  margin-top: 18px;
}

.matchup {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 40px minmax(0, 1fr);
  align-items: stretch;
}

.match-arrow {
  display: grid;
  place-items: center;
  color: var(--ink-subtle);
}

.match-arrow .ic {
  width: 22px;
  height: 22px;
}

/* Start and target panels, built like an infobox: header band, then the entry. */
.match-card {
  display: flex;
  flex-direction: column;
  min-width: 0;
  border: 1px solid var(--border);
  background: var(--bg-subtle);
}

.mc-head {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 3px 10px;
  background: var(--bg-neutral);
  font-weight: 700;
  font-size: 13px;
}

.is-target .mc-head {
  background: var(--bg-progressive-subtle);
}

.mc-head .ic {
  width: 14px;
  height: 14px;
}

.mc-body {
  flex: 1;
  min-height: 124px;
  padding: 10px 14px 12px;
}

.mc-body::after {
  content: '';
  display: block;
  clear: both;
}

.mc-thumb {
  float: right;
  width: 100px;
  height: 100px;
  margin: 2px 0 4px 14px;
  border: 1px solid var(--border-subtle);
  background: var(--bg);
  object-fit: cover;
}

.mc-title {
  margin: 0;
  font: 400 22px/1.3 var(--font-serif);
  overflow-wrap: anywhere;
}

.mc-desc {
  margin: 1px 0 0;
  color: var(--ink-subtle);
  font-size: 13px;
}

.mc-extract {
  margin: 8px 0 0;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.mc-empty {
  margin: 0;
  color: var(--ink-subtle);
  font-style: italic;
}

.hero-actions {
  display: flex;
  align-items: center;
  gap: 8px 14px;
  flex-wrap: wrap;
  margin-top: 14px;
}

/* Pack tabs (Codex tabs: bold labels, blue underline on the selected one). */
.pack-tabs {
  display: flex;
  flex-wrap: wrap;
  margin-bottom: 10px;
  box-shadow: inset 0 -1px 0 var(--border);
}

.pack-tab {
  padding: 7px 14px 9px;
  border: 0;
  border-radius: var(--radius) var(--radius) 0 0;
  background: transparent;
  color: var(--ink);
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
}

.pack-tab:hover {
  color: var(--link-hover);
  box-shadow: inset 0 -2px 0 var(--link-hover);
}

.pack-tab[aria-selected='true'] {
  color: var(--link);
  box-shadow: inset 0 -2px 0 var(--link);
}

.pack-blurb {
  margin: 0 0 4px;
  color: var(--ink-subtle);
  font-size: 13px;
}

/* Pairs read as a bulleted list of article links. */
.pair-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(270px, 1fr));
  gap: 0 24px;
}

.pair {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  padding: 4px 8px;
  border: 0;
  border-radius: var(--radius);
  background: transparent;
  color: var(--link);
  font-size: 14px;
  line-height: 1.5714;
  text-align: left;
  cursor: pointer;
}

.pair::before {
  content: '';
  flex: none;
  width: 5px;
  height: 5px;
  margin-right: 4px;
  border-radius: 50%;
  background: var(--ink-subtle);
}

.pair .ic {
  width: 13px;
  height: 13px;
  color: var(--ink-subtle);
}

.pair:hover:not(:disabled) {
  color: var(--link-hover);
}

.pair:hover:not(:disabled) span {
  text-decoration: underline;
}

.pair:disabled {
  color: var(--ink);
  cursor: default;
}

.pair.is-current {
  background: var(--bg-progressive-subtle);
  color: var(--ink);
  font-weight: 700;
}

.setup-row {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-top: 14px;
}

.custom-fields {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 10px;
  align-items: end;
}

.combo {
  position: relative;
  min-width: 0;
}

.combo.is-open {
  z-index: 85;
}

.combo label {
  display: block;
  margin-bottom: 4px;
  font-weight: 700;
}

.me label {
  display: block;
  margin-bottom: 4px;
  color: var(--ink-subtle);
  font-size: 13px;
}

/* Text inputs (Codex). */
.combo-box,
.me input,
.invite-row input {
  height: 32px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--ink);
  font-size: 14px;
}

.combo-box {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 8px;
}

.combo-box:focus-within,
.me input:focus,
.invite-row input:focus {
  outline: 0;
  border-color: var(--progressive);
  box-shadow: inset 0 0 0 1px var(--progressive);
}

.combo-box .ic {
  color: var(--ink-subtle);
}

.combo-box input {
  flex: 1;
  min-width: 0;
  height: 100%;
  padding: 0;
  border: 0;
  outline: 0;
  background: transparent;
}

.combo-box input::placeholder {
  color: var(--ink-placeholder);
  opacity: 1;
}

.combo-box:has(input:disabled) {
  background: var(--bg-neutral);
  border-color: var(--border-subtle);
}

.combo-box:has(input:disabled) .ic,
.combo-box input:disabled::placeholder {
  color: var(--border);
}

/* Suggestions menu, like the search suggestions. */
.combo-list {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  z-index: 90;
  margin: 0;
  padding: 0;
  list-style: none;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-menu);
  max-height: 360px;
  overflow-y: auto;
}

.combo-option {
  display: grid;
  grid-template-columns: 40px 1fr;
  gap: 10px;
  align-items: center;
  padding: 6px 10px;
  cursor: pointer;
}

.combo-option:hover {
  background: var(--bg-neutral);
}

.combo-option[aria-selected='true'] {
  background: var(--bg-progressive-subtle);
}

.combo-option img,
.combo-option .co-ph {
  width: 40px;
  height: 40px;
  object-fit: cover;
  background: var(--bg-neutral);
}

.co-title {
  display: block;
  font-weight: 700;
  line-height: 1.35;
}

.co-desc {
  display: block;
  font-size: 13px;
  color: var(--ink-subtle);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.combo-empty {
  padding: 8px 10px;
  color: var(--ink-subtle);
  font-size: 13px;
}

.custom-actions {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-top: 10px;
}

/* Rules: Codex checkboxes with a label and a description. */
.rule-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px 32px;
}

.rule {
  position: relative;
  display: grid;
  grid-template-columns: 20px 1fr;
  gap: 8px;
  align-items: start;
  cursor: pointer;
}

.rule input {
  position: absolute;
  top: 1px;
  left: 0;
  width: 20px;
  height: 20px;
  margin: 0;
  opacity: 0;
  cursor: inherit;
}

.check {
  width: 20px;
  height: 20px;
  margin-top: 1px;
  border: 1px solid var(--border-input);
  border-radius: var(--radius);
  background: var(--bg) center / 20px 20px no-repeat;
}

.rule:hover input:not(:disabled) + .check {
  border-color: var(--progressive-hover);
}

.rule input:checked + .check {
  background-color: var(--progressive);
  border-color: var(--progressive);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3E%3Cpath d='M4.6 10.4l3.5 3.5 7.3-7.8' fill='none' stroke='white' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}

.rule input:disabled + .check {
  background-color: var(--bg-disabled);
  border-color: var(--bg-disabled);
}

.rule input:focus-visible + .check {
  outline: 2px solid var(--progressive);
  outline-offset: 1px;
}

.rule:has(input:disabled) {
  cursor: default;
}

.rule-text b {
  display: block;
  font-weight: 400;
}

.rule-text small {
  display: block;
  color: var(--ink-subtle);
  font-size: 13px;
}

/* Racers sidebar */
.side {
  min-width: 0;
  padding-top: 24px;
}

.me input {
  width: 100%;
  padding: 0 8px;
}

.swatches {
  display: flex;
  gap: 8px;
  margin-top: 10px;
  flex-wrap: wrap;
}

.swatch {
  width: 20px;
  height: 20px;
  padding: 0;
  border: 0;
  border-radius: var(--radius);
  cursor: pointer;
}

.swatch[aria-checked='true'] {
  outline: 2px solid var(--ink);
  outline-offset: 2px;
}

.roster {
  list-style: none;
  margin: 16px 0 0;
  padding: 0;
  border-top: 1px solid var(--border-muted);
}

.roster li {
  display: grid;
  grid-template-columns: 10px minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
  border-bottom: 1px solid var(--border-muted);
}

.p-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--c, var(--ink-subtle));
  flex: none;
}

.p-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.p-you {
  color: var(--ink-subtle);
}

.p-meta {
  display: inline-flex;
  gap: 6px;
  align-items: center;
  color: var(--ink-subtle);
  font-size: 12px;
}

.p-meta .ic {
  width: 14px;
  height: 14px;
}

.p-meta .host {
  display: inline-flex;
}

.invite {
  margin-top: 18px;
}

.invite p {
  margin: 0 0 8px;
  font-size: 13px;
}

.invite-row {
  display: flex;
}

.invite-row input {
  flex: 1;
  min-width: 0;
  padding: 0 8px;
  border-right: 0;
  border-radius: var(--radius) 0 0 var(--radius);
  font: 12px var(--font-mono);
}

.invite-row .btn {
  border-radius: 0 var(--radius) var(--radius) 0;
}

/* ---------- Race ---------- */

.view-race {
  width: 100%;
}

/* A thin toolbar pinned over the article, like the sticky header. */
.hud {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 14px;
  height: var(--hud-h);
  padding: 0 16px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}

.hud-left {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  flex: 0 1 auto;
}

.hud-brand {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding-right: 14px;
  border-right: 1px solid var(--border-subtle);
  flex: none;
}

.hud-brand .ic {
  width: 18px;
  height: 18px;
}

.hud-brand .brand-word {
  font-size: 19px;
}

.matchup-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  max-width: 480px;
  height: 32px;
  padding: 0 8px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: transparent;
  font-size: 14px;
  cursor: pointer;
}

.matchup-pill:hover {
  background: var(--bg-neutral);
}

.matchup-pill[aria-expanded='true'] {
  background: var(--bg-progressive-subtle);
}

.matchup-pill .ic {
  width: 14px;
  height: 14px;
  color: var(--ink-subtle);
}

.mp-start,
.mp-target {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mp-target {
  color: var(--link);
  font-weight: 700;
}

.hud-stats {
  display: flex;
  align-items: center;
  gap: 16px;
  height: 24px;
  padding: 0 14px;
  border: solid var(--border-subtle);
  border-width: 0 1px;
  flex: none;
}

.stat {
  display: flex;
  align-items: baseline;
  gap: 6px;
}

.stat-label {
  color: var(--ink-subtle);
  font-size: 12px;
}

.stat-value {
  font-size: 15px;
  font-weight: 700;
  line-height: 1;
}

#hud-timer {
  min-width: 7ch;
}

.hud-actions {
  display: flex;
  gap: 4px;
  flex: none;
}

.hud-opponents {
  display: flex;
  gap: 2px;
  min-width: 0;
  overflow: hidden;
  flex: 1 1 auto;
  justify-content: flex-end;
}

.opp-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 28px;
  padding: 0 8px;
  border: 0;
  border-radius: var(--radius);
  background: transparent;
  font-size: 13px;
  white-space: nowrap;
  cursor: pointer;
}

.opp-pill:hover {
  background: var(--bg-neutral);
}

.opp-pill .p-dot {
  width: 8px;
  height: 8px;
}

.opp-pill .mono {
  color: var(--ink-subtle);
}

.opp-pill.is-finished .mono {
  color: var(--success);
  font-weight: 700;
}

.opp-pill.is-dnf {
  color: var(--ink-subtle);
}

.hud-right {
  display: flex;
  gap: 4px;
  flex: none;
}

.nav-progress {
  position: absolute;
  left: 0;
  right: 0;
  bottom: -1px;
  height: 2px;
  overflow: hidden;
}

.nav-progress span {
  display: block;
  height: 100%;
  width: 0;
  background: var(--progressive);
}

.race-body {
  display: grid;
  grid-template-columns: minmax(0, 960px) var(--rail-w);
  gap: var(--gutter);
  justify-content: center;
  align-items: start;
  padding: 16px var(--gutter) 48px;
}

.race-body.rail-collapsed {
  grid-template-columns: minmax(0, 960px);
}

.race-body.rail-collapsed .rail {
  display: none;
}

.article {
  min-width: 0;
}

.article[aria-busy='true'] .wiki {
  opacity: 0.55;
}

.article.is-hidden {
  visibility: hidden;
}

.article-title {
  margin: 0;
  padding: 0 0 3px;
  border-bottom: 1px solid var(--border);
  font: 400 28.8px/1.375 var(--font-serif);
  overflow-wrap: anywhere;
}

.article-meta {
  margin-top: 2px;
  font-size: 13px;
}

.article-meta:empty {
  display: none;
}

.meta-note {
  display: block;
}

/* Disambiguation notice, set like an article message box. */
.meta-note.is-disambig {
  display: flex;
  align-items: center;
  gap: 8px;
  width: fit-content;
  margin-top: 8px;
  padding: 4px 12px 4px 8px;
  border: 1px solid var(--border);
  border-left: 10px solid var(--progressive);
  background: var(--bg-subtle);
}

.article-desc {
  margin: 2px 0 0;
  color: var(--ink-subtle);
  font-size: 13px;
}

.article-desc:empty {
  display: none;
}

.article-license {
  margin-top: 36px;
  padding-top: 12px;
  border-top: 1px solid var(--border-subtle);
  color: var(--ink-subtle);
  font-size: 12.6px;
}

.article-license p {
  margin: 0 0 4px;
}

.article-loading {
  margin: 20px 0;
  color: var(--ink-subtle);
}

.article-error {
  margin: 20px 0;
  padding: 12px 16px;
  border: 1px solid var(--warning);
  border-radius: var(--radius);
  background: var(--warning-subtle);
}

.article-error p {
  margin: 0 0 10px;
}

/* Right sidebar: live racers and the target summary. */
.rail {
  position: sticky;
  top: calc(var(--hud-h) + 16px);
  max-height: calc(100vh - var(--hud-h) - 32px);
  padding-top: 8px;
  background: var(--bg);
  overflow-y: auto;
}

.rail-sec + .rail-sec {
  margin-top: 24px;
}

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

.rail-item {
  padding: 6px 0 7px;
  border-bottom: 1px solid var(--border-muted);
}

.ri-top {
  display: flex;
  align-items: center;
  gap: 8px;
}

.ri-top::before {
  content: '';
  flex: none;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--c, var(--ink-subtle));
}

.ri-top .p-name {
  flex: 1;
}

.ri-status {
  color: var(--ink-subtle);
  font: 12px var(--font-mono);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.ri-status.finished {
  color: var(--success);
  font-weight: 700;
}

.ri-status.dnf {
  font-family: var(--font-sans);
  font-style: italic;
}

.ri-page {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  margin-top: 1px;
  padding-left: 18px;
  color: var(--ink-subtle);
  font-size: 13px;
}

.ri-page span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ri-page .ic {
  width: 13px;
  height: 13px;
}

.ri-page.is-hidden {
  font-style: italic;
}

.blur-flag {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  color: var(--warning);
  font: 12px var(--font-mono);
}

.blur-flag .ic {
  width: 13px;
  height: 13px;
}

.rail-note {
  margin: 8px 0 0;
  color: var(--ink-subtle);
  font-size: 13px;
}

.rail-note:empty {
  display: none;
}

/* The target, as a small infobox. */
.target-card {
  padding: 3px;
  border: 1px solid var(--border);
  background: var(--bg-subtle);
  font-size: 13px;
  line-height: 1.5;
}

/* The target popover opens over the card as its expanded form. */
.rail.is-previewing .target-card {
  visibility: hidden;
}

.tc-title {
  margin: 0;
  padding: 3px 6px;
  background: var(--bg-progressive-subtle);
  font: 700 14px/1.4 var(--font-sans);
  text-align: center;
  overflow-wrap: anywhere;
}

.tc-thumb {
  display: block;
  width: 100%;
  max-height: 170px;
  margin-top: 3px;
  object-fit: cover;
}

.tc-desc {
  margin: 4px 6px 0;
  color: var(--ink-subtle);
  text-align: center;
}

.tc-extract {
  margin: 6px 6px 5px;
  display: -webkit-box;
  -webkit-line-clamp: 7;
  line-clamp: 7;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ---------- Countdown (Codex dialog) ---------- */

.countdown {
  position: fixed;
  inset: 0;
  z-index: 70;
  display: grid;
  place-items: center;
  padding: 16px;
  background: var(--scrim);
}

.cd-inner {
  width: min(440px, 100%);
  padding: 16px 24px 24px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  box-shadow: var(--shadow-menu);
  text-align: center;
}

.cd-matchup {
  margin: 0;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
  font: 400 20px/1.375 var(--font-serif);
  overflow-wrap: anywhere;
}

.cd-matchup b {
  font-weight: 400;
}

.cd-matchup .ic {
  vertical-align: -1px;
  color: var(--ink-subtle);
}

.cd-num {
  margin-top: 8px;
  font: 400 128px/1.15 var(--font-serif);
  font-variant-numeric: tabular-nums lining-nums;
}

.cd-num.is-go {
  color: var(--link);
}

.cd-sub {
  margin: 0 0 16px;
  color: var(--ink-subtle);
}

.cd-bar {
  height: 4px;
  background: var(--bg-neutral);
  overflow: hidden;
}

.cd-bar span {
  display: block;
  height: 100%;
  width: 0;
  background: var(--progressive);
}

/* ---------- Popovers, catch layer, messages ---------- */

.catch-layer {
  position: fixed;
  inset: 0;
  z-index: 80;
  background: transparent;
}

.catch-layer.is-dim {
  background: var(--scrim);
}

/* Target preview, like a page preview card. */
.popover {
  position: fixed;
  z-index: 90;
  width: min(420px, calc(100vw - 32px));
  padding: 14px 16px 16px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-menu);
}

.pop-head {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 14px;
}

.pop-label {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--ink-subtle);
  font-size: 13px;
}

.pop-label .ic {
  width: 14px;
  height: 14px;
}

.pop-title {
  margin: 0;
  font: 400 22px/1.3 var(--font-serif);
  overflow-wrap: anywhere;
}

.pop-desc {
  margin: 1px 0 0;
  color: var(--ink-subtle);
  font-size: 13px;
}

.pop-thumb {
  width: 96px;
  height: 96px;
  border: 1px solid var(--border-subtle);
  object-fit: cover;
  background: var(--bg-subtle);
}

.pop-extract {
  margin: 10px 0 0;
  max-height: 220px;
  overflow-y: auto;
}

.graph-tip {
  position: fixed;
  z-index: 95;
  max-width: 280px;
  padding: 4px 8px;
  border-radius: var(--radius);
  background: var(--ink);
  color: var(--bg);
  font-size: 13px;
  line-height: 1.4;
  pointer-events: none;
}

/* Rate-limit notice (Codex warning message). */
.banner {
  position: fixed;
  top: calc(var(--hud-h) + 12px);
  left: 50%;
  z-index: 96;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: calc(100vw - 32px);
  padding: 8px 16px 8px 12px;
  border: 1px solid var(--warning);
  border-radius: var(--radius);
  background: var(--warning-subtle);
  box-shadow: var(--shadow-menu);
}

.banner .ic {
  color: var(--warning);
}

.toasts {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 97;
  transform: translateX(-50%);
  display: grid;
  gap: 8px;
  justify-items: center;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: min(520px, calc(100vw - 32px));
  padding: 8px 16px 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  box-shadow: var(--shadow-menu);
}

.toast .ic {
  color: var(--ink-subtle);
}

.toast.is-warn {
  border-color: var(--warning);
  background: var(--warning-subtle);
}

.toast.is-warn .ic {
  color: var(--warning);
}

.toast.is-ok {
  border-color: var(--success);
  background: var(--success-subtle);
}

.toast.is-ok .ic {
  color: var(--success);
}

/* ---------- Results ---------- */

.res-title .mono {
  font-size: 0.86em;
}

.res-sub b {
  font-weight: 700;
}

.results-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 14px;
}

.results-actions .hint {
  margin-left: 6px;
}

.results-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 0 var(--gutter);
  align-items: start;
}

.results-grid .sec-h {
  margin-top: 22px;
}

/* Leaderboard: a wikitable. */
.lb-table {
  width: 100%;
  border-collapse: collapse;
  border: 1px solid var(--border);
  background: var(--bg-subtle);
}

.lb-table th,
.lb-table td {
  padding: 5px 10px;
  border: 1px solid var(--border);
  text-align: left;
  vertical-align: middle;
}

.lb-table th {
  background: var(--bg-neutral);
  text-align: center;
}

.lb-table th:nth-child(1),
.lb-table th:nth-child(3),
.lb-table th:nth-child(4) {
  width: 1%;
  white-space: nowrap;
}

.lb-row.is-me td {
  background: var(--bg-progressive-subtle);
}

.lb-table .lb-rank {
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.lb-row:first-child .lb-rank.has-rank {
  font-weight: 700;
}

.lb-name {
  margin-right: 10px;
  vertical-align: middle;
}

.lb-name .p-dot {
  margin-right: 8px;
  vertical-align: middle;
}

/* A long unbroken name wraps instead of widening the table past a phone screen. */
.lb-table .lb-racer {
  overflow-wrap: anywhere;
}

.lb-name .p-you {
  white-space: nowrap;
}

.lb-tags {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  vertical-align: middle;
}

.lb-tags:empty {
  display: none;
}

.lb-badge {
  padding: 0 6px;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--ink-subtle);
  font-size: 12px;
  line-height: 1.5;
  white-space: nowrap;
}

.lb-badge.is-left {
  font-style: italic;
}

.lb-table .lb-clicks,
.lb-table .lb-time {
  text-align: right;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.lb-row[data-status='finished']:first-child .lb-time {
  color: var(--success);
  font-weight: 700;
}

.lb-table .lb-status {
  color: var(--ink-subtle);
  font-family: var(--font-sans);
  font-style: italic;
}

/* Round badges: an infobox beside the leaderboard. */
.infobox-panel {
  margin-top: 22px;
  padding: 3px;
  border: 1px solid var(--border);
  background: var(--bg-subtle);
  font-size: 13px;
  line-height: 1.5;
}

.ib-title {
  margin: 0;
  padding: 3px 8px;
  background: var(--bg-neutral);
  font: 700 14px/1.4 var(--font-sans);
  text-align: center;
}

.badges {
  list-style: none;
  margin: 0;
  padding: 3px 0 0;
}

.badge {
  display: grid;
  grid-template-columns: 38% minmax(0, 1fr);
  gap: 10px;
  padding: 3px 8px;
}

.badge-label {
  font-weight: 700;
}

.badge-who,
.badge-detail {
  display: block;
  overflow-wrap: anywhere;
}

.badge-detail {
  color: var(--ink-subtle);
  font-size: 12px;
}

.badges-empty {
  padding: 4px 8px;
  color: var(--ink-subtle);
}

/* Route graph, framed like an article figure with the legend as its caption. */
.graph-frame {
  margin: 0;
  padding: 3px;
  border: 1px solid var(--border-subtle);
  background: var(--bg-subtle);
}

.graph-scroll {
  overflow-x: auto;
  padding: 6px 0;
  border: 1px solid var(--border-subtle);
  background: var(--bg);
}

.legend {
  display: flex;
  gap: 4px 16px;
  flex-wrap: wrap;
  padding: 5px 3px 2px;
  font-size: 13px;
}

.legend:empty {
  display: none;
}

.legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  overflow-wrap: anywhere;
}

.legend i {
  flex: none;
  width: 18px;
  height: 2px;
  background: var(--c);
}

.path-graph {
  display: block;
  margin: 0 auto;
}

.pg-edge {
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
}

.pg-back {
  stroke-dasharray: 4 4;
}

.pg-node {
  cursor: default;
  outline: none;
}

.pg-dot {
  fill: var(--bg);
  stroke: var(--ink-subtle);
  stroke-width: 1.5;
}

.pg-shared .pg-dot,
.pg-start .pg-dot {
  fill: var(--ink);
  stroke: var(--ink);
}

.pg-halo {
  fill: none;
  stroke: var(--border);
  stroke-width: 1;
  stroke-dasharray: 2 3;
}

.pg-target .pg-dot {
  fill: var(--success);
  stroke: var(--success);
}

.pg-flag {
  fill: none;
  stroke: #ffffff;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.pg-unreached .pg-dot {
  fill: var(--bg);
  stroke-dasharray: 3 3;
}

.pg-unreached .pg-flag {
  stroke: var(--success);
}

.pg-pip {
  stroke: var(--bg);
  stroke-width: 1.2;
}

.pg-label {
  font: 12.5px var(--font-sans);
  fill: var(--ink);
  paint-order: stroke;
  stroke: var(--bg);
  stroke-width: 4px;
  stroke-linejoin: round;
}

.pg-node:hover .pg-dot,
.pg-node:focus-visible .pg-dot {
  stroke: var(--progressive);
  stroke-width: 2.5;
}

.route-list {
  list-style: none;
  margin: 12px 0 0;
  padding: 0;
}

.route-list li {
  display: grid;
  grid-template-columns: 10px minmax(90px, 140px) 1fr;
  gap: 8px;
  align-items: baseline;
  padding: 3px 0;
}

.route-list .p-dot {
  align-self: center;
}

.route-who {
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.route-path .arr {
  margin: 0 5px;
  color: var(--ink-subtle);
}

.route-path .back {
  color: var(--ink-subtle);
  font-style: italic;
}

/* ---------- Wikipedia article content (scoped) ---------- */

.wiki {
  position: relative;
  isolation: isolate;
  contain: layout;
  margin-top: 12px;
  font-size: 15px;
  line-height: 1.6;
  color: var(--ink);
  overflow-wrap: break-word;
}

.wiki::after {
  content: '';
  display: block;
  clear: both;
}

.wiki p {
  margin: 0.5em 0;
}

.wiki h2,
.wiki h3,
.wiki h4,
.wiki h5,
.wiki h6 {
  margin: 0.3em 0 0;
  padding-top: 0.5em;
  font-weight: 700;
  line-height: 1.375;
  overflow: hidden;
}

.wiki h2 {
  margin: 1em 0 0.25em;
  padding: 0;
  border-bottom: 1px solid var(--border);
  font: 400 1.5em/1.375 var(--font-serif);
}

.wiki h3 {
  font-size: 1.2em;
}

.wiki h4,
.wiki h5,
.wiki h6 {
  font-size: 1em;
}

.wiki .mw-heading {
  overflow: hidden;
}

.wiki a {
  color: var(--link);
  text-decoration: none;
}

.wiki a[data-wiki-title],
.wiki a[data-wiki-anchor] {
  cursor: pointer;
}

.wiki a[data-wiki-title]:hover,
.wiki a[data-wiki-anchor]:hover {
  color: var(--link-hover);
  text-decoration: underline;
}

.wiki a[data-wiki-title]:active {
  color: var(--link-active);
}

/* Links that do not work in a race are greyed out. */
.wiki a[data-wiki-disabled] {
  color: var(--ink-placeholder);
  cursor: not-allowed;
}

.wiki a[data-wiki-reason='redlink'] {
  color: var(--redlink);
}

.wiki a[data-wiki-reason='none'],
.wiki a.mw-selflink {
  color: inherit;
  font-weight: 700;
  cursor: default;
}

.wiki img {
  max-width: 100%;
  height: auto;
  vertical-align: middle;
}

.wiki ul {
  margin: 0.3em 0 0 1.6em;
  padding: 0;
}

.wiki ol {
  margin: 0.3em 0 0 3.2em;
  padding: 0;
}

.wiki li {
  margin-bottom: 0.1em;
}

.wiki dl {
  margin: 0.2em 0 0.5em;
}

.wiki dt {
  font-weight: 700;
}

.wiki dd {
  margin-left: 1.6em;
}

.wiki blockquote {
  margin: 1em 0;
  padding: 8px 32px;
  border-left: 4px solid var(--border-muted);
}

.wiki sup,
.wiki sub {
  line-height: 1;
}

.wiki .reference {
  font-size: 80%;
  white-space: nowrap;
}

.wiki .hatnote {
  margin-bottom: 0.5em;
  padding-left: 1.6em;
  font-style: italic;
}

.wiki .shortdescription,
.wiki .mw-authority-control .navbox-styles,
.wiki .geo-nondefault,
.wiki .geo-multi-punct {
  display: none;
}

/* Infobox */
.wiki .infobox,
.wiki table.vcard,
.wiki .sidebar {
  float: right;
  clear: right;
  width: 22em;
  max-width: 100%;
  margin: 0.5em 0 0.5em 1em;
  padding: 0.2em;
  border: 1px solid var(--border);
  border-collapse: separate;
  border-spacing: 3px;
  background: var(--bg-subtle);
  color: var(--ink);
  font-size: 88%;
  line-height: 1.5;
}

.wiki .infobox th,
.wiki .infobox td,
.wiki .sidebar th,
.wiki .sidebar td {
  padding: 0.1em 0.3em;
  vertical-align: top;
  text-align: left;
}

.wiki .infobox-above,
.wiki .infobox caption,
.wiki .sidebar-title {
  font-size: 125%;
  font-weight: 700;
  text-align: center !important;
}

.wiki .infobox-header,
.wiki .infobox-subheader,
.wiki .sidebar-heading {
  background: var(--bg-neutral);
  text-align: center !important;
}

.wiki .infobox-image,
.wiki .infobox-caption {
  text-align: center !important;
}

.wiki .infobox-label {
  font-weight: 700;
  width: 38%;
}

/* Tables */
.wiki .wiki-table-wrap {
  overflow-x: auto;
  max-width: 100%;
  margin: 1em 0;
}

.wiki table.wikitable {
  margin: 0;
  border: 1px solid var(--border);
  border-collapse: collapse;
  background: var(--bg-subtle);
  color: var(--ink);
}

.wiki table.wikitable > * > tr > th,
.wiki table.wikitable > * > tr > td,
.wiki table.wikitable > tr > th,
.wiki table.wikitable > tr > td {
  border: 1px solid var(--border);
  padding: 0.2em 0.4em;
}

.wiki table.wikitable > * > tr > th {
  background: var(--bg-neutral);
  text-align: center;
}

.wiki table.wikitable caption {
  font-weight: 700;
  padding: 0.2em;
}

/* Figures and thumbnails (new and legacy markup) */
.wiki figure[typeof~='mw:File/Thumb'],
.wiki figure[typeof~='mw:File/Frame'],
.wiki .thumb {
  display: table;
  float: right;
  clear: right;
  max-width: min(100%, 320px);
  margin: 0.5em 0 1.3em 1.4em;
  padding: 3px;
  border: 1px solid var(--border-subtle);
  border-bottom: 0;
  background: var(--bg-subtle);
}

.wiki figure.mw-halign-left,
.wiki .thumb.tleft {
  float: left;
  clear: left;
  margin: 0.5em 1.4em 1.3em 0;
}

.wiki figure.mw-halign-center {
  float: none;
  margin: 0.5em auto;
}

.wiki figure.mw-halign-none {
  float: none;
  margin-left: 0;
}

.wiki figure[typeof~='mw:File/Thumb'] img,
.wiki figure[typeof~='mw:File/Frame'] img {
  border: 1px solid var(--border-subtle);
}

.wiki figcaption,
.wiki .thumbcaption {
  display: table-caption;
  caption-side: bottom;
  padding: 0 6px 6px;
  border: 1px solid var(--border-subtle);
  border-top: 0;
  background: var(--bg-subtle);
  font-size: 88.4%;
  line-height: 1.4;
}

.wiki .thumbinner {
  max-width: 100%;
}

.wiki .gallery {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  list-style: none;
  margin: 1em 0;
  padding: 0;
}

.wiki .gallerybox {
  width: auto !important;
}

.wiki .gallerytext {
  font-size: 88.4%;
}

.wiki .tright {
  float: right;
  clear: right;
  margin: 0.5em 0 1.3em 1.4em;
}

.wiki .tleft {
  float: left;
  clear: left;
  margin: 0.5em 1.4em 1.3em 0;
}

.wiki .center {
  text-align: center;
}

.wiki .center > * {
  margin-left: auto;
  margin-right: auto;
}

/* Inline lists */
.wiki .hlist ul,
.wiki .hlist ol {
  margin: 0;
  padding: 0;
}

.wiki .hlist li {
  display: inline;
  margin: 0;
}

.wiki .hlist li:not(:last-child)::after {
  content: ' · ';
  font-weight: 700;
}

.wiki .plainlist ul {
  list-style: none;
  margin: 0;
}

/* Navboxes */
.wiki .navbox,
.wiki .vertical-navbox {
  clear: both;
  margin: 1em 0;
  padding: 3px;
  border: 1px solid var(--border);
  background: var(--navbox-list);
  font-size: 88%;
}

.wiki .navbox table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0 2px;
}

.wiki .navbox-title,
.wiki .navbox-abovebelow {
  background: var(--navbox-title);
  text-align: center;
  font-weight: 700;
  padding: 0.25em 1em;
}

.wiki .navbox-group {
  background: var(--navbox-group);
  text-align: right;
  white-space: nowrap;
  padding: 0.25em 1em;
  font-weight: 700;
  width: 1%;
}

.wiki .navbox-list {
  padding: 0.25em 0.6em;
  border-left: 2px solid var(--navbox-list);
}

.wiki .navbar,
.wiki .mw-collapsible-toggle {
  display: none;
}

/* Message boxes */
.wiki .ambox,
.wiki .ombox,
.wiki .tmbox,
.wiki .side-box,
.wiki .sistersitebox,
.wiki .quotebox {
  margin: 0.8em 0;
  padding: 0.25em 0.9em;
  border: 1px solid var(--border);
  background: var(--bg-subtle);
  font-size: 88%;
}

.wiki .ambox {
  border-left: 10px solid var(--progressive);
}

.wiki .side-box,
.wiki .sistersitebox,
.wiki .quotebox {
  float: right;
  clear: right;
  max-width: 22em;
  margin-left: 1em;
}

/* References */
.wiki .reflist,
.wiki .mw-references-wrap {
  font-size: 90%;
}

.wiki .reflist .references,
.wiki .mw-references-columns .references {
  column-width: 30em;
  column-gap: 2em;
}

.wiki ol.references li {
  break-inside: avoid;
}

.wiki ol.references li:target,
.wiki .wr-target {
  background: var(--bg-progressive-subtle);
}

.wiki .mw-cite-backlink {
  margin-right: 0.3em;
}

.wiki cite {
  font-style: inherit;
}

.wiki .wiki-img-alt {
  color: var(--ink-subtle);
  font-style: italic;
}

/* Dark mode: Wikipedia's inline light backgrounds keep dark text. */
:root[data-theme='dark'] .wiki [style*='background'] {
  color: #202122;
}

:root[data-theme='dark'] .wiki [style*='background'] a[data-wiki-title],
:root[data-theme='dark'] .wiki [style*='background'] a[data-wiki-anchor] {
  color: #3366cc;
}

:root[data-theme='dark'] .wiki .mwe-math-fallback-image-inline,
:root[data-theme='dark'] .wiki .mwe-math-fallback-image-display {
  filter: invert(0.9);
}

/* ---------- Responsive ---------- */

@media (max-width: 1240px) {
  .hud-opponents {
    display: none;
  }

  .hud-right {
    margin-left: auto;
  }

  .race-body,
  .race-body.rail-collapsed {
    grid-template-columns: minmax(0, 960px);
  }

  /* The sidebar becomes a drawer over a catch layer. */
  .rail,
  .race-body.rail-collapsed .rail {
    display: none;
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    z-index: 90;
    width: min(320px, 88vw);
    max-height: none;
    padding: 16px;
    border-left: 1px solid var(--border);
  }

  .rail.is-open,
  .race-body.rail-collapsed .rail.is-open {
    display: block;
  }
}

@media (max-width: 980px) {
  :root {
    --gutter: 24px;
  }

  .lobby-grid,
  .results-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .side {
    padding-top: 28px;
  }

  .topbar-room .room-label,
  .net-status .txt,
  .hud-brand .brand-word {
    display: none;
  }

  .hud-brand {
    padding-right: 10px;
  }

  .hud {
    gap: 10px;
    padding: 0 12px;
  }

  .matchup-pill {
    max-width: 300px;
  }
}

@media (max-width: 720px) {
  :root {
    --gutter: 16px;
  }

  .topbar {
    flex-wrap: wrap;
  }

  .topbar-room {
    order: 3;
    flex: 1 1 100%;
  }

  .room-field {
    flex: 1;
  }

  .room-code {
    max-width: none;
  }

  .page-title,
  .article-title {
    font-size: 26px;
  }

  .matchup {
    grid-template-columns: minmax(0, 1fr);
  }

  .match-arrow {
    height: 32px;
    transform: rotate(90deg);
  }

  .mc-body {
    min-height: 0;
  }

  .mc-thumb {
    width: 72px;
    height: 72px;
  }

  .custom-fields {
    grid-template-columns: minmax(0, 1fr);
  }

  .swap-btn {
    justify-self: center;
    transform: rotate(90deg);
  }

  .rule-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .pack-tabs {
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: none;
  }

  .pack-tab {
    flex: none;
    padding-left: 10px;
    padding-right: 10px;
  }

  .setup-row,
  .custom-actions {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }

  .results-actions .hint {
    flex-basis: 100%;
    margin-left: 0;
  }

  .hud {
    height: auto;
    min-height: var(--hud-h);
    flex-wrap: wrap;
    padding: 6px 12px;
    row-gap: 4px;
  }

  /* Row 1: matchup and racers button. Row 2: time, clicks and actions. */
  .hud-brand {
    display: none;
  }

  .hud-left {
    flex: 1 1 calc(100% - 60px);
    min-width: 0;
  }

  .hud-right {
    order: 1;
  }

  /* The theme switch stays in the lobby header; the race toolbar keeps room for the matchup. */
  .hud-right .theme-toggle {
    display: none;
  }

  .hud-stats {
    order: 2;
    padding-left: 0;
    border-left: 0;
  }

  .hud-actions {
    order: 3;
    margin-left: auto;
  }

  .matchup-pill {
    max-width: 100%;
    padding-left: 0;
  }

  .race-body {
    padding-top: 12px;
    padding-bottom: 32px;
  }

  .wiki .infobox,
  .wiki table.vcard,
  .wiki .sidebar,
  .wiki figure[typeof~='mw:File/Thumb'],
  .wiki figure[typeof~='mw:File/Frame'],
  .wiki .thumb,
  .wiki .tright,
  .wiki .tleft,
  .wiki .side-box,
  .wiki .sistersitebox,
  .wiki .quotebox {
    float: none;
    width: auto;
    max-width: 100%;
    margin: 0.8em 0;
  }

  .lb-table th,
  .lb-table td {
    padding: 5px 7px;
  }

  .route-list li {
    grid-template-columns: 10px minmax(0, 1fr);
  }

  .route-path {
    grid-column: 1 / -1;
  }
}
