/* Gincana dorada: piedra de Villamayor, noche de fiesta y confeti. */
:root {
  --bg: #FFF7EA;
  --card: #FFFFFF;
  --ink: #2A1638;
  --muted: #7D6B86;
  --line: rgba(42, 22, 56, .12);
  --plum: #4B2366;
  --plum-2: #6B3A8E;
  --gold: #E6A93A;
  --gold-2: #F6D489;
  --pink: #FF4F93;
  --mint: #2BB673;
  --danger: #D64545;
  --radius: 18px;
  --ink-line: 2.5px solid var(--ink);
  --hard: 3px 3px 0 var(--ink);
  --shadow: 0 10px 30px rgba(42, 22, 56, .18);
  --tabbar-h: calc(64px + env(safe-area-inset-bottom));
  --font-display: 'Fredoka', system-ui, sans-serif;
  --font-body: 'Nunito', system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.4 var(--font-body);
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}
[hidden] { display: none !important; }
h1, h2, h3, h4 { font-family: var(--font-display); margin: 0; line-height: 1.15; }
button { font: inherit; color: inherit; cursor: pointer; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

/* ── Botones y controles ─────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 0; border-radius: 14px; padding: 11px 16px;
  background: var(--plum); color: #fff; font-weight: 800; text-decoration: none;
  border: 2px solid var(--ink); box-shadow: 0 3px 0 var(--ink);
  transition: transform .1s;
}
.btn:active { transform: translateY(2px); box-shadow: none; }
.btn--sm { padding: 8px 12px; font-size: 14px; white-space: nowrap; }
.btn--big { width: 100%; padding: 15px; font-size: 17px; margin-top: 12px; }
.btn--ghost { background: #fff; color: var(--plum); }
.btn--party { background: linear-gradient(135deg, var(--pink), var(--gold)); }
.btn--danger { background: var(--danger); width: 100%; margin-top: 8px; }

.chip {
  border: 0; border-radius: 999px; padding: 7px 12px;
  background: #F3E7F7; color: var(--plum); font-weight: 700; font-size: 14px;
}
.chip:disabled { opacity: .35; }
.chip--on { background: var(--mint); color: #fff; }
.chip--danger { background: #FBE3E3; color: var(--danger); }
.chip--pulse { margin-top: 10px; width: 100%; animation: pulse 1.8s infinite; }
.icon-btn { border: 0; background: #F6EFE2; border-radius: 12px; width: 36px; height: 36px; flex: none; }

.input {
  width: 100%; border: 2px solid var(--line); border-radius: 12px;
  padding: 10px 12px; font: inherit; background: #fff; color: var(--ink);
}
.input:focus { outline: none; border-color: var(--gold); }
.input--big { font-size: 18px; padding: 13px 14px; }
.input--title { font-family: var(--font-display); font-weight: 600; font-size: 18px; }
textarea.input { resize: vertical; }
.field { display: block; font-size: 13px; font-weight: 700; color: var(--muted); margin-top: 10px; }
.field .input { margin-top: 4px; }
.label { font-size: 13px; font-weight: 800; color: var(--muted); margin: 12px 0 6px; }
.row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }

.switch {
  width: 54px; height: 32px; border-radius: 999px; border: 0; flex: none;
  background: #D9CFE0; position: relative; transition: background .2s;
}
.switch::after {
  content: ''; position: absolute; top: 4px; left: 4px; width: 24px; height: 24px;
  border-radius: 50%; background: #fff; transition: transform .2s; box-shadow: 0 1px 3px rgba(0,0,0,.25);
}
.switch.is-on { background: var(--mint); }
.switch.is-on::after { transform: translateX(22px); }

/* ── Avatares ────────────────────────────────────────────── */
.av {
  --s: 36px; --c: var(--gold);
  position: relative; display: inline-grid; place-items: center; flex: none;
  width: var(--s); height: var(--s); border-radius: 50%;
  background: #fff; box-shadow: 0 0 0 3px var(--c), 0 3px 8px rgba(0,0,0,.25);
  font-size: calc(var(--s) * .58); line-height: 1;
}
.av > span, .av > img { grid-area: 1 / 1; }
.av > img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; }
.av--bday { box-shadow: 0 0 0 3px var(--gold), 0 0 0 6px #fff, 0 4px 14px rgba(230,169,58,.7); }
.av__crown {
  position: absolute; top: calc(var(--s) * -.42); left: 50%; transform: translateX(-50%) rotate(-8deg);
  font-size: calc(var(--s) * .45); font-style: normal;
}

/* ── Splash y onboarding ─────────────────────────────────── */
.splash, .onboard {
  position: fixed; inset: 0; z-index: 3000;
  background: radial-gradient(120% 80% at 50% 0%, var(--plum-2), var(--plum) 55%, #2A1638);
  color: #fff;
}
.splash { display: grid; place-content: center; text-align: center; font-weight: 700; }
.splash__frog { font-size: 72px; animation: hop 1s infinite; }
.onboard { overflow-y: auto; }
.ob {
  max-width: 440px; margin: 0 auto; min-height: 100%;
  padding: calc(28px + env(safe-area-inset-top)) 20px calc(28px + env(safe-area-inset-bottom));
  display: flex; flex-direction: column; gap: 12px;
}
.ob__hero { text-align: center; padding: 20px 0 8px; }
.ob__frog { font-size: 64px; animation: hop 2.2s infinite; }
.ob__kicker { text-transform: uppercase; letter-spacing: .14em; font-size: 12px; font-weight: 800; color: var(--gold-2); margin: 8px 0; }
.ob h1 { font-size: clamp(40px, 12vw, 56px); font-weight: 700; }
.ob h1 em { font-style: normal; color: var(--gold); }
.ob h2 { font-size: 26px; }
.ob__sub { color: #E9DDF2; margin: 4px 0; }
.ob__q { font-family: var(--font-display); font-size: 20px; margin: 12px 0 0; text-align: center; }
.ob__card {
  display: flex; align-items: center; gap: 14px; text-align: left;
  padding: 16px; border-radius: var(--radius); border: 0;
  background: rgba(255,255,255,.1); color: #fff; box-shadow: inset 0 0 0 2px rgba(255,255,255,.15);
}
.ob__card > span { font-size: 40px; }
.ob__card b { font-family: var(--font-display); font-size: 20px; display: block; }
.ob__card small { color: #E9DDF2; }
.ob__card--bday { background: linear-gradient(135deg, var(--gold), var(--pink)); box-shadow: 0 8px 24px rgba(255,79,147,.4); }
.ob--form .field { color: #E9DDF2; }
.ob--form .btn--ghost { color: #fff; box-shadow: inset 0 0 0 2px rgba(255,255,255,.25); }
.ob__err { color: var(--gold-2); font-weight: 700; margin: 0; }
.ob__chips { display: flex; flex-wrap: wrap; gap: 8px; }
.ob__photo {
  display: flex; align-items: center; gap: 14px; padding: 12px; border-radius: var(--radius);
  background: rgba(255,255,255,.1); cursor: pointer; margin-top: 6px;
}
.ob__photo small { display: block; color: #E9DDF2; }
.ob__preview {
  width: 64px; height: 64px; border-radius: 50%; background: #fff; flex: none;
  display: grid; place-items: center; font-size: 36px; box-shadow: 0 0 0 3px var(--gold); overflow: hidden;
}
.ob__preview img { width: 100%; height: 100%; object-fit: cover; }
.ob .label { color: #E9DDF2; }
.ob__emojis { display: grid; grid-template-columns: repeat(8, 1fr); gap: 6px; }
.ob__emojis button {
  aspect-ratio: 1; border: 0; border-radius: 12px; background: rgba(255,255,255,.1); font-size: 22px; padding: 0;
}
.ob__emojis button.is-on { background: var(--gold); transform: scale(1.08); }

/* ── Estructura principal ────────────────────────────────── */
#app { position: fixed; inset: 0; overflow: hidden; }
.map { position: absolute; inset: 0; bottom: var(--tabbar-h); background: #F3E6C8; z-index: 0; }
.map.is-picking { cursor: crosshair; }
.map--cartoon .leaflet-tile { filter: url(#cartoon); }
.tiles-labels { opacity: .8; }
.map--far .pair, .map--far .crew { display: none; }
.map--far .sticker { font-size: 18px; }

.topbar {
  position: absolute; z-index: 1000; top: calc(10px + env(safe-area-inset-top)); left: 12px; right: 12px;
  display: flex; align-items: center; gap: 10px;
  padding: 8px 8px 8px 12px; border-radius: var(--radius);
  background: #fff; border: var(--ink-line); box-shadow: var(--hard);
}
.brand { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; }
.brand b { font-family: var(--font-display); font-size: 17px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; }
.brand__frog { font-size: 28px; }
.dots { display: flex; gap: 4px; margin-top: 4px; }
.dot { width: 14px; height: 6px; border-radius: 3px; background: #E6DDEA; }
.dot--done { background: var(--gold); }
.dot--current { background: var(--pink); animation: pulse 1.6s infinite; }
.badge { background: var(--gold-2); color: var(--plum); font-size: 11px; font-weight: 800; padding: 3px 8px; border-radius: 999px; }
.me-btn { border: 0; background: none; padding: 4px; }

.map-ctrls {
  position: absolute; z-index: 1000; right: 12px; top: calc(86px + env(safe-area-inset-top));
  display: flex; flex-direction: column; gap: 8px;
}
.map-ctrls button {
  width: 44px; height: 44px; border: var(--ink-line); border-radius: 14px; font-size: 20px;
  background: #fff; box-shadow: var(--hard);
}

.card {
  position: absolute; z-index: 1000; left: 12px; right: 12px; bottom: calc(var(--tabbar-h) + 12px);
  padding: 12px; border-radius: var(--radius); background: #fff; border: var(--ink-line); box-shadow: var(--hard);
}
.card:empty { display: none; }
.card__row { display: flex; align-items: center; gap: 12px; }
.card__n {
  flex: none; width: 52px; height: 52px; border-radius: 16px; display: grid; place-content: center;
  background: var(--plum); color: #fff; font: 700 22px var(--font-display);
}
.card__n small { font-size: 12px; opacity: .7; text-align: center; }
.card__big { font-size: 40px; }
.card__txt { flex: 1; min-width: 0; }
.card__txt b { font-family: var(--font-display); font-size: 19px; display: block; }
.card__txt small { color: var(--muted); display: block; font-size: 13px; }

.pick {
  position: absolute; z-index: 1100; left: 12px; right: 12px; bottom: calc(var(--tabbar-h) + 12px);
  display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-radius: var(--radius);
  background: var(--plum); color: #fff; box-shadow: var(--shadow);
}
.pick p { margin: 0; flex: 1; font-weight: 700; }

.tabbar {
  position: absolute; z-index: 1200; left: 0; right: 0; bottom: 0; height: var(--tabbar-h);
  padding-bottom: env(safe-area-inset-bottom);
  display: flex; background: #fff; border-top: var(--ink-line);
}
.tab {
  flex: 1; border: 0; background: none; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px; font-size: 11px; font-weight: 800; color: var(--muted);
}
.tab span { font-size: 22px; transition: transform .15s; }
.tab.is-on { color: var(--plum); }
.tab.is-on span { transform: translateY(-2px) scale(1.12); }

.sheet {
  position: absolute; z-index: 1150; left: 0; right: 0; bottom: var(--tabbar-h);
  top: calc(76px + env(safe-area-inset-top));
  background: var(--bg); border-radius: 24px 24px 0 0; box-shadow: 0 -10px 40px rgba(42,22,56,.25);
  overflow-y: auto; padding: 18px 16px 28px; animation: up .25s ease-out;
}
.sheet > * { max-width: 640px; margin-left: auto; margin-right: auto; }
.sheet__close {
  position: sticky; top: 0; float: right; z-index: 2; width: 36px; height: 36px; border: 0; border-radius: 50%;
  background: #fff; box-shadow: 0 2px 8px rgba(0,0,0,.12); margin: 0;
}
.sheet__head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 2px 46px 12px 0; }
.sheet__head h2 { font-size: 24px; }
.sheet h3 { margin: 22px 0 8px; font-size: 18px; }

/* ── Tarjetas de parada ──────────────────────────────────── */
.scard {
  background: var(--card); border-radius: var(--radius); padding: 14px; margin-bottom: 14px;
  border: var(--ink-line); box-shadow: var(--hard);
}
.scard header { display: flex; align-items: center; gap: 10px; }
.scard__n {
  flex: none; width: 36px; height: 36px; border-radius: 12px; display: grid; place-items: center;
  background: #EFE6F3; color: var(--plum); font: 700 17px var(--font-display);
}
.scard__t { flex: 1; min-width: 0; }
.scard__t h3 { margin: 0; font-size: 17px; }
.scard__t small { color: var(--muted); }
.scard--done .scard__n { background: var(--gold); color: #fff; }
.scard--current { box-shadow: 4px 4px 0 var(--pink); border-color: var(--pink); }
.scard--current .scard__n { background: var(--pink); color: #fff; }
.scard--locked { opacity: .7; }
.scard--edit header .input { flex: 1; }
.score {
  flex: none; background: var(--gold-2); color: var(--plum); font-weight: 800; border-radius: 999px; padding: 4px 10px; font-size: 14px;
}
.challenge { font-size: 17px; font-weight: 600; margin: 12px 0 4px; }
.hint { background: #FFF1D3; border-radius: 12px; padding: 8px 12px; margin: 10px 0 0; font-size: 14px; }
.rate { display: grid; grid-template-columns: repeat(10, 1fr); gap: 4px; margin-bottom: 10px; }
.rate__b {
  aspect-ratio: 1; border: 0; border-radius: 10px; background: #F3E7F7; color: var(--plum);
  font: 700 16px var(--font-display); padding: 0;
}
.rate__b.is-on { background: var(--pink); color: #fff; transform: scale(1.12); box-shadow: 0 4px 10px rgba(255,79,147,.4); }

.notes { list-style: none; padding: 0; margin: 12px 0 0; display: grid; gap: 8px; }
.notes li { display: flex; align-items: center; gap: 10px; }
.notes li div { flex: 1; min-width: 0; }
.notes p { margin: 0; color: var(--muted); font-size: 14px; font-style: italic; }

.banner {
  background: linear-gradient(135deg, var(--gold), var(--pink)); color: #fff; font-weight: 700;
  padding: 14px; border-radius: var(--radius); margin-bottom: 12px; text-align: center;
}
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 14px; }
.stats div { background: #fff; border-radius: var(--radius); padding: 12px; text-align: center; }
.stats b { display: block; font: 700 26px var(--font-display); color: var(--plum); }
.stats small { color: var(--muted); font-weight: 700; }

/* ── Feed, perfil, gente ─────────────────────────────────── */
.feed { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.feed li { display: flex; gap: 10px; align-items: flex-start; background: #fff; border-radius: 14px; padding: 10px 12px; }
.feed__i { font-size: 22px; }
.feed p { margin: 0; flex: 1; font-weight: 600; }
.feed time { color: var(--muted); font-size: 12px; white-space: nowrap; }

.profile { display: flex; align-items: center; gap: 16px; margin: 4px 46px 18px 6px; }
.profile small { color: var(--muted); font-weight: 700; }
.setting { display: flex; align-items: center; gap: 12px; background: #fff; border-radius: var(--radius); padding: 14px; }
.setting div { flex: 1; }
.setting small { display: block; color: var(--muted); }
.people { list-style: none; padding: 0; margin: 0 0 8px; display: grid; gap: 8px; }
.people li { display: flex; align-items: center; gap: 10px; background: #fff; border-radius: 14px; padding: 8px 12px; }
.people b { flex: 1; }
.people small { color: var(--muted); }

/* ── Ruleta ──────────────────────────────────────────────── */
.wheel { display: flex; flex-direction: column; align-items: center; padding-top: 10px; }
.wheel__stage { position: relative; width: min(84vw, 360px); aspect-ratio: 1; }
.wheel canvas {
  width: 100%; height: 100%; border-radius: 50%;
  box-shadow: 0 0 0 8px var(--plum), 0 0 0 12px var(--gold), 0 18px 40px rgba(42,22,56,.35);
}
.wheel__pointer {
  position: absolute; z-index: 2; top: -18px; left: 50%; transform: translateX(-50%);
  width: 0; height: 0; border-left: 18px solid transparent; border-right: 18px solid transparent;
  border-top: 34px solid var(--pink); filter: drop-shadow(0 3px 3px rgba(0,0,0,.3));
}
.wheel__hub {
  position: absolute; inset: 0; margin: auto; width: 64px; height: 64px; border-radius: 50%;
  background: #fff; display: grid; place-items: center; font-size: 30px; box-shadow: 0 0 0 5px var(--gold), 0 4px 12px rgba(0,0,0,.3);
}
.wheel .btn--big { max-width: 360px; margin-top: 24px; }
.wheel__result { text-align: center; margin-top: 16px; min-height: 60px; }
.wheel__result b { display: block; font: 700 26px var(--font-display); color: var(--plum); }
.wheel__result small { color: var(--muted); }
.wheel__result.is-new b { animation: pop .5s; }

/* ── Marcadores del mapa ─────────────────────────────────── */
.mk { background: none; border: 0; }
/* Leaflet pone width:auto a las imágenes de los marcadores; las nuestras llenan su caja */
.leaflet-container .leaflet-marker-pane .mk img { width: 100%; height: 100%; }
.pin {
  position: absolute; transform: translate(-50%, -100%); display: flex; flex-direction: column; align-items: center;
  filter: drop-shadow(2px 3px 0 var(--ink));
}
.pin__head {
  width: 46px; height: 46px; border-radius: 50% 50% 50% 0; transform: rotate(-45deg);
  display: grid; place-items: center; background: var(--plum); border: 3px solid var(--ink);
}
.pin__head .ico { transform: rotate(45deg); width: 30px; height: 30px; font-size: 24px; }
.pin__num {
  position: absolute; right: -10px; bottom: 34px; min-width: 20px; height: 20px; padding: 0 4px;
  border-radius: 999px; background: #fff; color: var(--ink); border: 2px solid var(--ink);
  font: 800 11px/16px var(--font-body); font-style: normal; text-align: center;
}
.pin--done .pin__head { background: var(--gold); }
.pin--done .pin__num { background: var(--mint); color: #fff; }
.pin--current .pin__head { background: var(--pink); animation: bob 1.4s ease-in-out infinite; }
.pin--locked { opacity: .6; }
.pin--locked .pin__head { background: #9D8FA6; }
.pin--locked .ico { filter: grayscale(1); }
.pin--locked .pin__label { display: none; }
.ico { position: relative; display: inline-grid; place-items: center; line-height: 1; }
.ico > span, .ico > img { grid-area: 1 / 1; }
.ico > img { width: 100%; height: 100%; object-fit: contain; }
.pin__label { display: none; }
.pin__label {
  order: -1; margin-bottom: 6px; white-space: nowrap; background: #fff; color: var(--ink);
  font: 700 12px var(--font-body); padding: 2px 8px; border-radius: 999px; border: 2px solid var(--ink);
}
.crew {
  position: absolute; transform: translate(-50%, 8px); display: flex; padding: 3px 6px 3px 10px;
  background: rgba(255,255,255,.9); border-radius: 999px; box-shadow: 0 2px 6px rgba(0,0,0,.2);
}
.crew .av { margin-left: -6px; box-shadow: 0 0 0 2px var(--c); }
.crew__more { font-size: 11px; font-weight: 800; align-self: center; padding-left: 4px; }

.leaflet-popup-content-wrapper { border-radius: 16px; box-shadow: var(--shadow); }
.leaflet-popup-content { margin: 12px 14px; font-family: var(--font-body); }
.pop h4 { font-size: 17px; margin: 2px 0 6px; }
.pop small { color: var(--muted); font-weight: 700; }
.pop p { margin: 6px 0 0; }
.pop__hint { background: #FFF1D3; padding: 6px 8px; border-radius: 10px; }
.pop__muted { color: var(--muted); font-size: 13px; }
.pop__score { font: 700 20px var(--font-display); color: var(--plum); }
.leaflet-control-attribution { font-size: 10px; }

/* ── Overlays, toasts, confeti ───────────────────────────── */
.overlay {
  position: fixed; inset: 0; z-index: 2500; display: grid; place-items: center; padding: 20px;
  background: rgba(42,22,56,.6); backdrop-filter: blur(4px);
}
.ov__box {
  width: min(420px, 100%); max-height: 90vh; overflow-y: auto; background: var(--bg); border-radius: 26px;
  padding: 26px 22px 20px; text-align: center; border: 3px solid var(--ink); box-shadow: 5px 5px 0 var(--ink); animation: pop .35s;
}
.ov__box h2 { font-size: 28px; margin-bottom: 6px; }
.ov__box h3 { font-size: 24px; color: var(--plum); }
.ov__box hr { border: 0; border-top: 2px dashed var(--line); margin: 16px 0; }
.ov__big { font-size: 64px; }
.ov__score { font: 700 48px var(--font-display); color: var(--gold); }
.ov__score small { font-size: 20px; color: var(--muted); }
.ov__label { text-transform: uppercase; letter-spacing: .1em; font-size: 12px; font-weight: 800; color: var(--muted); margin: 0 0 4px; }

.toasts {
  position: fixed; z-index: 2600; left: 12px; right: 12px; top: calc(80px + env(safe-area-inset-top));
  display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none;
}
.toast {
  display: flex; align-items: center; gap: 10px; max-width: 420px; width: 100%;
  background: var(--plum); color: #fff; border-radius: 16px; padding: 10px 14px; box-shadow: var(--shadow);
  animation: down .3s ease-out; transition: opacity .4s, transform .4s;
}
.toast span { font-size: 22px; }
.toast p { margin: 0; font-weight: 700; }
.toast--out { opacity: 0; transform: translateY(-10px); }

.confetti { position: fixed; inset: 0; z-index: 2700; pointer-events: none; overflow: hidden; }
.confetti i {
  position: absolute; top: -20px; width: 9px; height: 14px; border-radius: 2px;
  animation: fall linear forwards;
}

@keyframes fall { to { transform: translate(var(--x), 110vh) rotate(var(--r)); } }
@keyframes hop { 0%, 100% { transform: translateY(0); } 40% { transform: translateY(-14px) scale(1.05, .95); } }
@keyframes bob { 0%, 100% { translate: 0 0; } 50% { translate: 0 -5px; } }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .55; } }
@keyframes ping { from { transform: scale(.8); opacity: .9; } to { transform: scale(1.6); opacity: 0; } }
@keyframes pop { 0% { transform: scale(.85); opacity: 0; } 70% { transform: scale(1.04); } 100% { transform: scale(1); opacity: 1; } }
@keyframes up { from { transform: translateY(40px); opacity: 0; } }
@keyframes down { from { transform: translateY(-16px); opacity: 0; } }

@media (min-width: 900px) {
  .sheet { left: auto; width: 440px; right: 12px; top: calc(86px + env(safe-area-inset-top)); bottom: calc(var(--tabbar-h) + 12px); border-radius: 24px; }
  .card { right: auto; width: 440px; }
  .map-ctrls { right: auto; left: 12px; }
}
@media (prefers-reduced-motion: reduce) {
  /* Los monigotes siguen moviéndose: son el alma de la web y se mueven poco */
  *:not(canvas):not(.mono):not(.mono *):not(.parade__w), *::before, *::after { animation: none !important; transition: none !important; }
}
