/* Dailo: палитра и общие стили. Цвета свои и не зависят от темы Telegram. */

:root {
  --mint: #cfe8d5;
  --green: #a8c66c;
  --green-deep: #6f9440;
  --cream: #fbf3dd;
  --beige: #ead9b8;
  --pink: #f6c6c9;
  --lavender: #cfc3ea;
  --yellow: #f7d774;
  --ink: #2f3b2a;
  --ink-soft: #6b7562;
  --card: #fffaf0;
  --radius: 18px;
  --nav-height: 64px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

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

html, body {
  margin: 0;
  height: 100%;
  background: var(--beige);
  color: var(--ink);
  font: 16px/1.4 ui-rounded, "SF Pro Rounded", "Nunito", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  overscroll-behavior: none;
}

button { font: inherit; color: inherit; border: 0; background: none; padding: 0; cursor: pointer; }
button:disabled { cursor: default; }
button:focus-visible, input:focus-visible { outline: 3px solid var(--green-deep); outline-offset: 2px; }
h1, h2, h3, p { margin: 0; }
img { display: block; max-width: 100%; }

/* Колонка приложения: на широком экране остаётся шириной с телефон. */
#app {
  position: relative;
  max-width: 480px;
  height: 100dvh;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  background: var(--cream);
  overflow: hidden;
}

.icon { display: inline-flex; flex: none; }
.icon svg { display: block; }

/* ---------- Плашка демо-режима ---------- */
.demo-banner {
  flex: none;
  padding: 4px 12px;
  background: var(--lavender);
  font-size: 12px;
  text-align: center;
}

/* ---------- Верхняя панель ---------- */
.topbar {
  flex: none;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  background: var(--cream);
  border-bottom: 2px solid var(--beige);
}
.level-badge {
  flex: none;
  width: 40px; height: 40px;
  display: grid; place-items: center;
  border-radius: 50%;
  background: var(--yellow);
  border: 2px solid var(--ink);
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}
.topbar-main { flex: 1; min-width: 0; }
.topbar-line { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.rank { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.xp-text { flex: none; font-size: 12px; color: var(--ink-soft); font-variant-numeric: tabular-nums; }
.xp-bar { height: 10px; margin-top: 4px; border-radius: 6px; background: var(--beige); border: 2px solid var(--ink); overflow: hidden; }
.xp-fill { height: 100%; background: var(--green); transition: width .4s ease; }
.coins {
  flex: none;
  display: flex; align-items: center; gap: 4px;
  padding: 4px 10px 4px 6px;
  border-radius: 999px;
  background: var(--card);
  border: 2px solid var(--ink);
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

/* ---------- Область экрана и нижнее меню ---------- */
.screen { flex: 1; min-height: 0; overflow-y: auto; overflow-x: hidden; padding: 12px; -webkit-overflow-scrolling: touch; }
.screen-title { font-size: 20px; font-weight: 800; margin-bottom: 10px; }

.nav {
  flex: none;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  height: calc(var(--nav-height) + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  background: var(--card);
  border-top: 2px solid var(--beige);
}
.nav-item {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  font-size: 12px; font-weight: 700; color: var(--ink-soft);
}
.nav-item.is-current { color: var(--ink); }
.nav-item.is-current .icon { background: var(--mint); border-radius: 12px; padding: 2px 12px; }
.nav-item .icon { padding: 2px 12px; }

/* ---------- Кнопки ---------- */
.button {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 44px; padding: 8px 16px;
  border-radius: 14px;
  background: var(--green);
  border: 2px solid var(--ink);
  box-shadow: 0 3px 0 var(--ink);
  font-weight: 800;
  text-align: center;
}
.button:active:not(:disabled) { transform: translateY(2px); box-shadow: 0 1px 0 var(--ink); }
.button.is-soft { background: var(--card); }
.button.is-pink { background: var(--pink); }
.button:disabled { background: var(--beige); color: var(--ink-soft); border-color: var(--ink-soft); box-shadow: none; }
.button.is-wide { width: 100%; }
.icon-button { width: 40px; height: 40px; display: grid; place-items: center; border-radius: 12px; }

/* ---------- Сад ---------- */
.garden { display: flex; flex-direction: column; gap: 10px; height: 100%; }
/* Окно сцены: если экран низкий, сверху обрезается небо, трава остаётся на месте. */
.scene {
  position: relative;
  flex: 1 1 auto;
  min-height: 300px;
  max-height: calc((min(100vw, 480px) - 24px) * 1.5);
  border-radius: var(--radius);
  border: 2px solid var(--ink);
  overflow: hidden;
  background: var(--green);
}
.scene-canvas {
  position: absolute; left: 0; right: 0; bottom: 0;
  aspect-ratio: 2 / 3;
  background: url("../assets/backgrounds/garden.jpg") center / 100% 100% no-repeat;
}
.scene-item { position: absolute; display: block; }
.scene-item img { width: 100%; height: auto; pointer-events: none; user-select: none; -webkit-user-drag: none; }
.scene-frog { pointer-events: none; }
.scene-frog.is-happy { animation: hop .5s ease 2; }
@keyframes hop { 50% { margin-top: -4%; } }
.slot-empty {
  position: absolute;
  width: 11%; aspect-ratio: 1;
  transform: translate(-50%, -70%);
  display: grid; place-items: center;
  border-radius: 50%;
  background: rgba(251, 243, 221, .55);
  border: 2px dashed rgba(47, 59, 42, .55);
  color: var(--ink);
}
.slot-empty.is-decor { border-radius: 30%; }
.garden-info {
  flex: none;
  display: flex; flex-direction: column; gap: 8px;
  padding: 10px 12px;
  border-radius: var(--radius);
  background: var(--card);
  border: 2px solid var(--beige);
}
.garden-today { font-weight: 700; }
.garden-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.garden-actions .button { padding: 8px 6px; font-size: 15px; white-space: nowrap; }

/* ---------- Задания ---------- */
.section-title { margin: 14px 0 6px; font-size: 14px; font-weight: 800; color: var(--ink-soft); text-transform: uppercase; letter-spacing: .04em; }
.section-title:first-child { margin-top: 0; }
.task {
  display: flex; align-items: center; gap: 10px;
  padding: 10px;
  margin-bottom: 8px;
  border-radius: var(--radius);
  background: var(--card);
  border: 2px solid var(--beige);
}
.task-check {
  flex: none;
  width: 40px; height: 40px;
  display: grid; place-items: center;
  border-radius: 50%;
  border: 2px solid var(--ink);
  background: var(--cream);
  color: transparent;
}
.task-check.is-done { background: var(--green); color: var(--ink); }
.task-check.is-later { border-style: dashed; border-color: var(--ink-soft); }
.task-body { flex: 1; min-width: 0; text-align: left; }
.task-title { font-weight: 700; overflow-wrap: anywhere; }
.task.is-done .task-title { text-decoration: line-through; color: var(--ink-soft); }
.task-meta { font-size: 13px; color: var(--ink-soft); }
.task-reward { flex: none; font-size: 12px; font-weight: 700; text-align: right; color: var(--ink-soft); white-space: nowrap; }
.empty { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 24px 12px; text-align: center; color: var(--ink-soft); }
.empty img { width: 140px; }
.sticky-action { position: sticky; bottom: 0; padding-top: 8px; background: linear-gradient(transparent, var(--cream) 30%); }

/* ---------- Форма задачи ---------- */
.field { margin-bottom: 14px; }
.field-label { display: block; margin-bottom: 6px; font-size: 14px; font-weight: 800; }
.field-error { margin-top: 4px; font-size: 13px; font-weight: 700; color: #a8323a; }
.input {
  width: 100%; min-height: 44px; padding: 8px 12px;
  border-radius: 12px; border: 2px solid var(--ink);
  background: #fff; color: var(--ink); font: inherit;
}
.choices { display: flex; flex-wrap: wrap; gap: 6px; }
.choice {
  min-height: 40px; padding: 6px 12px;
  border-radius: 12px; border: 2px solid var(--beige);
  background: var(--card); font-weight: 700; font-size: 14px;
}
.choice.is-on { border-color: var(--ink); background: var(--mint); }
.choice small { display: block; font-weight: 600; color: var(--ink-soft); }

/* ---------- Магазин ---------- */
.tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-bottom: 12px; padding: 4px; border-radius: 14px; background: var(--beige); }
.tab { min-height: 40px; border-radius: 10px; font-weight: 800; color: var(--ink-soft); }
.tab.is-on { background: var(--card); color: var(--ink); box-shadow: 0 0 0 2px var(--ink); }
.cards { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.card {
  display: flex; flex-direction: column; gap: 6px;
  padding: 10px;
  border-radius: var(--radius);
  background: var(--card);
  border: 2px solid var(--beige);
}
.card-picture { height: 110px; display: grid; place-items: center; border-radius: 12px; background: var(--mint); }
.card-picture img { max-height: 100px; max-width: 90%; object-fit: contain; }
.card-name { font-weight: 800; }
.card-about { flex: 1; font-size: 13px; color: var(--ink-soft); }
.card-price { display: flex; align-items: center; gap: 4px; font-weight: 800; }
.card .button { min-height: 40px; padding: 6px 8px; font-size: 14px; }

/* ---------- Профиль ---------- */
.profile-head { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.profile-head img { width: 84px; }
.profile-name { font-size: 20px; font-weight: 800; overflow-wrap: anywhere; }
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.stat { padding: 10px; border-radius: 14px; background: var(--card); border: 2px solid var(--beige); }
.stat-value { font-size: 20px; font-weight: 800; font-variant-numeric: tabular-nums; }
.stat-label { font-size: 12px; color: var(--ink-soft); }
.achievement { display: flex; align-items: center; gap: 10px; padding: 8px 10px; margin-bottom: 6px; border-radius: 14px; background: var(--card); border: 2px solid var(--beige); }
.achievement.is-locked { opacity: .55; filter: grayscale(1); }
.achievement-name { font-weight: 700; }
.achievement-hint { font-size: 13px; color: var(--ink-soft); }
.collection { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px 4px 4px; border-radius: 999px; background: var(--card); border: 2px solid var(--beige); font-size: 14px; font-weight: 700; }
.chip img { width: 28px; height: 28px; object-fit: contain; }
.chip.is-text { padding-left: 10px; }

/* ---------- Панель снизу ---------- */
.sheet-overlay { position: absolute; inset: 0; z-index: 20; display: flex; align-items: flex-end; background: rgba(47, 59, 42, .45); }
.sheet {
  width: 100%; max-height: 88%;
  display: flex; flex-direction: column;
  border-radius: 22px 22px 0 0;
  background: var(--cream);
  border-top: 2px solid var(--ink);
  padding-bottom: var(--safe-bottom);
  animation: rise .2s ease;
}
@keyframes rise { from { transform: translateY(30%); opacity: 0; } }
.sheet-head { flex: none; display: flex; align-items: center; justify-content: space-between; padding: 10px 8px 4px 16px; }
.sheet-head h2 { font-size: 18px; font-weight: 800; }
.sheet-body { overflow-y: auto; padding: 8px 16px 16px; }
.pick {
  width: 100%;
  display: flex; align-items: center; gap: 10px;
  padding: 8px; margin-bottom: 8px;
  border-radius: 14px; background: var(--card); border: 2px solid var(--beige);
  text-align: left; font-weight: 700;
}
.pick img { width: 48px; height: 48px; object-fit: contain; }
.pick small { display: block; font-weight: 600; color: var(--ink-soft); }
.stack { display: flex; flex-direction: column; gap: 8px; }

/* ---------- Сообщения ---------- */
.toast {
  position: absolute; left: 12px; right: 12px; z-index: 30;
  bottom: calc(var(--nav-height) + var(--safe-bottom) + 10px);
  padding: 10px 14px;
  border-radius: 14px;
  background: var(--ink); color: var(--cream);
  font-weight: 700; text-align: center;
  animation: rise .2s ease;
}
.notice { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; padding: 24px; text-align: center; }
.notice img { width: 160px; }
.notice h1 { font-size: 20px; }
.notice p { color: var(--ink-soft); max-width: 30ch; }

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