@import url('./assets/fonts/fonts.css');

:root {
  --ink: #191919;
  --muted: #6b6b6b;
  --line: #dedede;
  --accent: #b83b08;
  --orange: #ef591c;
  --paper: #fafafa;
  --surface: #fff;
  font-family: 'Golos Text', Arial, sans-serif;
  color: var(--ink);
  background: var(--paper);
  font-synthesis: none;
}
* { box-sizing: border-box; }
body { margin: 0; -webkit-font-smoothing: antialiased; }
button, a { -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
button { font: inherit; color: inherit; cursor: pointer; }
a { color: inherit; text-underline-offset: 4px; }
button:focus-visible, a:focus-visible, [tabindex]:focus-visible { outline: 2px solid var(--accent); outline-offset: 5px; }
::selection { background: #ffdbc9; color: var(--ink); }
[hidden] { display: none !important; }
.site-shell { --edge: clamp(12px, 1vw, 32px); padding: 0 calc(var(--edge) + 8px) calc(var(--edge) + 12px); }
.masthead { min-height: 64px; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 16px; border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 16px; margin: 0; }
.brand-logo { display: block; width: 112px; height: auto; flex-shrink: 0; }
.brand-event { display: flex; flex-direction: column; gap: 2px; font-size: 12px; font-weight: 600; line-height: 1.35; letter-spacing: .01em; }
.brand-year { color: var(--muted); font-size: 12px; font-weight: 400; }
.fullscreen-button { justify-self: end; display: grid; place-items: center; width: 44px; height: 44px; flex-shrink: 0; padding: 0; border: 0; background: none; }
.fullscreen-button:hover { color: var(--accent); }
.fullscreen-icon { width: 20px; height: 20px; }
.collapse-icon, :fullscreen .expand-icon { display: none; }
:fullscreen .collapse-icon { display: inline; }
.round-tabs { display: flex; align-items: center; gap: 26px; }
.round-tabs button { background: none; border: 0; padding: 13px 0; position: relative; font-size: 12px; color: var(--muted); min-height: 44px; white-space: nowrap; }
.round-tabs button.active { color: var(--ink); font-weight: 600; }
.round-tabs button.active::after { content: ''; position: absolute; bottom: 3px; left: 0; right: 0; height: 2px; background: var(--ink); }
.round-tabs button:hover { color: var(--ink); }
.preview-notice { color: var(--muted); font-size: 11px; line-height: 1.6; margin: 0; }
.connection-notice { margin: 0 0 24px; padding: 14px 16px; border: 1px solid #dba88f; font-size: 13px; line-height: 1.5; color: #92451f; }
.bracket-scroll { padding: 14px 0 24px; overflow: auto; scrollbar-width: thin; scrollbar-color: #b8b8b8 var(--paper); }
.bracket { display: grid; grid-template-columns: repeat(var(--columns), minmax(0, 1fr)); gap: 32px; position: relative; }
.round { min-width: 0; position: relative; z-index: 1; }
.round-heading { margin: 0; height: 40px; font-size: 12px; font-weight: 500; text-transform: uppercase; letter-spacing: .055em; color: var(--muted); }
.side-center .round-heading { color: var(--ink); font-weight: 600; }
.mode-mirrored .round-heading { text-align: center; }
.round-matches { display: grid; grid-template-rows: repeat(var(--match-count), minmax(0, 1fr)); align-items: center; position: relative; }
.match { width: 100%; min-width: 0; min-height: 144px; border: 1px solid var(--line); border-radius: 0; padding: 15px 16px 14px; background: var(--surface); text-align: left; position: relative; transition: border-color .18s ease, background .18s ease; }
.match:hover { border-color: #888; background: #f7f7f7; }
.match.live { border-color: var(--orange); background: #fff4ed; }
.match.live:hover { background: #ffecdf; }
.match-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; color: var(--muted); font-size: 11px; line-height: 1.4; margin-bottom: 14px; }
.match-status { font-size: 9px; font-weight: 500; letter-spacing: .025em; white-space: nowrap; }
.match-status.live { color: var(--accent); display: inline-flex; align-items: center; gap: 5px; }
.match-status.live::before { content: ''; width: 5px; height: 5px; border-radius: 50%; background: currentColor; }
.team-row {
  --shirt-size: clamp(22px, 1.8vw, 38px);
  display: grid;
  grid-template-areas: "shirt name score";
  grid-template-columns: var(--shirt-size) minmax(0, 1fr) max-content;
  grid-template-rows: minmax(var(--shirt-size), auto);
  column-gap: 10px;
  align-items: center;
  min-height: 34px;
}
.team-row + .team-row { margin-top: 3px; }
.team-badge { grid-area: shirt; display: block; width: var(--shirt-size); height: var(--shirt-size); object-fit: contain; }
.team-name { grid-area: name; position: relative; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: clamp(14px, 1.17vw, 20px); font-weight: 500; line-height: 1.4; }
.team-row.winner .team-name { font-weight: 700; }
.team-row.loser, .team-row.pending { color: var(--muted); }
.team-row.pending .team-name { font-size: 12px; font-weight: 400; }
.score { grid-area: score; justify-self: end; white-space: nowrap; font-size: 28px; font-weight: 600; line-height: 1; font-variant-numeric: tabular-nums; letter-spacing: -.025em; }
.team-row.winner .score { font-weight: 700; }
.live .score { color: var(--accent); }
.score.no-score { color: #727272; font-size: 20px; font-weight: 400; }
.penalty { font-size: 11px; font-weight: 400; color: var(--muted); margin-left: 4px; vertical-align: super; }
.match-main { border-color: #525252; }
.bronze-block { position: absolute; left: 0; right: 0; bottom: clamp(4px, calc(10dvh - 58px), 16px); }
.bronze-title { font-size: 11px; font-weight: 400; color: var(--muted); margin: 0 0 10px; text-align: center; }
.bronze-block .match { min-height: 130px; padding-top: 12px; padding-bottom: 12px; }
.bronze-block .match-top { margin-bottom: 8px; }
.bronze-block .team-row { min-height: 30px; }
.bronze-block .score { font-size: 24px; }
.champion-result { position: absolute; top: calc(50% + 84px); left: 0; right: 0; margin: 0; color: var(--accent); font-size: 12px; line-height: 1.5; text-align: center; }
.connector-layer { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; pointer-events: none; z-index: 0; }
.connector-line { stroke: #bcbcbc; stroke-width: 1; vector-effect: non-scaling-stroke; fill: none; }
.connector-line.completed { stroke: #555; }
.mode-stage { max-width: 1100px; margin: 12px auto 0; display: block; }
.mode-stage .round-heading { text-align: left; font-size: 22px; text-transform: none; letter-spacing: -.02em; color: var(--ink); height: auto; margin-bottom: 28px; }
.mode-stage .round-matches { height: auto; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
.mode-stage .match { min-height: 164px; padding: 20px 24px; }
.mode-stage .team-name { font-size: 20px; }
.mode-stage .team-row { min-height: 38px; }
.mode-stage .team-row.pending .team-name { font-size: 15px; }
.mode-stage .score { font-size: 32px; }
.mode-stage .match-top { font-size: 12px; }
.mode-stage .match-status { font-size: 10px; }
.mode-stage .round-final { max-width: 520px; margin: auto; }
.mode-stage .round-final .round-matches { display: block; }
.mode-stage .bronze-block { position: static; margin-top: 44px; }
.mode-stage .bronze-title { font-size: 16px; text-align: left; margin-bottom: 18px; color: var(--ink); }
.mode-stage .champion-result { position: static; margin-top: 18px; }
.empty-state { grid-column: 1/-1; padding: 100px 24px; color: var(--muted); text-align: center; font-size: 14px; }
dialog { width: min(460px, calc(100% - 32px)); max-height: 90dvh; padding: 32px; color: var(--ink); border: 1px solid var(--line); background: var(--surface); border-radius: 4px; }
dialog::backdrop { background: #0005; }
.dialog-close { position: absolute; top: 8px; right: 8px; width: 40px; height: 40px; border: 0; background: transparent; color: var(--muted); font-size: 26px; }
dialog h2 { font-size: 24px; font-weight: 600; letter-spacing: -.02em; margin: 6px 32px 24px 0; }
dialog p { font-size: 13px; line-height: 1.65; color: var(--muted); margin: 14px 0; }
.dialog-match { padding: 4px 0 24px; }
.dialog-match .team-row { --shirt-size: 34px; min-height: 42px; }
.dialog-match .team-name { font-size: 18px; white-space: normal; }
.dialog-meta { display: flex; flex-wrap: wrap; gap: 8px; justify-content: space-between; border-top: 1px solid var(--line); padding-top: 16px; font-size: 11px; color: var(--muted); }
.dialog-meta strong { font-size: 9px; font-weight: 500; }
.dialog-link { display: inline-block; font-size: 13px; margin: 8px 0 0; }
.demo-action { display: block; width: 100%; margin-top: 28px; padding: 13px 16px; background: var(--ink); color: white; border: 1px solid var(--ink); border-radius: 3px; font-size: 12px; }
.demo-action:hover { background: #353535; }
.toast { position: fixed; bottom: 24px; left: 50%; transform: translate(-50%, 8px); background: #262626; color: white; font-size: 12px; line-height: 1.5; padding: 13px 20px; border-radius: 4px; z-index: 20; pointer-events: none; max-width: calc(100% - 32px); opacity: 0; transition: opacity .2s, transform .2s; }
.toast.visible { opacity: 1; transform: translate(-50%, 0); }
.match.updated { animation: score-update .7s ease-out; }
@keyframes score-update { 0% { background: #ffe1cf; } 100% { background: var(--surface); } }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; }
#updates { position: fixed; top: 0; left: 0; }
.skip-link { position: absolute; top: -100px; padding: 12px; z-index: 20; color: white; background: var(--ink); }
.skip-link:focus { top: 10px; left: 10px; }
:fullscreen { background: var(--paper); }
@media (min-width: 1800px) {
  .brand-logo { width: 136px; }
  .brand-event, .brand-year { font-size: 15px; }
  .masthead { min-height: 72px; }
  .match { padding: 18px 22px; min-height: 168px; }
  .team-name { font-size: 22px; }
  .team-row { min-height: 40px; }
  .team-row.pending .team-name { font-size: 15px; }
  .score { font-size: 34px; }
  .match-top { font-size: 13px; }
  .match-status { font-size: 11px; }
  .round-heading { font-size: 15px; }
  .round-tabs button { font-size: 14px; }
  .preview-notice { font-size: 13px; }
  .champion-result { top: calc(50% + 96px); }
}
@media (min-width: 2400px) {
  .team-name { font-size: 27px; }
  .score { font-size: 42px; }
  .team-row.pending .team-name { font-size: 19px; }
  .match { min-height: 194px; }
  .team-row { min-height: 48px; }
  .champion-result { top: calc(50% + 110px); font-size: 17px; }
}
@media (max-width: 1279px) {
  .preview-notice span { display: none; }
  .round-tabs { gap: 22px; }
  .mode-linear .team-name { font-size: 17px; }
}
@media (max-width: 700px) {
  .masthead { grid-template-columns: minmax(0, 1fr) auto; grid-template-rows: 56px auto; gap: 0 12px; }
  .cup-tabs { grid-area: 2 / 1 / 3 / -1; }
  .fullscreen-button { grid-area: 1 / 2; }
  .brand { gap: 13px; }
  .brand-logo { width: 88px; }
  .brand-event, .brand-year { font-size: 9px; }
  .preview-notice { font-size: 11px; }
  .round-tabs { gap: 25px; overflow-x: auto; scrollbar-width: none; border-bottom: 1px solid var(--line); }
  .round-tabs button { font-size: 12px; padding-bottom: 15px; }
  .round-tabs button.active::after { bottom: 0; }
  .round-tabs .all-rounds { display: none; }
  .bracket-scroll { padding-top: 30px; overflow: visible; }
  .mode-stage { margin: 0; }
  .mode-stage .round-heading { font-size: 22px; margin-bottom: 22px; }
  .mode-stage .round-matches { grid-template-columns: 1fr; gap: 16px; }
  .mode-stage .match { padding: 17px 20px; min-height: 146px; }
  .mode-stage .team-name { font-size: 18px; }
  .mode-stage .team-row { min-height: 34px; }
  .mode-stage .team-row.pending .team-name { font-size: 14px; }
  .mode-stage .score { font-size: 28px; }
  .mode-stage .match-top { font-size: 11px; margin-bottom: 12px; }
  .mode-stage .match-status { font-size: 9px; }
  .connection-notice { margin-top: 20px; }
  dialog { padding: 28px 24px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}

/* The four tournament sheets share one toolbar; each board keeps its own rounds. */
.sheet-board .match { display: block; }
.sheet-board .match-top { margin-bottom: 8px; }
.sheet-board .match-id { font-weight: 600; }
.sheet-board .match-status { text-transform: uppercase; }
.match-venue { display: block; margin-top: 9px; font-size: 11px; line-height: 1.3; color: var(--muted); font-variant-numeric: tabular-nums; }
.sheet-board.mode-qualifiers {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: clamp(24px, 3vw, 64px);
  padding-bottom: 0;
}
.mode-qualifiers .round-heading { height: 30px; }
.mode-qualifiers .round-matches { grid-template: auto / repeat(2, minmax(0, 1fr)); gap: 12px; height: auto; }
.mode-qualifiers .match { min-height: 116px; padding: 10px 14px; align-self: stretch; }
.mode-qualifiers .team-row { min-height: 25px; }
.mode-qualifiers .team-row + .team-row { margin-top: 1px; }
.mode-qualifiers .score { font-size: 23px; }
.mode-qualifiers .score.no-score { font-size: 18px; }
.mode-qualifiers .team-row.pending .team-name { font-size: 13px; }
.mode-qualifiers .match-venue { margin-top: 6px; }
@media (min-width: 1800px) {
  .mode-qualifiers .round-matches { gap: 18px; }
  .mode-qualifiers .match { min-height: 155px; padding: 16px 20px; }
  .mode-qualifiers .team-row { min-height: 34px; }
  .mode-qualifiers .team-row.pending .team-name { font-size: 16px; }
  .mode-qualifiers .score { font-size: 30px; }
  .match-venue { font-size: 13px; }
}
@media (min-width: 701px) and (max-width: 960px) {
  .mode-qualifiers .round-matches { grid-template-columns: 1fr; }
}
@media (max-width: 700px) {
  .stage-tabs { display: flex; margin-top: 6px; gap: 20px; border-bottom: 0; }
  .stage-tabs button { font-size: 11px; padding: 8px 0; }
  .stage-tabs button.active::after { background: var(--accent); bottom: 3px; height: 1px; }
  .tournament .bracket-scroll { padding: 8px 0; }
  .mode-stage .round-final { max-width: none; }
  .sheet-board.mode-stage .round-heading { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .sheet-board.mode-stage .round-matches { grid-template-rows: none; }
  /* Keep the third-place match in position when the winner is announced. */
  .sheet-board.mode-stage .round-final .round-matches { display: grid; grid-template-rows: auto minmax(36px, auto); gap: 6px; }
  .mode-stage .champion-result { margin: 0; }
  .mode-stage .bronze-block { margin-top: 4px; }
  .mode-stage .bronze-title { margin-bottom: 14px; }
  .sheet-board .match-venue { font-size: 12px; }
}
@media (max-width: 359px) {
  .brand { gap: 8px; }
  .brand-logo { width: 64px; }
}

@media (min-width: 701px) {
  .site-shell { display: flex; flex-direction: column; min-height: 100dvh; }
  .masthead { flex: none; }
  .site-shell main, .tournament, #panel-bracket, .bracket-scroll {
    display: flex;
    flex-direction: column;
    flex: 1 0 auto;
    min-width: 0;
  }
  .bracket-scroll { padding: var(--edge) 0 0; }
  .sheet-board {
    --gap: clamp(10px, 1.1vw, 32px);
    --cup-card-height: clamp(126px, min(12.5vw, 19dvh), 320px);
    --third-card-height: max(120px, calc(var(--cup-card-height) * .8));
    --score-size: clamp(22px, min(2.05vw, 3.7dvh), 64px);
    flex: 1 0 auto;
    gap: var(--gap);
  }
  .sheet-board .round { display: grid; grid-template-rows: auto 1fr; }
  .sheet-board .round-heading { height: auto; margin-bottom: clamp(8px, 1dvh, 20px); font-size: clamp(12px, min(1vw, 1.6dvh), 26px); }
  .sheet-board .round-matches {
    min-height: max(calc(var(--max-matches) * (var(--cup-card-height) + var(--gap))),
                    calc(var(--cup-card-height) + 2 * (var(--third-card-height) + 80px)));
  }
  .sheet-board .match {
    display: grid;
    grid-template-rows: auto 1fr 1fr auto;
    height: var(--cup-card-height);
    min-height: min-content;
    padding: clamp(8px, 1dvh, 22px) clamp(10px, .9vw, 28px);
  }
  .sheet-board .match-top, .sheet-board .match-venue {
    font-size: clamp(11px, min(1vw, 1.6dvh), 26px);
    margin: 0;
  }
  .sheet-board .match-status { font-size: clamp(9px, min(.76vw, 1.35dvh), 21px); }
  .sheet-board .team-row {
    --shirt-size: clamp(22px, min(2vw, 3.7dvh), 66px);
    min-height: max(var(--shirt-size), var(--score-size));
    margin: 0;
  }
  .sheet-board .team-name { font-size: clamp(15px, min(1.35vw, 2.5dvh), 46px); }
  .sheet-board .pending .team-name { font-size: clamp(12px, min(1.12vw, 2dvh), 35px); }
  .sheet-board .score { font-size: var(--score-size); }
  .sheet-board .score.no-score { font-size: calc(var(--score-size) * .74); }
  .sheet-board .bronze-block .match { height: var(--third-card-height); }
  .sheet-board .champion-result { top: calc(50% + var(--cup-card-height) / 2 + 4px); }
  .sheet-board.mode-qualifiers .round-matches {
    min-height: 0;
    grid-auto-rows: 1fr;
    grid-template-rows: none;
    gap: var(--gap);
  }
  .sheet-board.mode-qualifiers .match { height: auto; row-gap: clamp(2px, .45dvh, 10px); }
}
@media (min-width: 701px) and (max-width: 960px) {
  .sheet-board.mode-qualifiers .match { padding-block: 6px; row-gap: 2px; }
}
