:root {
  --bg: #0b0d14;
  --bg2: #141826;
  --card: #1a1f30;
  --card2: #232a40;
  --line: #2c3450;
  --text: #f3f1ea;
  --muted: #8d93a8;
  --gold: #f5c542;
  --gold2: #e0a82e;
  --green: #4cd18a;
  --red: #ff6b6b;
  --radius: 16px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; overscroll-behavior: none; }
body { user-select: none; -webkit-user-select: none; }
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; }
input { font: inherit; }

#app { display: flex; flex-direction: column; height: 100vh; height: 100dvh;
  background: radial-gradient(120% 60% at 50% 30%, #1d2440 0%, var(--bg) 60%); }

/* --- Шапка --- */
.topbar { display: flex; justify-content: space-between; align-items: center; padding: 12px 16px 6px; gap: 8px; }
.player { display: flex; gap: 10px; align-items: center; min-width: 0; }
.avatar { width: 36px; height: 36px; border-radius: 50%; background: var(--card2); display: grid; place-items: center; font-size: 18px; }
.player-name { font-weight: 600; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 40vw; }
.player-sub { font-size: 12px; color: var(--muted); }
.top-actions { display: flex; gap: 6px; }
.chip { background: var(--card); border: 1px solid var(--line); padding: 7px 11px; border-radius: 999px; font-size: 13px; font-weight: 600; }
.chip.gold { color: var(--gold); border-color: #5a4a1e; }

main { flex: 1; overflow-y: auto; position: relative; }
.screen { display: none; padding: 8px 16px 24px; animation: fade .2s ease; }
.screen.active { display: block; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
h2 { margin: 8px 0 14px; font-size: 22px; }
h3 { margin: 20px 0 10px; font-size: 16px; color: var(--muted); font-weight: 600; }

/* --- Главный экран --- */
#screen-home.active { display: flex; flex-direction: column; height: 100%; }
.balance { display: flex; justify-content: center; align-items: center; gap: 8px; font-size: 40px; font-weight: 800; margin-top: 6px; letter-spacing: -1px; }
.coin { font-size: 34px; filter: drop-shadow(0 2px 8px rgba(245,197,66,.5)); }
.stats-row { display: flex; justify-content: center; gap: 10px; margin: 8px 0 0; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 6px 14px; text-align: center; min-width: 100px; }
.stat-label { font-size: 11px; color: var(--muted); }
.stat-val { font-size: 15px; font-weight: 700; color: var(--gold); }

.tap-zone { flex: 1; position: relative; display: flex; justify-content: center; align-items: center; min-height: 260px; touch-action: none; }
.glow { position: absolute; width: 70%; max-width: 300px; aspect-ratio: 1; border-radius: 50%;
  background: radial-gradient(circle, rgba(245,197,66,.35) 0%, rgba(245,197,66,0) 65%); filter: blur(4px); }
#charImg { position: relative; height: 100%; max-height: 46vh; max-width: 80vw; object-fit: contain; pointer-events: none;
  filter: drop-shadow(0 18px 24px rgba(0,0,0,.55)); transition: transform .08s ease; }
#charImg.hit { transform: scale(.94) rotate(var(--tilt, 0deg)); }
.tap-zone.tired #charImg { filter: grayscale(.7) drop-shadow(0 18px 24px rgba(0,0,0,.55)); }
.float { position: fixed; pointer-events: none; font-weight: 800; font-size: 26px; color: var(--gold);
  text-shadow: 0 2px 6px rgba(0,0,0,.6); animation: floatUp .9s ease-out forwards; z-index: 50; }
@keyframes floatUp { from { opacity: 1; transform: translate(-50%, -50%); } to { opacity: 0; transform: translate(-50%, -140px); } }

.energy { padding: 6px 0 4px; }
.energy-top { display: flex; justify-content: space-between; align-items: center; font-weight: 600; font-size: 14px; margin-bottom: 6px; }
.link-btn { color: var(--gold); font-weight: 600; font-size: 14px; padding: 6px 4px; }
.bar { height: 12px; background: var(--card); border-radius: 999px; overflow: hidden; border: 1px solid var(--line); }
#energyFill { height: 100%; width: 100%; background: linear-gradient(90deg, var(--gold2), var(--gold)); border-radius: 999px; transition: width .15s linear; }

/* --- Карточки и списки --- */
.list { display: flex; flex-direction: column; gap: 10px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.card.column { flex-direction: column; align-items: stretch; gap: 8px; }
.card-main { display: flex; gap: 12px; align-items: center; min-width: 0; }
.card-icon { width: 44px; height: 44px; border-radius: 12px; background: var(--card2); display: grid; place-items: center; font-size: 22px; flex-shrink: 0; }
.card-title { font-weight: 600; font-size: 15px; }
.card-sub { color: var(--muted); font-size: 13px; margin-top: 2px; }
.center { text-align: center; margin-bottom: 10px; }
.big { font-size: 28px; font-weight: 800; }

.btn { background: linear-gradient(180deg, var(--gold), var(--gold2)); color: #1b1404; font-weight: 700;
  padding: 13px 18px; border-radius: 12px; width: 100%; }
.btn.small { width: auto; padding: 9px 14px; font-size: 14px; white-space: nowrap; }
.btn.ghost { background: var(--card2); color: var(--text); border: 1px solid var(--line); }
.btn:disabled { opacity: .4; }
.btn.done { background: var(--card2); color: var(--green); }
.row { display: flex; gap: 10px; margin-top: 12px; }

.days { display: grid; grid-template-columns: repeat(7, 1fr); gap: 5px; margin: -2px 0 12px; }
.day { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 6px 2px; text-align: center; font-size: 10px; color: var(--muted); }
.day b { display: block; color: var(--text); font-size: 11px; margin-top: 2px; }
.day.got { border-color: var(--gold2); background: #2a2412; }
.day.next { border-color: var(--gold); box-shadow: 0 0 0 1px var(--gold) inset; }

.hero-card { background: linear-gradient(160deg, #2a2412, var(--card)); border: 1px solid #5a4a1e; border-radius: var(--radius); padding: 20px; text-align: center; }
.hero-emoji { font-size: 44px; }
.hero-text { margin: 8px 0; line-height: 1.4; }
.ref-count { color: var(--muted); }
.ref-count b { color: var(--gold); }
.ref-link { margin-top: 12px; background: var(--card); border: 1px dashed var(--line); border-radius: 12px; padding: 12px; font-size: 13px; color: var(--muted); word-break: break-all; text-align: center; }

.lb-row { display: flex; align-items: center; gap: 12px; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px; }
.lb-row.me { border-color: var(--gold); }
.lb-pos { width: 28px; font-weight: 800; color: var(--muted); text-align: center; }
.lb-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb-score { font-weight: 700; color: var(--gold); }

.ton-btn { display: flex; justify-content: center; margin-bottom: 14px; min-height: 40px; }
#withdrawInput { background: var(--bg2); border: 1px solid var(--line); border-radius: 12px; padding: 12px; color: var(--text); font-size: 18px; width: 100%; outline: none; }
#withdrawInput:focus { border-color: var(--gold); }
.status-pending { color: var(--gold); } .status-paid { color: var(--green); } .status-rejected { color: var(--red); }

/* --- Нижнее меню --- */
.tabbar { display: grid; grid-template-columns: repeat(5, 1fr); background: var(--bg2); border-top: 1px solid var(--line);
  padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); }
.tab { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 0; border-radius: 12px; color: var(--muted); }
.tab span { font-size: 22px; filter: grayscale(1) opacity(.6); transition: .15s; }
.tab small { font-size: 11px; font-weight: 600; }
.tab.active { color: var(--gold); background: var(--card); }
.tab.active span { filter: none; }

/* --- Оверлеи --- */
.overlay { position: fixed; inset: 0; z-index: 100; background: radial-gradient(120% 70% at 50% 40%, #1d2440 0%, var(--bg) 65%); display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 20px; }
.overlay.hidden { display: none; }
.close { position: absolute; top: 14px; right: 16px; width: 40px; height: 40px; border-radius: 50%; background: var(--card); font-size: 18px; }
.inspect-title { font-size: 22px; font-weight: 800; color: var(--gold); letter-spacing: 1px; }
.inspect-stage { position: relative; width: 100%; height: 62vh; display: flex; justify-content: center; align-items: flex-end; touch-action: none; cursor: grab; }
.inspect-stage:active { cursor: grabbing; }
#inspectImg { position: relative; z-index: 1; height: 92%; max-width: 90vw; object-fit: contain; pointer-events: none; filter: drop-shadow(0 20px 30px rgba(0,0,0,.6)); }
.floor { position: absolute; bottom: 2%; width: 55%; max-width: 260px; height: 26px; border-radius: 50%; background: radial-gradient(ellipse, rgba(245,197,66,.35), rgba(245,197,66,0) 70%); }
.dots { display: flex; gap: 6px; margin: 14px 0 8px; }
.dots i { width: 7px; height: 7px; border-radius: 50%; background: var(--line); }
.dots i.on { background: var(--gold); }
.inspect-controls { display: flex; align-items: center; gap: 16px; }
.round { width: 46px; height: 46px; border-radius: 50%; background: var(--card); border: 1px solid var(--line); font-size: 16px; color: var(--gold); }

.ad-box { text-align: center; display: flex; flex-direction: column; gap: 14px; align-items: center; }
.ad-placeholder { width: 280px; height: 200px; border-radius: var(--radius); background: var(--card); border: 1px dashed var(--line); display: grid; place-items: center; color: var(--muted); padding: 20px; }

.hidden { display: none !important; }
.btn.refill { margin-top: 10px; background: var(--card); color: var(--gold); border: 1px solid var(--gold2); padding: 10px; }
.offline-box { width: 100%; max-width: 320px; background: var(--card); border: 1px solid #5a4a1e; border-radius: var(--radius);
  padding: 24px 20px; text-align: center; display: flex; flex-direction: column; gap: 12px; }
.offline-box .big { color: var(--gold); }
.adtask-box { margin-top: 10px; }
adsgram-task { --adsgram-task-font-size: 15px; --adsgram-task-icon-size: 44px; --adsgram-task-icon-title-gap: 12px;
  --adsgram-task-icon-border-radius: 12px; --adsgram-task-button-width: 110px;
  display: block; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; color: var(--text); }
.ag-reward { color: var(--muted); font-size: 13px; }
.ag-btn { background: linear-gradient(180deg, var(--gold), var(--gold2)); color: #1b1404; font-weight: 700; padding: 9px 14px; border-radius: 12px; text-align: center; font-size: 14px; }
.ag-btn.done { background: var(--card2); color: var(--green); }
.toast { position: fixed; left: 50%; bottom: 90px; transform: translate(-50%, 20px); background: var(--card2); border: 1px solid var(--line);
  padding: 10px 16px; border-radius: 12px; font-size: 14px; opacity: 0; pointer-events: none; transition: .25s; z-index: 200; max-width: 90vw; text-align: center; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
