/* Мини-апп: уютная тёмная комната, крупный питомец, ничего лишнего.
   Палитра своя, а не из темы Телеграма: игра должна выглядеть одинаково
   у всех, а светлая тема мессенджера сделала бы свечение вокруг питомца
   грязным пятном. */

:root {
  --bg: #14121c;
  --bg-2: #1d1a29;
  --card: #241f33;
  --card-2: #2e2740;
  --ink: #f3eeff;
  --muted: #a79dc2;
  --line: #372f4d;
  --warm: #ffb020;
  --good: #56d97f;
  --bad: #ff6b6b;
  --joy: #ffd166;
  --fed: #ff9f68;
  --clean: #6ec8ff;
  --energy: #b98cff;
  --pad: 14px;
}

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

html, body {
  margin: 0; padding: 0; height: 100%;
  background: var(--bg); color: var(--ink);
  font: 15px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  overscroll-behavior: none;
}

body { user-select: none; }
b { font-weight: 700; }
.muted { color: var(--muted); font-size: 13px; }
[hidden] { display: none !important; }

/* --- загрузка ----------------------------------------------------------- */
.boot {
  position: fixed; inset: 0; display: grid; place-content: center;
  gap: 14px; text-align: center; background: var(--bg); z-index: 50;
}
.boot-egg { font-size: 64px; animation: wobble 1.6s ease-in-out infinite; }
.boot-text { color: var(--muted); }

/* --- вылупление --------------------------------------------------------- */
.screen { padding: 24px var(--pad); }
.hatch-title { margin: 8px 0 4px; font-size: 24px; text-align: center; }
.hatch-sub { margin: 0 0 18px; text-align: center; color: var(--muted); font-size: 14px; }
.starters { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.starter {
  background: var(--card); border: 2px solid transparent; border-radius: 18px;
  padding: 14px 6px; text-align: center; cursor: pointer;
}
.starter.is-on { border-color: var(--warm); background: var(--card-2); }
.starter .art { font-size: 40px; line-height: 1; }
.starter .nm { margin-top: 6px; font-size: 13px; }

.field {
  width: 100%; margin: 16px 0 12px; padding: 14px;
  background: var(--card); border: 1px solid var(--line); border-radius: 14px;
  color: var(--ink); font-size: 16px; outline: none;
}

/* --- кнопки ------------------------------------------------------------- */
.btn {
  width: 100%; padding: 14px; border: 0; border-radius: 14px;
  font-size: 15px; font-weight: 600; color: var(--ink);
  background: var(--card-2); cursor: pointer;
}
.btn:disabled { opacity: .45; }
.btn-main { background: linear-gradient(135deg, #ff9f68, #ff6fae); color: #201432; }
.btn-soft { background: var(--card); border: 1px solid var(--line); }
.btn:active { transform: translateY(1px); }

/* --- шапка -------------------------------------------------------------- */
.app { padding-bottom: 78px; }
.top {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; padding: 12px var(--pad) 6px;
}
.top-name { font-weight: 700; font-size: 17px; display: flex; gap: 8px; align-items: baseline; }
.top-wallet { display: flex; gap: 8px; }
.pill {
  background: var(--card); border: 1px solid var(--line);
  border-radius: 999px; padding: 5px 10px; font-size: 13px; white-space: nowrap;
}

/* --- сцена с питомцем --------------------------------------------------- */
.stage { position: relative; padding: 8px var(--pad) 4px; text-align: center; }
.stage-glow {
  position: absolute; left: 50%; top: 46%; width: 260px; height: 260px;
  transform: translate(-50%, -50%);
  background: radial-gradient(circle, rgba(255,176,32,.22), transparent 68%);
  filter: blur(6px); pointer-events: none;
}
.pet-art {
  position: relative; height: 210px; display: grid; place-items: center;
  animation: float 3.6s ease-in-out infinite;
}
.pet-art img { max-height: 200px; max-width: 78%; object-fit: contain;
               filter: drop-shadow(0 14px 22px rgba(0,0,0,.5)); }
.pet-fallback { font-size: 108px; line-height: 1; filter: drop-shadow(0 12px 18px rgba(0,0,0,.5)); }
.pet-hat { position: absolute; top: 6px; font-size: 34px; }
.zzz { position: absolute; right: 22%; top: 12%; font-size: 26px; animation: rise 2.4s ease-in-out infinite; }
.is-sleeping .pet-art { filter: saturate(.55) brightness(.8); animation-duration: 6s; }

.stars { min-height: 18px; letter-spacing: 2px; color: var(--warm); font-size: 15px; }
.hint { margin: 6px auto 2px; max-width: 320px; min-height: 38px; color: var(--muted); font-size: 14px; }

/* --- шкалы -------------------------------------------------------------- */
.bars { display: grid; gap: 7px; padding: 4px var(--pad) 0; }
.bar { display: flex; align-items: center; gap: 8px; font-size: 15px; }
.bar i { flex: 1; display: block; height: 10px; border-radius: 999px;
         background: var(--card); overflow: hidden; }
.bar u { display: block; height: 100%; border-radius: 999px; text-decoration: none;
         transition: width .45s ease; }
#barFed { background: var(--fed); }
#barJoy { background: var(--joy); }
#barClean { background: var(--clean); }
#barEnergy { background: var(--energy); }

.level { padding: 10px var(--pad) 0; text-align: center; }
.level-line { height: 6px; border-radius: 999px; background: var(--card); overflow: hidden; }
.level-line u { display: block; height: 100%; background: linear-gradient(90deg, #ff9f68, #ff6fae);
                text-decoration: none; transition: width .45s ease; }
.level span { display: block; margin-top: 5px; }
.level b { color: var(--ink); }

/* --- действия ----------------------------------------------------------- */
.actions {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px;
  padding: 14px var(--pad) 0;
}
.act {
  display: grid; gap: 2px; justify-items: center; padding: 10px 4px;
  background: var(--card); border: 1px solid var(--line); border-radius: 16px;
  color: var(--ink); font-size: 12px; cursor: pointer;
}
.act span { font-size: 26px; }
.act em { font-style: normal; color: var(--muted); font-size: 11px; }
.act:active { background: var(--card-2); }

.row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; padding: 12px var(--pad) 0; }
.row .btn { font-size: 13px; padding: 12px 8px; }

/* --- яйца --------------------------------------------------------------- */
.eggs { display: grid; gap: 12px; padding: 14px var(--pad) 8px; }
.egg {
  display: flex; align-items: center; gap: 14px; padding: 16px;
  background: linear-gradient(135deg, var(--card), var(--card-2));
  border: 1px solid var(--line); border-radius: 20px; cursor: pointer;
}
.egg .em { font-size: 46px; animation: wobble 3s ease-in-out infinite; }
.egg .nm { font-weight: 700; font-size: 16px; }
.egg .odds { color: var(--muted); font-size: 12px; margin-top: 3px; }
.egg .price { margin-left: auto; font-weight: 700; white-space: nowrap; }
.egg.is-poor { opacity: .5; }
.pity { padding: 4px var(--pad) 12px; text-align: center; }
#shardsBtn { width: calc(100% - var(--pad) * 2); margin: 0 var(--pad); }

/* --- коллекция ---------------------------------------------------------- */
.dex-head { padding: 12px var(--pad) 0; }
.dex { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; padding: 10px var(--pad); }
.cell {
  position: relative; padding: 12px 6px 10px; border-radius: 18px; text-align: center;
  background: var(--card); border: 2px solid transparent; cursor: pointer;
}
.cell.is-on { border-color: var(--warm); }
.cell.locked { opacity: .45; }
.cell.locked .art { filter: grayscale(1) brightness(.35); }
.cell .art { height: 62px; display: grid; place-items: center; font-size: 42px; }
.cell .art img { max-height: 62px; max-width: 100%; object-fit: contain; }
.cell .nm { font-size: 12px; margin-top: 4px; }
.cell .rr { font-size: 10px; margin-top: 2px; }
.cell .st { font-size: 11px; color: var(--warm); min-height: 13px; }

/* --- задания ------------------------------------------------------------ */
.quests { display: grid; gap: 10px; padding: 14px var(--pad) 10px; }
.quest {
  display: flex; align-items: center; gap: 12px; padding: 14px;
  background: var(--card); border: 1px solid var(--line); border-radius: 18px;
}
.quest .mark { font-size: 20px; }
.quest .nm { font-weight: 600; }
.quest .rw { margin-left: auto; color: var(--warm); font-weight: 700; white-space: nowrap; }
.quest a { color: var(--ink); text-decoration: none; }
#claimBtn { width: calc(100% - var(--pad) * 2); margin: 0 var(--pad); }
.invite { display: grid; gap: 8px; padding: 18px var(--pad); text-align: center; }

/* --- нижняя навигация --------------------------------------------------- */
.nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: grid; grid-template-columns: repeat(4, 1fr);
  background: rgba(20,18,28,.94); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
  backdrop-filter: blur(8px);
}
.nav-btn {
  display: grid; gap: 2px; justify-items: center; padding: 9px 0 10px;
  background: none; border: 0; color: var(--muted); font-size: 11px; cursor: pointer;
}
.nav-btn span { font-size: 21px; filter: grayscale(1) opacity(.7); }
.nav-btn.is-on { color: var(--ink); }
.nav-btn.is-on span { filter: none; }

/* --- всплывающая строка ------------------------------------------------- */
.toast {
  position: fixed; left: 50%; bottom: 92px; z-index: 40;
  transform: translateX(-50%); max-width: 88%;
  padding: 11px 16px; border-radius: 14px; text-align: center;
  background: rgba(46,39,64,.97); border: 1px solid var(--line);
  font-size: 14px; white-space: pre-line;
  animation: pop .25s ease;
}

/* --- вскрытие яйца ------------------------------------------------------ */
/* Ради этих трёх секунд игра и открывается. Тряска, вспышка, карточка. */
.reveal {
  position: fixed; inset: 0; z-index: 60; display: grid; place-items: center;
  background: rgba(10,8,16,.94); text-align: center;
}
/* Лучи: тонкие спицы, растворяющиеся к краям. Без маски conic-gradient
   на экране телефона сливается в ровный серый диск - проверено глазами,
   выглядит как грязное пятно, а не как вспышка. */
.reveal-rays {
  position: absolute; width: 560px; height: 560px; border-radius: 50%;
  background: repeating-conic-gradient(from 0deg,
              rgba(255,255,255,.16) 0 5deg, transparent 5deg 17deg);
  -webkit-mask-image: radial-gradient(circle, #000 18%, transparent 68%);
  mask-image: radial-gradient(circle, #000 18%, transparent 68%);
  opacity: 0; animation: spin 14s linear infinite;
}
.reveal.is-burst .reveal-rays { opacity: 1; transition: opacity .5s ease; }
.reveal-egg { position: relative; z-index: 2; font-size: 92px; animation: shake .5s ease-in-out infinite; }
.reveal.is-burst .reveal-egg { animation: burst .45s ease forwards; }

.reveal-card {
  position: relative; z-index: 2; display: grid; gap: 10px; justify-items: center;
  padding: 26px 22px; width: min(88vw, 340px);
  background: linear-gradient(160deg, #322a47, #221d31 70%);
  border-radius: 26px;
  border: 2px solid var(--rarity, var(--line));
  box-shadow: 0 0 60px -10px var(--rarity, transparent),
              0 24px 50px rgba(0,0,0,.55);
  animation: pop .4s ease;
}
.reveal-rarity {
  text-transform: uppercase; letter-spacing: 2px; font-size: 12px; font-weight: 700;
  color: var(--rarity, var(--muted));
}
.reveal-art { height: 170px; display: grid; place-items: center; font-size: 104px; }
.reveal-art img { max-height: 170px; max-width: 100%; object-fit: contain; }
.reveal-name { font-size: 22px; font-weight: 700; }
.reveal-note { color: var(--muted); font-size: 13px; min-height: 18px; }
.reveal-card .btn { margin-top: 6px; }

/* --- движение ----------------------------------------------------------- */
@keyframes float { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-10px); } }
@keyframes wobble { 0%,100% { transform: rotate(-6deg); } 50% { transform: rotate(6deg); } }
@keyframes rise { 0% { opacity: 0; transform: translateY(6px); }
                  40% { opacity: 1; } 100% { opacity: 0; transform: translateY(-16px); } }
@keyframes shake { 0%,100% { transform: rotate(-9deg) translateY(0); }
                   50% { transform: rotate(9deg) translateY(-6px); } }
@keyframes burst { to { transform: scale(2.6); opacity: 0; } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pop { from { transform: scale(.9); opacity: 0; } to { transform: scale(1); opacity: 1; } }

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .001s !important; animation-iteration-count: 1 !important; }
}


/* --- Мини-игра «найди еду» ------------------------------------------------ */
.bowls-box {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
  padding: 0 20px;
  text-align: center;
}
.bowls-title { font-size: 20px; font-weight: 700; }
.bowls-row { display: flex; gap: 14px; }
.bowl {
  width: 84px;
  height: 84px;
  font-size: 38px;
  line-height: 1;
  border: 0;
  border-radius: 20px;
  background: var(--card);
  color: inherit;
  cursor: pointer;
  transition: transform .15s ease, opacity .3s ease, background .3s ease;
}
.bowl:active { transform: scale(.94); }
.bowl.is-picked { outline: 2px solid var(--warm); }
.bowl.is-empty { opacity: .35; }
.bowl.is-food { background: rgba(255, 190, 90, .28); transform: translateY(-6px); }
.bowls-note { min-height: 42px; font-size: 15px; opacity: .85; }
.streak { margin-top: 10px; text-align: center; font-size: 13px; }
.btn.is-done { opacity: .55; }
