/* SotaDisfraces — tema baraja: azul sota + oro. Móvil primero. */

:root {
  --bg: #0c1633;
  --bg2: #12204a;
  --card: #17275580;
  --card-solid: #182a5c;
  --line: #2c3f7a;
  --text: #f2eedd;
  --muted: #9fabce;
  --blue: #2255e8;
  --blue-soft: #3f6cff;
  --gold: #f5c34d;
  --gold-deep: #c99418;
  --green: #3ecf8e;
  --red: #ff6b6b;
  --radius: 16px;
  --shadow: 0 10px 30px rgba(0, 0, 0, .35);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { -webkit-text-size-adjust: 100%; }

body {
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  background:
    radial-gradient(1200px 600px at 80% -10%, #1b2f6b 0%, transparent 60%),
    radial-gradient(900px 500px at -10% 110%, #14245530 0%, transparent 60%),
    var(--bg);
  color: var(--text);
  min-height: 100dvh;
}

button { font: inherit; cursor: pointer; }
input, select { font: inherit; }

#view { max-width: 640px; margin: 0 auto; padding: 16px 16px calc(32px + env(safe-area-inset-bottom)); }

/* ---------- utilidades ---------- */
.muted { color: var(--muted); }
.hidden { display: none !important; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(6px);
}

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid var(--line);
  background: var(--card-solid);
  color: var(--text);
  padding: 12px 18px;
  border-radius: 12px;
  font-weight: 600;
  transition: transform .06s ease, filter .15s ease;
  min-height: 46px;
}
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary { background: linear-gradient(135deg, var(--blue), var(--blue-soft)); border-color: transparent; }
.btn-gold { background: linear-gradient(135deg, var(--gold-deep), var(--gold)); color: #241a02; border-color: transparent; }
.btn-danger { background: transparent; border-color: #a33; color: var(--red); }
.btn-ghost { background: transparent; }
.btn-sm { padding: 7px 12px; min-height: 34px; border-radius: 10px; font-size: .85rem; }
.btn-block { width: 100%; }

.chip {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: .78rem; font-weight: 700;
  padding: 4px 10px; border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--muted);
  white-space: nowrap;
}
.chip-open { color: #7ee8b4; border-color: #2b6e51; background: #1a3a2c55; }
.chip-closed { color: #ff9e9e; border-color: #7a3333; background: #3a1a1a55; }
.chip-pending { color: #ffd98a; border-color: #7a6021; background: #3a2f1155; }
.chip-live { color: #ff8a8a; border-color: #7a3333; background: #3a1a1a55; }
.chip-live .dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--red);
  animation: pulse 1.2s infinite;
}
@keyframes pulse { 0%,100% { opacity: 1 } 50% { opacity: .25 } }

/* ---------- login ---------- */
.login-wrap {
  min-height: calc(100dvh - 60px);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; gap: 8px;
  position: relative;
}
.login-logo { width: 96px; filter: drop-shadow(0 6px 18px rgba(34, 85, 232, .5)); }
.login-title {
  font-size: 2rem; font-weight: 800; letter-spacing: .02em;
  background: linear-gradient(135deg, #ffe9ad, var(--gold), #b47f0e);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.login-sub { color: var(--muted); margin-bottom: 18px; }
.login-form { width: 100%; max-width: 360px; display: flex; flex-direction: column; gap: 12px; }

.field {
  width: 100%;
  background: #0e1c42;
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 12px;
  padding: 13px 16px;
  outline: none;
}
.field:focus { border-color: var(--blue-soft); }
.field::placeholder { color: #64719b; }

.error-text { color: var(--red); font-size: .9rem; min-height: 1.2em; }

/* ---------- cabecera ---------- */
.topbar {
  display: flex; align-items: center; gap: 12px;
  padding: 8px 0 16px;
}
.topbar img { width: 34px; }
.topbar .who { flex: 1; min-width: 0; }
.topbar .who .app { font-weight: 800; font-size: .95rem; }
.topbar .who .name { color: var(--muted); font-size: .8rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- lista de categorías ---------- */
.cat-list { display: flex; flex-direction: column; gap: 12px; }
.cat-card { display: flex; flex-direction: column; gap: 10px; }
.cat-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.cat-name { font-size: 1.15rem; font-weight: 800; }
.cat-meta { color: var(--muted); font-size: .85rem; }
.cat-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.progressbar {
  height: 8px; border-radius: 99px; background: #0e1c42; overflow: hidden;
  border: 1px solid var(--line);
}
.progressbar > div {
  height: 100%;
  background: linear-gradient(90deg, var(--blue), var(--blue-soft));
  transition: width .4s ease;
}
.progressbar.done > div { background: linear-gradient(90deg, var(--gold-deep), var(--gold)); }

/* ---------- votación ---------- */
.vote-head { display: flex; align-items: center; gap: 10px; padding-bottom: 12px; }
.vote-head h2 { flex: 1; font-size: 1.25rem; }

.golden-status {
  display: flex; align-items: center; gap: 8px;
  font-size: .85rem; color: var(--muted);
  padding: 10px 14px;
  border: 1px dashed var(--gold-deep);
  border-radius: 12px;
  margin-bottom: 14px;
  background: #2a220b40;
}

.entry-list { display: flex; flex-direction: column; gap: 14px; }
.entry-card { display: flex; flex-direction: column; gap: 12px; }
.entry-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.entry-name { font-size: 1.05rem; font-weight: 800; }
.entry-saved { color: var(--green); font-size: .8rem; font-weight: 700; }

.crit-row { display: grid; grid-template-columns: 110px 1fr 40px; align-items: center; gap: 10px; }
.crit-label { font-size: .85rem; font-weight: 600; }
.crit-desc { display: block; font-size: .68rem; color: var(--muted); font-weight: 400; }
.crit-value {
  text-align: center; font-weight: 800; font-variant-numeric: tabular-nums;
  background: #0e1c42; border: 1px solid var(--line); border-radius: 8px; padding: 4px 0;
}

input[type=range] {
  -webkit-appearance: none; appearance: none;
  width: 100%; height: 30px; background: transparent; touch-action: pan-y;
}
input[type=range]::-webkit-slider-runnable-track {
  height: 8px; border-radius: 99px;
  background: linear-gradient(90deg, var(--blue) var(--fill, 50%), #0e1c42 var(--fill, 50%));
  border: 1px solid var(--line);
}
input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 26px; height: 26px; border-radius: 50%;
  background: #fff; border: 3px solid var(--blue-soft);
  margin-top: -10px;
  box-shadow: 0 2px 8px rgba(0,0,0,.4);
}
input[type=range]::-moz-range-track {
  height: 8px; border-radius: 99px; background: #0e1c42; border: 1px solid var(--line);
}
input[type=range]::-moz-range-progress { height: 8px; border-radius: 99px; background: var(--blue); }
input[type=range]::-moz-range-thumb {
  width: 22px; height: 22px; border-radius: 50%;
  background: #fff; border: 3px solid var(--blue-soft);
}

.golden-toggle {
  display: flex; align-items: center; justify-content: space-between;
  border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px;
  background: #0e1c42;
}
.golden-toggle.on {
  border-color: var(--gold);
  background: linear-gradient(135deg, #453305, #2a220b);
  box-shadow: 0 0 18px #f5c34d33;
}
.golden-toggle .label { font-weight: 700; font-size: .95rem; }
.golden-toggle .sub { font-size: .75rem; color: var(--muted); }

.finished-banner {
  text-align: center; padding: 18px;
  border: 1px solid var(--gold-deep); border-radius: var(--radius);
  background: linear-gradient(135deg, #2a220b, #171d3a);
  display: flex; flex-direction: column; gap: 10px;
  margin-top: 4px;
}
.finished-banner .big { font-size: 1.1rem; font-weight: 800; color: var(--gold); }

/* ---------- resultados ---------- */
.results-meta { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }

.podium { display: flex; align-items: flex-end; gap: 8px; margin-bottom: 16px; }
.podium .slot {
  flex: 1; text-align: center; border-radius: 12px 12px 0 0;
  padding: 12px 6px 10px; border: 1px solid var(--line); border-bottom: none;
  display: flex; flex-direction: column; gap: 4px; min-width: 0;
}
.podium .slot .pos { font-size: 1.3rem; }
.podium .slot .pname { font-weight: 800; font-size: .85rem; overflow-wrap: anywhere; }
.podium .slot .pscore { font-variant-numeric: tabular-nums; color: var(--muted); font-size: .8rem; }
.podium .p1 { background: linear-gradient(180deg, #453305, #241d08); border-color: var(--gold-deep); min-height: 130px; }
.podium .p2 { background: #232f55; min-height: 104px; }
.podium .p3 { background: #1d2542; min-height: 88px; }

.result-row { display: flex; flex-direction: column; gap: 8px; padding: 12px 14px; }
.result-top { display: flex; align-items: center; gap: 10px; }
.result-rank {
  width: 34px; height: 34px; flex: none;
  display: flex; align-items: center; justify-content: center;
  border-radius: 10px; font-weight: 800;
  background: #0e1c42; border: 1px solid var(--line);
}
.result-rank.r1 { background: linear-gradient(135deg, var(--gold-deep), var(--gold)); color: #241a02; border: none; }
.result-rank.r2 { background: #b9c3d8; color: #1c2233; border: none; }
.result-rank.r3 { background: #b07a4a; color: #2a1708; border: none; }
.result-name { flex: 1; font-weight: 700; min-width: 0; overflow-wrap: anywhere; }
.result-score { font-weight: 800; font-variant-numeric: tabular-nums; font-size: 1.15rem; }
.result-score small { color: var(--muted); font-weight: 400; font-size: .7rem; }
.result-breakdown { display: flex; gap: 6px; flex-wrap: wrap; font-size: .72rem; color: var(--muted); }
.result-breakdown span {
  background: #0e1c42; border: 1px solid var(--line);
  padding: 2px 8px; border-radius: 99px; font-variant-numeric: tabular-nums;
}
.result-breakdown .oro { color: var(--gold); border-color: var(--gold-deep); }

.locked-box { text-align: center; padding: 40px 20px; display: flex; flex-direction: column; gap: 10px; align-items: center; }
.locked-box .icon { font-size: 2.4rem; }

/* ---------- admin ---------- */
.tabs { display: flex; gap: 6px; margin-bottom: 16px; overflow-x: auto; padding-bottom: 2px; }
.tab {
  flex: none; padding: 9px 16px; border-radius: 99px;
  border: 1px solid var(--line); background: transparent; color: var(--muted);
  font-weight: 700; font-size: .88rem;
}
.tab.active { background: var(--blue); border-color: transparent; color: #fff; }

.admin-list { display: flex; flex-direction: column; gap: 12px; }
.admin-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.admin-row .grow { flex: 1; min-width: 0; }
.inline-form { display: flex; gap: 8px; }
.inline-form .field { flex: 1; }

.entry-admin { display: flex; align-items: center; gap: 8px; padding: 8px 0; border-top: 1px solid var(--line); }
.entry-admin:first-of-type { border-top: none; }
.entry-admin .grow { flex: 1; min-width: 0; }

.progress-grid { display: flex; flex-wrap: wrap; gap: 6px; }
.progress-pill {
  font-size: .75rem; padding: 4px 10px; border-radius: 99px;
  border: 1px solid var(--line); color: var(--muted);
}
.progress-pill.done { color: #7ee8b4; border-color: #2b6e51; }

.danger-zone { border-color: #7a3333; }

/* ---------- modales y toasts ---------- */
#modal-root .overlay {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(4, 8, 22, .7); backdrop-filter: blur(3px);
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.modal {
  width: 100%; max-width: 380px;
  background: var(--card-solid); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 20px;
  box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: 14px;
  animation: modal-in .15s ease;
}
@keyframes modal-in { from { transform: scale(.94); opacity: 0 } to { transform: scale(1); opacity: 1 } }
.modal h3 { font-size: 1.05rem; }
.modal p { color: var(--muted); font-size: .92rem; line-height: 1.45; }
.modal .actions { display: flex; gap: 8px; justify-content: flex-end; }

#toast-root {
  position: fixed; left: 0; right: 0; bottom: calc(16px + env(safe-area-inset-bottom));
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  z-index: 60; pointer-events: none;
}
.toast {
  background: var(--card-solid); border: 1px solid var(--line);
  color: var(--text); font-size: .9rem; font-weight: 600;
  padding: 10px 18px; border-radius: 99px; box-shadow: var(--shadow);
  animation: toast-in .2s ease;
}
.toast.ok { border-color: #2b6e51; }
.toast.err { border-color: #7a3333; }
@keyframes toast-in { from { transform: translateY(10px); opacity: 0 } to { transform: none; opacity: 1 } }

@media (min-width: 700px) {
  .crit-row { grid-template-columns: 150px 1fr 44px; }
}
