:root {
  --bg: #edf0f3;
  --ink: #101722;
  --muted: #697386;
  --panel: #ffffff;
  --panel-soft: #f7f8fa;
  --line: #d9dee7;
  --line-strong: #c6cedb;
  --gold: #c8921f;
  --gold-soft: #fff4d8;
  --teal: #147f91;
  --teal-2: #23a9bf;
  --rose: #b9375c;
  --rose-2: #e75b83;
  --green: #16845d;
  --shadow: 0 18px 44px rgba(16, 23, 34, 0.11);
  --shadow-soft: 0 8px 22px rgba(16, 23, 34, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    linear-gradient(135deg, rgba(20, 127, 145, 0.10), transparent 30%),
    linear-gradient(225deg, rgba(200, 146, 31, 0.11), transparent 34%),
    var(--bg);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(16, 23, 34, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(16, 23, 34, 0.035) 1px, transparent 1px);
  background-size: 36px 36px;
  mask-image: linear-gradient(to bottom, black, transparent 86%);
}

button,
input {
  font: inherit;
}

button {
  min-height: 42px;
  cursor: pointer;
  border: 0;
  border-radius: 12px;
  padding: 0.72rem 1rem;
  color: #171006;
  background: linear-gradient(180deg, #f4c862, #dfaa32);
  font-weight: 850;
  box-shadow: 0 10px 20px rgba(200, 146, 31, 0.20);
  transition: transform 160ms ease, box-shadow 160ms ease, filter 160ms ease;
}

button:hover:not(:disabled) {
  transform: translateY(-1px);
  filter: saturate(1.05);
  box-shadow: 0 14px 26px rgba(200, 146, 31, 0.24);
}

button:disabled {
  cursor: default;
  opacity: 0.56;
}

input {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  padding: 0.78rem 0.9rem;
  color: var(--ink);
  background: #ffffff;
  outline: none;
}

input:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 4px rgba(200, 146, 31, 0.16);
}

.shell {
  position: relative;
  width: min(1280px, calc(100% - 44px));
  margin: 0 auto;
  padding: 24px 0 40px;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  max-width: 680px;
  font-size: clamp(2.2rem, 4.9vw, 4.6rem);
  line-height: 0.92;
  letter-spacing: 0;
  text-transform: uppercase;
}

h2,
h3 {
  line-height: 1.08;
}

.hidden {
  display: none !important;
}

.grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 18px;
  align-items: start;
}

#app[data-view="vote"] {
  min-height: calc(100vh - 48px);
  display: grid;
  grid-template-columns: minmax(0, 1160px);
  justify-content: center;
  align-content: center;
}

#app[data-view="vote"] .bracket,
#app[data-view="vote"] .admin {
  display: none;
}

#app[data-view="vote"] .stack {
  display: grid;
  grid-template-columns: minmax(0, 860px) 240px;
  gap: 22px;
  align-items: center;
  position: static;
}

body.is-admin #app[data-view="vote"] .stack {
  grid-template-columns: minmax(0, 820px) 300px;
}

body.is-admin #app[data-view="vote"] .admin {
  display: block;
  grid-column: 2;
  grid-row: 1;
}

body.is-admin #app[data-view="vote"] .arena {
  grid-column: 1;
  grid-row: 1 / span 2;
}

body.is-admin #app[data-view="vote"] .stack > .card:last-child {
  grid-column: 2;
  grid-row: 2;
}

#app[data-view="bracket"],
#app[data-view="complete"] {
  grid-template-columns: minmax(0, 1fr);
}

#app[data-view="complete"] {
  gap: 22px;
}

#app[data-view="bracket"] .stack,
#app[data-view="complete"] .stack {
  display: none;
}

body.is-admin #app[data-view="bracket"] {
  grid-template-columns: minmax(0, 1fr) 300px;
}

body.is-admin #app[data-view="complete"] {
  grid-template-columns: minmax(0, 1fr) 300px;
}

body.is-admin #app[data-view="bracket"] .stack {
  display: grid;
  position: sticky;
  top: 18px;
}

body.is-admin #app[data-view="complete"] .stack {
  display: grid;
  position: sticky;
  top: 18px;
}

body.is-admin #app[data-view="bracket"] .arena,
body.is-admin #app[data-view="bracket"] .stack > .card:last-child,
body.is-admin #app[data-view="complete"] .arena,
body.is-admin #app[data-view="complete"] .stack > .card:last-child {
  display: none;
}

body.is-admin #app[data-view="complete"] .champion,
body.is-admin #app[data-view="complete"] .bracket {
  grid-column: 1;
}

#app[data-view="bracket"] .bracket,
#app[data-view="complete"] .bracket {
  min-height: min(680px, calc(100vh - 96px));
}

.champion {
  display: none;
}

#app[data-view="complete"] .champion {
  position: relative;
  display: grid;
  place-items: center;
  min-height: min(58vh, 560px);
  overflow: hidden;
  border-radius: 34px;
  padding: 42px;
  color: #ffffff;
  background:
    radial-gradient(circle at 50% 42%, rgba(255, 255, 255, 0.30), transparent 18%),
    linear-gradient(135deg, #121a27, #147f91 48%, #c8921f);
  box-shadow: 0 32px 90px rgba(16, 23, 34, 0.22);
}

.champion p {
  z-index: 1;
  margin: 0 0 12px;
  color: rgba(255, 255, 255, 0.78);
  font-size: 0.82rem;
  font-weight: 950;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.champion h1 {
  z-index: 1;
  max-width: 100%;
  color: #ffffff;
  font-size: clamp(4rem, 14vw, 12rem);
  line-height: 0.86;
  text-align: center;
  text-shadow: 0 16px 48px rgba(0, 0, 0, 0.32);
  animation: champion-pop 760ms cubic-bezier(0.2, 1.35, 0.25, 1) both;
}

.confetti {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.confetti i {
  position: absolute;
  top: -20px;
  width: 12px;
  height: 28px;
  border-radius: 3px;
  background: #ffffff;
  opacity: 0.82;
  animation: confetti-drop 2600ms linear infinite;
}

.confetti i:nth-child(1) { left: 10%; background: #fff4d8; animation-delay: 0ms; }
.confetti i:nth-child(2) { left: 22%; background: #23a9bf; animation-delay: 260ms; }
.confetti i:nth-child(3) { left: 36%; background: #e75b83; animation-delay: 520ms; }
.confetti i:nth-child(4) { left: 49%; background: #ffffff; animation-delay: 160ms; }
.confetti i:nth-child(5) { left: 63%; background: #f4c862; animation-delay: 720ms; }
.confetti i:nth-child(6) { left: 74%; background: #23a9bf; animation-delay: 380ms; }
.confetti i:nth-child(7) { left: 84%; background: #e75b83; animation-delay: 900ms; }
.confetti i:nth-child(8) { left: 93%; background: #fff4d8; animation-delay: 620ms; }

.panel,
.card {
  border: 1px solid rgba(198, 206, 219, 0.86);
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: var(--shadow-soft);
  animation: rise-in 360ms ease both;
}

.panel {
  padding: 22px;
}

.card {
  padding: 16px;
}

.gate {
  display: grid;
  gap: 12px;
  width: min(460px, 100%);
  margin: calc(50vh - 110px) auto 0;
  padding: 22px;
}

.gate label {
  display: block;
  margin-bottom: 0;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 850;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.gate .row {
  align-items: stretch;
}

.gate input {
  min-height: 50px;
}

.gate button {
  min-width: 104px;
}

.row {
  display: flex;
  gap: 10px;
}

.section-head,
.match-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.section-head {
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
}

.section-head h2 {
  margin: 0;
  font-size: 1.35rem;
}

.section-head span,
.match-meta {
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 900;
  letter-spacing: 0.15em;
  text-transform: uppercase;
}

.bracket {
  min-height: 640px;
  overflow: hidden;
}

#bracket {
  display: grid;
  grid-template-columns: minmax(170px, 0.8fr) repeat(3, minmax(180px, 1fr));
  gap: 30px;
  min-height: 540px;
  margin-top: 18px;
  overflow-x: auto;
  padding: 2px 4px 14px;
}

.bracket-round {
  display: grid;
  grid-template-rows: 22px 1fr;
  min-width: 170px;
}

.round-title {
  color: var(--gold);
  font-size: 0.68rem;
  font-weight: 950;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.round-matches {
  display: flex;
  flex-direction: column;
  justify-content: space-around;
  gap: 14px;
}

.playin .round-matches {
  padding-block: 118px;
}

.quarters .round-matches {
  padding-block: 0;
}

.semis .round-matches {
  padding-block: 72px;
}

.final .round-matches {
  justify-content: center;
  padding-block: 134px;
}

.bracket-match {
  position: relative;
  display: grid;
  gap: 7px;
  min-height: 88px;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 9px;
  background: var(--panel);
  box-shadow: 0 8px 18px rgba(16, 23, 34, 0.055);
  animation: bracket-in 420ms ease both;
}

.bracket-round:not(:last-child) .bracket-match::after {
  content: "";
  position: absolute;
  top: 50%;
  right: -31px;
  width: 31px;
  border-top: 2px solid rgba(105, 115, 134, 0.28);
}

.bracket-match.active {
  border-color: rgba(200, 146, 31, 0.78);
  background: linear-gradient(180deg, #fffaf0, #ffffff);
  box-shadow: 0 0 0 4px rgba(200, 146, 31, 0.14), 0 14px 28px rgba(200, 146, 31, 0.13);
}

.bracket-slot {
  display: flex;
  align-items: center;
  min-height: 32px;
  border: 1px solid var(--line);
  border-radius: 11px;
  padding: 0 10px;
  background: var(--panel-soft);
  color: var(--ink);
  font-size: 0.9rem;
  font-weight: 850;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.bracket-slot.empty {
  justify-content: center;
  color: #a3abb9;
  font-weight: 800;
}

.bracket-slot.winner {
  border-color: rgba(22, 132, 93, 0.34);
  background: #eaf8f1;
  color: #12694c;
  animation: winner-pop 360ms ease both;
}

.bracket-slot.loser {
  color: #6f7888;
  background: #f4f6f8;
  text-decoration: line-through;
  text-decoration-thickness: 2px;
  text-decoration-color: rgba(105, 115, 134, 0.34);
}

.bracket-result {
  min-height: 16px;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
}

.stack {
  display: grid;
  gap: 14px;
  position: sticky;
  top: 18px;
}

.arena {
  padding: 18px;
  background: #ffffff;
  box-shadow: var(--shadow);
}

#app[data-view="vote"] .arena {
  display: grid;
  gap: 18px;
  padding: 28px;
  border: 0;
  background: transparent;
  box-shadow: none;
}

#app[data-view="vote"] .arena .match-meta,
#app[data-view="vote"] .arena h2,
#app[data-view="vote"] .summary {
  display: none;
}

.arena h2 {
  margin: 8px 0 16px;
  font-size: 1.06rem;
}

.versus {
  display: grid;
  gap: 10px;
  margin: 16px 0 12px;
}

.candidate {
  display: flex;
  position: relative;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 12px;
  min-height: 82px;
  border: 4px solid transparent;
  border-radius: 18px;
  color: #ffffff;
  font-size: clamp(1.25rem, 2.6vw, 1.85rem);
  font-weight: 950;
  letter-spacing: 0;
  line-height: 1;
  text-transform: uppercase;
  text-shadow: 0 1px 14px rgba(0, 0, 0, 0.20);
}

#app[data-view="vote"] .candidate {
  min-height: clamp(180px, 30vh, 280px);
  border-radius: 30px;
  font-size: clamp(3rem, 9vw, 7.4rem);
  box-shadow: 0 26px 70px rgba(16, 23, 34, 0.18);
}

#app[data-view="vote"] #voteA {
  order: 1;
}

#app[data-view="vote"] .vs {
  order: 4;
}

#app[data-view="vote"] #voteB {
  order: 5;
}

.candidate.selected {
  border-color: rgba(255, 255, 255, 0.92);
  transform: translateY(-4px) scale(1.015);
  box-shadow: 0 30px 80px rgba(16, 23, 34, 0.26), 0 0 0 8px rgba(255, 255, 255, 0.42);
}

.candidate.selected::after {
  content: "Tu voto";
  position: absolute;
  top: 18px;
  right: 20px;
  border-radius: 999px;
  padding: 0.38rem 0.6rem;
  color: rgba(255, 255, 255, 0.94);
  background: rgba(0, 0, 0, 0.18);
  font-size: 0.78rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  text-shadow: none;
}

.candidate-name {
  display: block;
}

#app[data-view="vote"] .vs {
  min-height: 30px;
  font-size: 0.86rem;
}

#voteA {
  background: linear-gradient(135deg, var(--teal), var(--teal-2));
}

#voteB {
  background: linear-gradient(135deg, var(--rose), var(--rose-2));
}

.vs {
  display: grid;
  place-items: center;
  min-height: 18px;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 950;
  letter-spacing: 0.18em;
}

.bar {
  display: flex;
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: #e5e9f0;
}

#app[data-view="vote"] .bar {
  order: 2;
  height: 18px;
  border: 2px solid rgba(255, 255, 255, 0.72);
  background: rgba(16, 23, 34, 0.08);
  box-shadow: 0 14px 36px rgba(16, 23, 34, 0.12);
}

#app[data-view="vote"] .vote-percentages {
  order: 3;
  display: flex;
  justify-content: space-between;
  margin-top: -8px;
  color: var(--muted);
  font-size: 1rem;
  font-weight: 950;
  letter-spacing: 0.08em;
}

#barA,
#barPending,
#barB {
  transition: width 240ms ease;
}

#barA {
  background: linear-gradient(90deg, var(--teal), var(--teal-2));
}

#barPending {
  background:
    repeating-linear-gradient(
      45deg,
      rgba(105, 115, 134, 0.24),
      rgba(105, 115, 134, 0.24) 8px,
      rgba(105, 115, 134, 0.34) 8px,
      rgba(105, 115, 134, 0.34) 16px
    );
}

#barB {
  background: linear-gradient(90deg, var(--rose), var(--rose-2));
}

.vote-percentages {
  display: none;
}

.summary,
.hint {
  margin-bottom: 0;
  color: var(--muted);
  line-height: 1.4;
}

.ghost {
  color: var(--ink);
  background: #ffffff;
  border: 1px solid var(--line-strong);
  box-shadow: none;
}

.ghost:hover:not(:disabled) {
  background: var(--panel-soft);
  box-shadow: none;
}

.admin .row {
  margin-top: 0;
}

.chips {
  display: grid;
  gap: 8px;
}

.chips span {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.55rem 0.65rem;
  color: var(--ink);
  background: var(--panel-soft);
  font-weight: 800;
}

@media (min-width: 1181px) {
  body:not(.is-admin) .stack {
    grid-template-rows: auto auto;
  }
}

@media (max-width: 1180px) {
  .grid {
    grid-template-columns: 1fr;
  }

  .stack {
    position: static;
    grid-template-columns: minmax(0, 1fr) 260px;
  }

  .arena {
    grid-row: span 2;
  }
}

@media (max-width: 760px) {
  .shell {
    width: min(100% - 22px, 1280px);
    padding-top: 18px;
  }

  .hero,
  .stack {
    display: grid;
    grid-template-columns: 1fr;
  }

  h1 {
    font-size: clamp(2rem, 13vw, 3.1rem);
  }

  .bracket {
    min-height: auto;
  }

  #bracket {
    grid-template-columns: repeat(4, minmax(170px, 1fr));
    gap: 28px;
    min-height: 520px;
  }

  .bracket-round:not(:last-child) .bracket-match::after {
    right: -29px;
    width: 29px;
  }

  .semis .round-matches {
    padding-block: 54px;
  }

  .final .round-matches {
    padding-block: 112px;
  }

  .row {
    flex-direction: column;
  }

  .panel,
  .card {
    border-radius: 18px;
    padding: 14px;
  }
}

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

@keyframes rise-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes bracket-in {
  from {
    opacity: 0;
    transform: translateX(-10px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes winner-pop {
  0% {
    transform: scale(0.985);
  }
  55% {
    transform: scale(1.025);
  }
  100% {
    transform: scale(1);
  }
}

@keyframes champion-pop {
  from {
    opacity: 0;
    transform: translateY(18px) scale(0.9);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes confetti-drop {
  from {
    transform: translateY(-40px) rotate(0deg);
  }
  to {
    transform: translateY(620px) rotate(540deg);
  }
}
