.bracket-app {
  --ink: #18181b;
  --muted: #71717a;
  --line: #e6e6ea;
  --card: #fff;
  --green: #3f6212;
  --green-bg: #f7fee7;
  background: #efeff1;
  color: var(--ink);
  border-radius: 16px;
  padding: 8px 16px 20px;
  font-family: "Avenir Next", "Segoe UI", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}
.bracket-app.is-public {
  border-radius: 0;
  min-height: 100vh;
  padding: 8px 20px 40px;
  box-sizing: border-box;
}
.bracket-app:not(.is-public) {
  box-shadow: 0 12px 32px rgb(0 0 0 / .18);
}
.bracket-app, .bracket-app * { box-sizing: border-box; }

.top {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 4px 6px;
}
.eyebrow { margin: 0; color: var(--muted); font-size: 13px; font-weight: 650; letter-spacing: .04em; text-transform: uppercase; }
.top h1 { margin: 2px 0 0; font-size: clamp(1.6rem, 3vw, 2rem); letter-spacing: -.03em; font-weight: 700; }
.sub { margin: 4px 0 0; color: var(--muted); font-size: 14px; }

.live {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 13px;
  font-weight: 650;
}
.live i {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #22c55e;
  box-shadow: 0 0 0 0 rgb(34 197 94 / .55);
  animation: live-pulse 1.8s ease-out infinite;
}
.live.off { color: var(--muted); }
.live.off i { background: #a1a1aa; animation: none; box-shadow: none; }
@keyframes live-pulse {
  70% { box-shadow: 0 0 0 7px rgb(34 197 94 / 0); }
}

.leaders { display: flex; flex-wrap: wrap; gap: 10px; padding: 12px 4px 14px; align-items: stretch; }
.quiet { margin: 0; color: var(--muted); font-size: 14px; padding: 6px 0; }
.leader {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 10px 14px 10px 10px;
  min-width: 180px;
  box-shadow: 0 1px 2px rgb(16 16 20 / .04);
}
.leader.champ { background: linear-gradient(180deg, #fffbeb, #fff); border-color: #fcd34d; }
.leader .who { margin: 0; font-size: 11px; font-weight: 750; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.leader.champ .who { color: #a16207; }
.leader .tname { font-size: 15px; }

.tools { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; padding: 0 4px 12px; }
.sizes { display: flex; align-items: center; gap: 8px; }
.sizes-label { font-size: 13px; color: var(--muted); font-weight: 650; }
.sizes-btns { display: flex; background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 3px; }
.sizes-btns button {
  border: 0;
  background: transparent;
  color: #3f3f46;
  font: inherit;
  font-weight: 650;
  font-size: 13px;
  border-radius: 8px;
  padding: 6px 10px;
  cursor: pointer;
}
.sizes-btns button.on { background: var(--ink); color: white; }
.help { margin: 0; flex: 1; min-width: 240px; color: var(--muted); font-size: 13px; line-height: 1.4; }
.texty { border: 0; background: transparent; color: var(--muted); font: inherit; font-size: 13px; cursor: pointer; text-decoration: underline; padding: 6px 0; }

.pool {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  min-height: 54px;
  align-items: center;
  margin: 0 4px 10px;
  padding: 10px;
  background: rgb(255 255 255 / .72);
  border: 1px dashed #d4d4d8;
  border-radius: 14px;
}
.pool-empty { color: var(--muted); font-size: 13px; padding: 0 4px; }
.pool .chip {
  width: auto;
  max-width: 240px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 12px 4px 4px;
  box-shadow: 0 1px 2px rgb(16 16 20 / .04);
}

.outzone {
  margin: 0 4px 14px;
  border: 1px dashed #d4d4d8;
  border-radius: 12px;
  color: #a1a1aa;
  text-align: center;
  padding: 10px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: .02em;
}

.toast {
  margin: 0 4px 12px;
  background: #fef2f2;
  color: #b91c1c;
  border-radius: 10px;
  padding: 8px 12px;
  font-size: 14px;
}

.frame {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 18px;
  background-color: #fbfbfc;
  background-image: radial-gradient(#e4e4e7 1.15px, transparent 1.15px);
  background-size: 18px 18px;
  padding: 18px 18px 28px;
}
.board { position: relative; width: max-content; min-width: 100%; }
.lines { position: absolute; left: 0; top: 0; pointer-events: none; }
.columns { position: relative; z-index: 1; display: flex; gap: 56px; }
.col { width: 210px; flex: none; }
.col-title { height: 28px; text-align: center; color: #a1a1aa; font-size: 13px; font-weight: 650; }
.col-body { position: relative; }

.match {
  position: absolute;
  left: 0;
  right: 0;
  height: 88px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 1px 2px rgb(16 16 20 / .04), 0 8px 20px rgb(16 16 20 / .03);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.slot {
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  padding: 0 8px;
}
.slot + .slot { box-shadow: inset 0 1px 0 #f1f1f4; }
.slot.in { background: var(--green-bg); }
.slot.out { background: #fafafa; }
.slot .hint { width: 100%; text-align: center; color: #a1a1aa; font-size: 13px; }

.champ {
  position: absolute;
  left: 0;
  right: 0;
  height: 76px;
  display: flex;
  align-items: center;
  padding: 0 10px;
  background: var(--card);
  border: 1px dashed #d4d4d8;
  border-radius: 14px;
}
.champ.filled {
  border-style: solid;
  border-color: #fcd34d;
  background: linear-gradient(180deg, #fffbeb, #fff);
}

.chip { display: flex; align-items: center; gap: 8px; min-width: 0; width: 100%; }
.bracket-app.editable .chip { cursor: grab; touch-action: none; }
.faces { display: flex; flex-shrink: 0; }
.face {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  object-fit: cover;
  display: grid;
  place-items: center;
  color: white;
  font-size: 11px;
  font-weight: 750;
  border: 2px solid white;
  margin-left: -7px;
}
.faces .face:first-child { margin-left: 0; }
.tname { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13.5px; font-weight: 650; }
.fate { margin-left: auto; flex-shrink: 0; font-size: 10px; font-weight: 750; letter-spacing: .04em; text-transform: uppercase; }
.slot.in .fate { color: var(--green); }
.slot.out .chip { opacity: .5; }
.slot.out .fate { color: #a1a1aa; }
.champ .fate { color: #a16207; }

body.dragging-team, body.dragging-team * { cursor: grabbing !important; }
.bracket-app.is-dragging .slot.can-drop,
.bracket-app.is-dragging .champ.can-drop { background: #f0fdf4; box-shadow: inset 0 0 0 1.5px #86efac; }
.bracket-app.is-dragging .slot.can-drop.over,
.bracket-app.is-dragging .champ.can-drop.over { background: #dcfce7; box-shadow: inset 0 0 0 2px #16a34a; }
.bracket-app.is-dragging .outzone.can-drop { border-color: #fca5a5; color: #ef4444; background: #fff5f5; }
.bracket-app.is-dragging .outzone.over { background: #fee2e2; border-style: solid; }
.chip.lifting { opacity: .35; }

.ghost {
  position: fixed;
  z-index: 1000;
  pointer-events: none;
  width: max-content;
  max-width: 220px;
  background: white;
  border-radius: 12px;
  padding: 8px 12px 8px 8px;
  box-shadow: 0 14px 34px rgb(0 0 0 / .18);
}

@media (max-width: 640px) {
  .bracket-app.is-public { padding: 4px 12px 28px; }
  .top { align-items: flex-start; }
  .help { flex-basis: 100%; }
}

/* Vista pública. El panel del boss no usa .is-public. */
.bracket-app.is-public {
  --ink: #1c1915;
  --muted: #6f675f;
  --line: #e3dacb;
  --card: #fffdf8;
  background: #f4efe6;
  color: var(--ink);
  font-family: "Source Sans 3", "Avenir Next", system-ui, sans-serif;
  padding: 8px 20px 48px;
}
.bracket-app.is-public h1,
.bracket-app.is-public h2 {
  font-family: Fraunces, "Times New Roman", serif;
  font-weight: 560;
  letter-spacing: -0.02em;
}
.bracket-app.is-public h1 { font-size: clamp(2.2rem, 5vw, 3.4rem); margin: 0; }
.bracket-app.is-public .sub { max-width: 38rem; font-size: 1.05rem; line-height: 1.45; }
.bracket-app.is-public .live i {
  background: #1e4a38;
  box-shadow: 0 0 0 0 rgb(30 74 56 / .45);
}
.bracket-app.is-public .frame {
  background-color: #fffdf8;
  background-image: radial-gradient(#e3dacb 1px, transparent 1px);
  border-color: #e3dacb;
}
.bracket-app.is-public .slot.in { background: #e7f2eb; }
.bracket-app.is-public .slot.in .fate { color: #1e4a38; }
.bracket-app.is-public .champ.filled,
.bracket-app.is-public .leader.champ {
  border-color: #9a6b12;
  background: #fffdf8;
}
.bracket-app.is-public .leader.champ .who,
.bracket-app.is-public .champ .fate { color: #9a6b12; }
.bracket-app.is-public button.leader {
  font: inherit;
  color: inherit;
  text-align: left;
  cursor: pointer;
  width: auto;
}
.bracket-app.is-public .chip { cursor: pointer; }
.bracket-app.is-public .face { border-color: #fffdf8; }

.sim { margin: 8px 4px 6px; }
.sim-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; flex-wrap: wrap; }
.sim h2 { margin: 0; font-size: 1.7rem; }
.sim-head p { margin: 4px 0 0; color: #6f675f; max-width: 36rem; }
.sim-round { margin: 0; font-weight: 700; color: #1e4a38; }
.mesas { display: grid; gap: 12px; margin-top: 12px; }
.mesa {
  background: #fffdf8;
  border: 1px solid #e3dacb;
  border-radius: 16px;
  padding: 12px 14px;
}
.mesa.is-empty { border-style: dashed; }
.mesa-k {
  margin: 0 0 4px;
  font-size: 12px;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: #6f675f;
  font-weight: 700;
}
.mesa .chip { min-height: 44px; }
.mesa .chip + .chip,
.mesa .chip + .sim-empty,
.mesa .sim-empty + .chip { border-top: 1px solid #e3dacb; }
.sim-empty { margin: 0; padding: 12px 0; text-align: center; color: #6f675f; }
.sim-wait { margin-top: 10px; }

.rounds { display: none; }
.round-tabs { display: flex; gap: 8px; overflow-x: auto; padding: 4px 0 12px; }
.round-tabs button {
  min-height: 44px;
  flex: none;
  border-radius: 999px;
  border: 1px solid #e3dacb;
  background: #fffdf8;
  color: #1c1915;
  font: inherit;
  font-weight: 700;
  padding: 0 14px;
  cursor: pointer;
}
.round-tabs button.on { background: #1e4a38; color: #f4efe6; border-color: #1e4a38; }
.phone-match {
  background: #fffdf8;
  border: 1px solid #e3dacb;
  border-radius: 16px;
  overflow: hidden;
  margin-bottom: 12px;
}
.phone-kicker {
  margin: 0;
  padding: 8px 14px;
  font-size: 12px;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: #6f675f;
  font-weight: 700;
  border-bottom: 1px solid #e3dacb;
}
.phone-match .slot { min-height: 48px; }

.how {
  display: grid;
  gap: 16px;
  margin: 28px 4px 0;
  padding-top: 20px;
  border-top: 1px solid #e3dacb;
}
.how h2 { margin: 0; font-size: 1.25rem; }
.how p { margin: 4px 0 0; color: #6f675f; }

.team-dialog { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 16px; }
.team-back { position: absolute; inset: 0; border: 0; background: rgb(28 25 21 / .4); cursor: pointer; }
.team-card {
  position: relative;
  z-index: 1;
  width: min(100%, 24rem);
  background: #fffdf8;
  border: 1px solid #e3dacb;
  border-radius: 24px;
  padding: 20px;
  box-shadow: 0 16px 40px rgb(28 25 21 / .16);
}
.team-card-top { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
.team-card h2 { margin: 0; font-size: 1.8rem; }
.team-card p { margin: 4px 0 0; color: #6f675f; }
.team-x {
  width: 44px;
  height: 44px;
  border-radius: 999px;
  border: 1px solid #e3dacb;
  background: transparent;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
}
.team-card ul { list-style: none; margin: 16px 0 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.team-card li {
  display: flex;
  align-items: center;
  gap: 12px;
  border: 1px solid #e3dacb;
  border-radius: 16px;
  padding: 10px 12px;
  font-weight: 650;
}
.team-card .face { width: 56px; height: 56px; margin: 0; font-size: 18px; }

@media (min-width: 720px) {
  .mesas, .how { grid-template-columns: 1fr 1fr; }
  .how { grid-template-columns: 1fr 1fr 1fr; }
}
@media (max-width: 760px) {
  .bracket-app.is-public { padding: 4px 12px 32px; }
  .bracket-app.is-public .frame { display: none; }
  .bracket-app.is-public .rounds { display: block; }
}
@media (prefers-reduced-motion: reduce) {
  .bracket-app.is-public .live i { animation: none; }
}
