:root {
  color-scheme: light;
  --grass-50: #f6fbf3;
  --grass-100: #e7f3df;
  --grass-500: #2c8650;
  --grass-700: #174f31;
  --chalk: #ffffff;
  --ink: #13221c;
  --muted: #6a7a71;
  --line: rgba(44, 134, 80, 0.34);
  --line-strong: #25834c;
  --gold: #d8ab36;
  --gold-deep: #9b6a13;
  --blue: #226aa8;
  --card: rgba(255, 255, 255, 0.94);
  --shadow: 0 18px 46px rgba(23, 79, 49, 0.15);
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  font-family:
    ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at 50% 42%, rgba(216, 171, 54, 0.22), transparent 24rem),
    linear-gradient(135deg, #eef8e9 0%, #fbfdf8 48%, #e1f0dc 100%);
}

button,
a {
  font: inherit;
}

a {
  color: var(--grass-700);
  text-decoration-color: rgba(44, 134, 80, 0.45);
  text-underline-offset: 0.22em;
}

a:hover {
  color: var(--blue);
}

.app-shell {
  position: fixed;
  inset: 0;
  display: grid;
  grid-template-rows: auto auto 1fr;
  min-width: 320px;
}

.app-header {
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 20px;
  border-bottom: 1px solid rgba(23, 79, 49, 0.12);
  background: rgba(255, 255, 255, 0.82);
  backdrop-filter: blur(18px);
}

.title-block {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.eyebrow,
.snapshot-line,
.source-panel {
  margin: 0;
}

.eyebrow {
  color: var(--grass-700);
  font-size: 0.76rem;
  font-weight: 850;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: clamp(1.55rem, 2.4vw, 2.8rem);
  line-height: 1;
  letter-spacing: 0;
}

.snapshot-line {
  color: var(--muted);
  font-size: 0.9rem;
}

.toolbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.tool-button,
.zoom-readout {
  min-height: 40px;
  border: 1px solid rgba(23, 79, 49, 0.16);
  border-radius: 8px;
  background: #ffffff;
  color: var(--ink);
  box-shadow: 0 8px 20px rgba(23, 79, 49, 0.08);
}

.tool-button {
  min-width: 42px;
  padding: 0 12px;
  cursor: pointer;
}

.tool-button:hover {
  border-color: rgba(44, 134, 80, 0.5);
}

.tool-button.is-primary {
  border-color: rgba(216, 171, 54, 0.45);
  color: var(--gold-deep);
  font-weight: 820;
}

.tool-button:focus-visible,
.team-button:focus-visible,
.final-slot:focus-visible {
  outline: 3px solid rgba(216, 171, 54, 0.72);
  outline-offset: 2px;
}

.zoom-readout {
  display: grid;
  place-items: center;
  min-width: 76px;
  padding: 0 12px;
  color: var(--grass-700);
  font-size: 0.84rem;
  font-weight: 760;
}

.source-panel {
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 8px 20px;
  border-bottom: 1px solid rgba(23, 79, 49, 0.08);
  background: rgba(255, 255, 255, 0.58);
  color: rgba(23, 79, 49, 0.7);
  font-size: 0.78rem;
  line-height: 1.35;
}

.source-panel p {
  margin: 0;
}

.source-links {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 4px 8px;
}

.sync-status {
  min-width: 150px;
  color: var(--grass-700);
  font-weight: 820;
  text-align: right;
}

#bracket-root {
  position: relative;
  min-height: 0;
}

.bracket-viewport {
  position: relative;
  width: 100%;
  height: 100%;
  min-height: 0;
  overflow: hidden;
  cursor: grab;
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.42) 0 1px, transparent 1px 120px),
    linear-gradient(0deg, rgba(255, 255, 255, 0.42) 0 1px, transparent 1px 120px),
    radial-gradient(circle at center, rgba(255, 255, 255, 0.7), transparent 46rem);
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

.bracket-viewport.is-dragging {
  cursor: grabbing;
}

.field-mark {
  position: absolute;
  inset: 56px;
  border: 2px solid rgba(255, 255, 255, 0.72);
  border-radius: 30px;
  pointer-events: none;
}

.center-circle {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 420px;
  height: 420px;
  border: 2px solid rgba(255, 255, 255, 0.64);
  border-radius: 999px;
  transform: translate(-50%, -50%);
  pointer-events: none;
}

.bracket-canvas {
  position: absolute;
  top: 0;
  left: 0;
  transform-origin: 0 0;
}

.connectors {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.connector {
  fill: none;
  stroke: var(--line);
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 3;
}

.connector.is-active {
  stroke: var(--line-strong);
  stroke-width: 4;
}

.round-label {
  position: absolute;
  width: 288px;
  color: var(--grass-700);
  font-size: 0.76rem;
  font-weight: 900;
  letter-spacing: 0;
}

.round-label.is-right {
  text-align: right;
}

.round-label.is-center {
  text-align: center;
}

.zone-label {
  position: absolute;
  width: 360px;
  color: rgba(23, 79, 49, 0.54);
  font-size: 0.86rem;
  font-weight: 820;
  letter-spacing: 0;
}

.match-card {
  position: absolute;
  width: 288px;
  min-height: 132px;
  border: 1px solid rgba(23, 79, 49, 0.13);
  border-radius: 8px;
  background: var(--card);
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
}

.match-card.is-next {
  background: rgba(255, 255, 255, 0.86);
}

.match-card.is-locked {
  border-color: rgba(216, 171, 54, 0.36);
}

.match-card.is-final {
  z-index: 5;
  border-color: rgba(216, 171, 54, 0.5);
  background:
    radial-gradient(circle at 50% 0%, rgba(255, 232, 167, 0.56), transparent 7rem),
    rgba(255, 255, 255, 0.94);
  box-shadow:
    0 22px 58px rgba(23, 79, 49, 0.18),
    0 0 44px rgba(216, 171, 54, 0.14);
}

.match-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 11px 14px 8px;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 860;
}

.match-id {
  color: var(--grass-700);
}

.match-status {
  min-height: 18px;
  margin: -2px 14px 7px;
  color: rgba(23, 79, 49, 0.66);
  font-size: 0.66rem;
  font-weight: 760;
  line-height: 1.25;
}

.team-list {
  display: grid;
  gap: 9px;
  padding: 0 14px 14px;
}

.team-button {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr) 46px;
  align-items: center;
  gap: 10px;
  min-height: 48px;
  width: 100%;
  border: 1px solid rgba(19, 34, 28, 0.08);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.74);
  color: var(--ink);
  text-align: left;
  cursor: pointer;
}

.team-button:hover:not(:disabled) {
  border-color: rgba(34, 106, 168, 0.45);
  background: #ffffff;
}

.team-button.is-selected,
.final-slot.is-selected {
  border-color: rgba(44, 134, 80, 0.62);
  background: #ebf7ea;
  box-shadow: inset 0 0 0 2px rgba(44, 134, 80, 0.16);
}

.team-button.is-locked {
  border-style: solid;
}

.team-button.is-locked.is-selected {
  border-color: rgba(216, 171, 54, 0.6);
  background: #fff8dc;
  box-shadow:
    inset 0 0 0 2px rgba(216, 171, 54, 0.17),
    0 8px 18px rgba(155, 106, 19, 0.08);
}

.team-button:disabled,
.final-slot:disabled {
  color: rgba(19, 34, 28, 0.44);
  cursor: default;
}

.team-button.is-locked.is-selected:disabled {
  color: var(--ink);
}

.team-button.is-locked:not(.is-selected):disabled {
  background: rgba(255, 255, 255, 0.54);
}

.flag {
  width: 28px;
  height: 20px;
  margin-left: 10px;
  border-radius: 4px;
  object-fit: cover;
  box-shadow: 0 0 0 1px rgba(19, 34, 28, 0.08);
}

.placeholder-flag {
  width: 28px;
  height: 20px;
  margin-left: 10px;
  border-radius: 4px;
  background:
    linear-gradient(90deg, transparent 44%, rgba(44, 134, 80, 0.28) 44% 56%, transparent 56%),
    rgba(44, 134, 80, 0.1);
}

.team-name {
  overflow-wrap: anywhere;
  font-size: 0.88rem;
  font-weight: 820;
  line-height: 1.16;
}

.team-code {
  padding-right: 10px;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 850;
  text-align: right;
}

.champion-hub {
  position: absolute;
  width: 390px;
  min-height: 360px;
  overflow: visible;
  z-index: 3;
  padding: 158px 24px 24px;
  border: 1px solid rgba(216, 171, 54, 0.46);
  border-radius: 14px;
  background:
    radial-gradient(circle at 50% -12%, rgba(255, 233, 164, 0.84), transparent 12rem),
    radial-gradient(circle at 50% 34%, rgba(216, 171, 54, 0.26), transparent 12rem),
    linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(255, 251, 234, 0.94));
  box-shadow:
    0 30px 90px rgba(23, 79, 49, 0.25),
    0 0 90px rgba(216, 171, 54, 0.24),
    inset 0 0 0 1px rgba(255, 255, 255, 0.72);
  isolation: isolate;
}

.champion-hub::before {
  position: absolute;
  inset: -140px -128px -56px;
  z-index: -1;
  border-radius: 999px;
  background:
    radial-gradient(circle at 50% 28%, rgba(255, 220, 118, 0.7), transparent 15rem),
    radial-gradient(circle at 50% 48%, rgba(44, 134, 80, 0.18), transparent 18rem);
  content: "";
  filter: blur(8px);
  pointer-events: none;
}

.champion-hub::after {
  position: absolute;
  right: 18px;
  bottom: 18px;
  left: 18px;
  z-index: 2;
  height: 132px;
  border-radius: 12px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.18), rgba(255, 253, 242, 0.94) 38%),
    rgba(255, 255, 255, 0.72);
  content: "";
  pointer-events: none;
}

.trophy-burst {
  position: absolute;
  top: -330px;
  left: 50%;
  z-index: 1;
  width: 500px;
  max-width: none;
  transform: translateX(-50%);
  filter:
    drop-shadow(0 32px 46px rgba(111, 73, 7, 0.34))
    drop-shadow(0 0 34px rgba(255, 226, 129, 0.38));
  pointer-events: none;
  user-select: none;
}

.champion-copy {
  position: relative;
  z-index: 3;
}

.champion-ring {
  display: grid;
  place-items: center;
  width: 58px;
  height: 58px;
  margin: 0 auto 8px;
  border: 1px solid rgba(216, 171, 54, 0.52);
  border-radius: 999px;
  background:
    radial-gradient(circle, #fffdf0 0 44%, rgba(216, 171, 54, 0.18) 45% 100%);
  color: var(--gold-deep);
  font-size: 1.05rem;
  font-weight: 950;
  letter-spacing: 0;
  box-shadow: 0 12px 28px rgba(155, 106, 19, 0.16);
}

.champion-label {
  display: block;
  color: var(--gold-deep);
  font-size: 0.78rem;
  font-weight: 900;
  text-align: center;
}

.champion-name {
  display: block;
  margin-top: 8px;
  font-size: 2.24rem;
  font-weight: 950;
  line-height: 1.08;
  text-align: center;
  text-shadow: 0 2px 0 rgba(255, 255, 255, 0.82);
}

.champion-team-card {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) 54px;
  align-items: center;
  gap: 10px;
  min-height: 48px;
  margin-top: 18px;
  padding: 0 12px;
  border: 1px solid rgba(216, 171, 54, 0.24);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.76);
  color: var(--ink);
  font-size: 0.92rem;
  font-weight: 850;
}

.champion-flag {
  width: 30px;
  height: 22px;
  border-radius: 4px;
  object-fit: cover;
  box-shadow: 0 0 0 1px rgba(19, 34, 28, 0.08);
}

.champion-flag.is-placeholder {
  background:
    linear-gradient(90deg, transparent 44%, rgba(216, 171, 54, 0.32) 44% 56%, transparent 56%),
    rgba(216, 171, 54, 0.12);
}

.champion-code {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 900;
  text-align: right;
}

.final-slots {
  display: grid;
  gap: 11px;
  margin-top: 22px;
}

.final-slot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 44px;
  padding: 0 14px;
  border: 1px solid rgba(216, 171, 54, 0.2);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.72);
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 820;
  cursor: pointer;
}

.final-slot:hover:not(:disabled) {
  border-color: rgba(216, 171, 54, 0.5);
  background: #ffffff;
}

.final-team {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--ink);
}

.final-team .flag {
  margin-left: 0;
}

@media (max-width: 860px) {
  .app-header {
    align-items: start;
    padding: 12px;
  }

  .toolbar {
    max-width: 210px;
  }

  .source-panel {
    display: none;
  }

  .app-shell {
    grid-template-rows: auto 1fr;
  }

  h1 {
    font-size: 1.7rem;
  }

  .snapshot-line {
    font-size: 0.8rem;
  }
}
