:root {
  --bg: #120d2e;
  --ink: #fbf8ff;
  --muted: #b9b2dd;
  --card: rgb(255 255 255 / .07);
  --line: rgb(255 255 255 / .14);
  --empty: rgb(255 255 255 / .13);
  --accent: #ffd23f;
  --hot: #ff4f8b;
  --ok: #3ee08f;
  --radius: 22px;
  color-scheme: dark;
  font-family: "Avenir Next", "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
}
* { box-sizing: border-box; }
html { background: var(--bg); color: var(--ink); }
body { margin: 0; min-height: 100vh; display: flex; flex-direction: column; overflow-x: hidden; }
a { color: inherit; }
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

/* Fondo de manchas de color animadas */
.blobs { position: fixed; inset: 0; z-index: -1; filter: blur(80px); opacity: .55; }
.blobs i { position: absolute; width: 42vmax; height: 42vmax; border-radius: 50%; animation: float 22s ease-in-out infinite alternate; }
.blobs i:nth-child(1) { background: #e30613; left: -10vmax; top: -12vmax; }
.blobs i:nth-child(2) { background: #1d84ce; right: -12vmax; top: 10vh; animation-delay: -6s; }
.blobs i:nth-child(3) { background: #63be21; left: 25vw; bottom: -20vmax; animation-delay: -12s; opacity: .7; }
.blobs i:nth-child(4) { background: #6b2c91; right: 20vw; bottom: -10vmax; animation-delay: -3s; }
@keyframes float { to { transform: translate(8vmax, 6vmax) scale(1.2) rotate(40deg); } }

/* Cabecera */
.top { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 1.2rem; padding: .7rem clamp(1rem, 4vw, 2.5rem);
  background: rgb(18 13 46 / .7); backdrop-filter: blur(14px); border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.brand { font-size: 1.45rem; font-weight: 800; text-decoration: none; display: flex; align-items: center; gap: .55rem; letter-spacing: -.02em; }
.brand b { color: var(--accent); }
.brand-arc { width: 34px; height: 17px; border-radius: 34px 34px 0 0;
  background: conic-gradient(from -90deg at 50% 100%, #e30613 0 30%, #ffd700 0 42%, #1d84ce 0 75%, #63be21 0 100%); }
nav { display: flex; gap: .3rem; }
nav a { text-decoration: none; padding: .45rem .9rem; border-radius: 999px; font-weight: 600; color: var(--muted); transition: .2s; }
nav a:hover { color: var(--ink); background: var(--card); }
nav a.on { color: #1a1240; background: var(--accent); }
.status { margin-left: auto; font-size: .9rem; color: var(--muted); display: flex; gap: .5rem; align-items: center; }
.status .pill { padding: .3rem .75rem; border-radius: 999px; font-weight: 700; font-variant-numeric: tabular-nums; }
.pill.open { background: rgb(62 224 143 / .18); color: var(--ok); }
.pill.closed { background: rgb(255 79 139 / .2); color: var(--hot); }
.me { display: flex; align-items: center; gap: .5rem; text-decoration: none; font-weight: 700; padding: .25rem .8rem .25rem .25rem;
  border-radius: 999px; background: var(--card); border: 1px solid var(--line); transition: transform .2s; }
.me:hover { transform: translateY(-2px); }

main { flex: 1; width: 100%; max-width: 1240px; margin: 0 auto; padding: clamp(1rem, 3vw, 2.2rem); outline: none; }
footer { text-align: center; color: var(--muted); font-size: .85rem; padding: 2rem 1rem; }

h1 { font-size: clamp(2rem, 5vw, 3.4rem); line-height: 1.02; letter-spacing: -.035em; margin: .2em 0 .3em; }
h2 { font-size: 1.5rem; letter-spacing: -.02em; margin: 1.8rem 0 .8rem; }
.lead { color: var(--muted); font-size: 1.1rem; max-width: 60ch; margin: 0 0 1.2rem; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: clamp(1rem, 2.5vw, 1.6rem); }

/* Botones */
.btn { border: 0; border-radius: 999px; padding: .7rem 1.3rem; font-weight: 800; cursor: pointer; background: var(--accent); color: #1a1240;
  transition: transform .15s, box-shadow .2s, opacity .2s; box-shadow: 0 6px 0 rgb(0 0 0 / .25); text-decoration: none; display: inline-flex; gap: .4rem; align-items: center; }
.btn:hover:not(:disabled) { transform: translateY(-2px); box-shadow: 0 9px 0 rgb(0 0 0 / .25); }
.btn:active:not(:disabled) { transform: translateY(3px); box-shadow: 0 2px 0 rgb(0 0 0 / .25); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.ghost { background: var(--card); color: var(--ink); border: 1px solid var(--line); box-shadow: none; }
.btn.hot { background: var(--hot); color: #fff; }
.row { display: flex; gap: .7rem; flex-wrap: wrap; align-items: center; }

/* Hemiciclo */
.hemi { width: 100%; height: auto; display: block; overflow: visible; }
.hemi circle { transition: fill .45s ease; transform-box: fill-box; transform-origin: center; }
.hemi.pop circle { animation: pop .5s cubic-bezier(.3, 1.6, .5, 1) backwards; animation-delay: calc(var(--i) * 2.2ms); }
@keyframes pop { from { transform: scale(0); opacity: 0; } }
.hemi .maj { stroke: #fff; stroke-width: .012; stroke-dasharray: .03 .02; opacity: .9; }
.hemi .maj-label { fill: #fff; font-size: .055px; font-weight: 800; text-anchor: middle; letter-spacing: .002em; }
.hemi .big { fill: #fff; font-size: .2px; font-weight: 900; text-anchor: middle; }
.hemi .small { fill: var(--muted); font-size: .06px; text-anchor: middle; font-weight: 600; }

/* Barra de mayoría */
.bar { position: relative; display: flex; height: 18px; border-radius: 999px; overflow: hidden; background: var(--empty); margin: 1rem 0 .3rem; }
.bar span { height: 100%; transition: flex-basis .45s ease; }
.bar::after { content: ""; position: absolute; left: calc(176 / 350 * 100%); top: -2px; bottom: -2px; width: 3px; background: #fff;
  box-shadow: 0 0 0 2px rgb(0 0 0 / .35); }
.bar-label { display: flex; justify-content: space-between; color: var(--muted); font-size: .8rem; }

/* Leyenda */
.legend { display: flex; flex-wrap: wrap; gap: .35rem .5rem; margin-top: .8rem; padding: 0; list-style: none; }
.legend li { display: flex; align-items: center; gap: .35rem; font-size: .88rem; background: rgb(255 255 255 / .06); padding: .2rem .6rem .2rem .3rem; border-radius: 999px; }
.legend i { width: 14px; height: 14px; border-radius: 50%; display: inline-block; }
.legend b { font-variant-numeric: tabular-nums; }

/* Inicio */
.hero { display: grid; grid-template-columns: 1.1fr 1fr; gap: 2rem; align-items: center; }
@media (max-width: 860px) { .hero { grid-template-columns: 1fr; } }
.cd { display: flex; gap: .6rem; margin: 1rem 0 1.4rem; }
.cd div { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: .5rem .8rem; text-align: center; min-width: 4.2rem; }
.cd b { display: block; font-size: 1.8rem; font-variant-numeric: tabular-nums; }
.cd small { color: var(--muted); font-size: .72rem; text-transform: uppercase; letter-spacing: .08em; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); gap: 1rem; }
.bet { cursor: pointer; text-align: left; transition: transform .25s, border-color .25s, background .25s; animation: rise .6s backwards;
  animation-delay: calc(var(--i) * 60ms); width: 100%; }
.bet:hover { transform: translateY(-5px) rotate(-.4deg); border-color: rgb(255 255 255 / .35); background: rgb(255 255 255 / .1); }
@keyframes rise { from { opacity: 0; transform: translateY(24px) scale(.97); } }
.bet header { display: flex; align-items: center; gap: .7rem; margin-bottom: .5rem; }
.bet header div { min-width: 0; }
.bet h3 { margin: 0; font-size: 1.1rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bet time { color: var(--muted); font-size: .78rem; }
.tag { font-size: .78rem; font-weight: 700; padding: .15rem .55rem; border-radius: 999px; background: rgb(255 255 255 / .1); }
.empty { text-align: center; padding: 3rem 1rem; color: var(--muted); }
.empty .em { font-size: 3.5rem; animation: bounce 1.6s ease-in-out infinite; display: inline-block; }
@keyframes bounce { 50% { transform: translateY(-12px) rotate(8deg); } }

/* Avatar */
.av { --s: 44px; width: var(--s); height: var(--s); flex: none; border-radius: 50%; display: grid; place-items: center; font-size: calc(var(--s) * .55);
  border: calc(var(--s) * .08) solid; box-shadow: 0 4px 14px rgb(0 0 0 / .3); line-height: 1; }
.me .av { --s: 34px; }

/* Editor */
.editor { display: grid; grid-template-columns: 1fr 1.05fr; gap: 1.6rem; align-items: start; }
@media (max-width: 900px) { .editor { grid-template-columns: 1fr; } }
.editor .sticky { position: sticky; top: 5.5rem; }
.total { font-size: 1.1rem; font-weight: 800; text-align: center; margin-top: .4rem; font-variant-numeric: tabular-nums; transition: color .3s; }
.total.ok { color: var(--ok); }
.total.over { color: var(--hot); animation: shake .35s; }
@keyframes shake { 25% { transform: translateX(-5px); } 75% { transform: translateX(5px); } }
.parties { display: grid; gap: .45rem; }
.party { display: grid; grid-template-columns: 1fr auto; gap: .2rem .7rem; align-items: center; padding: .55rem .8rem; border-radius: 16px;
  background: linear-gradient(90deg, color-mix(in srgb, var(--c) 30%, transparent), rgb(255 255 255 / .04) 60%); border: 1px solid var(--line); }
.party label { font-weight: 700; display: flex; gap: .5rem; align-items: center; min-width: 0; }
.party label i { width: 14px; height: 14px; border-radius: 50%; background: var(--c); flex: none; box-shadow: 0 0 10px var(--c); }
.party label small { color: var(--muted); font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.step { display: flex; align-items: center; gap: .25rem; }
.step button { width: 34px; height: 34px; border-radius: 50%; border: 1px solid var(--line); background: rgb(255 255 255 / .08); cursor: pointer; font-size: 1.1rem; font-weight: 800; }
.step button:hover:not(:disabled) { background: var(--c); }
.step input { width: 4.4rem; -moz-appearance: textfield; text-align: center; font-weight: 800; font-size: 1.1rem; background: rgb(0 0 0 / .25); border: 1px solid var(--line); border-radius: 10px; padding: .3rem; font-variant-numeric: tabular-nums; }
.step input::-webkit-inner-spin-button { -webkit-appearance: none; }
.party input[type=range] { grid-column: 1 / -1; width: 100%; accent-color: var(--c); }

/* Formularios */
.form { display: grid; gap: 1rem; max-width: 560px; }
.form label { display: grid; gap: .35rem; font-weight: 700; }
.form input[type=text], .form input[type=password], .form input[type=datetime-local] {
  padding: .75rem 1rem; border-radius: 14px; border: 1px solid var(--line); background: rgb(0 0 0 / .25); font-size: 1.05rem; }
.hint { color: var(--muted); font-size: .88rem; font-weight: 500; }
.err { color: var(--hot); font-weight: 700; min-height: 1.3em; margin: 0; }
.tabs { display: inline-flex; background: var(--card); border-radius: 999px; padding: 4px; border: 1px solid var(--line); margin-bottom: 1.2rem; }
.tabs button { border: 0; background: none; padding: .5rem 1.1rem; border-radius: 999px; font-weight: 700; cursor: pointer; color: var(--muted); }
.tabs button.on { background: var(--accent); color: #1a1240; }
.builder { display: grid; grid-template-columns: auto 1fr; gap: 1.2rem; align-items: center; }
.builder .av { --s: 110px; transition: transform .3s cubic-bezier(.3, 1.6, .5, 1); }
.builder .av.wiggle { animation: wig .45s; }
@keyframes wig { 30% { transform: scale(1.15) rotate(-10deg); } 60% { transform: scale(.95) rotate(6deg); } }
.picks { display: flex; flex-wrap: wrap; gap: .3rem; }
.picks button { width: 40px; height: 40px; border-radius: 12px; border: 2px solid transparent; background: rgb(255 255 255 / .07); cursor: pointer; font-size: 1.35rem; transition: transform .15s; }
.picks button:hover { transform: scale(1.12); }
.picks button[aria-pressed=true] { border-color: var(--accent); background: rgb(255 210 63 / .15); }
.picks.colors button { border-radius: 50%; width: 32px; height: 32px; }
.picks.colors button[aria-pressed=true] { border-color: #fff; transform: scale(1.15); }

/* Modal y avisos */
dialog { border: 1px solid var(--line); border-radius: var(--radius); background: #1d1647; color: var(--ink); padding: 1.6rem; width: min(760px, 94vw); }
dialog::backdrop { background: rgb(8 5 25 / .7); backdrop-filter: blur(4px); }
dialog[open] { animation: rise .35s; }
dialog .x { position: absolute; top: .6rem; right: .8rem; border: 0; background: none; font-size: 1.8rem; cursor: pointer; color: var(--muted); }
#toast { position: fixed; left: 50%; bottom: 1.5rem; transform: translate(-50%, 150%); background: #fff; color: #1a1240; font-weight: 800;
  padding: .8rem 1.3rem; border-radius: 999px; transition: transform .35s cubic-bezier(.3, 1.6, .5, 1); z-index: 50; box-shadow: 0 10px 30px rgb(0 0 0 / .4); opacity: 0; }
#toast.show { transform: translate(-50%, 0); opacity: 1; }
.confetti { position: fixed; top: -20px; width: 10px; height: 14px; z-index: 40; pointer-events: none; animation: fall linear forwards; }
@keyframes fall { to { transform: translateY(110vh) rotate(720deg); } }
.admin-table { width: 100%; border-collapse: collapse; }
.admin-table td { padding: .5rem; border-top: 1px solid var(--line); }

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