:root {
  --bg: #F6EBDD;
  --bg-deep: #EEDCC8;
  --card: #FFF9F2;
  --line: #EBD9C6;
  --ink: #5E4334;
  --ink-soft: #9C7E69;
  --pink: #F3AFC0;
  --pink-deep: #E2809D;
  --pink-dark: #C9617F;
  --pink-pale: #FCE4EA;
  --cream: #FFFDF9;
  --shadow: 0 10px 24px -14px rgba(120, 72, 48, .45);
  --radius: 28px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { background: var(--bg); }
body {
  margin: 0;
  min-height: 100vh;
  font-family: "Nunito", ui-rounded, "SF Pro Rounded", system-ui, sans-serif;
  font-weight: 700;
  color: var(--ink);
  background-color: var(--bg);
  /* узор из лапок */
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120' viewBox='0 0 120 120'%3E%3Cg fill='%23ECD8C3'%3E%3Cg transform='translate(14 18) rotate(-18) scale(.36)'%3E%3Cpath d='M32 30c-9 0-18 9-18 17 0 6 5 8 9 8 4 0 6-2 9-2s5 2 9 2c4 0 9-2 9-8 0-8-9-17-18-17z'/%3E%3Cellipse cx='13' cy='27' rx='6' ry='8'/%3E%3Cellipse cx='25' cy='15' rx='6' ry='8'/%3E%3Cellipse cx='39' cy='15' rx='6' ry='8'/%3E%3Cellipse cx='51' cy='27' rx='6' ry='8'/%3E%3C/g%3E%3Cg transform='translate(72 70) rotate(22) scale(.3)'%3E%3Cpath d='M32 30c-9 0-18 9-18 17 0 6 5 8 9 8 4 0 6-2 9-2s5 2 9 2c4 0 9-2 9-8 0-8-9-17-18-17z'/%3E%3Cellipse cx='13' cy='27' rx='6' ry='8'/%3E%3Cellipse cx='25' cy='15' rx='6' ry='8'/%3E%3Cellipse cx='39' cy='15' rx='6' ry='8'/%3E%3Cellipse cx='51' cy='27' rx='6' ry='8'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
  -webkit-user-select: none;
  user-select: none;
  overflow-x: hidden;
}
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; }
h1, h2, h3 { margin: 0; font-weight: 900; }
svg { display: block; }

.app {
  max-width: 480px;
  margin: 0 auto;
  padding: 12px 16px calc(96px + var(--safe-bottom));
}

/* ---------- шапка ---------- */
.hero { text-align: center; padding-top: 4px; }
.topline {
  display: flex; justify-content: space-between; align-items: center;
  min-height: 28px; font-size: 14px; color: var(--ink-soft);
}
.chip {
  background: var(--pink-pale); color: var(--pink-dark);
  border-radius: 999px; padding: 4px 10px; font-weight: 800; font-size: 13px;
}
.hero h1 { font-size: 30px; letter-spacing: -.5px; margin: 2px 0 6px; }

.cats { display: flex; justify-content: center; gap: 6px; }
.cat {
  position: relative; width: 31%; max-width: 124px;
  display: flex; flex-direction: column; align-items: center;
}
.cat svg { width: 100%; height: auto; overflow: visible; transition: transform .25s; }
.cat-pillow {
  width: 80%; height: 14px; margin-top: -10px; border-radius: 50%;
  background: radial-gradient(ellipse at 50% 30%, #F8C9D5, #EBA3B6);
  box-shadow: 0 4px 0 #DE90A6;
}
.cat-name {
  margin-top: 8px; font-size: 14px; font-weight: 900;
  background: var(--card); border-radius: 999px; padding: 2px 12px;
  box-shadow: 0 2px 0 var(--line);
}
.cat.happy svg { animation: bob 2.4s ease-in-out infinite; }
.cat:nth-child(2).happy svg { animation-delay: -.8s; }
.cat:nth-child(3).happy svg { animation-delay: -1.6s; }
.cat.sad svg { transform: translateY(4px); }
.cat.tapped svg { animation: wiggle .5s ease; }
@keyframes bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-5px); } }
@keyframes wiggle {
  0% { transform: rotate(0); } 25% { transform: rotate(-8deg) scale(1.05); }
  60% { transform: rotate(6deg) scale(1.05); } 100% { transform: rotate(0); }
}
.speech {
  position: absolute; top: -8px; left: 50%; z-index: 5;
  transform: translate(-50%, -100%);
  background: var(--cream); border-radius: 16px; padding: 6px 10px;
  font-size: 12px; font-weight: 800; white-space: nowrap;
  box-shadow: var(--shadow); animation: speech 2.2s ease forwards;
  pointer-events: none;
}
.speech::after {
  content: ""; position: absolute; left: 50%; bottom: -6px; margin-left: -6px;
  border: 6px solid transparent; border-top-color: var(--cream); border-bottom: 0;
}
@keyframes speech {
  0% { opacity: 0; transform: translate(-50%, -80%) scale(.8); }
  12%, 80% { opacity: 1; transform: translate(-50%, -100%) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -110%) scale(1); }
}

.newday { margin: 8px 0 4px; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.newday-btn {
  padding: 10px 20px; border-radius: 999px; font-size: 16px; font-weight: 900; color: #6E2741;
  background: linear-gradient(180deg, #FDE7C9, #F6C2CF); box-shadow: 0 4px 0 #DFA0B2;
  animation: glow 2.4s ease-in-out infinite;
}
.newday-btn:active { transform: translateY(3px); box-shadow: 0 1px 0 #DFA0B2; }
@keyframes glow { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.04); } }
.newday-note { font-size: 12px; color: var(--ink-soft); text-align: center; max-width: 300px; }
.undo-link.inline { display: inline-block; margin: 0 0 0 4px; }
.date { display: flex; align-items: center; gap: 6px; }
.navbtn {
  width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center;
  background: var(--card); box-shadow: 0 2px 0 var(--line); font-size: 20px; line-height: 1; font-weight: 900; color: var(--pink-dark);
}
.navbtn:disabled { opacity: .3; }
.navbtn:not(:disabled):active { transform: translateY(2px); box-shadow: none; }
.past-bar {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 8px;
  background: var(--pink-pale); color: #9A4F67; border-radius: 18px; padding: 8px 12px; font-size: 13px; max-width: 360px;
}
.today-btn { background: var(--card); color: var(--pink-dark); border-radius: 999px; padding: 4px 12px; font-weight: 900; font-size: 13px; box-shadow: 0 2px 0 #E7B3C2; }
.extra-row { display: flex; flex-direction: column; align-items: center; margin-top: 10px; }
.extras { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px; margin-top: 4px; }
.extras:empty { display: none; }
.food-status .extras { justify-content: flex-start; }
.extra-chip {
  display: inline-flex; align-items: center; gap: 4px; font-size: 11px; font-weight: 800; color: var(--ink);
  background: var(--bg-deep); border-radius: 999px; padding: 2px 8px;
}
.undo-x { color: var(--pink-dark); font-weight: 900; font-size: 12px; padding: 0 2px; }
/* «＋ Ещё раз» — маленький пузырь поп-ита */
.again-btn {
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  margin: 10px auto 0; padding: 0; background: none;
}
.bubble-sm {
  width: 46px; height: 46px; font-size: 24px; font-weight: 900; line-height: 1;
  color: #7A3550; text-shadow: 0 1px 0 rgba(255, 255, 255, .6);
  box-shadow: 0 5px 0 #D27392, 0 9px 14px -6px rgba(201, 97, 127, .55),
    inset 0 -5px 9px rgba(160, 60, 95, .18), inset 0 5px 8px rgba(255, 255, 255, .65);
}
.again-btn:active .bubble-sm {
  transform: translateY(4px) scale(.95);
  box-shadow: 0 1px 0 #D27392, inset 0 6px 10px rgba(170, 70, 100, .35);
}
.again-lbl { font-size: 11px; font-weight: 900; color: var(--pink-dark); }
.food-status .again-btn { margin: 10px 0 0; width: fit-content; }
.progress { margin: 14px 0 6px; }
.paw-progress { display: flex; justify-content: center; gap: 8px; }
.paw-progress .p { width: 30px; height: 30px; transition: transform .3s; }
.paw-progress .p.on { transform: scale(1.12) rotate(-8deg); }
.progress-label { margin-top: 6px; font-size: 14px; color: var(--ink-soft); }

/* ---------- карточки ---------- */
main { margin-top: 10px; }
.tab { display: none; }
.tab.active { display: block; animation: fadein .25s ease; }
@keyframes fadein { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.card {
  position: relative;
  background: var(--card);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 16px;
  box-shadow: 0 4px 0 var(--line), var(--shadow);
}
.card.eared { margin-top: 26px; }
.card.eared .ear { position: absolute; top: -30px; width: 58px; height: 38px; }
.card.eared .ear svg { width: 100%; height: 100%; }
.card.eared .ear.l { left: 26px; transform: rotate(-8deg); }
.card.eared .ear.r { right: 26px; transform: scaleX(-1) rotate(-8deg); }

.card-head, .section-head {
  display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 12px;
}
.card-head h2, .section-head h2 { font-size: 19px; }
.count { font-size: 14px; font-weight: 900; color: var(--pink-dark); }

/* ---------- поп-ит пузыри ---------- */
.bubble {
  position: relative;
  display: grid; place-items: center;
  border-radius: 50%;
  background: radial-gradient(circle at 34% 28%, #FFEFF3 0%, #F8C3D0 38%, #EE9DB4 78%, #E2809D 100%);
  box-shadow:
    0 7px 0 #D27392,
    0 14px 22px -8px rgba(201, 97, 127, .55),
    inset 0 -8px 14px rgba(160, 60, 95, .18),
    inset 0 8px 12px rgba(255, 255, 255, .65);
  transition: transform .12s ease, box-shadow .12s ease, background .2s;
  touch-action: manipulation;
}
.bubble:active:not(.done) {
  transform: translateY(5px) scale(.97);
  box-shadow: 0 2px 0 #D27392, 0 6px 12px -8px rgba(201, 97, 127, .55),
    inset 0 -4px 10px rgba(160, 60, 95, .2), inset 0 6px 10px rgba(255, 255, 255, .5);
}
/* продавленный пузырь — дело сделано */
.bubble.done {
  transform: translateY(5px);
  background: radial-gradient(circle at 62% 70%, #FFF3F6 0%, #F9D3DD 45%, #F0B4C4 100%);
  box-shadow:
    0 2px 0 #E7B3C2,
    inset 0 10px 18px rgba(170, 70, 100, .38),
    inset 0 -6px 10px rgba(255, 255, 255, .7);
}
.bubble.squish { animation: squish .42s cubic-bezier(.3, 1.6, .5, 1); }
@keyframes squish {
  0% { transform: translateY(5px) scale(.9, .86); }
  55% { transform: translateY(3px) scale(1.06, 1.08); }
  100% { transform: translateY(5px) scale(1); }
}

.bubble-xl { width: 188px; height: 188px; margin: 6px auto 18px; }
.bubble-face {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  font-size: 19px; line-height: 1.1; font-weight: 900; color: #7A3550;
  text-shadow: 0 1px 0 rgba(255, 255, 255, .6);
}
.bubble-face svg { width: 62px; height: 62px; }
.bubble.done .bubble-face { color: var(--pink-dark); opacity: .9; }

.mini-row { display: flex; justify-content: center; gap: 28px; }
.mini { display: flex; flex-direction: column; align-items: center; gap: 6px; min-width: 84px; }
.mini .dot {
  width: 30px; height: 30px; border-radius: 50%;
  background: radial-gradient(circle at 34% 28%, #FFEFF3, #F2B2C3 60%, #E58AA5);
  box-shadow: 0 3px 0 #D27392, inset 0 4px 6px rgba(255, 255, 255, .6);
}
.mini .dot.done {
  background: radial-gradient(circle at 62% 70%, #FFF3F6, #F3BFCD);
  box-shadow: 0 1px 0 #E7B3C2, inset 0 5px 8px rgba(170, 70, 100, .35);
  transform: translateY(2px);
}
.mini .lbl { font-size: 12px; color: var(--ink-soft); text-align: center; line-height: 1.25; }
.mini .lbl b { color: var(--ink); }

.bubble-row { display: flex; justify-content: space-between; gap: 8px; }
.bubble-cell { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.bubble-md { width: 88px; height: 88px; }
.bubble-md svg { width: 40px; height: 40px; }
.cell-title { font-size: 15px; font-weight: 900; }
.cell-sub { font-size: 12px; color: var(--ink-soft); margin-top: -6px; min-height: 15px; text-align: center; }

.undo-link {
  display: block; margin: 5px auto 0; padding: 3px 10px; border-radius: 999px;
  background: var(--pink-pale); color: var(--pink-dark);
  font-size: 11px; font-weight: 900; line-height: 1.3;
}
.undo-link:active { transform: scale(.95); }
.food-status .undo-link { margin: 6px 0 0; width: fit-content; }
.food-card { display: flex; align-items: center; gap: 18px; }
.food-card .bubble-md { flex: 0 0 auto; width: 96px; height: 96px; }
.food-text h2 { font-size: 19px; }
.food-status { font-size: 14px; color: var(--ink-soft); margin-top: 4px; }

/* ---------- ачивки ---------- */
.section-head { margin: 8px 4px 14px; }
.ach-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.ach {
  background: var(--card); border-radius: 22px; padding: 22px 12px 14px;
  text-align: center; box-shadow: 0 3px 0 var(--line), var(--shadow);
  display: flex; flex-direction: column; align-items: center; gap: 6px;
}
.badge {
  position: relative; width: 64px; height: 64px; border-radius: 50%;
  display: grid; place-items: center; font-size: 30px;
  background: radial-gradient(circle at 34% 28%, #FFEFF3, #F5B7C7 60%, #E58AA5);
  box-shadow: 0 4px 0 #D27392, inset 0 6px 8px rgba(255, 255, 255, .55);
}
.badge::before, .badge::after {
  content: ""; position: absolute; top: -8px; width: 22px; height: 22px;
  background: inherit; border-radius: 4px 12px 2px 12px; z-index: -1;
}
.badge::before { left: 2px; transform: rotate(-20deg); background: #F2AFC0; }
.badge::after { right: 2px; transform: rotate(20deg) scaleX(-1); background: #F2AFC0; }
.ach.locked .badge {
  background: radial-gradient(circle at 34% 28%, #FBF3EA, #EADBCB);
  box-shadow: 0 4px 0 #DCC8B3;
}
.ach.locked .badge::before, .ach.locked .badge::after { background: #E6D5C3; }
.ach.locked .badge span { filter: grayscale(1); opacity: .45; }
.ach h3 { font-size: 15px; line-height: 1.15; }
.ach p { margin: 0; font-size: 12px; color: var(--ink-soft); line-height: 1.3; }
.ach .date { font-size: 11px; color: var(--pink-dark); font-weight: 800; }
.bar { width: 100%; height: 8px; border-radius: 99px; background: var(--bg-deep); overflow: hidden; margin-top: 2px; }
.bar i { display: block; height: 100%; border-radius: 99px; background: linear-gradient(90deg, var(--pink), var(--pink-deep)); }
.bar-label { font-size: 11px; color: var(--ink-soft); }

/* ---------- статистика ---------- */
.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 16px; }
.tile {
  background: var(--card); border-radius: 22px; padding: 14px 16px;
  box-shadow: 0 3px 0 var(--line), var(--shadow);
}
.tile .num { font-size: 30px; font-weight: 900; line-height: 1.1; }
.tile .num small { font-size: 15px; color: var(--ink-soft); }
.tile .cap { font-size: 13px; color: var(--ink-soft); }
.tile.accent { background: linear-gradient(160deg, #FCE4EA, #F6C2CF); }
.tile.accent .cap { color: #9A4F67; }

.history { display: grid; grid-template-columns: repeat(7, 1fr); gap: 10px 6px; }
.hday { display: flex; flex-direction: column; align-items: center; gap: 4px; font-size: 11px; color: var(--ink-soft); }
.hring {
  width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center;
  background: conic-gradient(var(--pink-deep) calc(var(--p) * 1%), var(--bg-deep) 0);
}
.hring::before { content: ""; width: 24px; height: 24px; border-radius: 50%; background: var(--card); grid-area: 1 / 1; }
.hring svg { grid-area: 1 / 1; width: 20px; height: 20px; z-index: 1; }
.hring span { grid-area: 1 / 1; z-index: 1; font-size: 13px; font-weight: 900; color: var(--ink); }
.hring.zero span { color: var(--ink-soft); opacity: .5; }
.hday.today { color: var(--pink-dark); font-weight: 900; }

.totals { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; text-align: center; }
.totals .t svg { width: 40px; height: 40px; margin: 0 auto 4px; }
.totals .t b { display: block; font-size: 22px; font-weight: 900; }
.totals .t span { font-size: 12px; color: var(--ink-soft); }

.leaders { display: flex; flex-direction: column; gap: 10px; }
.leader { display: grid; grid-template-columns: 28px 1fr auto; align-items: center; gap: 10px; }
.leader .medal { font-size: 20px; text-align: center; }
.leader .nm { font-weight: 900; font-size: 15px; }
.leader .bar { height: 10px; margin-top: 4px; }
.leader .cnt { font-weight: 900; color: var(--pink-dark); }
.family-line {
  display: flex; gap: 10px; margin-bottom: 16px;
}
.family-line > div {
  flex: 1; background: var(--pink-pale); border-radius: 18px; padding: 10px 12px;
}
.family-line b { display: block; font-size: 22px; font-weight: 900; }
.family-line span { font-size: 12px; color: #9A4F67; }
.legend { margin-top: 12px; font-size: 12px; color: var(--ink-soft); text-align: center; }
.empty { color: var(--ink-soft); font-size: 14px; text-align: center; padding: 6px 0; }

/* ---------- нижнее меню ---------- */
.tabbar {
  position: fixed; left: 50%; bottom: calc(12px + var(--safe-bottom)); transform: translateX(-50%);
  width: min(448px, calc(100% - 32px));
  display: flex; gap: 4px; padding: 6px;
  background: rgba(255, 249, 242, .94); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border-radius: 999px; box-shadow: 0 4px 0 var(--line), 0 12px 30px -12px rgba(120, 72, 48, .5);
  z-index: 20;
}
.tabbtn {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 7px 4px 6px; border-radius: 999px; font-size: 12px; font-weight: 800; color: var(--ink-soft);
  transition: background .2s, color .2s;
}
.tabbtn .tabicon svg { width: 22px; height: 22px; }
.tabbtn.active { background: var(--pink-pale); color: var(--pink-dark); }

/* ---------- эффекты ---------- */
.fx { position: fixed; inset: 0; pointer-events: none; z-index: 60; overflow: hidden; }
.paw-particle { position: absolute; will-change: transform, opacity; }
.paw-particle svg { width: 100%; height: 100%; }
.ring {
  position: absolute; border-radius: 50%; border: 6px solid var(--pink);
  transform: translate(-50%, -50%); will-change: transform, opacity;
}

.toast {
  position: fixed; left: 50%; bottom: calc(92px + var(--safe-bottom));
  transform: translate(-50%, 30px); opacity: 0; pointer-events: none;
  width: max-content; max-width: calc(100% - 32px);
  display: flex; align-items: center; gap: 12px;
  background: var(--ink); color: var(--cream);
  padding: 10px 10px 10px 16px; border-radius: 999px;
  font-size: 14px; font-weight: 800; z-index: 70;
  transition: transform .25s cubic-bezier(.3, 1.4, .5, 1), opacity .2s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; }
.toast:not(:has(button)) { padding-right: 16px; }
.toast button {
  background: var(--pink); color: #6E2741; border-radius: 999px; padding: 6px 12px; font-weight: 900; font-size: 13px;
}

.modal {
  position: fixed; inset: 0; z-index: 80; display: grid; place-items: center; padding: 24px;
  background: rgba(94, 67, 52, .45); backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px);
  animation: fadein .2s ease;
}
.modal[hidden] { display: none; }
.modal-card {
  position: relative; width: min(340px, 100%); background: var(--card); border-radius: 32px;
  padding: 36px 24px 22px; text-align: center; box-shadow: 0 6px 0 var(--line), var(--shadow);
  animation: popin .45s cubic-bezier(.3, 1.6, .5, 1);
}
@keyframes popin { from { transform: scale(.6); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.modal-card .badge { width: 104px; height: 104px; font-size: 52px; margin: 0 auto 16px; }
.modal-card .badge::before, .modal-card .badge::after { width: 36px; height: 36px; top: -12px; }
.modal-card .kicker { font-size: 13px; text-transform: uppercase; letter-spacing: 1.5px; color: var(--pink-dark); font-weight: 900; }
.modal-card h3 { font-size: 24px; margin: 4px 0 6px; }
.modal-card p { margin: 0 0 20px; color: var(--ink-soft); font-size: 15px; }
.btn {
  width: 100%; padding: 14px; border-radius: 999px; font-size: 17px; font-weight: 900; color: #6E2741;
  background: linear-gradient(180deg, #F8C3D0, #EE9DB4); box-shadow: 0 5px 0 #D27392;
}
.btn:active { transform: translateY(4px); box-shadow: 0 1px 0 #D27392; }
.modal-btns { display: flex; flex-direction: column; gap: 10px; }
.btn-secondary { background: var(--bg-deep); color: var(--ink); box-shadow: 0 5px 0 var(--line); }

.blocker {
  position: fixed; inset: 0; z-index: 90; display: grid; place-items: center; padding: 32px;
  background: var(--bg); text-align: center; font-size: 17px;
}
.blocker[hidden] { display: none; }
.blocker svg { width: 140px; margin: 0 auto 16px; }

@media (prefers-reduced-motion: reduce) {
  .cat.happy svg, .newday-btn { animation: none; }
}
@media (max-width: 360px) {
  .bubble-md { width: 76px; height: 76px; }
  .bubble-xl { width: 164px; height: 164px; }
  .hero h1 { font-size: 26px; }
}
