/* Visual system: SPEC.md Amendment A1, "Broadcast Blue". Tokens, type scale and screens follow A1 exactly. */

@font-face { font-family: "Barlow Condensed"; font-style: normal; font-weight: 700; font-display: swap; src: url(fonts/barlow-condensed-700.woff2) format("woff2"); }
@font-face { font-family: "Barlow Condensed"; font-style: italic; font-weight: 700; font-display: swap; src: url(fonts/barlow-condensed-700-italic.woff2) format("woff2"); }
@font-face { font-family: "Barlow Condensed"; font-style: italic; font-weight: 800; font-display: swap; src: url(fonts/barlow-condensed-800-italic.woff2) format("woff2"); }
@font-face { font-family: "Barlow"; font-style: normal; font-weight: 400; font-display: swap; src: url(fonts/barlow-400.woff2) format("woff2"); }
@font-face { font-family: "Barlow"; font-style: normal; font-weight: 600; font-display: swap; src: url(fonts/barlow-600.woff2) format("woff2"); }

:root {
  --blue: #005A8F;
  --navy: #0B2A4A;
  --red: #C8102E;
  --gold: #F2B134;
  --white: #FFFFFF;
  --paper: #F3F6F9;
  --ink: #1A1F2B;
  --ink-2: #5A6B80;
  --line: #E3E8EE;
  --loss: #69707E;
  --warn-bg: #FFF4D6;
  --err: #B3261E;
  --f-body: Barlow, "Helvetica Neue", Arial, sans-serif;
  --f-disp: "Barlow Condensed", "Arial Narrow", "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 400 16px/1.45 var(--f-body);
  overflow-x: hidden;
}
body.noscroll { overflow: hidden; }
[hidden] { display: none !important; }
a { color: var(--blue); }
h1, h2, h3, h4, p { margin: 0; }
.vh { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Type scale */
h1, h2, h3, .disp {
  font-family: var(--f-disp); font-weight: 800; font-style: italic;
  text-transform: uppercase; letter-spacing: 0.02em; line-height: 1;
}
h1 { font-size: 34px; }
h2 { font-size: 26px; }
h3 { font-size: 20px; }
.lab {
  font: 600 13px/1.3 var(--f-body); text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink-2);
}
.num { font-family: var(--f-disp); font-weight: 700; font-variant-numeric: tabular-nums; }
.dash { color: var(--loss); }
.struck { text-decoration: line-through; }

/* Page heading: label, H1, red stripe */
.ph .lab { margin-bottom: 6px; }
.pg { color: var(--navy); }
.pg::after { content: ""; display: block; width: 44px; height: 3px; background: var(--red); margin-top: 10px; }

/* Focus */
:focus-visible { outline: 3px solid var(--blue); outline-offset: 2px; }
.top :focus-visible, .login :focus-visible, .abar :focus-visible { outline-color: var(--white); }

/* Buttons and inputs */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 44px; padding: 0 18px;
  border: 1px solid var(--navy); border-radius: 6px;
  background: var(--white); color: var(--navy);
  font: 600 16px/1 var(--f-body); cursor: pointer; text-decoration: none;
}
.btn.primary {
  background: var(--red); border-color: var(--red); color: var(--white);
  font-family: var(--f-disp); font-weight: 800; font-style: italic; font-size: 18px;
  text-transform: uppercase; letter-spacing: 0.08em;
}
.btn.danger { border-color: var(--err); color: var(--err); }
.btn.small { min-height: 40px; padding: 0 14px; font-size: 15px; }
.btn[disabled] { opacity: 0.45; cursor: default; }
.linkbtn {
  background: none; border: 0; border-radius: 6px; color: var(--white);
  font: 600 14px/1 var(--f-body); min-height: 44px; padding: 0 4px; cursor: pointer;
}
input[type=text], input[type=number], input[type=password], select, textarea {
  width: 100%; min-height: 44px; padding: 8px 12px;
  border: 1px solid var(--ink-2); border-radius: 6px;
  background: var(--white); color: var(--ink);
  font: 400 16px/1.3 var(--f-body);
}
textarea { min-height: 88px; resize: vertical; }
textarea.json { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 14px; min-height: 120px; }
label.fld { display: block; font: 600 13px/1.3 var(--f-body); text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink-2); }
label.fld > input, label.fld > select, label.fld > textarea { margin-top: 4px; text-transform: none; letter-spacing: 0; color: var(--ink); }
label.chk { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; font-weight: 600; }
label.chk input { width: 22px; height: 22px; accent-color: var(--blue); }
.msg { font-weight: 600; font-size: 14px; }
.msg.ok { color: var(--navy); }
.msg.err { color: var(--err); }

/* Login */
.login {
  min-height: 100vh; min-height: 100dvh; display: flex; align-items: center; justify-content: center;
  padding: 30px; background: var(--blue);
}
.login-box { width: 100%; max-width: 340px; display: flex; flex-direction: column; align-items: center; gap: 14px; }
.login-logo { display: block; width: 150px; height: auto; }
.login-sub { font: 600 12px/1.3 var(--f-body); letter-spacing: 0.14em; text-transform: uppercase; color: rgba(255, 255, 255, 0.72); text-align: center; }
.login input { height: 48px; min-height: 48px; border: 0; border-radius: 6px; padding: 0 14px; }
.login input::placeholder { color: var(--ink-2); opacity: 1; }
.login .btn { width: 100%; height: 48px; }
.login-msg { color: #F5C465; min-height: 1.4em; font-weight: 600; text-align: center; width: 100%; }

/* Header */
.top {
  position: sticky; top: 0; z-index: 20; height: 56px;
  display: flex; align-items: center; gap: 14px;
  padding: 0 max(14px, calc((100% - 960px) / 2 + 16px));
  background: var(--blue); color: var(--white);
}
.brand { display: flex; align-items: center; min-height: 44px; margin-right: auto; border-radius: 6px; }
.brand img { display: block; height: 36px; width: auto; }
.live { display: inline-flex; align-items: center; gap: 7px; font: 600 12px/1 var(--f-body); letter-spacing: 0.08em; text-transform: uppercase; color: var(--white); }
.live i { width: 8px; height: 8px; border-radius: 50%; background: #9EA6B5; display: inline-block; }
.live.on i { background: var(--red); box-shadow: 0 0 0 3px rgba(200, 16, 46, 0.25); }
.hdr-tag {
  position: relative; display: inline-flex; align-items: center; height: 28px; padding: 0 10px;
  border: 1px solid var(--white); border-radius: 3px;
  color: var(--white); font: 600 11px/1 var(--f-body); letter-spacing: 0.06em; text-transform: uppercase; text-decoration: none;
}
.hdr-tag::after { content: ""; position: absolute; inset: -8px -4px; }

main { max-width: 960px; margin: 0 auto; padding: 20px 16px 64px; }
.crumbs { display: flex; flex-wrap: wrap; gap: 0 18px; margin: -6px 0 8px; }
.crumbs a { display: inline-flex; align-items: center; min-height: 44px; font: 600 14px/1 var(--f-body); color: var(--blue); text-decoration: none; }
.crumbs a:hover { text-decoration: underline; }

/* Overview */
.ep-head { scroll-margin-top: 112px; }
.ep-head.later { margin-top: 36px; }
.seg {
  position: sticky; top: 56px; z-index: 10; display: flex;
  margin: 14px -16px 16px; padding: 0 16px;
  background: var(--paper); border-bottom: 1px solid var(--line);
}
.seg button {
  position: relative; flex: 1; min-height: 44px; padding: 0 4px;
  background: none; border: 0; cursor: pointer;
  font: 600 13px/1 var(--f-body); letter-spacing: 0.06em; text-transform: uppercase; color: var(--navy);
}
.seg button.on::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 3px; background: var(--red); }
.grid { display: grid; grid-template-columns: 1fr; gap: 12px; }
@media (min-width: 640px) { .grid { grid-template-columns: 1fr 1fr; gap: 16px; } }
.gcard {
  background: linear-gradient(var(--blue), var(--blue)) top / 100% 3px no-repeat, var(--white);
  padding: 3px 14px 4px;
}
.gh { display: flex; align-items: center; justify-content: space-between; min-height: 48px; }
.gh h3 a { display: inline-flex; align-items: center; min-height: 44px; color: var(--blue); text-decoration: none; }
.gh h3 a:hover { text-decoration: underline; }
.gcard ul { list-style: none; margin: 0; padding: 0; }
.gcard li { display: flex; align-items: center; gap: 10px; min-height: 46px; padding: 2px 0; border-top: 1px solid var(--line); }
.sd { flex: none; width: 26px; font-size: 18px; color: var(--ink-2); }
.who { flex: 1; min-width: 0; }
.nm { color: var(--ink); font-weight: 600; text-decoration: none; padding: 8px 0; }
.nm:hover { text-decoration: underline; }
.rec { flex: none; margin-left: auto; font-size: 19px; color: var(--navy); }

/* Tags */
.tags { display: inline-flex; flex-wrap: wrap; gap: 4px; margin-left: 6px; vertical-align: middle; }
.tag {
  display: inline-block; padding: 0 7px; border: 1px solid transparent; border-radius: 3px;
  font: 600 11px/1.6 var(--f-body); text-transform: uppercase; letter-spacing: 0.05em; white-space: nowrap;
}
.tag.teen { border-color: var(--blue); color: var(--blue); }
.tag.rk { background: var(--gold); border-color: var(--gold); color: var(--navy); }
.tag.alt, .tag.wd { background: var(--line); border-color: var(--line); color: var(--ink); }

/* Group page */
.cnotes { background: var(--warn-bg); color: var(--ink); padding: 10px 12px; margin: 14px 0 0; white-space: pre-wrap; }
.surface { background: var(--white); margin-top: 16px; }
.rule { margin: 0; padding: 10px 12px; background: var(--warn-bg); color: var(--ink); font-size: 14px; }
.qbtn {
  position: relative; width: 22px; height: 22px; margin-left: 6px; padding: 0; vertical-align: middle;
  border: 1px solid var(--ink-2); border-radius: 6px; background: var(--white); color: var(--ink-2);
  font: 600 13px/1 var(--f-body); cursor: pointer;
}
.qbtn::after { content: ""; position: absolute; inset: -11px; }
table { border-collapse: collapse; width: 100%; }
.standings th {
  padding: 12px 6px 10px; text-align: left; vertical-align: middle;
  font: 600 13px/1.3 var(--f-body); text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink-2);
  border-bottom: 1px solid var(--line);
}
.standings td { padding: 12px 6px; vertical-align: middle; border-bottom: 1px solid var(--line); }
.standings tbody tr:last-child td { border-bottom: 0; }
.standings th:first-child, .standings td:first-child { width: 1%; white-space: nowrap; padding-left: 12px; padding-right: 4px; }
.standings th:last-child, .standings td:last-child { padding-right: 12px; }
.standings .r { text-align: right; white-space: nowrap; width: 1%; padding-left: 3px; padding-right: 3px; }
.standings th:nth-child(2), .standings td:nth-child(2) { padding-left: 2px; }
.standings td.rk { font: 800 italic 20px/1 var(--f-disp); color: var(--navy); }
.standings .nm { font-weight: 400; padding: 0; }
.standings .lead .nm { font-weight: 600; }
.standings .lead td:first-child { background: linear-gradient(var(--red), var(--red)) left / 3px 100% no-repeat; }
.standings td.num { font-size: 18px; }
.standings td.wl { font-size: 20px; color: var(--navy); }
.standings .tie { margin-left: 2px; font: 600 11px/1 var(--f-body); color: var(--ink-2); }
.races { margin-top: 24px; }
.races > .lab { padding-left: 12px; margin-bottom: 2px; }
.race { position: relative; padding: 12px 0 12px 12px; border-top: 1px solid var(--line); }
.race.dirty { background: linear-gradient(var(--gold), var(--gold)) left / 3px 100% no-repeat; }
.mrow { display: grid; grid-template-columns: 34px 1fr 1fr; gap: 8px; align-items: start; }
.rn { padding-top: 1px; font-size: 18px; color: var(--ink-2); }
.side { min-width: 0; overflow-wrap: anywhere; }
.side .nm { padding: 0; font-weight: 600; color: var(--ink); }
.side.lost .nm { font-weight: 400; color: var(--loss); }
.side.pend .nm { font-weight: 400; color: var(--ink-2); }
.wm { margin-left: 5px; font: 700 italic 14px/1 var(--f-disp); color: var(--red); }
.meta { display: block; margin-top: 2px; font-size: 12px; line-height: 1.35; color: var(--ink-2); }
.meta.num { font-weight: 700; }
.rnotes { margin: 4px 0 0 42px; font-size: 14px; color: var(--ink-2); white-space: pre-wrap; }

/* Admin edit row: expands inline */
.mtog { margin: -4px 0 -6px 42px; }
.etoggle { min-height: 44px; padding: 0 4px; background: none; border: 0; cursor: pointer; font: 600 14px/1 var(--f-body); color: var(--blue); }
.ebody { display: none; margin: 4px 12px 0 0; padding: 14px 12px; background: var(--white); border: 1px solid var(--line); }
.race.open .ebody { display: block; }
.eside + .eside { margin-top: 14px; }
.ewho { font-weight: 600; margin-bottom: 2px; }
.pairs { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 4px; }
.rtop { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 14px; }
.rfoot { display: flex; align-items: center; gap: 10px; margin-top: 12px; flex-wrap: wrap; }
@media (min-width: 640px) {
  .esides { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
  .eside + .eside { margin-top: 0; }
}

/* Competitor card modal */
.modal { position: fixed; inset: 0; z-index: 50; display: flex; align-items: flex-end; justify-content: center; }
.backdrop { position: absolute; inset: 0; background: rgba(11, 42, 74, 0.6); }
.sheet {
  position: relative; width: 100%; max-width: 640px; max-height: 94vh; max-height: 94dvh;
  overflow-y: auto; overscroll-behavior: contain;
  background: var(--white); border-radius: 16px 16px 0 0;
  box-shadow: 0 -8px 32px rgba(11, 42, 74, 0.28);
  padding: 24px 16px calc(28px + env(safe-area-inset-bottom));
}
@media (min-width: 700px) { .modal { align-items: center; } .sheet { border-radius: 0; padding: 28px 24px 32px; } }
.x:focus-visible { outline-offset: -4px; }
.x {
  position: absolute; top: 6px; right: 6px; width: 44px; height: 44px;
  border: 0; border-radius: 6px; background: none; color: var(--navy);
  font-size: 32px; line-height: 1; cursor: pointer; z-index: 2;
}
.chead { display: flex; gap: 16px; align-items: center; padding-right: 36px; }
.photo { flex: none; width: 118px; height: 118px; padding: 3px; border-radius: 50%; background: var(--line); }
.photo.verified { background: var(--gold); }
.pimg {
  position: relative; width: 112px; height: 112px; border-radius: 50%; overflow: hidden;
  background: var(--navy); color: var(--white);
  display: flex; align-items: center; justify-content: center;
  font: 800 italic 38px/1 var(--f-disp); letter-spacing: 0.02em;
}
.pimg img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.cinfo { min-width: 0; }
.cname { font-size: 34px; color: var(--navy); overflow-wrap: anywhere; }
.csub { margin: 8px 0 0; }
.csub a { color: var(--blue); text-decoration: none; }
.csub a:hover { text-decoration: underline; }
.cinfo .tags { margin: 8px 0 0; }
.vbadge { display: inline-block; vertical-align: 2px; margin-left: 8px; line-height: 0; }
.vbadge svg { width: 20px; height: 20px; }
.vbadge.verified { color: var(--blue); }
.vbadge.partial { color: var(--ink-2); }
.sec { margin-top: 26px; }
.sec > h3 {
  font: 600 13px/1.3 var(--f-body); font-style: normal; text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink-2);
  margin-bottom: 10px; padding-bottom: 6px; border-bottom: 1px solid var(--line);
}
.sec p { white-space: pre-wrap; }
.links { display: flex; flex-wrap: wrap; gap: 0 20px; }
.links a { display: inline-flex; align-items: center; min-height: 40px; font-weight: 600; color: var(--blue); }
.sec table { font-size: 15px; }
.sec th { padding: 6px 8px 6px 0; text-align: left; font: 600 12px/1.3 var(--f-body); text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink-2); border-bottom: 1px solid var(--line); }
.sec td { padding: 8px 8px 8px 0; vertical-align: top; border-bottom: 1px solid var(--line); }
dl.kv { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; }
dl.kv dt { font-weight: 600; }
dl.kv dd { margin: 0; overflow-wrap: anywhere; }
ul.plain { list-style: none; margin: 0; padding: 0; }
ul.plain li { padding: 8px 0; border-top: 1px solid var(--line); }
ul.plain li:first-child { border-top: 0; }
ul.plain a.v { display: inline-block; padding: 6px 0; }
.frec { display: flex; align-items: baseline; gap: 10px; margin-bottom: 6px; }
.frec .num { font-size: 22px; color: var(--navy); }
.res { display: inline-block; min-width: 24px; margin-right: 8px; font: 700 20px/1 var(--f-disp); color: var(--loss); }
.res.W { color: var(--red); }
.res.L { color: var(--loss); }
.fmeta { font-size: 14px; color: var(--ink-2); }
.editbar { margin-top: 16px; display: flex; gap: 8px; flex-wrap: wrap; }
.adminnote { background: var(--warn-bg); color: var(--ink); padding: 10px 12px; }
.adminnote strong { display: block; font: 600 12px/1.3 var(--f-body); text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink-2); }

/* Edit form */
.eform { display: flex; flex-direction: column; gap: 12px; margin-top: 16px; }
.eform .row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.eform .checks { display: flex; flex-wrap: wrap; gap: 4px 18px; }
.pctl { display: flex; flex-wrap: wrap; gap: 8px; margin: 16px 0 0; }
.pctl .btn { flex: 1 1 auto; }

/* Admin panel */
.apanel { background: var(--white); margin-top: 28px; }
.apanel > h2 { padding: 16px 12px 4px; color: var(--navy); }
.ahint { margin: 0; padding: 6px 12px 0; font-size: 14px; color: var(--ink-2); }
.agroup > h3 { display: flex; align-items: baseline; gap: 8px; padding: 18px 12px 6px; color: var(--blue); }
.agroup > h3 span { font: 600 12px/1 var(--f-body); font-style: normal; letter-spacing: 0.06em; color: var(--ink-2); }
.arow { display: grid; grid-template-columns: 1fr 88px; gap: 10px; align-items: center; padding: 6px 12px; border-top: 1px solid var(--line); }
.arow.dirty { background: linear-gradient(var(--gold), var(--gold)) left / 3px 100% no-repeat; }
.arow.err { background: linear-gradient(var(--err), var(--err)) left / 3px 100% no-repeat; }
.aname { min-width: 0; overflow-wrap: anywhere; font-size: 15px; font-weight: 600; padding: 6px 0; }
.aname .vs { font-weight: 400; font-size: 13px; color: var(--ink-2); }
.aname .mark { display: none; margin-left: 8px; padding: 0 7px; border-radius: 3px; background: var(--warn-bg); color: var(--ink); font: 600 11px/1.6 var(--f-body); text-transform: uppercase; letter-spacing: 0.05em; }
.arow.dirty .mark { display: inline-block; }
.aname .rmsg { display: block; font-size: 13px; font-weight: 600; color: var(--err); }
.aname .rmsg:empty { display: none; }
.aname .rmsg.ok { color: var(--navy); }
.arow.dirty .rmsg.ok { display: none; }
.arow input { text-align: center; font: 700 20px/1.2 var(--f-disp); font-variant-numeric: tabular-nums; scroll-margin-top: 64px; scroll-margin-bottom: 90px; }
.abar {
  position: sticky; bottom: 0; z-index: 10; display: flex; align-items: center; flex-wrap: wrap; gap: 8px 12px;
  padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
  background: var(--blue); color: var(--white);
}
.abar .msg, .abar .msg.ok, .abar .msg.err { color: var(--white); }
.acount { font-weight: 600; font-size: 14px; }
.aform { display: flex; flex-direction: column; gap: 14px; padding: 12px; }
.aform .ahint { padding: 0; }
.aform .rfoot { margin-top: 0; }
.aform .checks { display: flex; flex-wrap: wrap; gap: 4px 18px; }
.aform .asub { font-size: 20px; color: var(--navy); }
.aform.adiv { border-top: 1px solid var(--line); margin-top: 8px; padding-top: 20px; }
.afine { margin: 0; font-size: 13px; color: var(--ink-2); }

@media (max-width: 380px) {
  .chead { gap: 12px; padding-right: 30px; }
  .cname { font-size: 30px; }
}
