:root {
  --bg: #08080b;
  --card: #15161b;
  --card-2: #1d1f26;
  --stroke: #26282f;
  --text: #f6f5f2;
  --muted: #7d808a;
  --accent: #ffb01f;
  --accent-2: #ffd36b;
  --accent-grad: linear-gradient(135deg, #ffe08a 0%, #ffb01f 55%, #f07b0a 100%);
  --num: "Unbounded", "Manrope", system-ui, sans-serif;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); overflow: hidden; }
body {
  font: 15px/1.3 "Manrope", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  user-select: none; -webkit-user-select: none; overscroll-behavior: none;
  background:
    radial-gradient(120% 60% at 50% 42%, rgba(255, 150, 20, .10), transparent 60%),
    var(--bg);
}
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
svg { width: 22px; height: 22px; fill: currentColor; }
svg[fill="none"] { fill: none; }
.hidden { display: none !important; }
.muted-s { color: var(--muted); font-weight: 600; font-size: 12px; }

#app { display: flex; flex-direction: column; height: 100vh; height: 100dvh; max-width: 480px; margin: 0 auto; }

/* --- верх --- */
.top { display: flex; align-items: center; gap: 10px; padding: 12px 16px 4px; }
.profile { flex: 1; display: flex; align-items: center; gap: 10px; min-width: 0; text-align: left; }
.profile:active { opacity: .8; }
.avatar {
  width: 44px; height: 44px; flex: none; border-radius: 50%; display: grid; place-items: center; overflow: hidden;
  background: var(--card-2); color: var(--accent); box-shadow: 0 0 0 2px var(--accent), 0 0 0 4px rgba(255,176,31,.15);
}
.avatar svg { width: 28px; height: 28px; fill: none; stroke: currentColor; stroke-width: 1.7; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.who { min-width: 0; flex: 1; }
.name { font-weight: 700; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lvl-row { display: flex; align-items: center; gap: 8px; margin-top: 4px; }
.lvl { font: 700 11px var(--num); color: var(--accent-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.bar { flex: 1 0 28px; max-width: 120px; height: 5px; border-radius: 5px; background: var(--card-2); overflow: hidden; }
.bar i { display: block; height: 100%; width: 0; background: var(--accent-grad); transition: width .3s; }

.chip {
  display: flex; align-items: center; gap: 6px; height: 38px; padding: 0 14px; border-radius: 99px;
  background: var(--card); border: 1px solid var(--stroke); font-weight: 700; font-size: 13px; white-space: nowrap;
}
.chip svg { width: 18px; height: 18px; color: #4fa3ff; }
.chip:active { transform: scale(.96); }
.chip.lang { padding: 0 12px; font: 700 12px var(--num); color: var(--accent-2); }
@media (max-width: 420px) { #btnTon span { display: none; } #btnTon { padding: 0 11px; } }

/* --- баланс --- */
.screen { flex: 1; min-height: 0; display: none; }
.screen.active { display: flex; }
#screen-home { flex-direction: column; }
.balance { text-align: center; padding-top: 14px; }
.balance .label { color: var(--muted); font-weight: 700; font-size: 13px; letter-spacing: .08em; text-transform: uppercase; }
.balance .amount { display: inline-flex; align-items: center; gap: 10px; margin-top: 6px; }
.balance b { font: 800 40px/1 var(--num); font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.mini-coin {
  width: 30px; height: 30px; border-radius: 50%; background: var(--accent-grad); position: relative;
  box-shadow: inset 0 -3px 0 rgba(120,50,0,.35), 0 0 14px rgba(255,170,30,.5);
}
.mini-coin::after {
  content: ""; position: absolute; inset: 7px 9px; background: #fff6d8;
  clip-path: polygon(60% 0, 10% 58%, 45% 58%, 35% 100%, 90% 38%, 55% 38%);
}
.per-tap { margin-top: 6px; font-weight: 800; color: var(--accent-2); font-size: 13px; }

/* --- монета --- */
.stage {
  position: relative; flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center;
  touch-action: none; padding: 8px 0;
}
.glow {
  position: absolute; height: min(120%, 360px, 90vw); aspect-ratio: 1; border-radius: 50%;
  background: radial-gradient(circle, rgba(255,170,30,.35) 0%, rgba(255,120,0,.12) 45%, transparent 70%);
  filter: blur(6px); pointer-events: none; animation: breathe 3s ease-in-out infinite;
}
@keyframes breathe { 50% { transform: scale(1.06); opacity: .85; } }
/* Монета — квадрат, который помещается и по ширине, и по высоте свободного места (окно Telegram на компьютере
   бывает невысоким) */
.coin-wrap {
  height: min(100%, 290px, 76vw); aspect-ratio: 1; perspective: 700px; cursor: pointer; flex: none;
}
.coin {
  width: 100%; height: 100%; display: block; transition: transform .12s ease-out;
  filter: drop-shadow(0 18px 30px rgba(0,0,0,.55)) drop-shadow(0 0 24px rgba(255,160,20,.25));
}
.boosted .coin { filter: drop-shadow(0 18px 30px rgba(0,0,0,.55)) drop-shadow(0 0 40px rgba(255,190,40,.8)); }
.boosted .glow { animation-duration: .9s; }

.float {
  position: absolute; pointer-events: none; z-index: 5; font: 800 30px var(--num); color: #fff;
  text-shadow: 0 0 14px rgba(255,170,30,.9), 0 2px 4px rgba(0,0,0,.4); animation: up .8s ease-out forwards;
}
@keyframes up { from { transform: translate(-50%, -30px); } to { transform: translate(-50%, -130px); opacity: 0; } }

/* --- нижняя панель --- */
.controls { padding: 0 16px 14px; }
.row { display: flex; align-items: stretch; gap: 10px; }
.tile {
  position: relative; width: 58px; flex: none; border-radius: 18px; background: var(--card); border: 1px solid var(--stroke);
  display: grid; place-items: center; color: var(--accent);
}
.tile svg { width: 28px; height: 28px; }
.tile.accent { background: var(--accent-grad); border: 0; color: #1a1205; }
.boost-x { font: 800 18px var(--num); }
.tile:active { transform: scale(.95); }
.tile-badge {
  position: absolute; top: -7px; right: -7px; min-width: 22px; height: 22px; padding: 0 6px; border-radius: 99px;
  background: var(--card-2); border: 1.5px solid var(--stroke); font: 700 10px var(--num); color: var(--text);
  display: grid; place-items: center;
}
.tile-badge.dark { background: #1a1205; border-color: #1a1205; color: var(--accent-2); }
#btnCase.ready { animation: wiggle 1.8s infinite; }
#btnCase.ready .tile-badge { background: var(--accent); border-color: var(--accent); color: #1a1205; }
@keyframes wiggle { 0%, 78%, 100% { transform: rotate(0); } 84% { transform: rotate(-8deg); } 92% { transform: rotate(8deg); } }
#btnBoost.off { filter: grayscale(1); opacity: .45; }
#btnBoost.on { animation: pulse .9s infinite alternate; }
@keyframes pulse { to { box-shadow: 0 0 22px rgba(255,176,31,.8); } }

.energy {
  flex: 1; min-width: 0; text-align: left; display: block; background: var(--card); border: 1px solid var(--stroke); border-radius: 18px; padding: 10px 12px;
}
.energy-top { display: flex; align-items: center; gap: 6px; }
.energy-top b { font: 700 14px var(--num); font-variant-numeric: tabular-nums; }
.energy-top .muted-s { margin-left: auto; }
.energy-ico svg { width: 16px; height: 16px; color: var(--accent); display: block; }
.ebar { height: 8px; margin-top: 8px; border-radius: 8px; background: var(--card-2); overflow: hidden; }
.ebar i { display: block; height: 100%; width: 100%; background: var(--accent-grad); border-radius: 8px; transition: width .2s; }

.boost-on {
  margin-top: 10px; text-align: center; font: 700 12px var(--num); color: #1a1205; background: var(--accent-grad);
  border-radius: 99px; padding: 7px; animation: pulse .9s infinite alternate;
}
.friends {
  width: 100%; height: 48px; margin-top: 10px; border-radius: 16px; display: flex; align-items: center; justify-content: center; gap: 8px;
  border: 1.5px solid rgba(255,176,31,.5); color: var(--accent-2); font-weight: 800; font-size: 15px;
  background: rgba(255,176,31,.06);
}
.friends svg { width: 20px; height: 20px; }
.friends:active { transform: scale(.98); }

/* --- вкладки «скоро» --- */
.screen.soon.active { display: grid; place-items: center; text-align: center; }
.screen.soon b { font: 700 22px var(--num); color: var(--accent-2); }
.screen.soon p { color: var(--muted); margin: 8px 0 0; }

/* --- нижнее меню --- */
.tabs {
  display: flex; margin: 0 12px calc(10px + env(safe-area-inset-bottom)); padding: 6px; border-radius: 22px;
  background: rgba(21,22,27,.92); border: 1px solid var(--stroke); backdrop-filter: blur(10px);
}
.tab { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px; color: var(--muted);
  font-weight: 700; font-size: 12px; padding: 7px 0; border-radius: 16px; }
.tab svg { width: 24px; height: 24px; }
.tab.active { color: var(--accent); background: rgba(255,176,31,.1); }

/* --- окно бонуса --- */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.65); display: flex; align-items: flex-end; z-index: 20; }
.sheet {
  position: relative; width: 100%; max-width: 480px; margin: 0 auto; background: var(--card); border-radius: 26px 26px 0 0;
  border-top: 1px solid var(--stroke); padding: 24px 18px calc(22px + env(safe-area-inset-bottom)); text-align: center;
  animation: slide .2s ease-out;
}
@keyframes slide { from { transform: translateY(40px); opacity: 0; } }
.sheet-ico { width: 72px; height: 72px; margin: 0 auto; border-radius: 22px; background: var(--accent-grad); display: grid; place-items: center; color: #1a1205;
  box-shadow: 0 0 30px rgba(255,170,30,.35); }
.sheet-ico svg { width: 40px; height: 40px; }
.sheet h2 { margin: 14px 0 16px; font: 700 20px var(--num); }
.close { position: absolute; right: 12px; top: 10px; font-size: 28px; color: var(--muted); width: 40px; height: 40px; }
.days { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 16px; }
.day { background: var(--card-2); border: 1.5px solid transparent; border-radius: 14px; padding: 9px 4px; font-size: 11px; font-weight: 700; color: var(--muted); }
.day b { display: block; color: var(--text); font: 700 13px var(--num); margin-top: 3px; }
.day.done { opacity: .4; }
.day.today { border-color: var(--accent); color: var(--accent-2); background: rgba(255,176,31,.08); }
.btn-main { width: 100%; height: 52px; border-radius: 16px; background: var(--accent-grad); color: #1a1205; font-weight: 800; font-size: 16px; }
.btn-main:disabled { opacity: .4; }
.muted { color: var(--muted); font-size: 13px; margin: 10px 0 0; }

.toast {
  position: fixed; left: 50%; top: 16px; transform: translateX(-50%); background: #23252c; color: #fff; font-weight: 700;
  padding: 10px 16px; border-radius: 14px; z-index: 30; font-size: 14px; box-shadow: 0 8px 24px rgba(0,0,0,.5);
  border: 1px solid var(--stroke); max-width: 90%; text-align: center;
}
.error { position: fixed; inset: 0; background: var(--bg); display: grid; place-items: center; text-align: center; padding: 24px; z-index: 40; color: var(--muted); }

@media (max-height: 640px) {
  .balance b { font-size: 32px; }
  .friends { height: 42px; }
}

/* --- экраны со списком (задания) --- */
.list-screen.active { display: flex; flex-direction: column; padding: 8px 16px 12px; overflow-y: auto; }
.list-screen h1 { font: 700 22px var(--num); margin: 6px 0 14px; }
.list { display: flex; flex-direction: column; gap: 10px; }
.task {
  display: flex; align-items: center; gap: 12px; padding: 12px; border-radius: 18px;
  background: var(--card); border: 1px solid var(--stroke);
}
.task-ico { width: 44px; height: 44px; flex: none; border-radius: 14px; display: grid; place-items: center;
  background: rgba(255,176,31,.1); color: var(--accent); }
.task-ico svg { width: 24px; height: 24px; }
.task-body { flex: 1; min-width: 0; }
.task-title { font-weight: 700; font-size: 14px; }
.task-reward { display: flex; align-items: center; gap: 5px; margin-top: 4px; font: 700 12px var(--num); color: var(--accent-2); }
.task-reward .mini-coin { width: 14px; height: 14px; box-shadow: none; }
.task-reward .mini-coin::after { inset: 3px 4px; }
.task-progress { height: 4px; margin-top: 6px; border-radius: 4px; background: var(--card-2); overflow: hidden; }
.task-progress i { display: block; height: 100%; background: var(--accent-grad); }
.task-btn {
  flex: none; min-width: 74px; height: 36px; padding: 0 14px; border-radius: 12px; font-weight: 800; font-size: 13px;
  background: var(--card-2); color: var(--text);
}
.task-btn.go { background: var(--accent-grad); color: #1a1205; }
.task-btn.done { background: transparent; color: #4ade80; font-size: 20px; }
.task-btn:disabled { opacity: .5; }
.task.is-done { opacity: .55; }
.empty { color: var(--muted); text-align: center; padding: 40px 0; }

/* --- окно друзей --- */
.bonus-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.bonus-card { background: var(--card-2); border-radius: 16px; padding: 14px 8px; }
.bonus-card b { display: block; font: 800 22px var(--num); color: var(--accent-2); }
.bonus-card span { color: var(--muted); font-size: 12px; font-weight: 700; }
.premium-note b { color: var(--accent-2); }
.link-box {
  margin: 14px 0 10px; padding: 12px; border-radius: 14px; background: var(--bg); border: 1px dashed var(--stroke);
  font-size: 12px; color: var(--muted); word-break: break-all; user-select: text; -webkit-user-select: text;
}
.two { display: grid; grid-template-columns: 1fr 1.4fr; gap: 10px; }
.btn-ghost { height: 52px; border-radius: 16px; border: 1.5px solid var(--stroke); font-weight: 800; }
.friends-head { display: flex; justify-content: space-between; margin: 18px 0 8px; font-weight: 800; }
.friends-head b { font-family: var(--num); color: var(--accent-2); }
.friends-list { max-height: 30vh; overflow-y: auto; text-align: left; }
.friend { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--stroke); }
.friend:last-child { border-bottom: 0; }
.friend-ava { width: 32px; height: 32px; border-radius: 50%; background: var(--card-2); display: grid; place-items: center;
  font-weight: 800; color: var(--accent); }
.friend-name { flex: 1; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.friend-bal { font: 700 12px var(--num); color: var(--accent-2); }

/* --- рейтинг --- */
#screen-leaders.active { padding-bottom: 0; }
.lb-head { display: flex; align-items: baseline; justify-content: space-between; }
.podium { display: grid; grid-template-columns: 1fr 1.15fr 1fr; align-items: end; gap: 8px; margin: 4px 0 16px; }
.pod { text-align: center; min-width: 0; }
.pod .ava { margin: 0 auto 8px; width: 56px; height: 56px; font-size: 20px; }
.pod.p1 .ava { width: 70px; height: 70px; font-size: 24px; }
.pod-name { font-weight: 800; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pod-bal { font: 700 12px var(--num); color: var(--accent-2); margin-top: 2px; }
.pod-base { margin-top: 8px; border-radius: 14px 14px 0 0; display: grid; place-items: center; font: 800 22px var(--num); color: #1a1205; }
.p1 .pod-base { height: 78px; background: linear-gradient(180deg, #ffe08a, #ffb01f); box-shadow: 0 0 24px rgba(255,176,31,.35); }
.p2 .pod-base { height: 56px; background: linear-gradient(180deg, #f1f3f6, #a9b0bb); }
.p3 .pod-base { height: 42px; background: linear-gradient(180deg, #f3c39a, #c07a43); }
.ava {
  width: 36px; height: 36px; flex: none; border-radius: 50%; background: var(--card-2); overflow: hidden;
  display: grid; place-items: center; font-weight: 800; color: var(--accent);
}
.ava img { width: 100%; height: 100%; object-fit: cover; }
.p1 .ava { box-shadow: 0 0 0 3px #ffb01f; } .p2 .ava { box-shadow: 0 0 0 3px #c9ced6; } .p3 .ava { box-shadow: 0 0 0 3px #d9925a; }
.lb-row {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 16px;
  background: var(--card); border: 1px solid var(--stroke);
}
.lb-row.me { border-color: var(--accent); background: rgba(255,176,31,.07); }
.lb-rank { width: 28px; flex: none; font: 700 13px var(--num); color: var(--muted); text-align: center; }
.lb-name { flex: 1; min-width: 0; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lb-name small { display: block; color: var(--muted); font-weight: 600; font-size: 11px; }
.lb-bal { font: 700 13px var(--num); color: var(--accent-2); }
.lb-me { position: sticky; bottom: 0; margin: 12px -16px 0; padding: 10px 16px 12px; background: linear-gradient(180deg, transparent, var(--bg) 30%); }
.lb-me:empty { display: none; }

.energy:active { transform: scale(.98); }

/* --- прокачка --- */
.sheet-bal { display: inline-flex; align-items: center; gap: 8px; margin: -6px 0 14px; font: 700 18px var(--num); }
.sheet-bal .mini-coin { width: 22px; height: 22px; }
.sheet-bal .mini-coin::after { inset: 5px 6px; }
#upList, .pr-grid { text-align: left; }
.up-meta { color: var(--muted); font-size: 12px; font-weight: 600; margin-top: 3px; }
.up-lvl { font: 700 11px var(--num); color: var(--accent-2); margin-left: 6px; }

/* --- профиль --- */
.pr-head { display: flex; align-items: center; gap: 14px; text-align: left; margin-bottom: 16px; }
.pr-head b { font: 700 18px var(--num); }
.ava.big { width: 64px; height: 64px; font-size: 24px; box-shadow: 0 0 0 3px var(--accent); }
.pr-level { color: var(--accent-2); font-weight: 800; font-size: 13px; margin-top: 4px; }
.pr-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.pr-cell { background: var(--card-2); border-radius: 14px; padding: 12px; }
.pr-cell span { display: block; color: var(--muted); font-size: 11px; font-weight: 700; }
.pr-cell b { display: block; margin-top: 4px; font: 700 17px var(--num); }
.pr-lang { display: flex; align-items: center; justify-content: space-between; margin-top: 16px; font-weight: 800; }
.seg { display: flex; background: var(--card-2); border-radius: 12px; padding: 3px; }
.seg button { padding: 8px 16px; border-radius: 10px; font: 700 12px var(--num); color: var(--muted); }
.seg button.on { background: var(--accent-grad); color: #1a1205; }
.task-hint { color: var(--muted); font-size: 11px; font-weight: 600; margin-top: 3px; }
.friend.pending .friend-bal { color: var(--muted); }
