/* Touchline dashboard — dark "broadcast-graphics" design.
 * Mobile-first, fluid (clamp), RTL-safe (logical properties), safe-area aware.
 * Self-hosted variable fonts: Inter (body) + Geist (display). */

@font-face {
  font-family: "Inter var"; font-style: normal; font-weight: 400 800; font-display: swap;
  src: url("../fonts/inter-var.woff2") format("woff2");
}
@font-face {
  font-family: "Geist var"; font-style: normal; font-weight: 400 800; font-display: swap;
  src: url("../fonts/geist-var.woff2") format("woff2");
}

:root {
  --bg: #0a0d0e; --panel: #11161a; --panel-2: #0d1216; --line: #1d262c;
  --ink: #e8eef0; --muted: #7d8a90; --faint: #4a565c;
  --lime: #c6ff36; --lime-dim: #7fa820; --amber: #ffb13b; --slate: #5b7c99; --rose: #ff5d73;
  --mono: "SF Mono", ui-monospace, "Cascadia Code", "Roboto Mono", Menlo, monospace;
  --sans: "Inter var", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --display: "Geist var", "Inter var", ui-sans-serif, system-ui, sans-serif;
  --maxw: 1180px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: radial-gradient(1200px 600px at 70% -10%, #10181b 0%, var(--bg) 55%);
  color: var(--ink); font-family: var(--sans); line-height: 1.5;
  -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; text-rendering: optimizeLegibility;
  font-variant-numeric: tabular-nums; /* aligned figures, like a real data product */
  letter-spacing: -0.006em; overflow-wrap: anywhere; overflow-x: hidden; /* contain the off-canvas sheet */
}
.wrap {
  max-width: var(--maxw); margin: 0 auto;
  padding: clamp(18px, 4vw, 28px) clamp(14px, 4vw, 22px) 90px;
  padding-inline: max(clamp(14px, 4vw, 22px), env(safe-area-inset-left)) max(clamp(14px, 4vw, 22px), env(safe-area-inset-right));
}
button { font-family: inherit; cursor: pointer; }

/* ── header ── */
header { display: flex; align-items: flex-end; justify-content: space-between; gap: 18px;
  flex-wrap: wrap; border-bottom: 1px solid var(--line); padding-bottom: 18px; margin-bottom: 26px; }
.brand { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.wordmark { font-family: var(--display); font-weight: 800; font-size: clamp(26px, 7vw, 34px); letter-spacing: .14em;
  text-transform: uppercase; display: flex; align-items: center; gap: 12px; }
.wordmark b { color: var(--lime); }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--lime); box-shadow: 0 0 14px var(--lime); flex: none; }
.tag { color: var(--muted); font-size: clamp(12px, 3.4vw, 13px); max-width: 560px; }
.head-right { display: flex; flex-direction: column; align-items: flex-end; gap: 10px; }
.meta { text-align: end; font-family: var(--mono); font-size: 11.5px; color: var(--faint); line-height: 1.7; }
.skill { display: inline-block; margin-top: 6px; padding: 6px 11px; border: 1px solid var(--lime-dim);
  border-radius: 6px; color: var(--lime); background: rgba(198,255,54,.06); font-size: 12px; }
/* language switcher */
.lang { position: relative; }
.lang select {
  appearance: none; background: var(--panel); color: var(--ink); border: 1px solid var(--line);
  border-radius: 8px; padding: 7px 30px 7px 12px; font-size: 12.5px; font-family: var(--sans);
}
.lang::after { content: ""; position: absolute; inset-inline-end: 13px; top: 44%;
  width: 6px; height: 6px; border-right: 1.6px solid var(--muted); border-bottom: 1.6px solid var(--muted);
  transform: translateY(-50%) rotate(45deg); pointer-events: none; }
html[dir="rtl"] .lang select { padding: 7px 12px 7px 30px; }

/* ── section heads ── */
.sec { margin: clamp(30px, 7vw, 44px) 0 16px; display: flex; align-items: baseline; gap: 14px; }
.sec h2 { margin: 0; font-family: var(--display); font-size: 12.5px; letter-spacing: .15em; text-transform: uppercase; color: var(--muted); font-weight: 700; }
.sec h2 .subh { color: var(--faint); font-weight: 600; }
.sec .rule { flex: 1; height: 1px; background: var(--line); }

/* ── favourites ── */
.hero { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(155px, 100%), 1fr)); gap: 13px; }
.fav { background: linear-gradient(180deg, var(--panel), var(--panel-2)); border: 1px solid var(--line);
  border-radius: 14px; padding: 17px 17px 15px; position: relative; overflow: hidden; cursor: pointer;
  transition: border-color .15s, transform .15s; }
.fav:hover, .fav:focus-visible { border-color: var(--lime-dim); transform: translateY(-2px); outline: none; }
.fav:first-child { border-color: var(--lime-dim); box-shadow: inset 0 0 0 1px rgba(198,255,54,.12); }
.fav .rank { font-family: var(--mono); font-size: 11px; color: var(--faint); }
.fav .name { font-family: var(--display); font-size: clamp(17px, 5vw, 20px); font-weight: 700; margin: 2px 0 10px; }
.fav .pct { font-family: var(--mono); font-size: clamp(26px, 8vw, 30px); font-weight: 600; color: var(--lime); line-height: 1; }
.fav .lbl { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .1em; margin-top: 4px; }
.fav .spark { position: absolute; inset-inline-end: -20px; bottom: -26px; font-size: 120px; font-weight: 800;
  color: rgba(255,255,255,.025); font-family: var(--mono); }

/* ── board ── */
.board { border: 1px solid var(--line); border-radius: 14px; overflow: hidden; background: var(--panel-2); }
.row { display: grid; grid-template-columns: 28px minmax(0, 1fr) 78px minmax(70px, 140px) auto; align-items: center;
  gap: clamp(8px, 2.5vw, 12px); padding: 11px clamp(12px, 3.5vw, 16px); border-top: 1px solid var(--line);
  font-size: 14px; cursor: pointer; }
.row:first-child { border-top: none; }
.row:hover, .row:focus-visible { background: rgba(255,255,255,.02); outline: none; }
.row .pos { font-family: var(--mono); color: var(--faint); font-size: 12px; }
.row .team { font-weight: 600; display: flex; align-items: center; gap: 9px; min-width: 0; }
.row .team .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.grp { font-family: var(--mono); font-size: 10px; color: var(--muted); border: 1px solid var(--line);
  border-radius: 4px; padding: 1px 5px; flex: none; }
.row .champ { font-family: var(--mono); color: var(--lime); text-align: end; font-size: 14px; }
.bar { height: 7px; background: #161d22; border-radius: 4px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: linear-gradient(90deg, var(--lime-dim), var(--lime)); border-radius: 4px; }
.row .final { font-family: var(--mono); color: var(--muted); text-align: end; font-size: 12px; white-space: nowrap; }
@media (max-width: 560px) {
  .row { grid-template-columns: 28px minmax(0, 1fr) 76px minmax(56px, 120px); }
  .row .final { display: none; }
}
@media (max-width: 420px) {
  .row { grid-template-columns: 24px minmax(0, 1fr) 66px; }
  .row .bar { display: none; }
}

/* ── fixtures ── */
.fixtures { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(280px, 100%), 1fr)); gap: 13px; }
.fx { background: var(--panel); border: 1px solid var(--line); border-radius: 13px; padding: 15px 16px; }
.fx .top { display: flex; justify-content: space-between; gap: 8px; font-family: var(--mono); font-size: 11px; color: var(--faint); margin-bottom: 11px; }
.fx .vs { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 13px; }
.fx .side { font-weight: 700; font-size: clamp(14px, 4vw, 15.5px); cursor: pointer; }
.fx .side:hover { color: var(--lime); }
.fx .side.a { text-align: end; flex: 1; min-width: 0; }
.fx .side.b { text-align: start; flex: 1; min-width: 0; }
.fx .xg { font-family: var(--mono); font-size: 12px; color: var(--amber); white-space: nowrap; flex: none; }
.wdl { display: flex; height: 30px; border-radius: 7px; overflow: hidden; font-family: var(--mono); font-size: 11px; font-weight: 600; }
.wdl > span { display: flex; align-items: center; justify-content: center; color: #0a0d0e; min-width: 24px; }
.wdl .h { background: var(--lime); } .wdl .d { background: var(--slate); } .wdl .a { background: var(--amber); }
.fx .foot { display: flex; justify-content: space-between; gap: 8px; margin-top: 11px; font-size: 11.5px; color: var(--muted); }
.fx .foot .ml { font-family: var(--mono); color: var(--ink); }
.fx .why { margin-top: 11px; padding-top: 11px; border-top: 1px solid var(--line); font-size: 12px; color: var(--muted); line-height: 1.45; }
.fx .why .lead { color: var(--lime); font-weight: 600; }
.chips { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 8px; }
.chip { font-size: 10px; font-family: var(--mono); color: var(--faint); border: 1px solid var(--line); border-radius: 5px; padding: 2px 7px; }
.chip b { color: var(--lime-dim); font-weight: 600; }

/* ── tournament path (survival curves) ── */
.pathcard { background: var(--panel-2); border: 1px solid var(--line); border-radius: 13px; padding: 18px clamp(12px, 3vw, 20px); }
.pathnote { color: var(--muted); font-size: 13px; margin-bottom: 14px; line-height: 1.5; }
.pcurve { width: 100%; height: auto; display: block; }
.pcurve .pg { stroke: #161d22; stroke-width: 1; }
.pcurve .pax { fill: var(--muted); font-family: var(--mono); font-size: 15px; text-anchor: middle; }
.pcurve .pay { text-anchor: end; fill: var(--faint); }
.pcurve .ptrophy { stroke: var(--muted); }
.pleg { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.pchip { display: inline-flex; align-items: center; gap: 7px; background: var(--panel); border: 1px solid var(--line);
  border-radius: 8px; padding: 6px 11px; color: var(--ink); font-size: 12.5px; cursor: pointer; }
.pchip:hover, .pchip:focus-visible { border-color: var(--muted); outline: none; }
.pchip b { color: var(--lime); font-family: var(--mono); margin-inline-start: 3px; }
.psw { width: 10px; height: 10px; border-radius: 3px; flex: none; }

/* ── compare mode ── */
.comparecard { background: var(--panel-2); border: 1px solid var(--line); border-radius: 13px; padding: 18px clamp(12px, 3vw, 20px); }
.cmprow { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 10px; margin-bottom: 18px; }
.cmpsel { width: 100%; min-width: 0; appearance: none; background: var(--panel); color: var(--ink);
  border: 1px solid var(--line); border-radius: 9px; padding: 11px 13px; font-size: clamp(13px, 3.6vw, 14.5px);
  font-weight: 600; font-family: var(--display); }
.cmpsel:focus-visible { outline: none; border-color: var(--lime-dim); }
.cmpvs { font-family: var(--mono); font-size: 11px; color: var(--faint); text-transform: uppercase; letter-spacing: .1em; }
.cmpneutral { font-size: 12px; color: var(--muted); text-align: center; margin-bottom: 9px; }
.cmpwdl { display: flex; height: 34px; border-radius: 8px; overflow: hidden; font-family: var(--mono); font-size: 12px; font-weight: 600; }
.cmpwdl > span { display: flex; align-items: center; justify-content: center; color: #0a0d0e; min-width: 26px; }
.cmpwdl .h { background: var(--lime); } .cmpwdl .d { background: var(--slate); } .cmpwdl .a { background: var(--amber); }
.cmpxg { display: flex; justify-content: space-between; font-family: var(--mono); font-size: 12px; color: var(--amber); margin-top: 7px; }
.cmpchips { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 12px; justify-content: center; }
.cmpstats { margin-top: 16px; }
.cmpr { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 10px; padding: 9px 2px;
  border-top: 1px solid var(--line); font-size: 13.5px; }
.cmpr > span:first-child { text-align: start; font-family: var(--mono); color: var(--ink); }
.cmpr > span:last-child { text-align: end; font-family: var(--mono); color: var(--ink); }
.cmpr .cmpl { color: var(--muted); font-size: 10.5px; text-transform: uppercase; letter-spacing: .08em; text-align: center; white-space: nowrap; }
.cmpr .win { color: var(--lime); font-weight: 700; }
.cmpnote { color: var(--muted); text-align: center; padding: 22px 8px; font-size: 13px; }
.cmpstatnote { color: var(--faint); font-size: 11px; text-align: center; margin-top: 12px; line-height: 1.45; }

/* ── calibration ── */
.calib { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(148px, 100%), 1fr)); gap: 13px; align-items: stretch; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: 13px; padding: 18px; }
.stat .v { font-family: var(--mono); font-size: clamp(22px, 6vw, 26px); font-weight: 600; color: var(--ink); }
.stat .v.good { color: var(--lime); }
.stat .k { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .1em; margin-top: 7px; }
.stat .sub { font-size: 11px; color: var(--faint); margin-top: 3px; }
.relcard { grid-column: 1 / -1; background: var(--panel); border: 1px solid var(--line); border-radius: 13px;
  padding: 20px; display: flex; gap: 24px; align-items: center; flex-wrap: wrap; }
.rel { width: min(300px, 100%); height: auto; aspect-ratio: 1 / 1; }
.rel .g { stroke: #161d22; stroke-width: 1; }
.rel .diag { stroke: var(--faint); stroke-width: 1.2; stroke-dasharray: 5 5; }
.rel .curve { fill: none; stroke: var(--lime); stroke-width: 2.5; stroke-linejoin: round; }
.rel .dot { fill: var(--lime); }
.rel .ax { fill: var(--faint); font-size: 12px; font-family: var(--mono); text-anchor: middle; }
.relcard .legend { flex: 1; min-width: 230px; color: var(--muted); font-size: 13px; line-height: 1.65; }
.relcard .legend b { color: var(--ink); } .relcard .legend .hl { color: var(--lime); }
.receipt { grid-column: 1 / -1; border: 1px dashed var(--line); border-radius: 13px; padding: 16px 18px;
  color: var(--muted); font-size: 13px; background: var(--panel-2); }
.receipt b { color: var(--lime); }

footer { margin-top: 50px; padding-top: 20px; border-top: 1px solid var(--line); color: var(--faint);
  font-size: 11.5px; font-family: var(--mono); display: flex; justify-content: space-between; flex-wrap: wrap; gap: 10px; }
.loading { color: var(--muted); padding: 38px; text-align: center; font-family: var(--mono); font-size: 13px; }

/* ── team detail overlay ── */
.scrim { position: fixed; inset: 0; background: rgba(4,7,8,.66); backdrop-filter: blur(3px);
  opacity: 0; pointer-events: none; transition: opacity .22s ease; z-index: 40; }
.scrim.open { opacity: 1; pointer-events: auto; }
.sheet { position: fixed; inset-block: 0; inset-inline-end: 0; width: min(440px, 100%);
  background: var(--panel-2); border-inline-start: 1px solid var(--line); z-index: 41;
  transform: translateX(100%); transition: transform .26s cubic-bezier(.2,.7,.2,1);
  display: flex; flex-direction: column; box-shadow: -20px 0 60px rgba(0,0,0,.5); }
html[dir="rtl"] .sheet { transform: translateX(-100%); box-shadow: 20px 0 60px rgba(0,0,0,.5); }
.sheet.open { transform: translateX(0); }
.sheet-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px;
  padding: max(20px, env(safe-area-inset-top)) 20px 16px; border-bottom: 1px solid var(--line); }
.sheet-head .tname { font-family: var(--display); font-size: clamp(22px, 6vw, 27px); font-weight: 800; line-height: 1.1; overflow-wrap: anywhere; }
.sheet-head .tsub { color: var(--muted); font-size: 12.5px; margin-top: 5px; font-family: var(--mono); }
.sheet-head .big { font-family: var(--mono); color: var(--lime); font-size: clamp(26px, 8vw, 34px); font-weight: 600; line-height: 1; }
.sheet-head .biglbl { color: var(--muted); font-size: 10px; text-transform: uppercase; letter-spacing: .1em; text-align: end; }
.x { background: none; border: 1px solid var(--line); color: var(--muted); border-radius: 8px; width: 34px; height: 34px; font-size: 18px; line-height: 1; flex: none; }
.x:hover { color: var(--ink); border-color: var(--muted); }
.sheet-body { overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 18px 20px max(28px, env(safe-area-inset-bottom)); }
.blk { margin-bottom: 24px; }
.blk h4 { margin: 0 0 12px; font-size: 11px; letter-spacing: .18em; text-transform: uppercase; color: var(--muted); font-weight: 700; }
/* path-to-title rows */
.path-row { display: grid; grid-template-columns: 1fr 52px; align-items: center; gap: 10px; margin-bottom: 9px; }
.path-row .rl { font-size: 13px; }
.path-row .pv { font-family: var(--mono); font-size: 13px; color: var(--lime); text-align: end; }
.path-bar { grid-column: 1 / -1; height: 6px; background: #161d22; border-radius: 4px; overflow: hidden; margin-top: 2px; }
.path-bar > i { display: block; height: 100%; background: linear-gradient(90deg, var(--lime-dim), var(--lime)); }
/* overlay fixtures */
.ovfx { display: flex; flex-direction: column; gap: 9px; }
.ovfx .m { border: 1px solid var(--line); border-radius: 10px; padding: 11px 13px; }
.ovfx .m .l1 { display: flex; justify-content: space-between; gap: 8px; font-size: 13.5px; font-weight: 600; }
.ovfx .m .l2 { display: flex; justify-content: space-between; gap: 8px; margin-top: 5px; font-family: var(--mono); font-size: 11.5px; color: var(--muted); }
.ovfx .m .l2 .w { color: var(--lime); }
.why-list { display: flex; flex-direction: column; gap: 8px; }
.why-list .d { display: flex; justify-content: space-between; gap: 10px; font-size: 12.5px; color: var(--muted); }
.why-list .d b { color: var(--ink); font-weight: 600; }
.why-list .d .fav { color: var(--lime); font-family: var(--mono); font-size: 11px; white-space: nowrap; }
.summary { color: var(--ink); font-size: 13.5px; line-height: 1.5; margin-bottom: 12px; }

@media (prefers-reduced-motion: reduce) {
  .scrim, .sheet, .fav { transition: none; }
}
