:root {
  --bg: #111216;
  --surface: #1c1d22;
  --surface-2: #25262c;
  --surface-3: #2f3037;
  --line: rgba(255, 255, 255, 0.06);
  --text: #ffffff;
  --muted: #8d8f9a;
  --primary-1: #9787ff;
  --primary-2: #6c58f0;
  --ton: #0098ea;
  --green: #34c77b;
  --red: #ff5a5f;
  --orange: #ff7a2e;
  --safe-bottom: max(env(safe-area-inset-bottom), var(--tg-safe-area-inset-bottom, 0px));
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  background: var(--bg);
  color: var(--text);
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}

button {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  cursor: pointer;
  text-align: inherit;
}

button:active { transform: scale(0.97); }
img { display: block; }
svg { fill: currentColor; }

#app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  padding-bottom: calc(110px + var(--safe-bottom));
}

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: 14px;
  font-weight: 700;
  transition: transform 0.12s, opacity 0.2s;
}

.btn svg { width: 18px; height: 18px; }

.btn-primary {
  background: linear-gradient(135deg, var(--primary-1), var(--primary-2));
  color: #fff;
  box-shadow: 0 6px 20px rgba(108, 88, 240, 0.35);
}

.btn-primary:disabled {
  background: var(--surface-3);
  color: var(--muted);
  box-shadow: none;
  transform: none;
  cursor: default;
}

.btn-sm { padding: 10px 14px; font-size: 14px; border-radius: 12px; }
.btn-lg { width: 100%; height: 54px; font-size: 16px; }
.btn-white { background: #fff; color: #111; flex: 1; height: 48px; }
.btn-glass { background: rgba(255, 255, 255, 0.16); color: #fff; flex: 1; height: 48px; backdrop-filter: blur(8px); }

/* ---------- Header ---------- */

.header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px 12px;
}

.logo-tile {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: radial-gradient(circle at 30% 25%, #2b2c33, #15161a);
  border: 1px solid var(--line);
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.logo-tile img { width: 26px; height: 26px; }

.balance-block {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.balance-label { font-size: 12px; color: var(--muted); font-weight: 500; }

.balance-value {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 19px;
  font-weight: 800;
}

.ton-ic { width: 20px; height: 20px; }

/* ---------- Pages ---------- */

.page { display: none; padding: 0 16px; animation: fadeUp 0.28s ease; }
.page.active { display: block; }

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

.page-title { font-size: 26px; font-weight: 800; margin: 6px 0 16px; }

.section-head { display: flex; align-items: center; justify-content: space-between; margin: 22px 0 12px; }
.section-head h2 { font-size: 18px; font-weight: 800; }

/* ---------- Live ---------- */

.live {
  display: flex;
  align-items: stretch;
  gap: 8px;
  margin-bottom: 14px;
}

.live-label {
  writing-mode: vertical-rl;
  transform: rotate(180deg);
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 800;
  color: var(--text);
  padding: 4px 0;
}

.live-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 0 3px rgba(52, 199, 123, 0.25);
  animation: blink 1.6s ease infinite;
}

@keyframes blink { 50% { opacity: 0.35; } }

.live-track {
  flex: 1;
  display: flex;
  gap: 8px;
  overflow-x: auto;
  scrollbar-width: none;
  min-height: 64px;
}

.live-track::-webkit-scrollbar { display: none; }

.live-item {
  flex: 0 0 62px;
  height: 64px;
  border-radius: 14px;
  background: linear-gradient(180deg, var(--surface-2), color-mix(in srgb, var(--c) 30%, var(--surface-2)));
  border: 1px solid color-mix(in srgb, var(--c) 45%, transparent);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
}

.live-item.new { animation: popIn 0.35s ease; }

.live-item img { width: 24px; height: 24px; filter: drop-shadow(0 2px 6px var(--c)); }
.live-item span { font-size: 11.5px; font-weight: 800; }

.live-empty {
  flex: 1;
  border-radius: 14px;
  background: var(--surface);
  color: var(--muted);
  font-size: 13px;
  display: grid;
  place-items: center;
  padding: 0 12px;
  text-align: center;
}

@keyframes popIn { from { opacity: 0; transform: scale(0.7); } to { opacity: 1; transform: none; } }

/* ---------- Banner ---------- */

.banner {
  position: relative;
  display: block;
  width: 100%;
  aspect-ratio: 2170 / 725;
  border-radius: 20px;
  overflow: hidden;
  background: #2f86ff;
}

.banner img { width: 100%; height: 100%; object-fit: cover; }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  font-weight: 800;
  padding: 5px 10px;
  border-radius: 999px;
}

.chip svg { width: 14px; height: 14px; }

.banner .chip { position: absolute; top: 12px; left: 12px; }
.chip-soon { background: #fff; color: var(--orange); }
.chip-free { background: rgba(52, 199, 123, 0.16); color: var(--green); }

/* ---------- Case card ---------- */

.case-card {
  position: relative;
  width: 100%;
  display: grid;
  grid-template-columns: 46% 1fr;
  align-items: center;
  gap: 6px;
  padding: 12px 16px 12px 6px;
  border-radius: 22px;
  overflow: hidden;
  background:
    radial-gradient(90% 120% at 22% 50%, rgba(47, 134, 255, 0.45), transparent 62%),
    linear-gradient(135deg, #1d2a4a, #181a22 70%);
  border: 1px solid rgba(80, 150, 255, 0.28);
}

.case-card-art img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: contain;
  filter: drop-shadow(0 10px 24px rgba(0, 120, 255, 0.45));
  animation: float 4s ease-in-out infinite;
}

@keyframes float { 50% { transform: translateY(-6px) rotate(-1.5deg); } }

.case-card-body { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; }
.case-card-title { font-size: 24px; font-weight: 900; letter-spacing: -0.3px; }
.case-card-sub { font-size: 13px; color: #b7bccb; line-height: 1.4; }

.case-card-btn {
  margin-top: 6px;
  padding: 10px 18px;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 800;
  background: linear-gradient(135deg, #ffd23f, #ffad0d);
  color: #2b1d00;
  box-shadow: 0 6px 18px rgba(255, 180, 20, 0.35);
  font-variant-numeric: tabular-nums;
}

.case-card-btn.wait { background: rgba(255, 255, 255, 0.1); color: #fff; box-shadow: none; }

/* ---------- Dock (нижняя навигация) ---------- */

.dock-fade {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  height: calc(110px + var(--safe-bottom));
  background: linear-gradient(180deg, transparent, var(--bg) 65%);
  pointer-events: none;
  z-index: 40;
}

.dock {
  position: fixed;
  left: 50%;
  bottom: calc(14px + var(--safe-bottom));
  transform: translateX(-50%);
  display: flex;
  gap: 10px;
  z-index: 50;
}

.dock-group {
  display: flex;
  gap: 2px;
  padding: 5px;
  border-radius: 999px;
  background: rgba(30, 31, 36, 0.92);
  border: 1px solid var(--line);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.5);
}

.dock-btn {
  width: 74px;
  height: 48px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  color: #e9e9ee;
  transition: background 0.2s, color 0.2s;
}

.dock-btn svg { width: 24px; height: 24px; }
.dock-btn.active { background: #34353c; color: #8d8f9a; }

.dock-solo {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: rgba(30, 31, 36, 0.92);
  border: 1px solid var(--line);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.5);
}

.dock-solo.active { background: #34353c; }

/* ---------- Case screen ---------- */

.screen {
  position: fixed;
  inset: 0;
  z-index: 80;
  background: var(--bg);
  overflow-y: auto;
  padding: 0 16px calc(28px + var(--safe-bottom));
  transform: translateX(100%);
  transition: transform 0.32s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.screen.open { transform: none; }
.screen > * { max-width: 448px; margin-left: auto; margin-right: auto; }

.screen-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 0 4px;
}

.icon-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--surface);
  display: grid;
  place-items: center;
}

.icon-btn svg { width: 24px; height: 24px; }
.screen-title { font-size: 17px; font-weight: 800; }

.balance-mini {
  display: flex;
  align-items: center;
  gap: 5px;
  font-weight: 800;
  font-size: 14px;
  background: var(--surface);
  padding: 8px 12px;
  border-radius: 999px;
}

.balance-mini img { width: 16px; height: 16px; }

.case-hero {
  display: grid;
  place-items: center;
  padding: 4px 0 8px;
  background: radial-gradient(50% 50% at 50% 50%, rgba(47, 134, 255, 0.35), transparent 70%);
}

.case-hero img {
  width: 210px;
  height: 210px;
  object-fit: contain;
  animation: float 4s ease-in-out infinite;
}

.roulette-wrap { position: relative; margin-bottom: 16px; }

.roulette {
  height: 124px;
  overflow: hidden;
  border-radius: 18px;
  background: var(--surface);
  border: 1px solid var(--line);
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 14%, #000 86%, transparent);
  mask-image: linear-gradient(90deg, transparent, #000 14%, #000 86%, transparent);
}

.roulette-track {
  display: flex;
  gap: 8px;
  height: 100%;
  align-items: center;
  will-change: transform;
}

.roulette-marker {
  position: absolute;
  top: -6px;
  bottom: -6px;
  left: 50%;
  width: 3px;
  transform: translateX(-50%);
  background: #ffd23f;
  border-radius: 3px;
  box-shadow: 0 0 12px rgba(255, 210, 63, 0.8);
  pointer-events: none;
}

.roulette-marker::before,
.roulette-marker::after {
  content: "";
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  border: 7px solid transparent;
}

.roulette-marker::before { top: -2px; border-top-color: #ffd23f; }
.roulette-marker::after { bottom: -2px; border-bottom-color: #ffd23f; }

.case-note { text-align: center; color: var(--muted); font-size: 13px; margin-top: 10px; }

/* ---------- Prize tiles ---------- */

.tile {
  --c: #8e9bb3;
  flex: 0 0 96px;
  height: 104px;
  border-radius: 16px;
  background: linear-gradient(180deg, var(--surface-2) 30%, color-mix(in srgb, var(--c) 32%, var(--surface-2)));
  border-bottom: 3px solid var(--c);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  position: relative;
}

.tile img { width: 40px; height: 40px; filter: drop-shadow(0 4px 12px color-mix(in srgb, var(--c) 70%, transparent)); }
.tile .tile-amount { font-size: 14px; font-weight: 800; }
.tile .tile-chance { position: absolute; top: 7px; right: 8px; font-size: 10.5px; font-weight: 700; color: var(--muted); }

.tile.win {
  box-shadow: 0 0 0 2px var(--c), 0 0 26px color-mix(in srgb, var(--c) 70%, transparent);
  animation: winPulse 0.6s ease 2;
}

@keyframes winPulse { 50% { transform: scale(1.06); } }

.prize-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.prize-grid .tile { height: 112px; }

/* ---------- Wallet ---------- */

.balance-card {
  position: relative;
  border-radius: 24px;
  padding: 20px;
  overflow: hidden;
  background:
    radial-gradient(120% 120% at 100% 0%, rgba(255, 255, 255, 0.22), transparent 50%),
    linear-gradient(135deg, #2f9bff, #6c58f0);
  box-shadow: 0 14px 36px rgba(70, 110, 255, 0.3);
}

.balance-card-label { font-size: 14px; font-weight: 600; opacity: 0.85; }

.balance-card-value {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 36px;
  font-weight: 900;
  margin: 6px 0 20px;
  letter-spacing: -0.5px;
}

.balance-card-value img { width: 34px; height: 34px; box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.35); border-radius: 50%; }
.balance-card-value .unit { font-size: 20px; opacity: 0.8; font-weight: 800; }
.balance-card-actions { display: flex; gap: 10px; }

.list {
  background: var(--surface);
  border-radius: 20px;
  padding: 4px 14px;
}

.list-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}

.list-row:last-child { border-bottom: 0; }
.list-row-main { flex: 1; min-width: 0; }
.list-row-title { font-weight: 700; font-size: 15px; }
.list-row-sub { color: var(--muted); font-size: 12.5px; margin-top: 2px; }
.list-row-end { text-align: right; }
.list-row-amount { font-weight: 800; font-size: 15px; }
.list-row-amount.plus { color: var(--green); }

.status { font-size: 11.5px; font-weight: 700; margin-top: 3px; }
.status-pending { color: #ffc23d; }
.status-approved, .status-completed { color: var(--green); }
.status-rejected { color: var(--red); }

.empty { color: var(--muted); font-size: 14px; text-align: center; padding: 26px 0; }

.odds-row .tile { flex: 0 0 44px; height: 44px; border-radius: 12px; gap: 0; border-bottom-width: 2px; }
.odds-row .tile img { width: 22px; height: 22px; }

.odds-bar { height: 6px; background: var(--surface-3); border-radius: 6px; margin-top: 7px; overflow: hidden; }
.odds-bar span { display: block; height: 100%; border-radius: 6px; background: var(--c); }

/* ---------- Info ---------- */

.info-list { display: flex; flex-direction: column; gap: 10px; }

.info-row {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  background: var(--surface);
  border-radius: 18px;
  padding: 14px;
}

.info-ic {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.info-ic svg { width: 22px; height: 22px; }
.ic-green { background: rgba(52, 199, 123, 0.15); color: var(--green); }
.ic-blue { background: rgba(0, 152, 234, 0.15); color: #3fb4ff; }
.ic-purple { background: rgba(151, 135, 255, 0.15); color: var(--primary-1); }

.info-title { font-weight: 800; font-size: 15px; }
.info-text { color: var(--muted); font-size: 13.5px; line-height: 1.45; margin-top: 3px; }

.support-btn {
  margin-top: 16px;
  width: 100%;
  height: 52px;
  border-radius: 16px;
  background: var(--surface);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-weight: 700;
}

.support-btn svg { width: 20px; height: 20px; color: var(--primary-1); }

/* ---------- Profile ---------- */

.profile-head {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 10px 0 20px;
}

.avatar {
  width: 92px;
  height: 92px;
  border-radius: 50%;
  padding: 3px;
  background: linear-gradient(135deg, var(--primary-1), #2f9bff);
  margin-bottom: 12px;
}

.avatar img, .avatar .avatar-letter {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
  border: 3px solid var(--bg);
}

.avatar .avatar-letter {
  display: grid;
  place-items: center;
  background: var(--surface-2);
  font-size: 34px;
  font-weight: 800;
}

.profile-name { font-size: 22px; font-weight: 800; }
.profile-username { color: var(--muted); font-size: 14px; margin-top: 2px; }

.id-chip {
  margin-top: 10px;
  font-size: 12.5px;
  font-weight: 700;
  color: var(--muted);
  background: var(--surface);
  padding: 6px 12px;
  border-radius: 999px;
}

.stats-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.stat { background: var(--surface); border-radius: 18px; padding: 14px; }

.stat-value {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 20px;
  font-weight: 800;
}

.stat-value img { width: 18px; height: 18px; }
.stat-label { color: var(--muted); font-size: 12.5px; margin-top: 4px; }

.menu { margin-top: 16px; background: var(--surface); border-radius: 20px; padding: 4px 12px; }

.menu-row {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}

.menu-row:last-child { border-bottom: 0; }
.menu-row:active { transform: none; opacity: 0.7; }
.menu-label { flex: 1; font-weight: 700; font-size: 15px; }
.chev { width: 22px; height: 22px; color: var(--muted); }

/* ---------- Sheets ---------- */

.backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s;
  z-index: 100;
}

.backdrop.show { opacity: 1; pointer-events: auto; }

.sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  max-width: 480px;
  margin: 0 auto;
  background: var(--surface);
  border-radius: 26px 26px 0 0;
  padding: 10px 18px calc(22px + var(--safe-bottom));
  transform: translateY(105%);
  visibility: hidden;
  transition: transform 0.32s cubic-bezier(0.2, 0.8, 0.2, 1), visibility 0s linear 0.32s;
  z-index: 110;
}

.sheet.open { transform: none; visibility: visible; transition-delay: 0s; }

.sheet-handle { width: 40px; height: 5px; border-radius: 5px; background: var(--surface-3); margin: 0 auto 14px; }
.sheet-title { font-size: 21px; font-weight: 800; margin-bottom: 8px; }
.sheet-text { color: var(--muted); font-size: 13.5px; line-height: 1.5; margin-bottom: 16px; }
.sheet-text.small { font-size: 12.5px; margin: 12px 0 0; text-align: center; }

.field-label { font-size: 13px; color: var(--muted); font-weight: 600; margin: 0 0 7px 2px; }
.field-hint { font-size: 12.5px; color: var(--muted); margin: 7px 0 16px 2px; }

.copy-field {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface-2);
  border-radius: 14px;
  padding: 13px 14px;
  margin-bottom: 14px;
  font-size: 14px;
  font-weight: 600;
}

.copy-field span { flex: 1; word-break: break-all; text-align: left; }
.copy-field svg { width: 20px; height: 20px; color: var(--primary-1); flex-shrink: 0; }

.warn {
  background: rgba(255, 122, 46, 0.12);
  color: #ffa36b;
  font-size: 13px;
  font-weight: 600;
  padding: 11px 14px;
  border-radius: 12px;
  margin-bottom: 16px;
}

.input-wrap {
  display: flex;
  align-items: center;
  background: var(--surface-2);
  border-radius: 14px;
  border: 1px solid transparent;
  padding: 0 6px 0 14px;
  transition: border-color 0.2s;
}

.input-wrap:focus-within { border-color: var(--primary-1); }

.input-wrap input {
  flex: 1;
  min-width: 0;
  height: 52px;
  background: none;
  border: 0;
  outline: 0;
  color: var(--text);
  font: inherit;
  font-size: 16px;
  font-weight: 600;
}

.input-wrap + .btn { margin-top: 18px; }

.max-btn {
  padding: 8px 12px;
  border-radius: 10px;
  background: rgba(151, 135, 255, 0.16);
  color: var(--primary-1);
  font-size: 13px;
  font-weight: 800;
}

/* ---------- Result ---------- */

.result {
  position: fixed;
  inset: 0;
  z-index: 150;
  background: rgba(8, 8, 12, 0.75);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.result.show { display: flex; }

.result-card {
  position: relative;
  width: 100%;
  max-width: 340px;
  background: var(--surface);
  border-radius: 28px;
  padding: 34px 22px 22px;
  display: flex;
  flex-direction: column;
  align-items: center;
  overflow: hidden;
  animation: resultIn 0.45s cubic-bezier(0.2, 1.4, 0.4, 1);
}

@keyframes resultIn { from { opacity: 0; transform: scale(0.8); } to { opacity: 1; transform: none; } }

.result-rays {
  position: absolute;
  top: -110px;
  left: 50%;
  width: 360px;
  height: 360px;
  margin-left: -180px;
  background: repeating-conic-gradient(from 0deg, var(--rc, rgba(255, 210, 63, 0.16)) 0 10deg, transparent 10deg 30deg);
  -webkit-mask-image: radial-gradient(circle, #000 20%, transparent 65%);
  mask-image: radial-gradient(circle, #000 20%, transparent 65%);
  animation: spin 14s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.tile-xl { flex: none; width: 128px; height: 136px; border-radius: 22px; position: relative; }
.tile-xl img { width: 60px; height: 60px; }
.tile-xl .tile-amount { font-size: 18px; }

.result-title { color: var(--muted); font-size: 14px; font-weight: 600; margin-top: 20px; position: relative; }
.result-amount { font-size: 34px; font-weight: 900; margin: 4px 0 22px; position: relative; color: var(--green); }

/* ---------- Toast ---------- */

.toast {
  position: fixed;
  left: 50%;
  top: calc(14px + var(--tg-content-safe-area-inset-top, 0px));
  transform: translate(-50%, -20px);
  background: var(--surface-3);
  color: var(--text);
  padding: 12px 18px;
  border-radius: 14px;
  font-size: 14px;
  font-weight: 600;
  opacity: 0;
  pointer-events: none;
  transition: all 0.25s ease;
  z-index: 300;
  max-width: calc(100% - 32px);
  text-align: center;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
}

.toast.show { opacity: 1; transform: translate(-50%, 0); }
