/* Minipuntos — Cozy Modern
 * Paleta cálida en pasteles, bordes muy redondeados y sombras suaves.
 */
:root {
  --bg: #fff6ee;
  --bg2: #ffe9dd;
  --surface: #ffffff;
  --ink: #4a3b35;
  --muted: #9b8b82;
  --line: #f1e2d8;

  --peach: #ffb487;
  --rose: #ff8fab;
  --rose-soft: #ffe1e9;
  --emerald: #43c59e;
  --emerald-soft: #d9f5ec;
  --amber: #ffcf6b;
  --violet: #b39ddb;

  --radius: 26px;
  --radius-sm: 18px;
  --shadow: 0 10px 28px rgba(180, 120, 90, 0.16);
  --shadow-sm: 0 4px 14px rgba(180, 120, 90, 0.12);
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body { margin: 0; padding: 0; }

body {
  font-family: "Nunito", system-ui, -apple-system, "Segoe UI", "Helvetica Neue", sans-serif;
  color: var(--ink);
  background: radial-gradient(120% 100% at 50% 0%, var(--bg2) 0%, var(--bg) 55%) fixed;
  min-height: 100vh;
  padding-bottom: 92px;
  letter-spacing: 0.2px;
}

h1, h2, h3 { margin: 0; font-weight: 800; }

/* ---------- Header ---------- */
.app-header {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 12px;
  padding: 14px 16px calc(14px) 16px;
  padding-top: max(14px, env(safe-area-inset-top));
  background: linear-gradient(180deg, rgba(255,246,238,0.96), rgba(255,246,238,0.7));
  backdrop-filter: blur(8px);
}
.brand { display: flex; align-items: center; gap: 10px; flex: 1; }
.brand-emoji { font-size: 30px; filter: drop-shadow(0 3px 6px rgba(255,160,90,.4)); }
.app-header h1 { font-size: 22px; line-height: 1; }
.app-header p { margin: 2px 0 0; font-size: 13px; color: var(--muted); font-weight: 700; }
.vs { color: var(--rose); font-style: italic; }
.gear {
  border: none; background: var(--surface); width: 44px; height: 44px;
  border-radius: 50%; font-size: 20px; box-shadow: var(--shadow-sm); cursor: pointer;
  transition: transform .2s var(--ease);
}
.gear:active { transform: rotate(40deg) scale(.94); }
.sync-pill {
  position: absolute; right: 16px; top: calc(58px + env(safe-area-inset-top));
  display: flex; align-items: center; gap: 6px;
  background: var(--surface); padding: 4px 10px; border-radius: 999px;
  font-size: 11px; font-weight: 800; color: var(--muted); box-shadow: var(--shadow-sm);
}
.sync-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--muted); }
.sync-dot.off { background: #c9bcb4; }
.sync-dot.ok { background: var(--emerald); }
.sync-dot.wait { background: var(--amber); }
.sync-dot.error { background: var(--rose); }

/* ---------- Layout ---------- */
.content { padding: 22px 16px 8px; max-width: 560px; margin: 0 auto; }
.sec-title { font-size: 15px; color: var(--muted); margin-bottom: 12px; text-transform: uppercase; letter-spacing: 1px; }

.card { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; }

/* ---------- Jugadores ---------- */
.players { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-bottom: 22px; }
.player {
  background: var(--surface); border-radius: var(--radius); padding: 16px 14px;
  box-shadow: var(--shadow); text-align: center; position: relative; overflow: hidden;
}
.player.paula { background: linear-gradient(170deg, #fff 60%, var(--rose-soft)); }
.player.marce { background: linear-gradient(170deg, #fff 60%, #e7f0ff); }
.player-head { display: flex; align-items: center; justify-content: center; gap: 8px; }
.avatar { font-size: 22px; }
.avatar.sm { font-size: 18px; }
.player h3 { font-size: 18px; }
.score { font-size: 46px; font-weight: 900; line-height: 1.1; margin-top: 6px; }
.score.pos { color: var(--emerald); }
.score.neg { color: var(--rose); }
.score.zero { color: var(--muted); }
.score-label { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 1px; font-weight: 700; }

.hitos { display: flex; flex-direction: column; gap: 8px; margin-top: 14px; }
.hito { display: flex; align-items: center; gap: 7px; justify-content: center; }
.hito-ico { font-size: 16px; }
.hito-n { font-size: 12px; font-weight: 800; color: var(--muted); min-width: 26px; }
.dots { display: flex; gap: 5px; }
.dot { width: 12px; height: 12px; border-radius: 50%; background: var(--line); transition: transform .3s var(--ease), background .3s; }
.hito.plus .dot.on { background: var(--emerald); transform: scale(1.12); }
.hito.minus .dot.on { background: var(--rose); transform: scale(1.12); }

.locked-row { display: flex; flex-direction: column; gap: 3px; margin-top: 12px; }
.locked { font-size: 10.5px; color: var(--muted); font-weight: 700; }

/* ---------- Negociación ---------- */
.negotiation { margin-bottom: 22px; }
.challenge {
  background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 16px; margin-bottom: 14px; border: 2px solid transparent;
  animation: pop .35s var(--ease);
}
.challenge.plus { border-color: var(--emerald-soft); }
.challenge.minus { border-color: var(--rose-soft); }
@keyframes pop { from { opacity: 0; transform: translateY(10px) scale(.97); } to { opacity: 1; transform: none; } }

.ch-head { display: flex; align-items: center; gap: 12px; }
.ch-emoji { font-size: 30px; }
.ch-head strong { font-size: 16px; }
.ch-head p { margin: 2px 0 0; font-size: 12px; font-weight: 800; color: var(--muted); letter-spacing: .5px; }
.ch-roles { font-size: 12px; color: var(--muted); margin: 10px 0; background: var(--bg); padding: 8px 10px; border-radius: var(--radius-sm); }
.ch-decide { font-size: 13px; font-weight: 800; margin: 12px 0 8px; }

.reto-box {
  position: relative; background: var(--bg); border-radius: var(--radius-sm);
  padding: 14px 12px 12px; margin-top: 6px; font-size: 14.5px; font-weight: 700; line-height: 1.35;
}
.reto-box.revealed { background: var(--emerald-soft); }
.challenge.minus .reto-box.revealed { background: var(--rose-soft); }
.reto-box.alt { background: #fff5e3; margin-top: 10px; }
.reto-tag {
  position: absolute; top: -9px; left: 12px; font-size: 10px; font-weight: 800;
  background: var(--ink); color: #fff; padding: 2px 8px; border-radius: 999px; letter-spacing: .5px;
}

.ch-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 14px; }
.alt-input { margin-top: 12px; }
.alt-input textarea { width: 100%; }

/* ---------- Botones ---------- */
.btn {
  border: none; border-radius: var(--radius-sm); padding: 12px 16px; font-size: 14px;
  font-weight: 800; cursor: pointer; flex: 1; min-width: 130px;
  background: var(--bg2); color: var(--ink); box-shadow: var(--shadow-sm);
  transition: transform .15s var(--ease), filter .2s, opacity .2s;
}
.btn:active { transform: scale(.96); }
.btn.ok { background: var(--emerald); color: #fff; }
.btn.no { background: #fff; color: var(--rose); box-shadow: inset 0 0 0 2px var(--rose-soft); }
.btn.alt { background: var(--amber); color: #6a4b00; }
.btn.ghost { background: #fff; color: var(--muted); box-shadow: inset 0 0 0 2px var(--line); }
.btn.danger { background: var(--rose); color: #fff; }
.btn.block { width: 100%; }
.btn.big { padding: 16px; font-size: 16px; }
.btn.big.plus { background: var(--emerald); color: #fff; }
.btn.big.minus { background: var(--rose); color: #fff; }
.btn:disabled { opacity: .45; filter: grayscale(.3); cursor: not-allowed; }

/* ---------- Barra de deshacer ---------- */
.undo-bar {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  background: #fff7e9; border: 1.5px dashed var(--amber); border-radius: var(--radius-sm);
  padding: 10px 14px; margin-bottom: 14px; font-size: 13px; font-weight: 700; color: #8a6500;
  animation: pop .3s var(--ease);
}
.undo-bar b { color: var(--ink); }
.btn.sm { flex: 0 0 auto; min-width: 0; padding: 9px 14px; font-size: 13px; }
.muted { color: var(--muted); font-weight: 700; font-size: 12px; }

/* ---------- Formulario de votación ---------- */
.vote { margin-bottom: 8px; }
.seg { display: flex; gap: 8px; background: var(--bg); padding: 5px; border-radius: 999px; margin-bottom: 12px; }
.seg-btn {
  flex: 1; border: none; background: transparent; padding: 10px; border-radius: 999px;
  font-weight: 800; font-size: 13.5px; color: var(--muted); cursor: pointer; transition: all .2s var(--ease);
}
.seg-btn.active { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-sm); }
textarea, input[type="text"] {
  width: 100%; border: 2px solid var(--line); border-radius: var(--radius-sm); padding: 12px;
  font-family: inherit; font-size: 15px; color: var(--ink); resize: vertical; background: #fff;
}
textarea:focus, input[type="text"]:focus { outline: none; border-color: var(--peach); }
.vote-actions { display: flex; gap: 10px; margin-top: 12px; }

/* ---------- Historial ---------- */
.log-item { background: var(--surface); border-radius: var(--radius-sm); box-shadow: var(--shadow-sm); padding: 14px; margin-bottom: 12px; }
.log-top { display: flex; align-items: center; gap: 8px; }
.log-top b { font-size: 15px; }
.log-time { margin-left: auto; font-size: 11px; color: var(--muted); font-weight: 700; }
.log-badge { font-size: 12px; font-weight: 900; padding: 3px 9px; border-radius: 999px; }
.log-badge.plus { background: var(--emerald-soft); color: #1c7d63; }
.log-badge.minus { background: var(--rose-soft); color: #c43c63; }
.log-badge.reto { background: #fff0d2; color: #9a6b00; }
.log-reason { margin-top: 8px; font-size: 14px; color: #6a5a52; background: var(--bg); border-radius: 12px; padding: 9px 11px; }
.empty { color: var(--muted); text-align: center; padding: 30px; font-weight: 700; }

/* ---------- Tabbar ---------- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: flex; gap: 8px; padding: 8px 16px;
  padding-bottom: max(8px, env(safe-area-inset-bottom));
  background: linear-gradient(0deg, var(--surface) 70%, rgba(255,255,255,0));
}
.tab {
  flex: 1; border: none; background: var(--bg); border-radius: var(--radius-sm); padding: 10px;
  font-weight: 800; font-size: 13px; color: var(--muted); cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 3px; transition: all .2s var(--ease);
}
.tab span { font-size: 20px; }
.tab.active { background: var(--rose); color: #fff; box-shadow: var(--shadow-sm); }

/* ---------- Modal ---------- */
.modal {
  position: fixed; inset: 0; z-index: 40; display: none; align-items: flex-end; justify-content: center;
  background: rgba(74, 59, 53, 0.4); backdrop-filter: blur(3px);
}
.modal.open { display: flex; animation: fade .2s ease; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.modal-card {
  background: var(--surface); width: 100%; max-width: 560px; border-radius: 28px 28px 0 0;
  padding: 22px 20px calc(26px + env(safe-area-inset-bottom)); box-shadow: var(--shadow);
  animation: slideUp .3s var(--ease);
}
@keyframes slideUp { from { transform: translateY(100%); } to { transform: none; } }
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.modal-head h2 { font-size: 20px; }
.x { border: none; background: var(--bg); width: 38px; height: 38px; border-radius: 50%; font-size: 16px; cursor: pointer; }
.field label { display: block; font-weight: 800; margin-bottom: 6px; font-size: 15px; }
.hint { font-size: 12.5px; color: var(--muted); margin: 0 0 10px; line-height: 1.4; }
.hint code, code { background: var(--bg2); padding: 1px 6px; border-radius: 6px; font-size: 12px; }
.modal-actions { display: flex; gap: 10px; margin-top: 12px; }
.modal hr { border: none; border-top: 1px solid var(--line); margin: 20px 0; }
.foot { text-align: center; color: var(--muted); font-size: 12px; margin: 16px 0 0; font-weight: 700; }

/* ---------- Efectos a pantalla completa ---------- */
#confetti { position: fixed; inset: 0; z-index: 50; pointer-events: none; display: none; }
#flash {
  position: fixed; inset: 0; z-index: 45; pointer-events: none; opacity: 0;
  background: radial-gradient(circle at 50% 40%, rgba(255,209,107,0.5), transparent 60%);
}
#flash.go { animation: flashAnim .8s ease; }
@keyframes flashAnim { 0% { opacity: 0; } 25% { opacity: 1; } 100% { opacity: 0; } }

#toast {
  position: fixed; left: 50%; bottom: 104px; transform: translate(-50%, 16px);
  z-index: 60; background: var(--ink); color: #fff; padding: 11px 18px; border-radius: 999px;
  font-size: 14px; font-weight: 800; box-shadow: var(--shadow); opacity: 0; pointer-events: none;
  transition: opacity .25s var(--ease), transform .25s var(--ease); max-width: 80vw; text-align: center;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }

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

@media (min-width: 600px) {
  .content { padding-top: 28px; }
}
