:root {
  color-scheme: dark;
  font-family: Inter, "Segoe UI", Arial, sans-serif;
  color: #f5e8c8;
  background: #27150d;
  font-synthesis: none;
  --gold: #d6a34b;
  --gold-soft: #8d6128;
  --panel: rgba(55, 31, 18, 0.96);
  --panel-soft: rgba(77, 40, 22, 0.94);
  --line: rgba(245, 189, 86, 0.84);
  --muted: #b59e78;
  --win: #58c88b;
  --loss: #d56e5e;
  --pending: #d5b66e;
}

* { box-sizing: border-box; }
html { min-width: 320px; background: #27150d; }
body {
  position: relative;
  isolation: isolate;
  min-height: 100vh;
  margin: 0;
  background:
    radial-gradient(circle at 13% 10%, rgba(182, 105, 31, 0.15), transparent 31%),
    radial-gradient(circle at 88% 20%, rgba(126, 29, 20, 0.14), transparent 29%),
    radial-gradient(ellipse at 52% 120%, rgba(156, 87, 26, 0.14), transparent 52%),
    linear-gradient(135deg, #0d0a08 0%, #1c100b 46%, #0c0907 100%);
}
body::before {
  position: fixed;
  z-index: -1;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(circle at -4% 100%, transparent 0 150px, rgba(239, 175, 64, 0.24) 152px 154px, transparent 156px 205px, rgba(239, 175, 64, 0.14) 207px 209px, transparent 211px),
    radial-gradient(circle at 104% 3%, transparent 0 130px, rgba(245, 190, 78, 0.22) 132px 134px, transparent 136px 188px, rgba(245, 190, 78, 0.12) 190px 192px, transparent 194px),
    repeating-radial-gradient(circle at 50% 110%, transparent 0 42px, rgba(255, 211, 115, 0.035) 43px 44px, transparent 45px 88px);
  content: "";
}
body::after {
  position: fixed;
  z-index: -1;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(125deg, rgba(112, 15, 17, 0.78), transparent 24%) left bottom / 38% 48% no-repeat,
    linear-gradient(305deg, rgba(112, 15, 17, 0.7), transparent 25%) right top / 35% 43% no-repeat;
  opacity: 0.6;
  content: "";
}

button, input, select { font: inherit; }
button { -webkit-tap-highlight-color: transparent; }

.topbar {
  position: sticky;
  z-index: 50;
  top: 0;
  display: grid;
  grid-template-columns: auto minmax(240px, 1fr) auto;
  align-items: center;
  gap: 18px;
  min-height: 76px;
  padding: 10px 22px;
  border-bottom: 1px solid #d0953e;
  background: linear-gradient(90deg, rgba(78, 25, 18, 0.98), rgba(41, 22, 14, 0.98) 48%, rgba(92, 35, 22, 0.98));
  box-shadow: 0 10px 34px rgba(0, 0, 0, 0.42);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: inherit;
  text-decoration: none;
}
.brand-mark {
  display: grid;
  width: 46px;
  height: 46px;
  place-items: center;
  border: 1px solid #e2b85e;
  border-radius: 50%;
  color: #f2ce78;
  background: radial-gradient(circle, #71301d, #2b160e 72%);
  font: 800 15px Georgia, serif;
  box-shadow: inset 0 0 0 3px #120b07;
}
.brand strong, .brand small { display: block; white-space: nowrap; }
.brand strong { font: 700 14px Georgia, serif; letter-spacing: 0.08em; }
.brand small { margin-top: 3px; color: #a98d62; font-size: 9px; letter-spacing: 0.18em; }

.title-field { display: grid; gap: 4px; min-width: 0; }
.title-field span { color: #9f855e; font-size: 9px; font-weight: 800; letter-spacing: 0.12em; text-transform: uppercase; }
.title-field input {
  width: min(460px, 100%);
  height: 37px;
  padding: 0 11px;
  border: 1px solid #a87331;
  border-radius: 5px;
  outline: 0;
  color: #f8e8bd;
  background: rgba(55, 28, 16, 0.92);
  font: 700 15px Georgia, serif;
}
.title-field input:focus { border-color: #d6a34b; box-shadow: 0 0 0 3px rgba(214, 163, 75, 0.13); }

.toolbar-actions { display: flex; align-items: center; justify-content: flex-end; gap: 7px; }
.save-status { max-width: 155px; overflow: hidden; color: #b69c73; font-size: 10px; text-align: right; text-overflow: ellipsis; white-space: nowrap; }
.save-status.ok { color: #72d69e; }
.save-status.error { color: #ef8d7d; }
.button {
  min-height: 38px;
  padding: 0 13px;
  border: 1px solid #a87635;
  border-radius: 5px;
  color: #f4e4bc;
  background: linear-gradient(#5d2f1c, #3d2115);
  cursor: pointer;
  font-size: 11px;
  font-weight: 800;
}
.button:hover, .button:focus-visible { border-color: #e0b35a; outline: 0; filter: brightness(1.13); }
.button-secondary { background: linear-gradient(#8b4226, #552617); }
.button-primary { border-color: #d5a148; color: #241509; background: linear-gradient(#f1cb77, #c8943e); }
.button:disabled { cursor: wait; opacity: 0.55; }

main { width: 100%; padding: 18px 18px 40px; }
.participants-panel, .bracket-shell {
  border: 1px solid #d09a47;
  outline: 1px solid rgba(255, 217, 136, 0.16);
  outline-offset: -5px;
  background: rgba(45, 25, 15, 0.9);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}
.participants-panel { max-width: 1500px; margin: 0 auto 14px; padding: 18px; }
.participants-panel[hidden] { display: none; }
.panel-heading { display: flex; align-items: end; justify-content: space-between; gap: 24px; margin-bottom: 13px; }
.panel-heading span, .eyebrow { color: #d4a14b; font-size: 9px; font-weight: 900; letter-spacing: 0.15em; text-transform: uppercase; }
.panel-heading h1 { margin: 4px 0 0; font: 700 20px Georgia, serif; }
.panel-heading p { max-width: 620px; margin: 0; color: #9f8a69; font-size: 11px; line-height: 1.45; }
.participants-grid { display: grid; grid-template-columns: repeat(8, minmax(118px, 1fr)); gap: 7px; }
.participant {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr);
  align-items: center;
  gap: 7px;
  min-width: 0;
  padding: 5px;
  border: 1px solid #8c5b2d;
  background: linear-gradient(135deg, rgba(91, 46, 25, 0.98), rgba(53, 29, 18, 0.98));
}
.participant img {
  width: 42px;
  height: 42px;
  padding: 4px;
  border: 1px solid rgba(255, 222, 150, 0.66);
  border-radius: 9px;
  object-fit: contain;
  background: linear-gradient(145deg, #fff2d0, #c8a56c);
  filter: drop-shadow(0 3px 5px rgba(0, 0, 0, 0.35));
}
.participant input { min-width: 0; width: 100%; border: 0; outline: 0; color: #fff0c9; background: transparent; font-size: 12px; font-weight: 780; }

.bracket-shell { overflow: hidden; }
.bracket-heading {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  min-height: 104px;
  padding: 20px 28px 20px 36px;
  border-bottom: 1px solid #c78d39;
  background:
    radial-gradient(circle at 16% 50%, rgba(235, 174, 69, 0.18), transparent 29%),
    linear-gradient(90deg, rgba(116, 40, 22, 0.98), rgba(59, 30, 17, 0.98) 48%, rgba(91, 35, 21, 0.98));
}
.bracket-heading::before {
  position: absolute;
  top: 17px;
  left: 15px;
  bottom: 17px;
  width: 4px;
  border: 1px solid #ffd77d;
  border-top: 0;
  border-bottom: 0;
  background: #9d281e;
  box-shadow: 4px 0 0 rgba(241, 185, 77, 0.24);
  content: "";
}
.bracket-heading::after {
  position: absolute;
  right: 26px;
  bottom: 8px;
  color: rgba(252, 205, 111, 0.34);
  font: 700 12px Georgia, "Times New Roman", serif;
  letter-spacing: 0.42em;
  content: "天命之战";
}
.bracket-heading h1 { margin: 4px 0 0; color: #ffe2a0; font: 700 31px Georgia, serif; letter-spacing: 0.055em; text-shadow: 0 2px 15px rgba(255, 178, 50, 0.2); }
.legend { display: flex; gap: 15px; color: #ab9572; font-size: 10px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--pending); }
.legend-dot.win { background: var(--win); }
.legend-dot.loss { background: var(--loss); }

.bracket-scroll {
  overflow: auto;
  padding: 28px;
  scrollbar-color: #d19743 #301a10;
  background:
    linear-gradient(rgba(24, 17, 12, 0.9), rgba(12, 10, 8, 0.97)),
    repeating-linear-gradient(45deg, transparent 0 31px, rgba(246, 190, 87, 0.035) 32px 33px);
}
.bracket {
  display: grid;
  grid-template-columns: repeat(6, 276px);
  align-items: start;
  gap: 42px;
  width: max-content;
  min-width: 100%;
}
.stage { position: relative; display: grid; align-content: start; gap: 18px; min-width: 0; }
.stage:not(:last-child)::after {
  position: absolute;
  top: 31px;
  right: -22px;
  bottom: 18px;
  width: 1px;
  background: linear-gradient(transparent, var(--line) 5%, var(--line) 95%, transparent);
  content: "";
}
.stage-header { min-height: 50px; padding: 0 3px 10px; border-bottom: 2px solid #d9a64f; text-align: center; }
.stage-header span { color: #947751; font-size: 9px; font-weight: 900; letter-spacing: 0.12em; text-transform: uppercase; }
.stage-header h2 { margin: 4px 0 0; color: #ffe3a2; font: 700 19px Georgia, serif; letter-spacing: 0.025em; }
.record-group { position: relative; display: grid; gap: 8px; }
.record-group::after {
  position: absolute;
  top: 50%;
  right: -22px;
  width: 22px;
  height: 1px;
  background: var(--line);
  content: "";
}
.stage:last-child .record-group::after { display: none; }
.group-label {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 32px;
  padding: 0 10px;
  border: 1px solid #b27b35;
  border-left: 3px solid var(--gold);
  color: #e3bd69;
  background: linear-gradient(90deg, #71301d, #472517 70%, #632d1c);
}
.group-label strong { width: 100%; font: 700 14px Georgia, serif; text-align: center; }
.group-label span { position: absolute; right: 8px; color: #9d835d; font-size: 9px; text-transform: uppercase; }
.record-group.qualify .group-label { border-left-color: var(--win); }
.record-group.eliminate .group-label { border-left-color: var(--loss); }

.match-card {
  position: relative;
  display: grid;
  gap: 4px;
  padding: 8px;
  border: 1px solid #c28a42;
  border-radius: 5px;
  background: linear-gradient(135deg, rgba(93, 48, 27, 0.99), rgba(53, 29, 18, 0.99));
  box-shadow: inset 0 0 0 1px rgba(255, 222, 151, 0.12), 0 7px 18px rgba(16, 6, 3, 0.34);
}
.match-card.complete { border-color: #e2b058; box-shadow: inset 0 0 0 1px rgba(255, 225, 155, 0.18), 0 0 18px rgba(232, 161, 55, 0.12); }
.team-row { display: grid; grid-template-columns: 44px minmax(0, 1fr) 38px; align-items: center; gap: 8px; min-height: 46px; }
.team-row + .team-row { border-top: 1px solid rgba(235, 179, 83, 0.35); }
.team-row img {
  width: 40px;
  height: 40px;
  padding: 4px;
  border: 1px solid rgba(255, 226, 163, 0.68);
  border-radius: 9px;
  object-fit: contain;
  opacity: 0.94;
  background: linear-gradient(145deg, #fff3d5, #c9a56b);
  filter: drop-shadow(0 3px 5px rgba(0, 0, 0, 0.38));
}
.team-row.winner img { opacity: 1; }
.team-select {
  min-width: 0;
  width: 100%;
  border: 0;
  outline: 0;
  color: #e7d7b3;
  background: transparent;
  font-size: 13px;
  font-weight: 760;
}
.team-select option { color: #f3e5c5; background: #21150e; }
.team-row.winner .team-select { color: #7ee0a8; }
.team-row.loser .team-select { color: #c28e83; }
.score {
  width: 38px;
  height: 32px;
  padding: 0;
  border: 1px solid #b37c37;
  border-radius: 3px;
  outline: 0;
  color: #f4d486;
  background: #2d180f;
  font-size: 15px;
  font-weight: 850;
  text-align: center;
}
.score:focus, .team-select:focus { box-shadow: 0 0 0 2px rgba(220, 170, 80, 0.18); }
.result-list { display: grid; gap: 5px; padding: 8px; border: 1px solid #a87537; background: rgba(60, 31, 19, 0.9); }
.result-team { display: grid; grid-template-columns: 40px minmax(0, 1fr); align-items: center; gap: 9px; min-height: 44px; padding: 3px 5px; color: #ead8ae; font-size: 12px; font-weight: 780; }
.result-team img {
  width: 38px;
  height: 38px;
  padding: 4px;
  border: 1px solid rgba(255, 225, 159, 0.58);
  border-radius: 8px;
  object-fit: contain;
  background: linear-gradient(145deg, #fff1d1, #c4a064);
}
.result-team.empty { color: #705d41; }
.qualify .result-team:not(.empty) { color: #78d59f; }
.eliminate .result-team:not(.empty) { color: #d38a7c; }

.view-mode .topbar, .view-mode .participants-panel { display: none !important; }
.view-mode main { padding: 0; }
.view-mode .bracket-shell { min-height: 100vh; border: 0; }
.view-mode .bracket-heading { min-height: 68px; }
.view-mode .team-select, .view-mode .score { pointer-events: none; }
.view-mode .team-select { appearance: none; }
.view-mode .score { border-color: transparent; background: transparent; }

@media (min-width: 1780px) {
  .bracket { grid-template-columns: repeat(6, minmax(270px, 1fr)); width: 100%; gap: 36px; }
}
@media (max-width: 1180px) {
  .topbar { grid-template-columns: auto 1fr; }
  .toolbar-actions { grid-column: 1 / -1; justify-content: flex-start; overflow-x: auto; }
  .participants-grid { grid-template-columns: repeat(4, minmax(118px, 1fr)); }
}
@media (max-width: 650px) {
  .topbar { position: relative; padding: 9px 10px; gap: 10px; }
  .brand small, .save-status { display: none; }
  .brand-mark { width: 40px; height: 40px; }
  .title-field input { height: 35px; font-size: 13px; }
  .button { flex: 0 0 auto; padding: 0 10px; }
  main { padding: 9px 7px 28px; }
  .participants-panel { padding: 12px; }
  .panel-heading { display: block; }
  .panel-heading p { margin-top: 8px; }
  .participants-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .bracket-heading { display: block; padding: 13px; }
  .bracket-heading h1 { font-size: 19px; }
  .legend { margin-top: 9px; flex-wrap: wrap; }
  .bracket-scroll { padding: 13px; }
  .bracket { grid-template-columns: repeat(6, 252px); gap: 34px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}

/* Compact broadcast board: six columns fit a 16:9 capture, logos carry the match. */
.bracket-heading {
  min-height: 82px;
  padding-block: 14px;
}
.bracket-heading h1 { font-size: 28px; }
.bracket-scroll { padding: 18px 22px 22px; }
.bracket {
  grid-template-columns: repeat(6, minmax(162px, 1fr));
  gap: 26px;
  width: 100%;
  min-width: 1102px;
  max-width: 1480px;
  margin: 0 auto;
}
.stage { gap: 12px; }
.stage:not(:last-child)::after { right: -14px; }
.stage-header {
  min-height: 42px;
  padding-bottom: 7px;
}
.stage-header span { font-size: 8px; }
.stage-header h2 { font-size: 16px; }
.record-group {
  gap: 0;
  padding: 0 6px 6px;
  border: 1px solid #d29b49;
  border-radius: 5px;
  background: linear-gradient(150deg, rgba(75, 40, 23, 0.96), rgba(39, 24, 16, 0.96));
  box-shadow: inset 0 0 0 1px rgba(255, 224, 153, 0.08), 0 5px 14px rgba(19, 7, 3, 0.28);
}
.record-group::after {
  right: -14px;
  width: 14px;
}
.group-label {
  min-height: 28px;
  margin: 0 -6px 3px;
  padding: 0 7px;
  border: 0;
  border-bottom: 1px solid #d09a48;
  border-left: 3px solid var(--gold);
  border-radius: 4px 4px 0 0;
  background: linear-gradient(90deg, #7b321f, #4c2718 72%, #682c1b);
}
.group-label strong { font-size: 14px; }
.group-label span { font-size: 7px; letter-spacing: 0.05em; }
.match-card {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 15px;
  min-height: 34px;
  padding: 1px 2px;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}
.match-card::before {
  position: absolute;
  z-index: 1;
  top: 50%;
  left: 50%;
  color: #e8c477;
  font-size: 11px;
  font-weight: 850;
  line-height: 1;
  content: "–";
  transform: translate(-50%, -50%);
}
.match-card.complete { border-color: transparent; box-shadow: none; }
.record-group > .match-card + .match-card { border-top: 1px solid rgba(225, 169, 75, 0.18); }
.team-row {
  position: relative;
  display: grid;
  min-height: 34px;
  gap: 4px;
}
.team-row:first-child {
  grid-template-areas: "logo score";
  grid-template-columns: 34px minmax(20px, 1fr);
}
.team-row:nth-child(2) {
  grid-template-areas: "score logo";
  grid-template-columns: minmax(20px, 1fr) 34px;
}
.team-row + .team-row { border-top: 0; }
.team-row img {
  grid-area: logo;
  align-self: center;
  justify-self: center;
  width: 31px;
  height: 31px;
  padding: 1px;
  border: 0;
  border-radius: 6px;
  object-fit: contain;
  background: radial-gradient(circle, rgba(255, 239, 198, 0.16), transparent 72%);
  filter: drop-shadow(0 0 4px rgba(255, 213, 116, 0.32)) drop-shadow(0 2px 3px rgba(0, 0, 0, 0.52));
}
.team-row.winner img { filter: drop-shadow(0 0 5px rgba(92, 231, 147, 0.62)) drop-shadow(0 2px 3px rgba(0, 0, 0, 0.5)); }
.team-row.loser img { opacity: 0.58; filter: grayscale(0.32) drop-shadow(0 2px 3px rgba(0, 0, 0, 0.48)); }
.team-select {
  z-index: 3;
  grid-area: logo;
  align-self: stretch;
  justify-self: stretch;
  width: 34px;
  min-width: 34px;
  height: 34px;
  cursor: pointer;
  opacity: 0;
}
.team-row:nth-child(2) .team-select { justify-self: end; }
.team-row:focus-within img { outline: 2px solid #f2c76d; outline-offset: 1px; }
.score {
  grid-area: score;
  align-self: center;
  justify-self: center;
  width: 25px;
  height: 25px;
  border: 0;
  color: #ffe2a0;
  background: transparent;
  font-size: 12px;
}
.score:focus {
  border: 1px solid #cf9542;
  background: #321a10;
  box-shadow: 0 0 0 2px rgba(220, 170, 80, 0.16);
}
.result-list {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 3px;
  padding: 5px 2px 2px;
  border: 0;
  background: transparent;
}
.result-team {
  display: grid;
  width: 32px;
  min-height: 32px;
  padding: 0;
  place-items: center;
}
.result-team span { display: none; }
.result-team img {
  width: 30px;
  height: 30px;
  padding: 1px;
  border: 0;
  border-radius: 6px;
  background: radial-gradient(circle, rgba(255, 239, 198, 0.15), transparent 72%);
  filter: drop-shadow(0 0 4px rgba(255, 213, 116, 0.28));
}
.result-team.empty::before {
  display: grid;
  width: 28px;
  height: 28px;
  place-items: center;
  border: 1px dashed rgba(226, 178, 90, 0.34);
  border-radius: 50%;
  color: #856b45;
  font-size: 7px;
  content: "TBD";
}
.result-team.empty img { display: none; }
.view-mode .legend { display: none; }
.view-mode .bracket-shell {
  display: grid;
  grid-template-rows: auto 1fr;
  height: 100vh;
  min-height: 540px;
}
.view-mode .bracket-scroll {
  display: flex;
  min-height: 0;
  align-items: center;
  overflow: hidden;
}
.view-mode .bracket-heading { min-height: 74px; }

@media (max-width: 1180px) {
  .bracket { grid-template-columns: repeat(6, 162px); width: max-content; min-width: 1102px; }
}

@media (max-width: 650px) {
  .bracket-heading { min-height: 72px; padding: 12px 16px 12px 25px; }
  .bracket-heading h1 { font-size: 20px; }
  .bracket-heading::after { display: none; }
  .bracket-scroll { padding: 12px; }
  .view-mode .bracket-scroll { align-items: flex-start; overflow: auto; }
}

/* Symmetric match row: logo | score - score | logo. */
.match-card {
  grid-template-columns: 40px minmax(46px, 1fr) 40px;
  gap: 2px;
  width: min(100%, 140px);
  margin-inline: auto;
}
.team-row,
.team-row:first-child,
.team-row:nth-child(2) {
  display: contents;
}
.team-row:first-child img,
.team-row:first-child .team-select {
  grid-row: 1;
  grid-column: 1;
}
.team-row:nth-child(2) img,
.team-row:nth-child(2) .team-select {
  grid-row: 1;
  grid-column: 3;
}
.team-row img {
  align-self: center;
  justify-self: center;
  width: 38px;
  height: 38px;
}
.team-select,
.team-row:nth-child(2) .team-select {
  align-self: center;
  justify-self: center;
  width: 40px;
  min-width: 40px;
  height: 40px;
}
.team-row:first-child .score,
.team-row:nth-child(2) .score {
  grid-row: 1;
  grid-column: 2;
  align-self: center;
  width: 24px;
  margin: 0;
}
.team-row:first-child .score {
  justify-self: center;
  transform: translateX(-14px);
}
.team-row:nth-child(2) .score {
  justify-self: center;
  transform: translateX(14px);
}
.match-card::before { font-size: 13px; }

/* Large logos and a single rigid scoreboard prevent score drift. */
.bracket {
  grid-template-columns: repeat(6, minmax(184px, 1fr));
  gap: 22px;
  min-width: 1214px;
}
.stage:not(:last-child)::after { right: -12px; }
.record-group::after { right: -12px; width: 12px; }
.match-card {
  grid-template-columns: 58px 52px 58px;
  gap: 0;
  width: 168px;
  min-height: 58px;
}
.match-card::before { content: none; }
.match-card > .team-row:first-child,
.match-card > .team-row:last-child {
  display: grid;
  grid-row: 1;
  grid-template: 58px / 58px;
  place-items: center;
}
.match-card > .team-row:first-child { grid-column: 1; }
.match-card > .team-row:last-child { grid-column: 3; }
.match-card > .team-row img,
.match-card > .team-row .team-select {
  grid-area: 1 / 1;
}
.match-card > .team-row img {
  width: 56px;
  height: 56px;
}
.match-card > .team-row .team-select {
  width: 58px;
  min-width: 58px;
  height: 58px;
}
.team-row img.logo-empty { visibility: hidden; }
.match-score {
  z-index: 2;
  display: grid;
  grid-row: 1;
  grid-column: 2;
  grid-template-columns: 22px 8px 22px;
  align-items: center;
  justify-items: center;
  width: 52px;
}
.match-score .score,
.team-row:first-child .score,
.team-row:nth-child(2) .score {
  grid-row: auto;
  grid-column: auto;
  width: 22px;
  height: 28px;
  margin: 0;
  padding: 0;
  justify-self: center;
  transform: none;
  appearance: textfield;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}
.match-score .score::-webkit-inner-spin-button,
.match-score .score::-webkit-outer-spin-button { margin: 0; appearance: none; }
.score-divider {
  color: #f1cb79;
  font-size: 13px;
  font-weight: 900;
  line-height: 1;
  text-align: center;
}
.result-team { width: 44px; min-height: 44px; }
.result-team img { width: 42px; height: 42px; }

@media (max-width: 1280px) {
  .bracket {
    grid-template-columns: repeat(6, 184px);
    gap: 22px;
    width: max-content;
    min-width: 1214px;
  }
}

/* Dark broadcast finish and reference-style bracket arrows. */
.bracket-shell {
  background: rgba(10, 8, 6, 0.97);
  box-shadow: 0 20px 70px rgba(0, 0, 0, 0.58);
}
.bracket-heading {
  background:
    radial-gradient(circle at 16% 50%, rgba(198, 136, 44, 0.1), transparent 29%),
    linear-gradient(90deg, rgba(52, 20, 14, 0.99), rgba(17, 13, 10, 0.99) 48%, rgba(48, 20, 14, 0.99));
}
.stage-header {
  display: grid;
  justify-items: center;
  text-align: center;
}
.stage-header span,
.stage-header h2 { width: 100%; text-align: center; }
.record-group {
  background: linear-gradient(150deg, rgba(47, 28, 19, 0.98), rgba(16, 13, 10, 0.99));
}
.group-label {
  padding-inline: 8px;
  background: linear-gradient(90deg, #572619, #251812 72%, #472117);
}
.group-label strong {
  padding-inline: 38px;
  text-align: center;
}
.group-label span { right: 7px; }
.stage:not(:last-child)::after {
  width: 1px;
  background: linear-gradient(transparent, rgba(239, 195, 109, 0.78) 5%, rgba(239, 195, 109, 0.78) 95%, transparent);
  box-shadow: 0 0 5px rgba(226, 166, 62, 0.24);
}
.record-group::after {
  height: 1px;
  background: rgba(239, 195, 109, 0.86);
  box-shadow: 0 0 5px rgba(226, 166, 62, 0.28);
}
.record-group::before {
  position: absolute;
  z-index: 3;
  top: 50%;
  right: -17px;
  width: 0;
  height: 0;
  border-top: 4px solid transparent;
  border-bottom: 4px solid transparent;
  border-left: 6px solid #efc36d;
  filter: drop-shadow(0 0 3px rgba(226, 166, 62, 0.5));
  content: "";
  transform: translateY(-50%);
}
.stage:last-child .record-group::before { display: none; }

/* Orthogonal tournament routes replace the old isolated arrowheads. */
.bracket {
  position: relative;
  grid-template-columns: repeat(6, minmax(176px, 1fr));
  gap: 38px;
  min-width: 1246px;
}
.stage {
  z-index: 1;
}
.stage:not(:last-child)::after,
.record-group::after,
.record-group::before {
  display: none;
}
.bracket-connectors {
  position: absolute;
  z-index: 2;
  inset: 0;
  overflow: visible;
  pointer-events: none;
}
.bracket-route {
  --connector-color: rgba(239, 195, 109, 0.68);
  --connector-glow: rgba(226, 166, 62, 0.26);
  position: absolute;
  inset: 0;
}
.bracket-route--win {
  --connector-color: rgba(239, 195, 109, 0.82);
}
.bracket-route--loss {
  --connector-color: rgba(218, 165, 98, 0.68);
}
.bracket-route.is-focus {
  --connector-color: #f5ce7a;
  --connector-glow: rgba(245, 184, 69, 0.56);
}
.connector-segment,
.connector-junction,
.connector-arrow {
  position: absolute;
  display: block;
}
.connector-segment {
  background: var(--connector-color);
  box-shadow: 0 0 7px var(--connector-glow);
}
.connector-segment--horizontal {
  height: 2px;
  transform: translateY(-1px);
}
.connector-segment--vertical {
  width: 2px;
  transform: translateX(-1px);
}
.connector-junction {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--connector-color);
  box-shadow: 0 0 8px var(--connector-glow);
  transform: translate(-2.5px, -2.5px);
}
.connector-arrow {
  width: 0;
  height: 0;
  border-top: 5px solid transparent;
  border-bottom: 5px solid transparent;
  border-left: 7px solid var(--connector-color);
  filter: drop-shadow(0 0 4px var(--connector-glow));
}
.bracket-route.is-focus .connector-segment--horizontal { height: 3px; }
.bracket-route.is-focus .connector-segment--vertical { width: 3px; }

@media (max-width: 1280px) {
  .bracket {
    grid-template-columns: repeat(6, 176px);
    gap: 38px;
    width: max-content;
    min-width: 1246px;
  }
}

/* Complete four-win Swiss path: 4-0 / 0-4 exits, two later rounds and five deciders. */
.group-label .dual-record {
  display: flex;
  justify-content: space-between;
  gap: 28px;
  padding-inline: 8px 42px;
}
.dual-record em { font-style: normal; }
.record-group.result-outcome {
  border-color: rgba(231, 185, 96, 0.82);
  background: linear-gradient(150deg, rgba(54, 31, 19, 0.98), rgba(18, 14, 10, 0.99));
}
.record-group.result-outcome .result-list { min-height: 34px; }
.record-group.single-result .result-team {
  grid-template-columns: 34px minmax(0, 1fr);
  width: 100%;
  gap: 6px;
  padding-inline: 4px;
}
.record-group.single-result .result-team span {
  display: block;
  overflow: hidden;
  color: #f2d78f;
  font-size: 10px;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.record-group.result-above::after,
.record-group.result-below::after {
  position: absolute;
  left: 50%;
  display: block;
  width: 2px;
  height: 10px;
  background: #efc36d;
  box-shadow: 0 0 6px rgba(239, 195, 109, 0.42);
  content: "";
  transform: translateX(-1px);
}
.record-group.result-above::after { bottom: -11px; }
.record-group.result-below::after { top: -11px; }
.record-group.result-above::before,
.record-group.result-below::before,
.stage:last-child .record-group.result-above::before,
.stage:last-child .record-group.result-below::before {
  position: absolute;
  z-index: 4;
  left: 50%;
  display: block;
  width: 0;
  height: 0;
  border-right: 4px solid transparent;
  border-left: 4px solid transparent;
  content: "";
  transform: translateX(-4px);
}
.record-group.result-above::before {
  bottom: -2px;
  border-bottom: 6px solid #efc36d;
}
.record-group.result-below::before {
  top: -2px;
  border-top: 6px solid #efc36d;
}

/* Fit the entire broadcast board into a 1280x720 view like the reference. */
.view-mode .bracket-scroll { padding: 10px 16px 14px; }
.view-mode .bracket {
  grid-template-columns: repeat(6, minmax(164px, 1fr));
  gap: 34px;
  width: 100%;
  min-width: 1154px;
  max-width: none;
}
.view-mode .stage { gap: 7px; }
.view-mode .stage-header { display: none; }
.view-mode .record-group {
  gap: 0;
  padding: 0 4px 3px;
  border-radius: 4px;
}
.view-mode .group-label {
  min-height: 22px;
  margin: 0 -4px 2px;
  padding-inline: 5px;
}
.view-mode .group-label strong { padding-inline: 30px; font-size: 12px; }
.view-mode .group-label span { right: 5px; font-size: 6px; }
.view-mode .group-label .dual-record {
  gap: 34px;
  padding-inline: 8px 37px;
}
.view-mode .match-card {
  grid-template-columns: 42px 44px 42px;
  width: 128px;
  min-height: 40px;
  margin-inline: auto;
}
.view-mode .match-card > .team-row:first-child,
.view-mode .match-card > .team-row:last-child {
  grid-template: 40px / 42px;
}
.view-mode .match-card > .team-row img {
  width: 39px;
  height: 39px;
}
.view-mode .match-card > .team-row .team-select {
  width: 42px;
  min-width: 42px;
  height: 40px;
}
.view-mode .match-score {
  grid-template-columns: 18px 8px 18px;
  width: 44px;
}
.view-mode .match-score .score,
.view-mode .team-row:first-child .score,
.view-mode .team-row:nth-child(2) .score {
  width: 18px;
  height: 22px;
  font-size: 11px;
}
.view-mode .score-divider { font-size: 11px; }
.view-mode .result-list { gap: 2px; padding: 3px 1px 1px; }
.view-mode .result-team { width: 30px; min-height: 30px; }
.view-mode .result-team img { width: 29px; height: 29px; }
.view-mode .result-team.empty::before { width: 27px; height: 27px; font-size: 6px; }
.view-mode .single-result .result-team {
  grid-template-columns: 29px minmax(0, 1fr);
  width: 100%;
  min-height: 30px;
}
.view-mode .final-result .result-list { flex-wrap: nowrap; }
.view-mode .final-result .result-team { width: 28px; }
.view-mode .final-result .result-team img { width: 27px; height: 27px; }
.view-mode .final-result .result-team.empty::before { width: 25px; height: 25px; }

@media (max-width: 1180px) {
  .view-mode .bracket {
    grid-template-columns: repeat(6, 164px);
    width: max-content;
    min-width: 1154px;
  }
}

/* Larger broadcast logos and cleaner outcome placeholders. */
.view-mode .bracket-heading { min-height: 60px; }
.view-mode .stage { gap: 3px; }
.view-mode .group-label { min-height: 17px; }
.view-mode .match-card {
  grid-template-columns: 46px 44px 46px;
  width: 136px;
  min-height: 44px;
}
.view-mode .match-card > .team-row:first-child,
.view-mode .match-card > .team-row:last-child {
  grid-template: 44px / 46px;
}
.view-mode .match-card > .team-row img {
  width: 44px;
  height: 44px;
}
.view-mode .match-card > .team-row .team-select {
  width: 46px;
  min-width: 46px;
  height: 44px;
}
.view-mode .result-list {
  gap: 5px;
  padding: 5px 2px 3px;
}
.view-mode .result-team,
.view-mode .final-result .result-team {
  width: 42px;
  min-height: 42px;
}
.view-mode .result-team img,
.view-mode .final-result .result-team img {
  width: 42px;
  height: 42px;
}
.view-mode .result-team.empty::before,
.view-mode .final-result .result-team.empty::before {
  width: auto;
  height: auto;
  border: 0;
  border-radius: 0;
  color: #b89152;
  background: none;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.04em;
  content: "TBD";
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.75);
}
.view-mode .single-result .result-team {
  grid-template-columns: 44px minmax(0, 1fr);
  min-height: 44px;
  gap: 8px;
}
.view-mode .single-result .result-team span { font-size: 12px; }
.view-mode .final-result .result-list {
  flex-wrap: wrap;
  max-width: 146px;
  margin-inline: auto;
}

/* Keep single-team outcomes centered as one logo/name unit. */
.view-mode .record-group.single-result .result-list {
  justify-content: center;
}
.view-mode .record-group.single-result .result-team {
  display: inline-flex;
  width: auto;
  min-width: 0;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-inline: auto;
  padding: 0 12px;
}
.view-mode .record-group.single-result .result-team img {
  flex: 0 0 42px;
  width: 42px;
  height: 42px;
}
.view-mode .record-group.single-result .result-team span {
  display: block;
  flex: 0 0 auto;
  overflow: visible;
  font-size: 12px;
  text-overflow: clip;
}
.record-group.result-above::before {
  bottom: -14px;
  border-top: 0;
  border-bottom: 6px solid #efc36d;
}
.record-group.result-below::before {
  top: -14px;
  border-top: 6px solid #efc36d;
  border-bottom: 0;
}

/* Outcome cards show the emblem only; connector arrows stay outside. */
.view-mode .record-group.single-result .result-team span {
  display: none;
}
.record-group.result-above::before {
  top: auto;
  right: auto;
  bottom: -14px;
}
.record-group.result-below::before {
  top: -14px;
  right: auto;
  bottom: auto;
}

/* Correct outcome arrow direction and keep every connector clear of team logos. */
.record-group.result-above::after {
  bottom: -13px;
  height: 12px;
}
.record-group.result-below::after {
  top: -13px;
  height: 12px;
}
.record-group.result-above::before,
.record-group.result-below::before,
.record-group.result-above::after,
.record-group.result-below::after {
  pointer-events: none;
}

/* Pin outcome markers outside their cards even if an older connector rule is cached. */
.view-mode .record-group.result-outcome.result-above::before {
  top: auto;
  right: auto;
  bottom: -14px;
  border-top: 0;
  border-bottom: 6px solid #efc36d;
}
.view-mode .record-group.result-outcome.result-below::before {
  top: -14px;
  right: auto;
  bottom: auto;
  border-top: 6px solid #efc36d;
  border-bottom: 0;
}

/* Outcome emblems stay true to the source artwork: no gold halo beside Vision. */
.view-mode .record-group.single-result .result-team img {
  background: none;
  filter: none;
}

/* Reserve a clean connector lane so 3–0 never renders as 3▲0. */
.view-mode .record-group.result-outcome.single-result .result-list {
  padding: 1px 2px;
}
.view-mode .record-group.result-outcome.single-result.result-above {
  margin-bottom: 6px;
}
.view-mode .record-group.result-outcome.single-result.result-below {
  margin-top: 6px;
}
.view-mode .record-group.result-outcome.result-above::before {
  bottom: -8px;
}
.view-mode .record-group.result-outcome.result-above::after {
  top: auto;
  bottom: -7px;
  height: 8px;
}
.view-mode .record-group.result-outcome.result-below::before {
  top: -8px;
}
.view-mode .record-group.result-outcome.result-below::after {
  top: -7px;
  bottom: auto;
  height: 8px;
}
