/* Teams page (/teams/): the livery home's world (liveries.css + home.css: header, photograph band, pills),
   like the tournament page, with its own photograph. Hairlines where other sites draw boxes, ink for "you
   are here" (an ink rule over a block waiting on you): the board, a team's drivers and the battles coming
   up are open rows, a war's state is words with a coloured dot. A team's own colours show only in its mark
   (main and second colour, split on the diagonal), never as stripes or glows. Sentence case throughout
   (DESIGN.md). */

/* Its own photograph: two cars nose to tail down the pass at night, a team war's 1v1s. */
.tm-band {
  min-height: 0;
  background:
    linear-gradient(90deg, rgba(4, 6, 10, .94) 0%, rgba(4, 6, 10, .8) 38%, rgba(4, 6, 10, .25) 72%, rgba(4, 6, 10, .35) 100%),
    linear-gradient(180deg, rgba(4, 6, 10, .5) 0%, rgba(4, 6, 10, 0) 35%, rgba(4, 6, 10, .55) 78%, var(--night) 100%),
    url(../assets/rules-duel.jpg) 65% 55% / cover no-repeat var(--shot);
}
.tm-band .lv-band-copy { padding: 44px 48px 34px; }
.tm-band h1 { max-width: none; margin-top: 10px; font-size: clamp(34px, 3.8vw, 56px); }
.tm-band .lv-lede { max-width: 60ch; margin-top: 12px; font-size: 16px; }
.tm-col { padding-top: 30px; }
.tm-col h2 { margin: 0; color: var(--ink); font: 800 clamp(22px, 2.2vw, 28px)/1.1 var(--font-sans); font-stretch: 112%; letter-spacing: -.01em; }
.tm-sub { margin-top: 8px; }

/* The team mark: a small square in the team's two colours. */
.tm-mark { display: inline-block; flex: none; width: 12px; height: 12px; border-radius: 3px; background: linear-gradient(135deg, var(--c1) 50%, var(--c2) 50%); }
.tm-tag { display: inline-flex; align-items: center; gap: 8px; color: var(--ink); font: 700 13px/1 var(--font-sans); letter-spacing: .06em; white-space: nowrap; }

/* ── Board ─────────────────────────────────────────────────────────────────────────────────── */

.tm-rows { border-bottom: 1px solid var(--hair); }
.tm-row {
  display: grid; grid-template-columns: 40px 86px minmax(0, 1fr) minmax(0, 300px) 96px; gap: 16px; align-items: center;
  padding: 16px 8px; border-top: 1px solid var(--hair); color: var(--ink-2); text-decoration: none; transition: background .15s;
}
.tm-row:hover { background: rgba(243, 245, 248, .03); }
.tm-row .tm-pos { color: var(--ink-3); font: 700 15px/1 var(--font-sans); font-variant-numeric: tabular-nums; text-align: right; }
.tm-row .tm-pos.top { color: var(--ink); }
.tm-row .tm-nm { min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; color: var(--ink); font: 600 17px/1.3 var(--font-sans); }
.tm-row .tm-nm small { display: none; }
.tm-row .tm-who { min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font: 500 14px/1.35 var(--font-sans); }
.tm-row .tm-rating { text-align: right; color: var(--ink); font: 700 18px/1 var(--font-sans); font-variant-numeric: tabular-nums; }
.tm-row .tm-rating small { display: block; margin-top: 4px; color: var(--ink-3); font: 600 11px/1 var(--font-sans); }
.tm-head { padding-top: 0; padding-bottom: 10px; border-top: 0; color: var(--ink-3); font: 500 13px/1 var(--font-sans); }
.tm-head:hover { background: none; }
.tm-head span:last-child { text-align: right; }

.tm-unlisted { margin-top: 56px; }
.tm-unlisted .tm-row { grid-template-columns: 86px minmax(0, 1fr) minmax(0, 300px) 96px; }
.tm-empty { padding: 24px 0; color: var(--ink-3); }
.tm-empty a { color: var(--ink); }

/* ── One team ──────────────────────────────────────────────────────────────────────────────── */

.tm-back {
  display: inline-flex; align-items: center; gap: 6px; color: var(--ink-3); font: 600 14px/1 var(--font-sans); text-decoration: none;
}
.tm-back:hover { color: var(--ink); }
.tm-back svg { width: 16px; height: 16px; }
.tm-tagline { margin: 22px 0 0; }
.tm-tagline .tm-mark { width: 16px; height: 16px; border-radius: 4px; }
.tm-tagline .tm-tag { font-size: 15px; gap: 10px; }

.tm-facts { display: flex; flex-wrap: wrap; gap: 14px 40px; margin: 22px 0 0; }
.tm-facts div { min-width: 0; }
.tm-facts dt { color: var(--ink); font: 800 28px/1 var(--font-sans); font-stretch: 112%; font-variant-numeric: tabular-nums; }
.tm-facts dd { margin: 6px 0 0; color: var(--ink-3); font: 500 13px/1.3 var(--font-sans); }

/* Drivers as ladder rows on hairlines, as many columns as fit (the tournament's entrants); the tier in its colour. */
.tm-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); column-gap: 40px; margin-top: 18px; }
.tm-drv {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 12px; align-items: center; min-height: 62px;
  padding: 8px 6px; border-bottom: 1px solid var(--hair); text-decoration: none; transition: background .15s;
}
.tm-drv:hover { background: rgba(243, 245, 248, .03); }
.tm-drv-who { min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; color: var(--ink); font: 600 16px/1.3 var(--font-sans); }
.tm-drv-who small { display: block; margin-top: 3px; overflow: hidden; text-overflow: ellipsis; color: var(--ink-3); font: 500 13px/1.3 var(--font-sans); }
.tm-tier { color: var(--tier); font-weight: 600; }
.tm-tier i { display: inline-block; width: 7px; height: 7px; margin-right: 6px; border-radius: 50%; background: var(--tier); vertical-align: 1px; }
.tm-cap { color: var(--ink); font-weight: 600; }
.tm-mmr { text-align: right; color: var(--ink); font: 700 16px/1 var(--font-sans); font-variant-numeric: tabular-nums; }
.tm-mmr small { display: block; margin-top: 3px; color: var(--ink-3); font: 600 11px/1 var(--font-sans); }
.tm-dot { color: var(--ink-3); }

@media (max-width: 720px) {
  .tm-band .lv-band-copy { padding: 30px 16px 26px; }
  .lv-col.tm-col { padding-left: 16px; padding-right: 16px; }
  .tm-row, .tm-unlisted .tm-row { grid-template-columns: 28px minmax(0, 1fr) 76px; gap: 12px; padding: 14px 4px; }
  .tm-unlisted .tm-row { grid-template-columns: minmax(0, 1fr) 76px; }
  .tm-row .tm-tagcell, .tm-row .tm-who { display: none; }
  .tm-row .tm-nm small { display: flex; align-items: center; gap: 8px; margin-top: 4px; color: var(--ink-3); font: 500 13px/1.3 var(--font-sans); }
  .tm-head { display: none; }
  .tm-facts { gap: 14px 28px; }
  .tm-facts dt { font-size: 24px; }
  .tm-grid { grid-template-columns: minmax(0, 1fr); }
}

/* ── Wars: a team page's list, the challenge form and the war page ─────────────────────────── */

.tw-section { margin-top: 56px; }
.tw-do { margin-top: 18px; }
.tw-list { margin-top: 18px; }
.tw-note { margin: 12px 0 0; color: var(--ink-3); font: 500 14px/1.5 var(--font-sans); }
.tw-note a, .tw-files a, .tw-lineup a { color: var(--ink); }
.tw-x { margin: 0 10px; color: var(--ink-3); font: 600 13px/1 var(--font-sans); letter-spacing: 0; }
.tw-vs { display: flex; align-items: center; flex-wrap: wrap; }
.tm-row.tw-row { grid-template-columns: minmax(0, 220px) minmax(0, 1fr) auto; }
.tw-row .tw-st { text-align: right; }
/* A war's state in a list: words with a dot in the state's colour, no pill (as the tournament's status).
   Green = ready to race, red = racing, gold = decided; the rest plain, or dim once called off. */
.tw-chip { display: inline-flex; align-items: center; gap: 8px; color: var(--ink-2); font: 600 13px/1.2 var(--font-sans); white-space: nowrap; }
.tw-chip::before { content: ""; flex: none; width: 7px; height: 7px; border-radius: 50%; background: var(--tone, var(--ink-3)); }
.tw-chip.tw-ready { --tone: #1ae566; color: var(--ink); }
.tw-chip.tw-live { --tone: #ff3340; color: var(--ink); }
.tw-chip.tw-won { --tone: #e6cc1a; color: var(--ink); }
.tw-chip.tw-declined, .tw-chip.tw-withdrawn, .tw-chip.tw-cancelled { --tone: rgba(243, 245, 248, .25); color: var(--ink-3); }

/* The war page's status, a line over the tags: its dot in the state's colour, red pulsing while live. */
.tw-status { display: flex; align-items: center; gap: 9px; margin: 22px 0 0; color: var(--ink); font: 600 14px/1.3 var(--font-sans); }
.tw-status:empty { display: none; }
.tw-status i { flex: none; width: 8px; height: 8px; border-radius: 50%; background: var(--tone, var(--ink-3)); }
.tw-status-ready { --tone: #1ae566; }
.tw-status-live { --tone: #ff3340; }
.tw-status-live i { animation: tw-pulse 1.6s ease-in-out infinite; }
.tw-status-gold { --tone: #e6cc1a; }
.tw-status-dim { --tone: rgba(243, 245, 248, .25); color: var(--ink-3); }
@keyframes tw-pulse { 50% { opacity: .35; } }
@media (prefers-reduced-motion: reduce) { .tw-status-live i { animation: none; } }
.tw-status + .tm-tagline { margin-top: 14px; }

.tw-form { max-width: 760px; padding: 22px 0 0; border-top: 2px solid var(--ink); }
.tw-form label, .tw-block label { display: flex; flex-direction: column; gap: 6px; color: var(--ink-2); font: 600 13px/1.4 var(--font-sans); }
.tw-form .tw-note { margin: 0; }
.tw-lead { display: flex; align-items: center; margin: 0; }
.tw-btns { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 18px; }
.tw-btns .lv-btn { height: 46px; padding: 0 22px; font-size: 15px; }

/* The set-up's steps along a rule, as the tournament's track: done ones brighter, the current one in ink with a
   heavier rule, the rest dim. */
.tw-steps { display: grid; grid-auto-columns: minmax(0, 1fr); grid-auto-flow: column; gap: 0 6px; margin: 0 0 12px; padding: 0; list-style: none; }
.tw-steps li { display: flex; align-items: baseline; gap: 8px; min-width: 0; padding-top: 12px; border-top: 2px solid var(--hair); color: var(--ink-3); font: 600 14px/1.2 var(--font-sans); }
.tw-steps li span { flex: none; font: 700 14px/1.2 var(--font-sans); font-variant-numeric: tabular-nums; }
.tw-steps li.done { border-top-color: rgba(243, 245, 248, .4); color: var(--ink-2); }
.tw-steps li.now { border-top-color: var(--ink); color: var(--ink); }

.tw-quote { margin: 22px 0 0; color: var(--ink); font: 500 17px/1.5 var(--font-sans); }
.tw-quote span { margin-left: 8px; color: var(--ink-3); font-size: 14px; }

.tw-block { margin-top: 28px; padding: 24px 0 0; border-top: 1px solid var(--hair); }
/* A block waiting on the viewer: an ink rule instead of the hairline, no box. */
.tw-block.live { border-top: 2px solid var(--ink); }
.tw-block h2 { font-size: clamp(19px, 1.8vw, 22px) !important; }
.tw-block .lv-body { margin: 12px 0 0; }
.tw-block .lv-fields { margin-top: 16px; }
.tw-big { margin: 12px 0 0; color: var(--ink); font: 700 22px/1.3 var(--font-sans); }
.tw-dateform { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px; margin-top: 16px; }
.tw-dateform[hidden] { display: none; }
.tw-dateform .lv-btn { height: 46px; padding: 0 22px; font-size: 15px; }
.tw-slots { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; margin-top: 16px; }
.tw-mod { color: var(--ink-3); font: 600 12px/1 var(--font-sans); }
.tw-upload { margin-top: 20px; }
.tw-upload summary { color: var(--ink-2); font: 600 14px/1.4 var(--font-sans); cursor: pointer; }
.tw-upload .lv-progress { margin-top: 14px; }

.tw-lineup { margin-top: 16px; border-bottom: 1px solid var(--hair); }
.tw-lrow { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr) minmax(0, 1fr); gap: 16px; align-items: center; padding: 12px 4px; border-top: 1px solid var(--hair); color: var(--ink); font: 600 15px/1.35 var(--font-sans); }
.tw-lrow > span { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.tw-lhead { border-top: 0; padding-top: 0; }
.tw-lrow select { width: 100%; }
.tw-car { color: var(--ink-2); }
.tw-hidden { color: var(--ink-3); font-weight: 500; }
.tw-files { margin: 12px 0 0; padding: 0; list-style: none; }
.tw-files li { padding: 8px 0; color: var(--ink); font: 600 15px/1.4 var(--font-sans); }
.tw-dim { margin-left: 8px; color: var(--ink-3); font: 500 13px/1 var(--font-sans); }

@media (max-width: 720px) {
  .tm-row.tw-row { grid-template-columns: minmax(0, 1fr) auto; }
  .tw-row .tm-who { display: none; }
  .tw-lrow { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .tw-lrow .tw-car { grid-column: 1 / -1; }
  .tw-lhead span:first-child { display: none; }
}
.tw-saved { margin: 14px 0 0; color: var(--ink); font: 600 14px/1.4 var(--font-sans); }
.tw-saved::before { content: ""; display: inline-block; width: 7px; height: 7px; margin-right: 8px; border-radius: 50%; background: var(--ink); vertical-align: 1px; }
.tw-block .lv-body .tm-tag, .tw-block .tw-note .tm-tag { vertical-align: -1px; font-size: 14px; }
.tw-battles { margin-top: 16px; border-bottom: 1px solid var(--hair); }
.tw-battle { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 10px 20px; align-items: center; padding: 14px 4px; border-top: 1px solid var(--hair); }
.tw-bhead { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; color: var(--ink); font: 600 15px/1.35 var(--font-sans); }
.tw-bhead .tw-dim { margin-left: 0; }
.tw-bn { color: var(--ink-3); font: 600 13px/1.2 var(--font-sans); }
.tw-bdate { display: flex; flex-direction: column; gap: 4px; color: var(--ink); font: 500 15px/1.4 var(--font-sans); }
.tw-bdate .tw-dim { margin-left: 0; }
.tw-bctl { grid-column: 1 / -1; display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.tw-bctl .lv-btn { height: 40px; padding: 0 18px; font-size: 14px; }
.tw-bctl input { height: 40px; }
@media (max-width: 720px) {
  .tw-battle { grid-template-columns: minmax(0, 1fr); }
}

/* Dropdowns on the war page: a solid dark field and dark rows with light text. The open list is drawn by
   the OS, and a group heading ("On our servers") otherwise falls back to black on dark. */
#war-body select, .tw-form select { background-color: #10141b; }
#war-body select option, .tw-form select option { background: #10141b; color: var(--ink); }
#war-body select optgroup, .tw-form select optgroup { background: #10141b; color: var(--ink-3); font-style: normal; font-weight: 700; }
#war-body select option:disabled { color: rgba(243, 245, 248, .35); }
.tw-err { margin: 14px 0 0; font-size: 14px; }

/* ── Wars on a team page, and the My team page (#mine) ─────────────────────────────────────── */

.tw-facts { margin-top: 18px; }
.tw-h3 { margin: 30px 0 10px; color: var(--ink); font: 700 16px/1.3 var(--font-sans); }
.tw-h2h { border-bottom: 1px solid var(--hair); }
.tw-h2h-row { display: grid; grid-template-columns: minmax(0, 1fr) auto 64px; gap: 16px; align-items: center; padding: 12px 4px; border-top: 1px solid var(--hair); }
.tw-h2h-row > span:first-child { display: flex; align-items: center; gap: 12px; min-width: 0; }
.tw-h2h-row .tw-dim { margin-left: 0; }
.tw-rec { text-align: right; color: var(--ink); font: 700 16px/1 var(--font-sans); font-variant-numeric: tabular-nums; }
.tm-row.tw-row .tm-who small { display: block; margin-top: 3px; color: var(--ink-3); font: 500 13px/1.3 var(--font-sans); }
.tw-step.us .tm-who { color: var(--ink); font-weight: 600; }
.tw-go { display: inline-block; padding: 7px 14px; border-radius: 999px; color: var(--night); background: var(--ink); font: 700 13px/1 var(--font-sans); }
.tw-mine-tag { gap: 14px; }
.tw-mine-tag .tw-dim { margin-left: 0; font-size: 14px; }
.tw-mine-h { margin-top: 48px !important; }
.tw-todo { margin-top: 14px; }
#mine-body > h2:first-child + .tm-empty, #mine-body .tm-empty { padding: 14px 0; }
/* The battles coming up: ladder rows on hairlines; the viewer's own race on a light tint. */
.tw-coming { margin-top: 14px; border-bottom: 1px solid var(--hair); }
.tw-cb {
  display: grid; grid-template-columns: 200px minmax(0, 1fr) minmax(0, 1fr); gap: 16px; align-items: center; padding: 14px 6px;
  border-top: 1px solid var(--hair); color: var(--ink-2); text-decoration: none; font: 500 14px/1.4 var(--font-sans); transition: background .15s;
}
.tw-cb:hover { background: rgba(243, 245, 248, .03); }
.tw-cb.you { background: rgba(243, 245, 248, .06); }
.tw-cb-when { color: var(--ink); font: 700 15px/1.3 var(--font-sans); }
.tw-cb-what { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.tw-cb-what .tw-dim { margin-left: 0; }
.tw-cb-who { min-width: 0; color: var(--ink); }
.tw-mine-foot { margin-top: 40px; }

@media (max-width: 720px) {
  .tw-cb { grid-template-columns: minmax(0, 1fr); gap: 6px; }
  .tw-h2h-row { grid-template-columns: minmax(0, 1fr) auto; }
  .tw-h2h-row .tw-rec { display: none; }
}
.tw-x.tw-x-lead { margin-left: 0; }
.tw-dl { margin-top: 14px; border-bottom: 1px solid var(--hair); }
.tw-dl-row { display: grid; grid-template-columns: 90px minmax(0, 1fr) auto; gap: 16px; align-items: center; padding: 12px 4px; border-top: 1px solid var(--hair); }
.tw-dl-name { min-width: 0; color: var(--ink); font: 600 15px/1.35 var(--font-sans); }
.tw-dl-get { text-align: right; }
.tw-dl-get .tw-dim { margin-left: 0; }
.lv-btn.tw-dl-btn { height: 38px; padding: 0 18px; font-size: 14px; }
@media (max-width: 720px) {
  .tw-dl-row { grid-template-columns: minmax(0, 1fr) auto; }
  .tw-dl-row .tw-bn { grid-column: 1 / -1; }
}
.tw-chip.tw-won { color: var(--night); background: var(--ink); border-color: var(--ink); }
.tw-res { display: block; margin-top: 3px; color: var(--ink-3); font: 500 13px/1.3 var(--font-sans); }
.tw-res.home, .tw-res.away { color: var(--ink); font-weight: 600; }
.tw-res a { color: var(--ink); }

/* The war server's Join banner (war page and My team), while it runs that war. */
.tw-join { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 16px 24px; margin: 0 0 28px; padding: 20px 0 22px;
  border-top: 2px solid var(--ink); border-bottom: 1px solid var(--hair); }
.tw-join-k { display: flex; align-items: center; gap: 9px; margin: 0; color: var(--ink); font: 600 14px/1.3 var(--font-sans); }
.tw-live-dot { flex: none; width: 8px; height: 8px; border-radius: 50%; background: #ff3340; animation: tw-pulse 1.6s ease-in-out infinite; }
@media (prefers-reduced-motion: reduce) { .tw-live-dot { animation: none; } }
.tw-join-t { display: flex; align-items: center; margin: 10px 0 0; }
.tw-join .tw-note { margin-top: 6px; }
.tw-join-soon { margin: 0 0 18px; }
@media (max-width: 720px) {
  .tw-join .lv-btn { width: 100%; }
  .tw-steps { grid-auto-flow: row; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px 6px; }
}
