:root {
  --sky-top: #2a1b52;
  --sky-mid: #170f33;
  --sky-bottom: #0b0820;
  --glass: rgba(255, 255, 255, .06);
  --line: rgba(255, 255, 255, .12);
  --text: #f6f2ff;
  --muted: #b3a9d6;
  --gold: #ffc83d;
  --gold-light: #ffe27a;
  --orange: #ff8a1f;
  --green: #7be07f;
  --blue: #2ea6ff;
  --safe-top: max(env(safe-area-inset-top), calc(var(--tg-content-safe-area-inset-top, 0px) + var(--tg-safe-area-inset-top, 0px)));
  --safe-bottom: max(env(safe-area-inset-bottom), var(--tg-safe-area-inset-bottom, 0px));
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; margin: 0; }

body {
  background: linear-gradient(180deg, var(--sky-top) 0%, var(--sky-mid) 45%, var(--sky-bottom) 100%);
  background-color: var(--sky-bottom);
  color: var(--text);
  font: 15px/1.35 -apple-system, "SF Pro Rounded", "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  overflow: hidden;
  overscroll-behavior: none;
  user-select: none;
  -webkit-user-select: none;
}

.sprite { position: absolute; }
.ico { width: 26px; height: 26px; flex: none; }

/* звёздное небо */
.sky i {
  position: fixed;
  z-index: 0;
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: #fff;
  opacity: .5;
  animation: twinkle 3s ease-in-out infinite;
}
.sky i:nth-child(1) { left: 22%; top: 30%; }
.sky i:nth-child(2) { left: 30%; top: 36%; animation-delay: -.5s; width: 4px; height: 4px; }
.sky i:nth-child(3) { left: 78%; top: 44%; animation-delay: -1s; }
.sky i:nth-child(4) { left: 92%; top: 52%; animation-delay: -1.5s; }
.sky i:nth-child(5) { left: 8%; top: 58%; animation-delay: -2s; }
.sky i:nth-child(6) { left: 84%; top: 63%; animation-delay: -2.5s; width: 4px; height: 4px; }
.sky i:nth-child(7) { left: 14%; top: 70%; animation-delay: -.8s; }
.sky i:nth-child(8) { left: 93%; top: 70%; animation-delay: -1.8s; }
.sky i:nth-child(9) { left: 62%; top: 26%; animation-delay: -2.2s; }
.sky i:nth-child(10) { left: 5%; top: 38%; animation-delay: -1.2s; }
.sky i:nth-child(11) { left: 48%; top: 22%; animation-delay: -2.8s; }
.sky i:nth-child(12) { left: 72%; top: 34%; animation-delay: -.3s; width: 4px; height: 4px; }
@keyframes twinkle { 50% { opacity: .1; transform: scale(.6); } }

main {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  height: 100%;
  padding: calc(var(--safe-top) + 14px) 16px calc(var(--safe-bottom) + 18px);
}

/* шапка */
.top { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }

.balance {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 12px 16px 12px 14px;
  border-radius: 20px;
  background: rgba(10, 6, 30, .55);
  border: 1px solid var(--line);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .06);
  min-width: 0;
}
.label { color: var(--muted); font-size: 13px; font-weight: 600; }
.value { display: flex; align-items: center; gap: 8px; font-size: 20px; font-weight: 800; font-variant-numeric: tabular-nums; }
.value .ico { width: 30px; height: 30px; filter: drop-shadow(0 0 8px rgba(255, 200, 61, .6)); }

.withdraw-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  border: 0;
  border-radius: 20px;
  padding: 9px 16px 9px 9px;
  font: inherit;
  color: #3a2200;
  background: linear-gradient(180deg, var(--gold-light), var(--gold) 55%, #f3a500);
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, .6), 0 6px 0 #b86e00, 0 12px 24px rgba(255, 170, 0, .3);
  transition: transform .08s, box-shadow .08s;
}
.withdraw-btn:active { transform: translateY(4px); box-shadow: inset 0 2px 0 rgba(255, 255, 255, .6), 0 2px 0 #b86e00, 0 6px 12px rgba(255, 170, 0, .3); }
.tile {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 13px;
  background: #fff6d6;
  box-shadow: inset 0 -2px 0 rgba(180, 110, 0, .25);
}
.tile .ico { width: 28px; height: 28px; }
.wtext { display: flex; flex-direction: column; align-items: flex-start; line-height: 1.1; }
.wtext b { font-size: 18px; font-weight: 900; }
.wtext small { font-size: 13px; font-weight: 700; opacity: .75; }
.withdraw-btn.locked { filter: saturate(.9); }

/* сцена с огром */
.stage {
  flex: 1;
  min-height: 0;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px 0 8px;
}
.moon {
  position: absolute;
  top: 6%;
  right: 12%;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  box-shadow: inset -12px 6px 0 0 #f4ecd0;
  transform: rotate(-20deg);
  filter: drop-shadow(0 0 14px rgba(255, 240, 200, .35));
}
.glow {
  position: absolute;
  width: min(80vw, 340px);
  aspect-ratio: 1;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(150, 230, 90, .32), rgba(120, 200, 60, .1) 45%, transparent 70%);
  animation: breathe 3.2s ease-in-out infinite;
}
.ogre {
  position: relative;
  width: min(70vw, 300px);
  max-height: 100%;
  object-fit: contain;
  filter: drop-shadow(0 0 26px rgba(160, 235, 90, .35)) drop-shadow(0 16px 22px rgba(0, 0, 0, .5));
  transform-origin: 50% 92%;
  animation: idle 3.2s ease-in-out infinite;
  pointer-events: none;
}
.ogre.hit { animation: hit .22s ease-out; }
@keyframes idle { 50% { transform: translateY(-6px); } }
@keyframes breathe { 50% { transform: scale(1.08); opacity: .7; } }
@keyframes hit {
  0% { transform: scale(1); }
  35% { transform: scale(1.07, .9) rotate(-3deg); filter: brightness(1.25) drop-shadow(0 0 30px rgba(255, 210, 90, .6)); }
  100% { transform: scale(1); }
}

/* прогресс */
.goal { margin-top: 6px; }
.bar {
  height: 16px;
  border-radius: 99px;
  background: rgba(255, 255, 255, .08);
  border: 1px solid var(--line);
  overflow: hidden;
}
.bar-fill {
  height: 100%;
  width: 0;
  min-width: 14px;
  border-radius: inherit;
  background: linear-gradient(180deg, #b7ff9c, var(--green) 50%, #3fb34a);
  box-shadow: 0 0 12px rgba(123, 224, 127, .55);
  transition: width .3s;
}
.goal-row { display: flex; justify-content: space-between; margin-top: 7px; font-size: 13px; color: var(--muted); }
.goal-row b { color: var(--green); }

.headline {
  margin: 14px 4px 4px;
  text-align: center;
  font-size: 21px;
  line-height: 1.22;
  font-weight: 900;
  color: var(--gold-light);
  text-shadow: 0 2px 0 rgba(120, 60, 0, .45), 0 0 18px rgba(255, 190, 60, .25);
}
.hint { margin: 0 0 14px; text-align: center; color: var(--muted); font-size: 14px; }

/* главная кнопка */
.tap-btn {
  width: 100%;
  height: 72px;
  flex: none;
  border: 0;
  border-radius: 24px;
  font: inherit;
  font-size: 24px;
  font-weight: 900;
  color: #3b1a00;
  text-shadow: 0 1px 0 rgba(255, 255, 255, .35);
  background: linear-gradient(180deg, #ffd27a 0%, #ffab3d 45%, var(--orange) 100%);
  box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, .55),
    0 8px 0 #c2560a,
    0 18px 34px rgba(255, 120, 20, .35);
  touch-action: none;
  transition: transform .06s, box-shadow .06s;
}
.tap-btn.down {
  transform: translateY(7px);
  box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, .55),
    0 1px 0 #c2560a,
    0 6px 14px rgba(255, 120, 20, .3);
}

/* всплывающие +0.0xx */
.float {
  position: fixed;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 4px;
  pointer-events: none;
  font-weight: 900;
  font-size: 22px;
  color: #fff4c2;
  text-shadow: 0 0 10px rgba(255, 200, 61, .9), 0 2px 4px rgba(0, 0, 0, .6);
  transform: translateX(-50%);
  animation: rise .9s ease-out forwards;
}
.float .ico { width: 20px; height: 20px; }
@keyframes rise { to { transform: translate(calc(-50% + var(--dx, 0px)), -150px) scale(1.1); opacity: 0; } }

/* экран приза */
.prize {
  position: fixed;
  inset: 0;
  z-index: 8;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: calc(var(--safe-top) + 10px) 16px calc(var(--safe-bottom) + 18px);
  background:
    radial-gradient(80% 40% at 50% 18%, rgba(255, 170, 40, .16), transparent 70%),
    linear-gradient(180deg, #1a1426, #0d0a14);
  overflow-y: auto;
  animation: fade .2s ease-out;
}
.prize[hidden] { display: none; }
.prize-back {
  align-self: flex-start;
  border: 0;
  background: none;
  color: var(--muted);
  font: inherit;
  font-size: 14px;
  padding: 6px 0;
}
.prize-badge {
  margin-top: 4px;
  padding: 7px 16px;
  border-radius: 99px;
  border: 1px solid rgba(255, 200, 61, .45);
  background: rgba(255, 200, 61, .08);
  color: var(--gold);
  font-size: 13px;
  font-weight: 900;
  letter-spacing: 1px;
  text-transform: uppercase;
}
.prize-title {
  margin: 14px 0 8px;
  font-size: 32px;
  font-weight: 900;
  text-align: center;
  color: #fff5e0;
  text-shadow: 0 0 22px rgba(255, 190, 80, .35);
}
.prize-sub { margin: 0 8px 16px; text-align: center; color: #a89a8a; font-size: 15px; }

.prize-card {
  width: 100%;
  padding: 16px;
  border-radius: 22px;
  background: linear-gradient(180deg, #2e2418, #1e1812);
  border: 1px solid rgba(255, 200, 120, .22);
  text-align: center;
}
.prize-amount { display: flex; align-items: center; justify-content: center; gap: 8px; font-size: 34px; font-weight: 900; color: #fff1c7; }
.prize-amount .ico { width: 34px; height: 34px; filter: drop-shadow(0 0 10px rgba(255, 200, 61, .6)); }
.prize-stats { margin: 8px 0 0; font-size: 13px; color: #a89a8a; }
.prize-stats[hidden] { display: none; }

.prize-list { width: 100%; display: flex; flex-direction: column; gap: 12px; margin: 14px 0 16px; }
.chan {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 62px;
  padding: 10px 48px;
  border-radius: 20px;
  background: linear-gradient(180deg, #2a221d, #1c1714);
  border: 1px solid rgba(255, 200, 120, .25);
  color: #fff;
  font-weight: 800;
  font-size: 17px;
  text-decoration: none;
  text-align: center;
}
.chan:active { transform: scale(.98); }
.chan .mark {
  position: absolute;
  right: 16px;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 14px;
  background: rgba(255, 255, 255, .08);
  color: transparent;
}
.chan.done { border-color: rgba(123, 224, 127, .5); }
.chan.done .mark { background: var(--green); color: #0b2a0d; }
.chan.missing { border-color: #ff5f5f; animation: shake .35s; }
@keyframes shake { 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }

.prize-check { margin-top: auto; }
.prize-check:disabled { opacity: .7; }

.notice { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; padding: 24px; text-align: center; color: var(--muted); }
.notice[hidden] { display: none; }

.toast {
  position: fixed;
  left: 16px;
  right: 16px;
  top: calc(var(--safe-top) + 12px);
  padding: 12px 14px;
  border-radius: 16px;
  background: #2b1d55;
  border: 1px solid var(--line);
  box-shadow: 0 10px 30px rgba(0, 0, 0, .4);
  text-align: center;
  z-index: 20;
}
.toast[hidden] { display: none; }

@keyframes fade { from { opacity: 0; } }

@media (prefers-reduced-motion: reduce) {
  .sky i, .glow, .ogre { animation: none; }
}
@media (max-height: 680px) {
  .headline { font-size: 18px; margin-top: 10px; }
  .hint { margin-bottom: 10px; }
  .tap-btn { height: 64px; font-size: 22px; }
}

main {
  padding-bottom: calc(var(--safe-bottom) + 40px);
}

.tap-btn {
  margin-bottom: 24px;
}