/* Dicey Downs -- application shell, components and view layouts.
   Track-specific styling lives in track.css. */

:root {
  /* Surfaces: a night meeting at a country track. */
  --felt: #12301f;
  --felt-deep: #0b1f14;
  --ink: #0a0f0c;
  --panel: rgba(14, 32, 22, 0.92);
  --panel-2: rgba(9, 22, 15, 0.94);
  --rail: rgba(255, 255, 255, 0.11);
  --rail-strong: rgba(255, 255, 255, 0.2);
  --brass: #d8b45a;
  --brass-dim: #9b7f34;
  --chalk: #f2f0e6;
  --chalk-dim: rgba(242, 240, 230, 0.62);
  --chalk-faint: rgba(242, 240, 230, 0.36);

  /* The six colours. Mirrors COLORS in js/core/horses.js -- keep in step. */
  --c-red: #d93a34;
  --c-blue: #2f74d0;
  --c-green: #2e9e57;
  --c-purple: #8a4fd0;
  --c-yellow: #e3b408;
  --c-orange: #e2761b;

  --font-display: "Rubik Dirt", Georgia, serif;
  --font-head: "Oswald", "Arial Narrow", sans-serif;
  --font-body: "Inter", system-ui, -apple-system, sans-serif;
  --font-mono: "SFMono-Regular", Consolas, "Liberation Mono", monospace;

  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 16px;
  --shadow: 0 18px 40px rgba(0, 0, 0, 0.45);
  --topbar-h: 62px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-body);
  color: var(--chalk);
  background-color: var(--felt-deep);
  background-image:
    radial-gradient(1200px 700px at 50% -10%, rgba(45, 120, 75, 0.35), transparent 70%),
    linear-gradient(rgba(8, 20, 13, 0.9), rgba(8, 20, 13, 0.96)),
    url(../images/carpet.jpg);
  background-attachment: fixed;
  background-size: cover;
  line-height: 1.5;
}

/* Links never underline on hover -- they lift and warm instead. An underline
   on every clickable thing turns a page this link-dense into a mess of rules
   the moment the pointer moves across it. */
a {
  color: inherit;
  text-decoration: none;
  transition: color 0.15s ease, text-shadow 0.15s ease, filter 0.15s ease;
}
a:hover {
  color: #fffdf4;
  text-shadow: 0 0 14px rgba(255, 248, 214, 0.55);
}
a:focus-visible {
  outline: 2px solid var(--brass);
  outline-offset: 3px;
  border-radius: 3px;
}

/* Whole-panel links glow at the edge rather than tinting their text, so the
   card reads as one target instead of a paragraph of hot words. */
a.panel:hover,
a.horse-card:hover,
a.coc-slot:hover,
a.race-row:hover,
a.chip:hover {
  color: inherit;
  text-shadow: none;
}
a.panel:hover,
a.coc-slot.filled:hover {
  border-color: var(--brass-dim);
  box-shadow: var(--shadow), 0 0 22px rgba(216, 180, 90, 0.22);
}
a.horse-card:hover {
  box-shadow: 0 0 20px rgba(216, 180, 90, 0.18);
}
button { font: inherit; cursor: pointer; }

/* ---------- top bar ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  gap: 1rem;
  height: var(--topbar-h);
  padding: 0 clamp(0.75rem, 3vw, 2rem);
  background: linear-gradient(rgba(6, 16, 11, 0.97), rgba(6, 16, 11, 0.88));
  border-bottom: 1px solid var(--rail);
  backdrop-filter: blur(8px);
}

.brand { display: flex; align-items: center; gap: 0.6rem; flex: 0 0 auto; }

.brand-die {
  width: 30px; height: 30px;
  display: grid;
  grid-template: repeat(3, 1fr) / repeat(3, 1fr);
  padding: 4px;
  background: var(--chalk);
  border-radius: 7px;
  box-shadow: 0 2px 0 #b9b6a8, 0 6px 14px rgba(0, 0, 0, 0.5);
  transform: rotate(-8deg);
}
.brand-die i { background: var(--ink); border-radius: 50%; }
/* Five pips, arranged as a die face. */
.brand-die i:nth-child(1) { grid-area: 1 / 1; }
.brand-die i:nth-child(2) { grid-area: 1 / 3; }
.brand-die i:nth-child(3) { grid-area: 2 / 2; }
.brand-die i:nth-child(4) { grid-area: 3 / 1; }
.brand-die i:nth-child(5) { grid-area: 3 / 3; }

.brand-text {
  font-family: var(--font-display);
  font-size: 1.32rem;
  letter-spacing: 0.5px;
  color: var(--chalk);
}
.brand-text span { color: var(--brass); }

.nav { display: flex; gap: 0.15rem; margin-left: auto; flex-wrap: wrap; }
.nav a {
  display: flex; align-items: center; gap: 0.45rem;
  padding: 0.5rem 0.8rem;
  border-radius: var(--r-sm);
  font-family: var(--font-head);
  font-size: 0.93rem;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  color: var(--chalk-dim);
  transition: background 0.15s, color 0.15s;
}
.nav a:hover { background: rgba(255, 255, 255, 0.07); color: var(--chalk); }
.nav a.active { background: rgba(216, 180, 90, 0.16); color: var(--brass); }
.nav a[hidden] { display: none; }
.nav a.nav-admin { color: #ff9c8a; }
.nav a.nav-admin.active { background: rgba(255, 120, 100, 0.16); color: #ffb3a4; }

.nav-toggle {
  display: none;
  margin-left: auto;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--rail);
  color: var(--chalk);
  border-radius: var(--r-sm);
  padding: 0.45rem 0.7rem;
}

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

.view {
  max-width: 1180px;
  margin: 0 auto;
  padding: clamp(1rem, 3vw, 2rem) clamp(0.75rem, 3vw, 2rem) 4rem;
  outline: none;
}

.loading { padding: 4rem 0; text-align: center; color: var(--chalk-faint); }

.page-head { margin-bottom: 1.5rem; }
.page-head h1 {
  font-family: var(--font-display);
  font-size: clamp(1.7rem, 4vw, 2.6rem);
  margin: 0 0 0.3rem;
  line-height: 1.1;
}
.page-head p { margin: 0; color: var(--chalk-dim); max-width: 62ch; }

.eyebrow {
  font-family: var(--font-head);
  text-transform: uppercase;
  letter-spacing: 2px;
  font-size: 0.78rem;
  color: var(--brass-dim);
  margin-bottom: 0.35rem;
}

h2.section {
  font-family: var(--font-head);
  text-transform: uppercase;
  letter-spacing: 1.4px;
  font-size: 1.05rem;
  color: var(--chalk-dim);
  margin: 2.2rem 0 0.9rem;
  padding-bottom: 0.45rem;
  border-bottom: 1px solid var(--rail);
}
h2.section:first-child { margin-top: 0; }

.panel {
  background: var(--panel);
  border: 1px solid var(--rail);
  border-radius: var(--r-lg);
  padding: clamp(0.9rem, 2vw, 1.4rem);
  box-shadow: var(--shadow);
}

.grid { display: grid; gap: 0.9rem; }
.grid.cols-2 { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.grid.cols-4 { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }

.row { display: flex; gap: 0.6rem; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1 1 auto; }
.muted { color: var(--chalk-dim); }
.faint { color: var(--chalk-faint); }
.mono { font-family: var(--font-mono); }
.nowrap { white-space: nowrap; }
.center { text-align: center; }

/* ---------- buttons, pills, chips ---------- */

.btn {
  display: inline-flex; align-items: center; gap: 0.45rem;
  padding: 0.5rem 0.95rem;
  border: 1px solid var(--rail-strong);
  border-radius: var(--r-sm);
  background: rgba(255, 255, 255, 0.06);
  color: var(--chalk);
  font-family: var(--font-head);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-size: 0.88rem;
  transition: background 0.15s, border-color 0.15s;
}
.btn:hover { background: rgba(255, 255, 255, 0.12); }
.btn.primary { background: var(--brass); color: #241a03; border-color: var(--brass); font-weight: 600; }
.btn.primary:hover { background: #eac874; }
.btn.danger { border-color: rgba(255, 120, 100, 0.5); color: #ff9c8a; }
.btn.small { padding: 0.3rem 0.6rem; font-size: 0.78rem; }
.btn[disabled] { opacity: 0.4; cursor: not-allowed; }

.pill {
  display: inline-flex; align-items: center; gap: 0.35rem;
  padding: 0.16rem 0.55rem;
  border-radius: 999px;
  font-family: var(--font-head);
  font-size: 0.76rem;
  letter-spacing: 0.7px;
  text-transform: uppercase;
  border: 1px solid var(--rail-strong);
  color: var(--chalk-dim);
  white-space: nowrap;
}
.pill.live {
  background: #c0342c; border-color: #ff6b5f; color: #fff;
  animation: pulse 1.6s ease-in-out infinite;
}
.pill.final { background: rgba(216, 180, 90, 0.18); border-color: var(--brass-dim); color: var(--brass); }
.pill.upcoming { background: rgba(255, 255, 255, 0.05); }
.pill.edited { background: rgba(255, 120, 100, 0.16); border-color: #ff9c8a; color: #ffb3a4; }

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

.family-tag { font-size: 0.7rem; padding: 0.1rem 0.45rem; }
.family-balanced { border-color: #6fa8dc; color: #9cc7f0; }
.family-shifting { border-color: #b79ce8; color: #cbb4f5; }
.family-volatile { border-color: #e8926f; color: #f5b596; }

/* ---------- colour theming ---------- */

[data-color="red"] { --team: var(--c-red); }
[data-color="blue"] { --team: var(--c-blue); }
[data-color="green"] { --team: var(--c-green); }
[data-color="purple"] { --team: var(--c-purple); }
[data-color="yellow"] { --team: var(--c-yellow); }
[data-color="orange"] { --team: var(--c-orange); }

/* ---------- horse sprite (masked silhouette, never drawn) ---------- */

.sprite {
  position: relative;
  display: inline-block;
  width: var(--sprite-w, 84px);
  aspect-ratio: 2657 / 1736;
  flex: 0 0 auto;
}
.sprite::before {
  content: "";
  position: absolute;
  inset: 0;
  background-color: var(--team, var(--chalk));
  -webkit-mask-image: url(../images/horse-silhouette.png);
  mask-image: url(../images/horse-silhouette.png);
  -webkit-mask-size: contain;
  mask-size: contain;
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
  -webkit-mask-position: center;
  mask-position: center;
  filter: drop-shadow(0 3px 5px rgba(0, 0, 0, 0.55));
}
/* A lighter topline so the flat colour reads as a figure, not a blob. */
.sprite::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(160deg, rgba(255, 255, 255, 0.45), transparent 52%);
  -webkit-mask-image: url(../images/horse-silhouette.png);
  mask-image: url(../images/horse-silhouette.png);
  -webkit-mask-size: contain;
  mask-size: contain;
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
  -webkit-mask-position: center;
  mask-position: center;
  mix-blend-mode: screen;
  pointer-events: none;
}

/* The rank banner the horse wears. */
.sprite-banner {
  position: absolute;
  left: 34%;
  top: 44%;
  transform: rotate(-7deg);
  z-index: 2;
  padding: 1px 5px;
  border-radius: 3px;
  background: #fffdf3;
  color: #1a1a1a;
  font-family: var(--font-head);
  font-weight: 600;
  font-size: calc(var(--sprite-w, 84px) * 0.135);
  letter-spacing: 0.4px;
  line-height: 1.25;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.55);
  white-space: nowrap;
  pointer-events: none;
}

.sprite.sm { --sprite-w: 56px; }
.sprite.lg { --sprite-w: 150px; }
.sprite.xl { --sprite-w: 230px; }

/* ---------- horse cards ---------- */

.horse-card {
  display: flex;
  gap: 0.85rem;
  align-items: center;
  padding: 0.75rem 0.9rem;
  background: var(--panel-2);
  border: 1px solid var(--rail);
  border-left: 4px solid var(--team, var(--rail-strong));
  border-radius: var(--r-md);
  transition: transform 0.12s, border-color 0.12s, background 0.12s;
}
.horse-card:hover {
  transform: translateY(-2px);
  background: rgba(20, 44, 30, 0.95);
  border-color: var(--rail-strong);
  border-left-color: var(--team);
}
.horse-card .hc-body { min-width: 0; flex: 1; }
.horse-card .hc-name {
  font-family: var(--font-head);
  font-size: 1.05rem;
  letter-spacing: 0.3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.horse-card .hc-rank {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--team);
  font-weight: 700;
  letter-spacing: 1px;
}
.horse-card .hc-meta { font-size: 0.8rem; color: var(--chalk-dim); }

/* ---------- die faces ---------- */

.faces { display: inline-flex; gap: 4px; flex-wrap: wrap; }
.face {
  width: 26px; height: 26px;
  display: grid;
  place-items: center;
  border-radius: 5px;
  background: var(--chalk);
  color: var(--ink);
  font-family: var(--font-head);
  font-weight: 600;
  font-size: 0.85rem;
  box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.18);
}
.face.zero { background: #5d6660; color: rgba(255, 255, 255, 0.7); }
.face.one { background: #e4b3ad; }
.face.big { background: var(--brass); }
.face.banked { background: #6ad08a; color: #08210f; box-shadow: inset 0 -2px 0 rgba(0,0,0,.2), 0 0 0 2px rgba(106,208,138,.35); }
.face.rolled { outline: 3px solid var(--brass); outline-offset: 2px; }
.face.lg { width: 38px; height: 38px; font-size: 1.15rem; border-radius: 7px; }

/* ---------- stat blocks ---------- */

.stat { padding: 0.65rem 0.8rem; background: rgba(0, 0, 0, 0.28); border-radius: var(--r-md); border: 1px solid var(--rail); }
.stat .label {
  font-family: var(--font-head);
  text-transform: uppercase;
  font-size: 0.7rem;
  letter-spacing: 1.2px;
  color: var(--chalk-faint);
}
.stat .value { font-size: 1.45rem; font-family: var(--font-head); line-height: 1.2; }
.stat .value small { font-size: 0.72rem; color: var(--chalk-dim); font-family: var(--font-body); }

.meter { height: 7px; border-radius: 4px; background: rgba(255, 255, 255, 0.1); overflow: hidden; margin-top: 0.4rem; }
.meter > span { display: block; height: 100%; background: var(--team, var(--brass)); border-radius: 4px; }

/* ---------- tables ---------- */

table.data { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
table.data th {
  text-align: left;
  font-family: var(--font-head);
  text-transform: uppercase;
  font-size: 0.73rem;
  letter-spacing: 1px;
  color: var(--chalk-faint);
  padding: 0.5rem 0.6rem;
  border-bottom: 1px solid var(--rail-strong);
  white-space: nowrap;
}
table.data td { padding: 0.5rem 0.6rem; border-bottom: 1px solid rgba(255, 255, 255, 0.055); }
table.data tbody tr:hover { background: rgba(255, 255, 255, 0.045); }
table.data td.num, table.data th.num { text-align: right; font-family: var(--font-mono); }
.table-wrap { overflow-x: auto; }

/* ---------- race board ---------- */

.board-day {
  border: 1px solid var(--rail);
  border-radius: var(--r-lg);
  background: var(--panel);
  overflow: hidden;
}
.board-day > header {
  display: flex; align-items: center; gap: 0.6rem;
  padding: 0.6rem 0.9rem;
  background: linear-gradient(90deg, color-mix(in srgb, var(--team, #444) 40%, transparent), transparent);
  border-bottom: 1px solid var(--rail);
}
.board-day > header h3 {
  margin: 0;
  font-family: var(--font-head);
  text-transform: uppercase;
  letter-spacing: 1.2px;
  font-size: 1rem;
}
.board-day > header .daynote { font-size: 0.8rem; color: var(--chalk-dim); }

.race-row {
  display: grid;
  grid-template-columns: 76px 1fr auto;
  gap: 0.75rem;
  align-items: center;
  padding: 0.6rem 0.9rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}
.race-row:last-child { border-bottom: none; }
.race-row:hover { background: rgba(255, 255, 255, 0.04); }
.race-row .rtime { font-family: var(--font-head); font-size: 0.95rem; color: var(--chalk); }
.race-row .rname { font-weight: 600; }
.race-row .rsub { font-size: 0.8rem; color: var(--chalk-dim); }
.race-row.is-live { background: rgba(192, 52, 44, 0.14); }
.race-row.is-final .rname { color: var(--chalk-dim); }

/* ---------- champion of champions board ---------- */

.coc {
  border: 1px solid var(--brass-dim);
  border-radius: var(--r-lg);
  background:
    radial-gradient(600px 240px at 50% 0%, rgba(216, 180, 90, 0.16), transparent 70%),
    var(--panel);
  padding: clamp(1rem, 2.5vw, 1.6rem);
}
.coc h2 {
  font-family: var(--font-display);
  font-size: clamp(1.3rem, 3.4vw, 2rem);
  margin: 0 0 0.2rem;
  color: var(--brass);
}
.coc-slots {
  display: grid;
  /* Six weeks, read as one row wherever there is room -- the shape of the
     board is part of the point. */
  grid-template-columns: repeat(6, 1fr);
  gap: 0.75rem;
  margin-top: 1.1rem;
}
@media (max-width: 980px) { .coc-slots { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 560px) { .coc-slots { grid-template-columns: repeat(2, 1fr); } }
.coc-slot {
  position: relative;
  border: 1px dashed var(--rail-strong);
  border-radius: var(--r-md);
  padding: 0.8rem 0.7rem;
  text-align: center;
  min-height: 150px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  background: rgba(0, 0, 0, 0.25);
}
.coc-slot.filled {
  border-style: solid;
  border-color: var(--team);
  background: linear-gradient(rgba(0, 0, 0, 0.25), color-mix(in srgb, var(--team) 18%, transparent));
}
.coc-slot .slot-week {
  position: absolute; top: 6px; left: 8px;
  font-family: var(--font-head);
  font-size: 0.68rem;
  letter-spacing: 1px;
  color: var(--chalk-faint);
}
.coc-slot .slot-name { font-family: var(--font-head); font-size: 0.95rem; line-height: 1.2; }
.coc-slot .slot-rank { font-family: var(--font-mono); font-size: 0.76rem; color: var(--team); font-weight: 700; }
.coc-slot .slot-pending { color: var(--chalk-faint); font-size: 0.82rem; }
.coc-slot .slot-lock { font-size: 1.5rem; color: rgba(255, 255, 255, 0.14); }

.coc-progress { height: 9px; border-radius: 5px; background: rgba(0,0,0,.4); overflow: hidden; margin-top: 0.9rem; border: 1px solid var(--rail); }
.coc-progress > span { display: block; height: 100%; background: linear-gradient(90deg, var(--brass-dim), var(--brass)); }

/* ---------- countdown ---------- */

.countdown {
  font-family: var(--font-head);
  font-variant-numeric: tabular-nums;
  letter-spacing: 1px;
}
.countdown.big { font-size: clamp(1.6rem, 5vw, 2.6rem); color: var(--brass); }

/* ---------- filters ---------- */

.filters { display: flex; gap: 0.4rem; flex-wrap: wrap; margin-bottom: 1rem; }
.chip {
  padding: 0.35rem 0.75rem;
  border-radius: 999px;
  border: 1px solid var(--rail-strong);
  background: rgba(255, 255, 255, 0.04);
  color: var(--chalk-dim);
  font-family: var(--font-head);
  font-size: 0.83rem;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}
.chip:hover { background: rgba(255, 255, 255, 0.1); color: var(--chalk); }
.chip.active { background: var(--team, var(--brass)); border-color: var(--team, var(--brass)); color: #10140f; font-weight: 600; }

input[type="text"], input[type="search"], input[type="number"], select, textarea {
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--rail-strong);
  color: var(--chalk);
  border-radius: var(--r-sm);
  padding: 0.45rem 0.65rem;
  font: inherit;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brass-dim); outline-offset: 1px; }

/* ---------- notices ---------- */

.notice {
  border-left: 3px solid var(--brass);
  background: rgba(216, 180, 90, 0.09);
  padding: 0.7rem 0.95rem;
  border-radius: 0 var(--r-md) var(--r-md) 0;
  font-size: 0.9rem;
  color: var(--chalk-dim);
}
.notice.warn { border-left-color: #ff7a66; background: rgba(255, 122, 102, 0.1); }
.notice strong { color: var(--chalk); }

/* ---------- footer ---------- */

.site-footer {
  border-top: 1px solid var(--rail);
  padding: 1.6rem clamp(0.75rem, 3vw, 2rem) 2.4rem;
  text-align: center;
  color: var(--chalk-faint);
  font-size: 0.85rem;
}
.site-footer p { margin: 0.2rem 0; }
.site-footer .fine { font-size: 0.78rem; max-width: 60ch; margin: 0.5rem auto 0; }

/* ---------- responsive ---------- */

@media (max-width: 860px) {
  .nav-toggle { display: block; }
  .nav {
    position: absolute;
    top: var(--topbar-h);
    left: 0; right: 0;
    flex-direction: column;
    gap: 0;
    background: rgba(6, 16, 11, 0.99);
    border-bottom: 1px solid var(--rail);
    padding: 0.4rem;
    display: none;
  }
  .nav.open { display: flex; }
  .nav a { padding: 0.75rem 0.9rem; }
  .race-row { grid-template-columns: 64px 1fr; }
  .race-row > :last-child { grid-column: 1 / -1; }
}

/* ---------- run-dice mood ----------
   Stands in for the raw six faces during a race. Players get the shape of the
   roll, never the numbers behind it. */

.mood {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.12rem 0.5rem;
  border-radius: 999px;
  font-family: var(--font-head);
  font-size: 0.72rem;
  letter-spacing: 0.9px;
  text-transform: uppercase;
  border: 1px solid currentColor;
  white-space: nowrap;
}
.mood-glyph { font-size: 0.62rem; letter-spacing: -1px; opacity: 0.85; }
.mood-loaded { color: #7ee2a0; background: rgba(126, 226, 160, 0.13); }
.mood-strong { color: #bcd98a; background: rgba(188, 217, 138, 0.11); }
.mood-mixed  { color: #e4cf8a; background: rgba(228, 207, 138, 0.1); }
.mood-wild   { color: #e8a7f0; background: rgba(232, 167, 240, 0.11); }
.mood-thin   { color: #f0958a; background: rgba(240, 149, 138, 0.11); }

/* ---------- running order during a race ---------- */

.order-strip { display: grid; gap: 0.4rem; margin-top: 1rem; }
.order-line {
  display: grid;
  /* Six cells: place, rank, name, mood, progress bar, distance. */
  grid-template-columns: 30px auto 1fr auto 90px 58px;
  gap: 0.6rem;
  align-items: center;
  padding: 0.45rem 0.7rem;
  background: var(--panel-2);
  border: 1px solid var(--rail);
  border-left: 4px solid var(--team, var(--rail-strong));
  border-radius: var(--r-md);
  transition: transform 0.3s ease;
}
.order-line .op {
  font-family: var(--font-display);
  font-size: 0.95rem;
  color: var(--chalk-faint);
  text-align: center;
}
.order-line.lead .op { color: var(--brass); }
.order-line .orank {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 0.76rem;
  color: var(--team);
}
.order-line .oname {
  font-family: var(--font-head);
  font-size: 0.95rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.order-line .obar {
  width: 90px;
  height: 6px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.1);
  overflow: hidden;
}
.order-line .obar > span { display: block; height: 100%; background: var(--team); }
.order-line .odist {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--chalk-dim);
  min-width: 52px;
  text-align: right;
}

@media (max-width: 640px) {
  .order-line { grid-template-columns: 26px auto 1fr auto 52px; }
  .order-line .obar { display: none; }
}

/* ---------- account chip ---------- */

.account-slot { flex: 0 0 auto; display: flex; align-items: center; gap: 0.35rem; }
.account-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.4rem 0.8rem;
  border-radius: 999px;
  border: 1px solid var(--rail-strong);
  background: rgba(255, 255, 255, 0.05);
  font-family: var(--font-head);
  font-size: 0.85rem;
  letter-spacing: 0.4px;
  color: var(--chalk-dim);
  max-width: 190px;
}
.account-chip span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.account-chip:hover { color: var(--chalk); border-color: var(--brass-dim); text-shadow: none; }
.account-chip.signin { background: rgba(216, 180, 90, 0.14); border-color: var(--brass-dim); color: var(--brass); }
.account-chip.signout { padding: 0.4rem 0.62rem; }
.account-chip.signout:hover { color: #ff9c8a; border-color: rgba(255, 120, 100, 0.5); }

.plan-current { border-color: var(--brass-dim); box-shadow: var(--shadow), 0 0 22px rgba(216, 180, 90, 0.12); }

@media (max-width: 860px) {
  .account-slot { order: 3; margin-left: auto; margin-right: 0.5rem; }
  .account-chip span { display: none; }
  .account-chip { padding: 0.45rem 0.6rem; }
}

/* ---------- admin matchup grid ---------- */

.matrix-wrap { overflow: auto; max-height: 72vh; }
.matrix {
  display: grid;
  grid-template-columns: 104px repeat(36, 30px);
  gap: 1px;
  font-family: var(--font-mono);
  font-size: 0.6rem;
}
.mx-corner { position: sticky; left: 0; top: 0; z-index: 3; background: var(--panel-2); }
.mx-col {
  position: sticky;
  top: 0;
  z-index: 2;
  writing-mode: vertical-rl;
  transform: rotate(180deg);
  height: 88px;
  padding: 3px 0;
  color: var(--chalk-faint);
  background: var(--panel-2);
  overflow: hidden;
  white-space: nowrap;
  font-size: 0.58rem;
}
.mx-row {
  position: sticky;
  left: 0;
  z-index: 2;
  padding: 0 6px;
  display: flex;
  align-items: center;
  color: var(--chalk-dim);
  background: var(--panel-2);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.62rem;
}
.mx-cell {
  display: grid;
  place-items: center;
  height: 24px;
  border-radius: 2px;
  color: rgba(255, 255, 255, 0.85);
}
.mx-self { background: rgba(255, 255, 255, 0.05); }

/* Prestige on the header chip, and the viewer's own row on the leaderboard. */
.chip-prestige {
  font-family: var(--font-mono);
  font-size: 0.76rem;
  color: var(--brass);
  background: rgba(216, 180, 90, 0.15);
  border-radius: 999px;
  padding: 0.05rem 0.4rem;
}
tr.lb-you { background: rgba(216, 180, 90, 0.12); }
tr.lb-you td { border-bottom-color: rgba(216, 180, 90, 0.25); }
