/* =========================================================
   ChiquiPuntos · estilos
   ========================================================= */
:root {
  --ink: #2B2350;
  --ink-soft: #6B6391;
  --bg: #FFF8EC;
  --card: #FFFFFF;
  --pink: #FF5D8F;
  --pink-2: #FF9EC0;
  --yellow: #FFD23F;
  --orange: #FF8A3D;
  --sky: #3EC1F3;
  --grape: #8E6CEF;
  --mint: #22C99A;
  --mint-2: #B9F3DF;
  --coral: #FF6B5E;
  --coral-2: #FFD3CE;
  --radius: 26px;
  --shadow: 0 6px 0 rgba(43, 35, 80, .12), 0 14px 30px rgba(43, 35, 80, .08);
  --font: "Fredoka", "Baloo 2", "Comic Sans MS", "Chalkboard SE", system-ui, sans-serif;
  color-scheme: light;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 18px;
  line-height: 1.4;
  color: var(--ink);
  background-color: var(--bg);
  background-image:
    radial-gradient(circle at 12% 18%, rgba(255, 210, 63, .35) 0 7px, transparent 8px),
    radial-gradient(circle at 82% 12%, rgba(255, 93, 143, .25) 0 6px, transparent 7px),
    radial-gradient(circle at 64% 72%, rgba(62, 193, 243, .25) 0 8px, transparent 9px),
    radial-gradient(circle at 28% 84%, rgba(142, 108, 239, .22) 0 6px, transparent 7px),
    radial-gradient(circle at 92% 58%, rgba(34, 201, 154, .25) 0 5px, transparent 6px);
  background-size: 260px 260px;
  min-height: 100vh;
  overflow-x: hidden;
}

a { color: var(--grape); font-weight: 600; }
h1, h2, h3 { line-height: 1.15; margin: 0 0 .6em; }
h2 { font-size: 1.35rem; }
img { max-width: 100%; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--ink-soft); }
.center { text-align: center; }
.grow { flex: 1; }
:focus-visible { outline: 4px solid var(--sky); outline-offset: 3px; border-radius: 12px; }

/* Nubes decorativas */
.sky { position: fixed; inset: 0; pointer-events: none; z-index: -1; overflow: hidden; }
.sky span {
  position: absolute; width: 120px; height: 40px; background: #fff; border-radius: 40px; opacity: .8;
  animation: drift 60s linear infinite;
}
.sky span::before, .sky span::after { content: ""; position: absolute; background: #fff; border-radius: 50%; }
.sky span::before { width: 56px; height: 56px; top: -28px; left: 18px; }
.sky span::after { width: 40px; height: 40px; top: -18px; left: 60px; }
.sky span:nth-child(1) { top: 8%; left: -10%; }
.sky span:nth-child(2) { top: 30%; left: -30%; animation-duration: 85s; transform: scale(.7); }
.sky span:nth-child(3) { top: 60%; left: -20%; animation-duration: 70s; }
.sky span:nth-child(4) { top: 82%; left: -40%; animation-duration: 95s; transform: scale(.8); }
.sky span:nth-child(5) { top: 45%; left: -60%; animation-duration: 110s; }
@keyframes drift { to { left: 120%; } }

/* ---------- Barra superior ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 16px; max-width: 1100px; margin: 0 auto;
}
.brand { display: flex; align-items: center; gap: 8px; text-decoration: none; color: var(--ink); font-size: 1.5rem; font-weight: 700; }
.brand b { color: var(--pink); }
.brand img { animation: wiggle 4s ease-in-out infinite; }
.topbar-right { display: flex; align-items: center; gap: 10px; }
.me {
  display: flex; align-items: center; gap: 8px; text-decoration: none; color: var(--ink);
  background: #fff; padding: 4px 14px 4px 4px; border-radius: 999px; box-shadow: var(--shadow);
}
.me img { width: 40px; height: 40px; border-radius: 50%; object-fit: cover; border: 3px solid var(--yellow); }
.icon-btn {
  border: 0; background: #fff; width: 44px; height: 44px; border-radius: 50%; font-size: 1.3rem;
  cursor: pointer; box-shadow: var(--shadow); transition: transform .15s;
}
.icon-btn:active { transform: scale(.9); }

.tabs {
  display: flex; gap: 6px; justify-content: center; flex-wrap: wrap;
  max-width: 1100px; margin: 4px auto 6px; padding: 0 12px;
}
.tabs a {
  display: flex; align-items: center; gap: 6px; padding: 8px 14px; border-radius: 999px;
  background: rgba(255, 255, 255, .8); color: var(--ink); text-decoration: none; font-weight: 600; font-size: 1rem;
}
.tabs a.is-active { background: var(--grape); color: #fff; box-shadow: 0 4px 0 #6a4fd1; }
.tab-ico { font-size: 1.15rem; }
@media (max-width: 560px) {
  .tabs {
    position: fixed; bottom: 0; left: 0; right: 0; margin: 0; z-index: 20;
    background: #fff; padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
    box-shadow: 0 -4px 20px rgba(43, 35, 80, .12); flex-wrap: nowrap; justify-content: space-around; gap: 0;
  }
  .tabs a { flex-direction: column; gap: 0; font-size: .72rem; padding: 6px 8px; background: transparent; border-radius: 16px; }
  .tabs a.is-active { box-shadow: none; }
  .tab-ico { font-size: 1.45rem; }
  body { padding-bottom: 84px; }
  .me span { display: none; }
  .me { padding: 4px; }
}

/* ---------- Contenedor y tarjetas ---------- */
.wrap { max-width: 1100px; margin: 0 auto; padding: 8px 16px 24px; }
.card {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 22px; margin: 18px 0;
}
.page-title { text-align: center; font-size: 2rem; margin-top: 10px; }

/* ---------- Avisos ---------- */
.flash {
  border-radius: 18px; padding: 12px 18px; margin: 12px 0; font-weight: 600;
  animation: pop .4s cubic-bezier(.2, 1.6, .4, 1);
}
.flash-success { background: var(--mint-2); color: #0b6b50; }
.flash-error { background: var(--coral-2); color: #a12a20; }
.flash-info { background: #DCEFFF; color: #1f5f8b; }

/* ---------- Botones ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font: inherit; font-weight: 700; border: 0; cursor: pointer; text-decoration: none;
  padding: 12px 22px; border-radius: 18px; color: #fff; background: var(--grape);
  box-shadow: 0 5px 0 rgba(0, 0, 0, .18); transition: transform .1s, box-shadow .1s;
}
.btn:active { transform: translateY(4px); box-shadow: 0 1px 0 rgba(0, 0, 0, .18); }
.btn-big { width: 100%; font-size: 1.25rem; padding: 16px 22px; border-radius: 22px; }
.btn-small { padding: 8px 14px; font-size: .95rem; }
.btn-pink { background: linear-gradient(135deg, var(--pink), #ff7a59); }
.btn-green { background: linear-gradient(135deg, var(--mint), #18b0d6); }
.btn-blue { background: linear-gradient(135deg, var(--sky), var(--grape)); }
.btn-red { background: linear-gradient(135deg, var(--coral), #d63a62); }
.link-btn { border: 0; background: none; font: inherit; color: var(--grape); font-weight: 600; cursor: pointer; padding: 8px; text-decoration: underline; }
.link-btn.danger { color: #c43a2e; }

/* ---------- Formularios ---------- */
.form { display: grid; gap: 14px; }
.field { display: grid; gap: 6px; border: 0; padding: 0; margin: 0; min-width: 0; }
.field > span, .field > legend { font-weight: 600; padding: 0; }
.field small { font-weight: 400; color: var(--ink-soft); }
.field-small input { max-width: 200px; }
input[type=text], input[type=password], input[type=number] {
  font: inherit; font-size: 1.15rem; padding: 12px 16px; border-radius: 16px;
  border: 3px solid #E9E3FF; background: #FBFAFF; color: var(--ink); width: 100%;
  transition: border-color .15s, box-shadow .15s;
}
input:focus { outline: none; border-color: var(--grape); box-shadow: 0 0 0 4px rgba(142, 108, 239, .2); }
.inline-form { display: flex; gap: 10px; align-items: end; }
.hint { background: #FFF4C9; border-radius: 14px; padding: 10px 14px; margin: 0; font-size: .95rem; }
.check { display: flex; gap: 10px; align-items: center; font-weight: 600; }
.check input { width: 22px; height: 22px; }

.emoji-picker { display: flex; flex-wrap: wrap; gap: 8px; }
.emoji-picker input { position: absolute; opacity: 0; pointer-events: none; }
.emoji-picker label {
  font-size: 1.7rem; width: 54px; height: 54px; display: grid; place-items: center;
  background: #F4F1FF; border-radius: 16px; cursor: pointer; border: 3px solid transparent; transition: transform .15s;
}
.emoji-picker label:hover { transform: scale(1.1) rotate(-4deg); }
.emoji-picker input:checked + label { border-color: var(--grape); background: #fff; transform: scale(1.12); box-shadow: 0 4px 0 rgba(142, 108, 239, .35); }
.emoji-picker input:focus-visible + label { outline: 4px solid var(--sky); }

.kind-toggle { display: flex; gap: 10px; }
.kind-toggle input { position: absolute; opacity: 0; }
.kind-toggle label { flex: 1; text-align: center; padding: 12px; border-radius: 16px; font-weight: 700; cursor: pointer; border: 3px solid transparent; background: #F4F1FF; }
.kind-toggle input:checked + .k-plus { background: var(--mint-2); border-color: var(--mint); }
.kind-toggle input:checked + .k-minus { background: var(--coral-2); border-color: var(--coral); }
.kind-toggle input:focus-visible + label { outline: 4px solid var(--sky); }

/* ---------- Acceso / registro ---------- */
.page-auth .wrap { max-width: 480px; }
.auth-card {
  background: #fff; border-radius: 34px; box-shadow: var(--shadow); padding: 28px 24px;
  margin: 24px 0; text-align: center;
}
.auth-card .form { text-align: left; }
.auth-mascot { display: block; margin: -10px auto 4px; }
.rainbow-title { font-size: 2.3rem; margin-bottom: .2em; }
.rainbow-title span { color: var(--pink); }
.lead { font-size: 1.15rem; color: var(--ink-soft); margin-top: 0; }
.auth-switch { margin-bottom: 0; }

.photo-pick { display: grid; justify-items: center; gap: 6px; text-align: center; }
.photo-pick input[type=file] { position: absolute; width: 1px; height: 1px; opacity: 0; }
.photo-circle { position: relative; cursor: pointer; display: block; }
.photo-circle img {
  width: 140px; height: 140px; border-radius: 50%; object-fit: cover; display: block;
  border: 6px solid var(--yellow); box-shadow: 0 0 0 6px var(--pink-2), var(--shadow); background: #fff;
}
.photo-badge {
  position: absolute; right: -2px; bottom: 4px; width: 46px; height: 46px; border-radius: 50%;
  background: var(--sky); display: grid; place-items: center; font-size: 1.4rem; box-shadow: 0 3px 0 rgba(0, 0, 0, .2);
}
.photo-pick:focus-within .photo-circle img { box-shadow: 0 0 0 6px var(--sky), var(--shadow); }

/* ---------- Panel: saludo ---------- */
.hello { display: flex; align-items: center; gap: 16px; margin-top: 8px; }
.hello-avatar { width: 84px; height: 84px; border-radius: 50%; object-fit: cover; border: 5px solid #fff; box-shadow: var(--shadow); flex-shrink: 0; }
.hello h1 { font-size: 1.9rem; margin-bottom: 6px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { background: #fff; border-radius: 999px; padding: 4px 12px; font-weight: 600; font-size: .95rem; box-shadow: 0 3px 0 rgba(43, 35, 80, .08); }
.chip-streak { background: #FFE7D6; }
.chip-stars { background: #FFF4C9; }
.chip-level { background: #EDE7FF; }

.bubble-row { display: flex; align-items: flex-end; gap: 10px; margin: 18px 0 4px; }
.bubble-mascot { flex-shrink: 0; animation: float 3s ease-in-out infinite; }
.bubble {
  position: relative; margin: 0 0 18px; background: #fff; padding: 14px 18px; border-radius: 22px 22px 22px 6px;
  font-weight: 600; font-size: 1.1rem; box-shadow: var(--shadow); flex: 1;
}
.bubble.pop { animation: pop .45s cubic-bezier(.2, 1.6, .4, 1); }
.bubble.is-plus { background: #E9FFF6; }
.bubble.is-minus { background: #FFF1EE; }

/* ---------- Objetivo ---------- */
.goal-card { background: linear-gradient(160deg, #fff 55%, #FFF0F6); position: relative; overflow: hidden; }
.goal-card.is-done { background: linear-gradient(160deg, #FFF8D6, #FFE1EE); }
.goal-head { display: flex; align-items: center; gap: 16px; }
.goal-emoji {
  font-size: 3.4rem; width: 92px; height: 92px; display: grid; place-items: center; flex-shrink: 0;
  background: #FFF4C9; border-radius: 28px; box-shadow: inset 0 -6px 0 rgba(0, 0, 0, .06);
  animation: wiggle 5s ease-in-out infinite;
}
.goal-kicker { margin: 0; color: var(--pink); font-weight: 700; text-transform: uppercase; letter-spacing: .06em; font-size: .85rem; }
.goal-title { font-size: 1.9rem; margin: 0; word-break: break-word; }
.goal-count { text-align: center; font-size: 1.2rem; margin: 10px 0 0; }
.goal-count strong { font-size: 2rem; color: var(--pink); }
.goal-left { color: var(--ink-soft); font-weight: 600; }
.done-box { text-align: center; margin-top: 12px; }
.done-big { font-size: 3rem; margin: 0; animation: bounce 1.2s ease-in-out infinite; }

.progress {
  position: relative; height: 38px; margin-top: 18px; border-radius: 999px;
  background: #F1ECFF; box-shadow: inset 0 4px 0 rgba(43, 35, 80, .08); overflow: visible;
}
.progress-fill {
  height: 100%; width: 0; border-radius: 999px; min-width: 0;
  background: linear-gradient(90deg, var(--yellow), var(--orange), var(--pink), var(--grape), var(--sky));
  background-size: 300% 100%; animation: shimmer 6s linear infinite;
  transition: width .9s cubic-bezier(.2, 1.3, .4, 1); position: relative;
}
.progress-fill::after {
  content: "⭐"; position: absolute; right: -14px; top: 50%; transform: translateY(-50%);
  font-size: 1.8rem; filter: drop-shadow(0 2px 2px rgba(0, 0, 0, .2));
}
.progress-fill[data-pct="0"]::after { right: -24px; }
.progress-star { position: absolute; right: -6px; top: 50%; transform: translateY(-50%); font-size: 1.7rem; }
.progress.small { height: 16px; margin-top: 6px; }
.progress.small .progress-fill::after { display: none; }

.today { display: flex; justify-content: center; gap: 18px; font-size: 1.1rem; margin-top: 4px; }
.plus-text { color: #0f9c74; }
.minus-text { color: #d1453a; }

/* ---------- Botones de acciones ---------- */
.boards { display: grid; gap: 0 18px; grid-template-columns: 1fr; }
@media (min-width: 860px) { .boards { grid-template-columns: 1.4fr 1fr; } }
.board-plus h2 { color: #0f9c74; }
.board-minus h2 { color: #d1453a; }
.board-plus { border-top: 8px solid var(--mint); }
.board-minus { border-top: 8px solid var(--coral); }
.action-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; }
.action-grid form { margin: 0; display: contents; }
.action-btn {
  position: relative; font: inherit; border: 0; cursor: pointer; border-radius: 22px; padding: 14px 10px 12px;
  display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center; min-height: 128px;
  transition: transform .12s, box-shadow .12s; color: var(--ink); width: 100%;
}
.action-btn.plus { background: var(--mint-2); box-shadow: 0 6px 0 #7fdcbc; }
.action-btn.minus { background: var(--coral-2); box-shadow: 0 6px 0 #f3a79e; }
.action-btn:hover { transform: translateY(-2px) rotate(-1deg); }
.action-btn:active, .action-btn.is-pressed { transform: translateY(5px) scale(.97); box-shadow: 0 1px 0 rgba(0, 0, 0, .1); }
.action-btn:disabled { opacity: .6; cursor: wait; }
.a-emo { font-size: 2.6rem; line-height: 1; }
.a-label { font-weight: 600; font-size: 1rem; line-height: 1.15; }
.a-delta {
  position: absolute; top: 8px; right: 10px; font-weight: 700; font-size: .9rem;
  background: #fff; border-radius: 999px; padding: 1px 8px;
}
.plus .a-delta { color: #0f9c74; }
.minus .a-delta { color: #d1453a; }

.float-num {
  position: fixed; z-index: 50; font-size: 2.2rem; font-weight: 700; pointer-events: none;
  animation: floatUp 1s ease-out forwards; text-shadow: 0 3px 0 #fff;
}
.float-num.plus { color: #0f9c74; }
.float-num.minus { color: #d1453a; }

/* ---------- Listas de eventos ---------- */
.events { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.ev { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 18px; background: #FAF8FF; }
.ev-plus { background: #EFFFF8; }
.ev-minus { background: #FFF4F2; }
.ev-emo { font-size: 1.7rem; width: 44px; text-align: center; flex-shrink: 0; }
.ev-label { flex: 1; font-weight: 600; display: grid; }
.ev-label small { font-weight: 400; color: var(--ink-soft); font-size: .85rem; }
.ev-delta { font-weight: 700; font-size: 1.3rem; }
.ev-plus .ev-delta { color: #0f9c74; }
.ev-minus .ev-delta { color: #d1453a; }
.ev form { margin: 0; }
.undo-btn { font: inherit; font-size: .85rem; border: 0; background: #fff; border-radius: 999px; padding: 6px 10px; cursor: pointer; box-shadow: 0 2px 0 rgba(0, 0, 0, .1); }

/* ---------- Medallas ---------- */
.badges { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 12px; }
.badge { text-align: center; padding: 14px 8px; border-radius: 20px; background: #F6F3FF; display: grid; gap: 2px; }
.badge.won { background: linear-gradient(160deg, #FFF4C9, #FFE1EE); }
.badge.won .badge-emo { animation: wiggle 3s ease-in-out infinite; }
.badge.locked { opacity: .55; filter: grayscale(.6); }
.badge-emo { font-size: 2.3rem; }
.badge-name { font-weight: 700; }
.badge small { color: var(--ink-soft); font-size: .8rem; }
.level-box { margin-top: 18px; }
.level-box p { margin: 0; }

/* ---------- Objetivos / trofeos ---------- */
.trophies { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; }
.trophy {
  text-align: center; padding: 16px 10px; border-radius: 22px; display: grid; gap: 4px;
  background: linear-gradient(160deg, #FFF8D6, #FFE7C2); box-shadow: 0 4px 0 #f3d38b;
}
.trophy-emo { font-size: 2.6rem; }
.trophy small { color: var(--ink-soft); }
.more summary { cursor: pointer; font-weight: 700; padding: 8px 0; color: var(--grape); }
.plain-list { padding-left: 1.2em; }

/* ---------- Acciones (gestión) ---------- */
.manage-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.manage-list li { display: flex; align-items: center; gap: 10px; background: #FAF8FF; border-radius: 16px; padding: 6px 8px 6px 10px; }
.manage-list form { margin: 0; }
.manage-list .icon-btn { width: 38px; height: 38px; font-size: 1.05rem; box-shadow: none; background: #fff; }

/* ---------- Historial ---------- */
.week { display: grid; grid-template-columns: repeat(7, 1fr); gap: 8px; align-items: end; }
.week-day { display: grid; justify-items: center; gap: 4px; }
.week-bars { display: flex; align-items: flex-end; gap: 3px; height: 120px; }
.wb { width: 14px; border-radius: 8px 8px 3px 3px; height: 0; transition: height .8s cubic-bezier(.2, 1.3, .4, 1); min-height: 3px; }
.wb-plus { background: var(--mint); }
.wb-minus { background: var(--coral); }
.legend { text-align: center; color: var(--ink-soft); font-size: .9rem; margin-bottom: 0; }
.dot { display: inline-block; width: 12px; height: 12px; border-radius: 50%; vertical-align: middle; margin-left: 10px; }
.dot-plus { background: var(--mint); }
.dot-minus { background: var(--coral); }
.day-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; font-size: 1.15rem; }
.day-sum b { margin-left: 8px; }
.pager { display: flex; justify-content: center; align-items: center; gap: 12px; flex-wrap: wrap; }

/* ---------- Perfil ---------- */
.profile-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin: 18px 0 8px; }
.profile-stats div { background: #F6F3FF; border-radius: 18px; padding: 12px 6px; text-align: center; display: grid; }
.profile-stats b { font-size: 1.6rem; }
.profile-stats span { font-size: .85rem; color: var(--ink-soft); }
@media (max-width: 480px) { .profile-stats { grid-template-columns: repeat(2, 1fr); } }
.danger-zone { border: 3px dashed var(--coral-2); }

/* ---------- Pie, toast y confeti ---------- */
.foot { text-align: center; color: var(--ink-soft); padding: 10px 16px 30px; font-size: .95rem; }
.foot form { margin: 0; }
.toast {
  position: fixed; left: 50%; bottom: 100px; transform: translate(-50%, 40px); opacity: 0;
  background: var(--ink); color: #fff; padding: 12px 20px; border-radius: 16px; font-weight: 600; z-index: 60;
  transition: opacity .25s, transform .25s; max-width: calc(100% - 32px); text-align: center; pointer-events: none;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
#confetti { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 70; }

/* ---------- Animaciones ---------- */
@keyframes pop { 0% { transform: scale(.85); opacity: 0; } 100% { transform: scale(1); opacity: 1; } }
@keyframes wiggle { 0%, 100% { transform: rotate(0); } 10% { transform: rotate(-8deg); } 20% { transform: rotate(8deg); } 30% { transform: rotate(0); } }
@keyframes float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-8px); } }
@keyframes bounce { 0%, 100% { transform: translateY(0) scale(1); } 50% { transform: translateY(-10px) scale(1.06); } }
@keyframes shimmer { to { background-position: 300% 0; } }
@keyframes floatUp { 0% { opacity: 1; transform: translateY(0) scale(.8); } 30% { transform: translateY(-20px) scale(1.25); } 100% { opacity: 0; transform: translateY(-90px) scale(1); } }
@keyframes shake { 0%, 100% { transform: translateX(0); } 20%, 60% { transform: translateX(-8px); } 40%, 80% { transform: translateX(8px); } }
@keyframes jump { 0%, 100% { transform: translateY(0) rotate(0); } 40% { transform: translateY(-26px) rotate(-12deg); } 70% { transform: translateY(0) rotate(8deg); } }
.bounce { animation: bounce 2.4s ease-in-out infinite; }
.shake { animation: shake .45s; }
.jump { animation: jump .7s ease-out; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
  .sky { display: none; }
}
