:root {
  --bg: #f6f7fb;
  --card: #ffffff;
  --text: #111827;
  --muted: #6b7280;
  --line: #e5e7eb;
  --strong: #111827;
  --live: #16a34a;
  --next: #2563eb;
  --ok: #16a34a;
  --warn: #d97706;
  --shadow: 0 8px 24px rgba(15, 23, 42, 0.08);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
}
.topbar {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  padding: 20px clamp(16px, 4vw, 40px);
  background: var(--card);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 10;
}
.eyebrow { color: var(--muted); font-size: 0.85rem; text-transform: uppercase; letter-spacing: .06em; }
h1 { margin: 2px 0 0; font-size: clamp(1.5rem, 4vw, 2.2rem); }
.meta { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; color: var(--muted); font-size: .9rem; }
.badge { display: inline-flex; align-items: center; border-radius: 999px; padding: 4px 10px; background: #eef2ff; color: #3730a3; font-weight: 700; }
.badge.ok { background: #dcfce7; color: #166534; }
.badge.error { background: #fee2e2; color: #991b1b; }
.tabs { display: flex; gap: 8px; padding: 12px clamp(16px, 4vw, 40px); overflow-x: auto; background: var(--bg); }
.tab { border: 1px solid var(--line); background: var(--card); color: var(--text); padding: 10px 16px; border-radius: 999px; font-weight: 700; cursor: pointer; white-space: nowrap; }
.tab.active { background: var(--strong); color: white; }
main { padding: 8px clamp(16px, 4vw, 40px) 40px; }
.view { display: none; }
.view.active { display: block; }
.section-title { margin: 12px 0 16px; }
.section-title h2 { margin: 0; font-size: 1.35rem; }
.section-title p { margin: 4px 0 0; color: var(--muted); }
/* .live-grid, .pools-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 16px; } */

.live-grid { display: grid; grid-template-columns: repeat(2, minmax(420px, 1fr)); gap: 16px; }
.pools-grid { display: grid; grid-template-columns: repeat(4, minmax(280px, 1fr)); gap: 16px; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow); overflow: hidden; }
.card-header { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.card-title { font-weight: 800; font-size: 1.05rem; }
.card-body { padding: 14px 16px; }
.status-live { color: white; background: var(--live); }
.status-next { color: white; background: var(--next); }
.status-finished { color: white; background: var(--ok); }
.status-idle { color: var(--muted); background: #f3f4f6; }

.live-fight-line {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto auto minmax(0, 1fr);
  gap: 4px 16px;
  align-items: center;
  margin: 10px 0 12px;
}
.live-name {
  min-width: 0;
  font-weight: 900;
  font-size: clamp(1rem, 2.2vw, 1.25rem);
  line-height: 1.15;
  overflow-wrap: normal;
  word-break: normal;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.live-country {
  min-width: 0;
  color: var(--muted);
  font-size: .9rem;
  font-weight: 900;
  line-height: 1.1;
}
.live-red { color: #dc2626; justify-self: start; max-width: 100%; }
.live-white { text-align: right; justify-self: end; max-width: 100%; }
.live-fight-line .ippon {
  align-self: start;
  padding-top: 2px;
  white-space: nowrap;
  flex-shrink: 0;
}
.live-fight-line .score-separator {
  align-self: start;
  padding-top: 2px;
  flex-shrink: 0;
}

.fight-line { display: grid; grid-template-columns: minmax(0, 1.2fr) auto auto auto minmax(0, 1.2fr); gap: 8px; align-items: center; margin: 8px 0; }
.fighter { min-width: 0; }
.fighter .name { font-weight: 800; overflow-wrap: anywhere; }
.fighter .country { color: var(--muted); font-size: .9rem; font-weight: 800; }
.fighter-red, .fighter-red .country, .fighter-red .fight-fighter-country { color: #dc2626; }
.fighter-white { text-align: right; }

.fight-fighter-label { display: flex; flex-direction: column; min-width: 0; line-height: 1.1; }
.fight-fighter-name { min-width: 0; max-width: 100%; font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fight-fighter-country { font-size: .72rem; color: var(--muted); font-weight: 800; letter-spacing: .03em; }

.ippon { display: inline-block; min-width: 2.2em; font-weight: 900; letter-spacing: .04em; text-align: center; }
/* .ippon.red { color: #dc2626; } */
.score-separator { color: var(--muted); font-weight: 900; }
.score-separator.hikiwake {display: inline-flex; align-items: center; justify-content: center; padding: 2px 8px; border-radius: 999px; background: rgba(217, 119, 6, 0.12); color: var(--warn); font-size: .72rem; font-weight: 800; letter-spacing: .02em; white-space: nowrap; text-transform: uppercase; }
.vs { color: var(--muted); font-weight: 800; }
.subtle { color: var(--muted); font-size: .9rem; }
.toolbar { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; margin: 0 0 16px; }
.toolbar input[type="search"] { flex: 1; min-width: 240px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px; font: inherit; }
.standings { width: 100%; border-collapse: collapse; margin-top: 10px; }
.standings th, .standings td { padding: 8px 6px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.standings th { color: var(--muted); font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; }

.standings th:nth-child(1),
.standings td:nth-child(1),
.standings th:nth-child(3),
.standings td:nth-child(3),
.standings th:nth-child(4),
.standings td:nth-child(4),
.standings th:nth-child(5),
.standings td:nth-child(5),
.standings th:nth-child(6),
.standings td:nth-child(6) {
  width: 1%;
  white-space: nowrap;
}

.standings td:nth-child(2) { width: 100%; min-width: 0; }

.standing-fighter {display: flex; flex-direction: column; min-width: 0; line-height: 1.1; }
.standing-fighter .fighter-name { min-width: 0; max-width: 100%; font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.standing-fighter .fighter-country { font-size: .72rem; color: var(--muted); letter-spacing: .03em; }

.standings td:nth-child(6),
.standings th:nth-child(6) {
  white-space: nowrap;
}

.rank { font-weight: 900; }
.qual { color: var(--ok); font-weight: 800; font-size: .85rem; }
.prov { color: var(--warn); font-weight: 800; font-size: .85rem; }
.fights-list { display: grid; gap: 8px; margin-top: 12px; }
.small-fight { border: 1px solid var(--line); border-radius: 12px; padding: 8px 10px; }

/* .bracket-grid { display: grid; gap: 14px; }
.bracket-round { background: var(--card); border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow); padding: 14px; }
.bracket-round h3 { margin: 0 0 10px; }
.bracket-matches { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 10px; } */

.bracket-grid { width: 100%; }
.bracket-scroll { overflow-x: auto; overflow-y: hidden; padding: 8px 0 24px; }
.bracket-tree { position: relative; display: flex; gap: 54px; min-width: max-content; align-items: stretch; }
.bracket-lines { position: absolute; inset: 0; pointer-events: none; overflow: visible; z-index: 0; }
.bracket-line { fill: none; stroke: var(--line); stroke-width: 2; }
.bracket-column { width: 260px; display: flex; flex-direction: column; position: relative; z-index: 1; }
.bracket-match::after { display: none; }

.bracket-column h3 { margin: 0 0 14px; font-size: 1rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.bracket-column-matches { display: flex; flex-direction: column; gap: 18px; }

.bracket-round-1 .bracket-column-matches { padding-top: 36px; gap: 54px; }
.bracket-round-2 .bracket-column-matches { padding-top: 90px; gap: 126px; }
.bracket-round-3 .bracket-column-matches { padding-top: 198px; gap: 270px; }
.bracket-round-4 .bracket-column-matches { padding-top: 414px; gap: 558px; }
.bracket-round-5 .bracket-column-matches { padding-top: 846px; }

.bracket-match { position: relative; background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 10px; box-shadow: var(--shadow); min-height: 104px; }
/* .bracket-match::after { content: ""; position: absolute; top: 50%; right: -55px; width: 55px; border-top: 2px solid var(--line); } */
.bracket-column:last-child .bracket-match::after { display: none; }
.bracket-match.is-live { border-color: var(--live); }
.bracket-match-top { display: flex; justify-content: space-between; gap: 8px; align-items: center; margin-bottom: 8px; }
.bracket-match-title { color: var(--muted); font-size: .78rem; font-weight: 800; }
.bracket-player { display: flex; justify-content: space-between; gap: 8px; padding: 6px 8px; border-radius: 8px; font-weight: 800; }
.bracket-player + .bracket-player { margin-top: 4px; }
.bracket-player.winner { background: rgba(22, 163, 74, 0.12); color: var(--ok); }
.bracket-player-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bracket-player-country { flex: 0 0 auto; color: var(--muted); font-size: .75rem; font-weight: 900; }
.bracket-player.winner .bracket-player-country { color: var(--ok); }

.empty-player { color: var(--muted); }
.empty { color: var(--muted); background: var(--card); border: 1px dashed var(--line); border-radius: 18px; padding: 20px; }

@media (max-width: 1400px) {
  .pools-grid {
    grid-template-columns: repeat(3, minmax(280px, 1fr));
  }
}

@media (max-width: 1100px) {
  .pools-grid {
    grid-template-columns: repeat(2, minmax(280px, 1fr));
  }
}

@media (max-width: 1000px) {
  .live-grid, .pools-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .live-grid, .pools-grid {
    grid-template-columns: 1fr;
  }

  .live-fight-line {
    grid-template-columns: minmax(0, 1fr) auto auto auto minmax(0, 1fr);
    gap: 3px 5px;
  }
  .live-name {
    font-size: .98rem;
    white-space: normal;
    overflow: visible;
    text-overflow: unset;
    overflow-wrap: anywhere;
  }

  .live-country { font-size: .78rem; }
  .live-fight-line .ippon { min-width: 1.2em; }

  .topbar { align-items: flex-start; flex-direction: column; }
  .meta { justify-content: flex-start; }
  .fight-line { grid-template-columns: 1fr auto auto auto 1fr; font-size: .95rem; }
  .ippon { min-width: 1.6em; }
  .vs { display: none; }
  .standings th:nth-child(5), .standings td:nth-child(5) { display: none; }
  .card-header { align-items: flex-start; flex-direction: column; }
}
