:root {
  --bg1: #ffd6c9;
  --bg2: #ffe8d6;
  --bg3: #fff3e0;
  --coral: #ff6b6b;
  --coral-dark: #e85a5a;
  --teal: #2ec4b6;
  --teal-dark: #1fa89c;
  --gold: #f4b942;
  --green-deep: #1f4d3a;
  --ink: #2c2a32;
  --muted: #6b6570;
  --card: #ffffff;
  --shadow: 0 10px 30px rgba(44, 42, 50, 0.08);
  --radius: 1.5rem;
  --radius-sm: 1rem;
  --nav-h: 4.5rem;
  --font-display: "Fredoka", system-ui, sans-serif;
  --font-body: "Nunito", system-ui, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: var(--font-body);
  color: var(--ink);
  background: var(--bg2);
  padding-bottom: calc(var(--nav-h) + 1.5rem);
}
.app-bg {
  position: fixed; inset: 0; z-index: -1;
  background:
    radial-gradient(ellipse 80% 50% at 50% -10%, rgba(255,255,255,0.55), transparent 60%),
    linear-gradient(165deg, var(--bg1), var(--bg2) 45%, var(--bg3));
}
.app-bg::after {
  content: "";
  position: absolute; inset: 0;
  background: repeating-conic-gradient(from 0deg at 50% -5%, rgba(255,255,255,0.12) 0deg 8deg, transparent 8deg 16deg);
  opacity: 0.45;
  pointer-events: none;
}

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 1rem 1.25rem 0.25rem;
}
.brand {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.25rem;
  color: var(--ink);
  text-decoration: none;
}
.link-quiet { color: var(--muted); text-decoration: none; font-weight: 700; margin-left: 1rem; font-size: 0.9rem; }
.main { max-width: 42rem; margin: 0 auto; padding: 0.75rem 1.25rem 2rem; }

h1, h2, h3 { font-family: var(--font-display); font-weight: 600; margin: 0 0 0.5rem; }
.subtitle { color: var(--muted); margin: 0 0 1.25rem; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.4rem;
  border: none; border-radius: 999px; padding: 0.85rem 1.4rem;
  font-family: var(--font-body); font-weight: 800; font-size: 1rem;
  cursor: pointer; text-decoration: none; transition: transform .15s ease, background .15s ease;
}
.btn:active { transform: scale(0.98); }
.btn-primary { background: var(--coral); color: #fff; }
.btn-primary:hover { background: var(--coral-dark); }
.btn-secondary { background: #fff; color: var(--ink); box-shadow: var(--shadow); }
.btn-teal { background: var(--teal); color: #fff; }
.btn-teal:hover { background: var(--teal-dark); }
.btn-block { width: 100%; }
.btn-sm { padding: 0.5rem 0.9rem; font-size: 0.85rem; }

.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1rem 1.1rem;
  margin-bottom: 0.85rem;
}
.card-row {
  display: flex; align-items: center; gap: 0.85rem;
  text-decoration: none; color: inherit;
}

.avatar {
  width: 3.25rem; height: 3.25rem; border-radius: 50%;
  display: grid; place-items: center;
  font-family: var(--font-display); font-weight: 700; color: #fff;
  background-size: cover; background-position: center;
  flex-shrink: 0; border: 3px solid #fff; box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}
.avatar-lg { width: 5.5rem; height: 5.5rem; font-size: 1.6rem; border-width: 4px; }
.avatar-xl { width: 6.5rem; height: 6.5rem; font-size: 1.9rem; border-width: 4px; }

.star { color: var(--gold); font-weight: 800; }
.points { font-weight: 800; white-space: nowrap; }

/* Podium */
.podium {
  display: grid;
  grid-template-columns: 1fr 1.15fr;
  gap: 0.75rem;
  align-items: end;
  margin: 1rem 0 1.5rem;
  animation: rise 0.6s ease both;
}
.podium-slot {
  text-align: center;
  padding: 1rem 0.5rem 0;
}
.podium-slot.is-first { order: 2; }
.podium-slot.is-second { order: 1; }
.podium-base {
  margin-top: 0.75rem;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  padding: 0.85rem 0.5rem 1.1rem;
  font-family: var(--font-display);
  font-weight: 700;
}
.podium-slot.is-first .podium-base {
  background: linear-gradient(180deg, #ffe8a3, #ffd55a);
  min-height: 5.5rem;
}
.podium-slot.is-second .podium-base {
  background: linear-gradient(180deg, #c8f3ef, #8ee0d8);
  min-height: 4rem;
}
.crown {
  display: inline-block;
  margin-bottom: 0.25rem;
  font-size: 1.25rem;
  animation: pop 0.5s ease 0.2s both;
}
.kid-name { font-family: var(--font-display); font-weight: 600; margin: 0.4rem 0 0.15rem; }
.progress-wrap { margin-top: 0.35rem; }
.progress {
  height: 0.45rem; background: rgba(0,0,0,0.08); border-radius: 999px; overflow: hidden;
}
.progress > span {
  display: block; height: 100%; background: linear-gradient(90deg, var(--coral), var(--gold));
  border-radius: inherit; transition: width 0.4s ease;
}
.progress-label { font-size: 0.8rem; color: var(--muted); margin-top: 0.25rem; }

.rank-list .card-row { padding: 0.15rem 0; }
.rank-num {
  width: 1.75rem; height: 1.75rem; border-radius: 50%;
  background: #f3eef0; display: grid; place-items: center;
  font-weight: 800; font-size: 0.85rem;
}

.task-icon {
  width: 3rem; height: 3rem; border-radius: 1rem;
  display: grid; place-items: center;
  background: #fff0eb; font-size: 1.25rem; flex-shrink: 0;
}
.task-meta { flex: 1; min-width: 0; }
.task-meta h3 { font-size: 1.05rem; margin: 0 0 0.15rem; }
.task-meta p { margin: 0; color: var(--muted); font-size: 0.85rem; }
.badge {
  display: inline-flex; align-items: center; gap: 0.25rem;
  border-radius: 999px; padding: 0.2rem 0.55rem;
  font-size: 0.75rem; font-weight: 800;
}
.badge-open { background: #fff3cd; color: #8a6d00; }
.badge-done { background: #d8f5f1; color: #0f6e64; }
.badge-missed { background: #ffe0e0; color: #a33; }

.kid-pick {
  display: grid; gap: 0.75rem; margin-top: 1rem;
}
.kid-pick button {
  min-height: 5rem; font-size: 1.25rem;
  border-radius: var(--radius);
  border: none; color: #fff; font-family: var(--font-display); font-weight: 700;
  cursor: pointer; box-shadow: var(--shadow);
}
.kid-pick button:disabled { opacity: 0.45; cursor: default; }

.timer {
  font-family: var(--font-display);
  font-size: 2.5rem; text-align: center; margin: 1rem 0;
  color: var(--green-deep);
}

.bottom-nav {
  position: fixed; left: 50%; bottom: 0.85rem; transform: translateX(-50%);
  width: min(24rem, calc(100% - 1.5rem));
  display: grid; grid-template-columns: repeat(3, 1fr);
  background: #fff; border-radius: 1.25rem;
  box-shadow: 0 12px 40px rgba(44,42,50,0.15);
  padding: 0.4rem;
  z-index: 20;
}
.bottom-nav a {
  text-decoration: none; color: var(--muted);
  display: flex; flex-direction: column; align-items: center; gap: 0.15rem;
  padding: 0.55rem 0.25rem; border-radius: 1rem;
  font-size: 0.75rem; font-weight: 800;
}
.bottom-nav a.is-active { background: #ffe8e4; color: var(--coral); }
.nav-icon { font-size: 1.1rem; line-height: 1; }

.modal {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(44,42,50,0.45);
  display: grid; place-items: center; padding: 1.25rem;
  animation: fade 0.2s ease;
}
.modal[hidden] { display: none; }
.modal-card {
  background: #fff; border-radius: 1.75rem; padding: 1.75rem 1.5rem;
  text-align: center; width: min(22rem, 100%);
  box-shadow: var(--shadow); animation: pop 0.35s ease;
}
.modal-badge {
  width: 4.5rem; height: 4.5rem; margin: 0 auto 0.75rem;
  border-radius: 50%; background: linear-gradient(145deg, #ffe8a3, #ffd55a);
  display: grid; place-items: center; font-size: 2rem; color: #fff;
}
.modal-points { font-size: 1.5rem; font-weight: 800; color: var(--coral); margin: 0.5rem 0 1.25rem; }

.login-card { max-width: 22rem; margin: 3rem auto; }
.form-group { margin-bottom: 1rem; }
.form-group label { display: block; font-weight: 700; margin-bottom: 0.35rem; }
input[type="text"], input[type="password"], input[type="number"], select, textarea {
  width: 100%; padding: 0.85rem 1rem; border-radius: var(--radius-sm);
  border: 2px solid #efe7ea; font: inherit; background: #fff;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--coral); }

.admin-header {
  background: var(--green-deep); color: #fff;
  margin: -0.75rem -1.25rem 1.25rem; padding: 1.25rem 1.25rem 1.5rem;
  border-radius: 0 0 1.75rem 1.75rem;
}
.admin-header a { color: #c8f3ef; }
.flash { padding: 0.75rem 1rem; border-radius: var(--radius-sm); margin-bottom: 1rem; font-weight: 700; }
.flash-ok { background: #d8f5f1; color: #0f6e64; }
.flash-err { background: #ffe0e0; color: #a33; }

.timeline { border-left: 3px solid #efe7ea; margin: 1rem 0 0 0.75rem; padding-left: 1rem; }
.timeline-item { position: relative; padding-bottom: 1rem; }
.timeline-item::before {
  content: ""; position: absolute; left: -1.35rem; top: 0.25rem;
  width: 0.75rem; height: 0.75rem; border-radius: 50%;
  background: #ccc; border: 2px solid #fff;
}
.timeline-item.is-done::before { background: var(--teal); }
.timeline-item.is-missed::before { background: var(--coral); }
.timeline-item h4 { margin: 0 0 0.15rem; font-size: 1rem; }
.timeline-item p { margin: 0; color: var(--muted); font-size: 0.85rem; }

.reward-card.is-unlocked { border: 2px solid var(--coral); }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; }
@media (max-width: 520px) { .grid-2 { grid-template-columns: 1fr; } }

@keyframes rise { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
@keyframes pop { from { opacity: 0; transform: scale(0.92); } to { opacity: 1; transform: scale(1); } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

.admin-layout .bottom-nav { display: none; }
body.admin-layout { padding-bottom: 1.5rem; }
