:root {
  --bay: #0D3B5E;
  --bay-deep: #0A2F4B;
  --foam: #F2F6F9;
  --paper: #FFFFFF;
  --ink: #10283A;
  --muted: #587084;
  --line: #D6E1EA;
  --track: #E4ECF2;
  --sea: #1F6FB2;
  --sun: #F5C518;
  --sun-soft: #FFF3C4;
  --up: #1D8A57;
  --down: #C2412A;
  --display: 'Unbounded', 'Arial Black', sans-serif;
  --text: 'Golos Text', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --r-lg: 14px;
  --r-sm: 8px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--foam);
  color: var(--ink);
  font: 400 16px/1.5 var(--text);
  font-variant-numeric: tabular-nums;
}
img { display: block; }
a { color: var(--sea); }
button { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--sun); outline-offset: 2px; border-radius: 4px; }

.wrap { width: min(1240px, 100%); margin: 0 auto; padding: 0 16px; }

/* header */
.top {
  background: var(--bay);
  color: #fff;
  padding: 28px 0 26px;
  padding-top: max(28px, env(safe-area-inset-top));
}
.top .wrap { display: grid; gap: 10px; }
.event { margin: 0; color: #B9D3E6; font-size: 14px; }
.top h1 {
  margin: 0;
  font: 700 clamp(34px, 9vw, 72px)/1.02 var(--display);
  letter-spacing: -0.02em;
}
.lead { margin: 4px 0 0; max-width: 60ch; color: #DCE9F2; font-size: 17px; }
.stamp { margin: 0; color: #fff; font-weight: 500; }
.stamp b { color: var(--sun); font-weight: 600; }
.ukr {
  justify-self: start;
  display: inline-flex; align-items: center; gap: 10px;
  margin-top: 6px;
  padding: 10px 16px;
  border: 0; border-radius: 999px;
  background: var(--sun); color: var(--bay-deep);
  font-weight: 600; cursor: pointer;
}
.ukr img { border-radius: 2px; }

/* sections */
.block { padding-top: 36px; }
.block-head { margin-bottom: 16px; }
.block-head h2, .method h2 {
  margin: 0 0 6px;
  font: 700 clamp(22px, 5.4vw, 32px)/1.15 var(--display);
  letter-spacing: -0.01em;
}
.block-head p { margin: 0; color: var(--muted); max-width: 70ch; }

/* current round groups */
.groups { display: grid; gap: 12px; grid-template-columns: 1fr; }
.gcard {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 14px 14px 10px;
}
.gcard-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 8px; }
.gcard-head h3 { margin: 0; font: 700 18px/1.2 var(--display); }
.pips { display: flex; align-items: center; gap: 4px; color: var(--muted); font-size: 12px; }
.pip { width: 12px; height: 12px; border-radius: 50%; border: 2px solid var(--sea); }
.pip.x2 { width: 22px; border-radius: 6px; }
.pip.on { background: var(--sea); }
.pips span { margin-left: 4px; white-space: nowrap; }

.trow {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr) auto;
  grid-template-areas: "flag name pct" "bar bar bar";
  align-items: center;
  column-gap: 10px;
  padding: 10px 6px 12px;
  margin: 0 -6px;
  border: 0; border-radius: var(--r-sm);
  background: none; text-align: left; width: calc(100% + 12px);
  cursor: pointer;
}
.trow:hover { background: var(--foam); }
.trow.sel { background: var(--sun-soft); }
.trow > img { grid-area: flag; width: 28px; height: 19px; border-radius: 3px; box-shadow: 0 0 0 1px rgba(16,40,58,.12); }
.tname { grid-area: name; min-width: 0; }
.tname b { display: block; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.races { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 3px; font-size: 13px; color: var(--muted); }
.races i {
  font-style: normal; min-width: 22px; padding: 0 5px; border-radius: 5px;
  background: var(--track); color: var(--ink); text-align: center; line-height: 20px;
}
.races i.empty { background: none; border: 1px dashed var(--line); color: transparent; }
.races .tot { margin-left: 2px; color: var(--ink); font-weight: 600; line-height: 20px; }
.tpct { grid-area: pct; text-align: right; line-height: 1.1; }
.tpct strong { font: 700 24px/1 var(--display); letter-spacing: -0.02em; }
.delta { display: block; font-size: 12px; font-weight: 600; margin-top: 3px; }
.delta.up { color: var(--up); }
.delta.down { color: var(--down); }
.delta.flat { color: var(--muted); font-weight: 400; }
.bar { grid-area: bar; height: 8px; margin-top: 9px; border-radius: 4px; background: var(--track); overflow: hidden; }
.bar > div { height: 100%; width: 0; background: var(--sea); border-radius: 4px; }
.trow.out .bar > div { background: #A9BCCB; }
.trow.out .tname b, .trow.out .tpct strong { color: var(--muted); }
.trow.in .tpct strong { color: var(--up); }
.cut {
  position: relative; height: 0; margin: 2px 0;
  border-top: 2px dashed var(--sun);
}
.cut span {
  position: absolute; right: 0; top: -10px; padding: 0 6px;
  background: var(--paper); color: #8A6A00; font-size: 12px; font-weight: 600;
}
.gcard-foot { margin: 6px 0 2px; font-size: 13px; color: var(--muted); }

/* bracket */
.tabs { display: flex; gap: 6px; margin-bottom: 12px; overflow-x: auto; }
.tabs button {
  flex: 1 0 auto; min-width: 64px;
  padding: 9px 14px; border: 1px solid var(--line); border-radius: 999px;
  background: var(--paper); cursor: pointer; font-weight: 600;
}
.tabs button[aria-selected="true"] { background: var(--bay); border-color: var(--bay); color: #fff; }
.tree { display: block; }
.col { display: none; }
.col.show { display: block; }
.col h3 { margin: 0 0 10px; font: 700 16px/1.2 var(--display); }
.col h3 span { display: block; margin-top: 4px; font: 400 13px/1.3 var(--text); color: var(--muted); }
.col-body { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 260px), 1fr)); }
.box {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  padding: 8px 10px;
}
.box h4 { margin: 0 0 4px; font-size: 13px; font-weight: 600; color: var(--muted); }
.ent {
  display: grid; grid-template-columns: 22px minmax(0, 1fr) auto; align-items: center; gap: 8px;
  width: 100%; padding: 6px 4px; border: 0; border-radius: 6px; background: none; text-align: left; cursor: pointer;
}
.ent:hover { background: var(--foam); }
.ent.sel { background: var(--sun-soft); }
.ent img { width: 22px; height: 15px; border-radius: 2px; box-shadow: 0 0 0 1px rgba(16,40,58,.12); }
.ent .n { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 500; }
.ent .p { font-weight: 600; }
.ent.out .n, .ent.out .p { color: var(--muted); text-decoration: line-through; text-decoration-color: rgba(88,112,132,.5); }
.ent.in .p { color: var(--up); }
.slot { padding: 6px 4px; border-radius: 6px; }
.slot-l { font-size: 13px; color: var(--muted); }
.cands { display: flex; flex-wrap: wrap; gap: 4px 6px; margin-top: 4px; }
.cand {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 7px 3px 4px; border: 1px solid var(--line); border-radius: 999px;
  background: var(--paper); cursor: pointer; font-size: 13px;
}
.cand img { width: 18px; height: 12px; border-radius: 2px; }
.cand.sel { background: var(--sun-soft); border-color: var(--sun); }
.box-foot { margin-top: 4px; padding-top: 6px; border-top: 1px solid var(--line); font-size: 12px; color: var(--muted); }

/* title ranking */
.rank { background: var(--paper); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 6px 8px; }
.rrow {
  display: grid; grid-template-columns: 24px 24px minmax(0, 1fr) 64px; align-items: center; gap: 8px;
  width: 100%; padding: 8px 6px; border: 0; border-radius: var(--r-sm); background: none; text-align: left; cursor: pointer;
}
.rrow + .rrow { border-top: 1px solid var(--foam); }
.rrow:hover { background: var(--foam); }
.rrow.sel { background: var(--sun-soft); }
.rrow.head { cursor: default; font-size: 12px; color: var(--muted); padding-top: 4px; padding-bottom: 4px; }
.rrow.head:hover { background: none; }
.rrow .i { color: var(--muted); font-size: 13px; text-align: right; }
.rrow img { width: 24px; height: 16px; border-radius: 2px; box-shadow: 0 0 0 1px rgba(16,40,58,.12); }
.rrow .nm { min-width: 0; }
.rrow .nm b { display: block; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rbar { height: 6px; margin-top: 5px; border-radius: 3px; background: var(--track); overflow: hidden; }
.rbar div { height: 100%; width: 0; background: var(--sun); }
.rrow .w { text-align: right; font: 700 17px/1 var(--display); }
.rrow .st { display: none; text-align: right; color: var(--muted); font-size: 14px; }

/* method */
.method { max-width: 860px; margin-left: auto; margin-right: auto; padding-bottom: 12px; }
.method h3 { margin: 28px 0 8px; font: 700 17px/1.3 var(--display); }
.method p, .method li { max-width: 72ch; }
.method ul, .method ol { padding-left: 20px; }
.method li { margin-bottom: 8px; }
.ratings-wrap { overflow-x: auto; margin-top: 12px; }
.ratings { width: 100%; border-collapse: collapse; font-size: 14px; background: var(--paper); border: 1px solid var(--line); border-radius: var(--r-sm); }
.ratings caption { text-align: left; color: var(--muted); padding-bottom: 6px; caption-side: top; }
.ratings th, .ratings td { padding: 7px 10px; border-bottom: 1px solid var(--foam); text-align: left; vertical-align: top; }
.ratings th { font-weight: 600; color: var(--muted); font-size: 13px; }
.ratings .num { text-align: right; white-space: nowrap; }
.ratings td.why { color: var(--muted); }
.ratings .cell-team { display: flex; align-items: center; gap: 8px; white-space: nowrap; }
.ratings img { width: 20px; height: 14px; border-radius: 2px; }

.foot { margin-top: 32px; padding: 20px 0 calc(28px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); color: var(--muted); font-size: 14px; }
.foot p { margin: 4px 0; }
.err { color: var(--down); }

/* team panel: bottom sheet on phones, floating card on wide screens */
.panel {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  max-height: 78vh; overflow-y: auto;
  background: var(--paper);
  border-radius: 18px 18px 0 0;
  box-shadow: 0 -10px 40px rgba(10, 47, 75, .25);
  padding: 16px 16px calc(16px + env(safe-area-inset-bottom));
}
.panel[hidden] { display: none; }
.panel-head { display: grid; grid-template-columns: 36px minmax(0, 1fr) auto; gap: 12px; align-items: center; }
.panel-head img { width: 36px; height: 24px; border-radius: 3px; box-shadow: 0 0 0 1px rgba(16,40,58,.12); }
.panel-head h2 { margin: 0; font: 700 20px/1.15 var(--display); }
.panel-head p { margin: 2px 0 0; color: var(--muted); font-size: 14px; }
.close { padding: 8px 12px; border: 1px solid var(--line); border-radius: 999px; background: var(--paper); cursor: pointer; font-size: 14px; }
.path { list-style: none; margin: 14px 0 0; padding: 0; display: grid; gap: 10px; }
.path li { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 12px; align-items: baseline; }
.path li span { color: var(--muted); }
.path li strong { font: 700 20px/1 var(--display); }
.path li .bar { grid-column: 1 / -1; margin-top: 0; }
.path li.done strong { color: var(--up); }
.spark { margin: 16px 0 0; }
.spark figcaption { font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.spark svg { width: 100%; height: 64px; display: block; overflow: visible; }
.spark .ln { fill: none; stroke: var(--sea); stroke-width: 2; }
.spark .dt { fill: var(--sea); }
.spark text { font-size: 11px; fill: var(--muted); font-family: var(--text); }

@media (min-width: 640px) {
  .block { padding-top: 52px; }
  .groups { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .rrow { grid-template-columns: 28px 26px minmax(0, 1fr) 60px 60px 60px 72px; }
  .rrow .st { display: block; }
  .wrap { padding: 0 24px; }
}

@media (min-width: 1100px) {
  .groups { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .tabs { display: none; }
  .tree { display: grid; grid-template-columns: 1.15fr 1.15fr 1fr 1fr; gap: 14px; align-items: start; }
  .col, .col.show { display: block; }
  .col-body { grid-template-columns: 1fr; }
  .col[data-round="SF"] .col-body { margin-top: 60px; gap: 120px; }
  .col[data-round="F"] .col-body { margin-top: 210px; }
  .panel {
    left: auto; right: 24px; bottom: 24px; width: 360px;
    border-radius: var(--r-lg);
    box-shadow: 0 14px 50px rgba(10, 47, 75, .28);
  }
}

@media (prefers-reduced-motion: no-preference) {
  .grow .bar > div, .grow .rbar div { transition: width .9s cubic-bezier(.2, .7, .2, 1); }
}
