:root {
  --bg: #FAF3EA;
  --card: #FFFFFF;
  --ink: #2A211C;
  --muted: #857A72;
  --accent: #C4552D;
  --accent-dark: #A34321;
  --accent-soft: #F8E5DB;
  --sage: #6F8F6B;
  --sage-soft: #EEF3EA;
  --sand: #E9B98A;
  --line: #EEE3D6;
  --radius: 22px;
  --shadow: 0 6px 20px rgba(70, 40, 20, .07);
  --font: -apple-system, "SF Pro Text", "Segoe UI", Roboto, system-ui, sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  line-height: 1.35;
  padding-bottom: calc(96px + env(safe-area-inset-bottom));
  overflow-x: hidden;
}
button { font-family: inherit; }
.ic { display: inline-block; vertical-align: middle; flex: none; }

.wrap { max-width: 540px; margin: 0 auto; padding: 0 16px; }

/* ── Hero ────────────────────────────────────────────────────────────────── */
.hero {
  position: relative;
  padding: calc(40px + env(safe-area-inset-top)) 20px 46px;
  text-align: center;
  color: #FFF8F1;
  background: linear-gradient(160deg, #B94C26 0%, #C4552D 55%, #D6774F 100%);
  border-radius: 0 0 36px 36px;
  overflow: hidden;
}
.hero h1 { font-size: 2.2rem; margin: .3em 0 0; letter-spacing: -.02em; font-weight: 700; }
.hero .date { margin: 6px 0 0; opacity: .85; font-weight: 500; letter-spacing: .02em; }
.badge {
  display: inline-flex; align-items: center; gap: 7px;
  background: rgba(255,255,255,.16);
  border: 1px solid rgba(255,255,255,.28);
  padding: 6px 14px 6px 11px;
  border-radius: 999px;
  font-weight: 600;
  font-size: .82rem;
  letter-spacing: .03em;
  text-transform: uppercase;
}
.blob { position: absolute; border-radius: 50%; pointer-events: none; }
.b1 { width: 220px; height: 220px; background: #fff; opacity: .07; top: -90px; left: -60px; }
.b2 { width: 140px; height: 140px; background: var(--sand); opacity: .22; right: -40px; top: 10px; }
.b3 { width: 100px; height: 100px; background: #fff; opacity: .08; right: 50px; bottom: -50px; }

/* ── Progreso ────────────────────────────────────────────────────────────── */
.progress-card {
  display: flex;
  gap: 16px;
  align-items: center;
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: 0 10px 30px rgba(70, 40, 20, .12);
  padding: 16px;
  margin: -28px 0 22px;
  position: relative;
}
.ring { width: 78px; height: 78px; flex: none; transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: 7; stroke-linecap: round; }
.ring .track { stroke: var(--line); }
.ring .fill { stroke: var(--accent); transition: stroke-dashoffset .7s cubic-bezier(.2,.8,.2,1); }
.ring text { transform: rotate(90deg); transform-origin: 36px 36px; font-weight: 700; font-size: 1.45rem; fill: var(--ink); }
.progress-text strong { font-size: 1.15rem; display: block; }
.progress-text p { margin: 2px 0 4px; color: var(--muted); font-size: .92rem; }
.link {
  background: none; border: 0; padding: 0; color: var(--accent); font-weight: 600; font-size: .85rem; cursor: pointer; text-align: left;
}

/* ── Retos ───────────────────────────────────────────────────────────────── */
.group { margin: 28px 0 10px; }
.group h2 {
  display: flex; align-items: baseline; gap: 10px;
  font-size: .8rem; font-weight: 700; letter-spacing: .1em; text-transform: uppercase;
  color: var(--muted); margin: 0 0 12px 4px;
}
.group h2 .n { color: var(--accent); font-variant-numeric: tabular-nums; }
.challenge {
  display: grid;
  grid-template-columns: 44px 1fr 52px;
  gap: 12px;
  align-items: center;
  background: var(--card);
  border-radius: 20px;
  padding: 14px;
  margin-bottom: 10px;
  box-shadow: var(--shadow);
  border: 1.5px solid transparent;
  cursor: pointer;
  transition: transform .12s ease, border-color .25s, background .25s;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}
.challenge:active { transform: scale(.982); }
.challenge.done { border-color: var(--sage); background: var(--sage-soft); }
.challenge .icon {
  width: 44px; height: 44px; border-radius: 14px;
  display: grid; place-items: center;
  background: var(--accent-soft); color: var(--accent);
  transition: background .25s, color .25s;
}
.done .icon { background: #fff; color: var(--sage); }
.challenge h3 { margin: 0; font-size: 1rem; font-weight: 600; }
.challenge .hint { margin: 2px 0 0; font-size: .82rem; color: var(--muted); }
.shoot {
  width: 48px; height: 48px;
  border-radius: 50%;
  border: 0;
  display: grid; place-items: center;
  background: var(--accent);
  color: #fff;
  box-shadow: 0 6px 14px rgba(196, 85, 45, .32);
  cursor: pointer;
  transition: background .25s, box-shadow .25s;
}
.done .shoot { background: var(--sage); box-shadow: 0 6px 14px rgba(111, 143, 107, .3); }
.thumbs { grid-column: 2 / 4; display: flex; align-items: center; gap: 6px; }
.thumbs:empty { display: none; }
.thumbs img, .thumb-fallback {
  width: 54px; height: 54px;
  object-fit: cover;
  border-radius: 12px;
  border: 2px solid #fff;
  box-shadow: 0 3px 8px rgba(0,0,0,.12);
  background: var(--line);
  color: var(--muted);
  display: grid; place-items: center;
  animation: pop .35s cubic-bezier(.2,.9,.3,1.3);
}
.thumbs .more { font-weight: 600; color: var(--muted); font-size: .9rem; margin-left: 2px; }
.thumbs .check {
  margin-left: auto;
  width: 26px; height: 26px; border-radius: 50%;
  background: var(--sage); color: #fff;
  display: grid; place-items: center;
}
@keyframes pop { from { transform: scale(.4); opacity: 0; } to { transform: scale(1); opacity: 1; } }

.foot { text-align: center; color: var(--muted); font-size: .85rem; padding: 24px 0 8px; }

/* ── Barra de estado ─────────────────────────────────────────────────────── */
.statusbar {
  position: fixed;
  left: 16px; right: 16px;
  bottom: calc(16px + env(safe-area-inset-bottom));
  max-width: 508px;
  margin: 0 auto;
  background: var(--ink);
  color: #FFF8F1;
  border-radius: 999px;
  padding: 13px 18px;
  display: flex; align-items: center; gap: 10px;
  box-shadow: 0 12px 30px rgba(42, 33, 28, .3);
  font-size: .9rem; font-weight: 500;
  z-index: 10;
  cursor: pointer;
}
.statusbar .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--sage); flex: none; }
.statusbar.pending .dot { background: var(--sand); animation: pulse 1.1s infinite; }
.statusbar.offline .dot { background: #A89E96; }
.statusbar.warn .dot { background: var(--accent); }
@keyframes pulse { 0%, 100% { transform: scale(1); opacity: 1; } 50% { transform: scale(1.5); opacity: .55; } }

/* ── Toast ───────────────────────────────────────────────────────────────── */
.toast {
  position: fixed;
  top: calc(14px + env(safe-area-inset-top));
  left: 50%;
  transform: translate(-50%, -24px);
  opacity: 0;
  background: #fff;
  color: var(--ink);
  padding: 12px 20px;
  border-radius: 999px;
  box-shadow: 0 10px 30px rgba(70, 40, 20, .18);
  font-weight: 600;
  transition: transform .28s cubic-bezier(.2,.9,.3,1.2), opacity .2s;
  z-index: 30;
  pointer-events: none;
  max-width: calc(100vw - 32px);
  text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ── Modal nombre ────────────────────────────────────────────────────────── */
.modal {
  position: fixed; inset: 0;
  background: rgba(42, 33, 28, .55);
  backdrop-filter: blur(3px);
  display: grid; place-items: end center;
  padding: 16px;
  z-index: 40;
  animation: fade .2s;
}
@media (min-width: 600px) { .modal { place-items: center; } }
.modal-card {
  background: #fff;
  border-radius: 28px;
  padding: 28px 22px calc(22px + env(safe-area-inset-bottom));
  width: 100%; max-width: 440px;
  text-align: center;
  display: flex; flex-direction: column; gap: 10px;
  animation: rise .3s cubic-bezier(.2,.9,.3,1.1);
}
.modal-icon {
  width: 60px; height: 60px; border-radius: 50%; margin: 0 auto 4px;
  display: grid; place-items: center;
  background: var(--accent-soft); color: var(--accent);
}
.modal-card h2 { margin: 0; font-size: 1.5rem; }
.modal-card p { margin: 0 0 6px; color: var(--muted); }
.modal-card input {
  font: inherit; font-size: 1.1rem;
  padding: 14px 16px;
  border-radius: 16px;
  border: 1.5px solid var(--line);
  text-align: center;
  outline: none;
}
.modal-card input:focus { border-color: var(--accent); }
.btn-primary {
  font: inherit; font-weight: 700; font-size: 1.05rem;
  background: var(--accent); color: #fff;
  border: 0; border-radius: 16px;
  padding: 14px;
  cursor: pointer;
  box-shadow: 0 8px 18px rgba(196, 85, 45, .3);
}
.btn-primary:active { background: var(--accent-dark); }
.modal-card .link { text-align: center; color: var(--muted); padding: 6px; }
@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { transform: translateY(30px); opacity: 0; } }

.fatal { text-align: center; padding: 60px 16px; }
.fatal .btn-primary { margin-top: 12px; }

.confetti { position: fixed; inset: 0; width: 100vw; height: 100vh; pointer-events: none; z-index: 50; }

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

/* ── Yo / Mesa ───────────────────────────────────────────────────────────── */
.seg {
  display: inline-flex; gap: 2px;
  background: var(--line); border-radius: 999px; padding: 3px;
  margin-top: 8px;
}
.seg button {
  border: 0; background: transparent; color: var(--muted);
  font-weight: 600; font-size: .82rem; padding: 6px 14px; border-radius: 999px;
  cursor: pointer; transition: background .2s, color .2s;
}
.seg button.on { background: #fff; color: var(--ink); box-shadow: 0 2px 6px rgba(70,40,20,.12); }
.mesa-tag { display: inline-block; font-size: .78rem; color: var(--muted); margin-top: 4px; }
.by { grid-column: 2 / 4; font-size: .78rem; color: var(--muted); margin-top: -2px; }
.by:empty { display: none; }
.table-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(88px, 1fr)); gap: 8px;
  max-height: 46vh; overflow-y: auto; padding: 2px; margin: 4px 0 6px;
}
.table-grid button {
  border: 1.5px solid var(--line); background: #fff; color: var(--ink);
  border-radius: 14px; padding: 12px 6px; font-weight: 600; font-size: .95rem; cursor: pointer;
}
.table-grid button.on { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.stale { font-size: .78rem; color: var(--muted); text-align: center; margin: -6px 0 12px; }
