/* Изумруд — премиальный тёмный крипто-интерфейс */
:root {
  --bg: #070a09;
  --bg-2: #0a100e;
  --ink: #eef6f1;
  --muted: #7d918a;
  --green: #3df0a5;
  --green-soft: #8ffbc9;
  --green-dim: #16764f;
  --gold: #f4cf7d;
  --gold-dim: #7a6435;
  --red: #ff6f70;
  --line: rgba(255, 255, 255, .075);
  --glass: rgba(19, 27, 24, .72);
  --ease: cubic-bezier(.22, 1, .36, 1);
  --ease-quart: cubic-bezier(.16, 1, .3, 1);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

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

html, body {
  margin: 0; padding: 0; width: 100%;
  height: var(--tg-viewport-stable-height, 100dvh);
  overflow: hidden; overscroll-behavior: none;
  -webkit-font-smoothing: antialiased;
  user-select: none;
}

body {
  background:
    radial-gradient(120% 60% at 85% -10%, rgba(61, 240, 165, .16), transparent 55%),
    radial-gradient(90% 50% at 5% 105%, rgba(244, 207, 125, .09), transparent 60%),
    linear-gradient(180deg, #08100d 0%, var(--bg) 45%, #060908 100%);
  color: var(--ink);
  font-family: Manrope, system-ui, -apple-system, sans-serif;
  font-size: 14px;
  line-height: 1.45;
}

input, textarea { font-size: 16px; user-select: text; }
input[type=number]::-webkit-outer-spin-button,
input[type=number]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
input[type=number] { -moz-appearance: textfield; appearance: textfield; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
button:disabled { opacity: .42; cursor: default; }
button, .tab, .tile { transition: transform .18s var(--ease), background-color .18s var(--ease), border-color .18s var(--ease), color .18s var(--ease), opacity .18s var(--ease); }
button:active:not(:disabled) { transform: scale(.97); }
h1 { font-family: Unbounded, Manrope, sans-serif; font-size: 25px; line-height: 1.15; letter-spacing: -.03em; margin: 6px 0 8px; font-weight: 600; }
h1 span { color: var(--green); }
p { margin: 0; color: var(--muted); font-size: 12.5px; line-height: 1.55; }

#app { display: flex; flex-direction: column; width: 100%; height: 100%; overflow: hidden; }

/* ── Шапка ───────────────────────────────────────────── */
.app-header {
  flex-shrink: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: calc(10px + var(--safe-top)) 16px 12px;
  background: linear-gradient(180deg, rgba(8, 14, 12, .96), rgba(8, 14, 12, .82));
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(20px);
}
.who { display: flex; align-items: center; gap: 10px; min-width: 0; flex: 1; }
.avatar {
  position: relative; width: 40px; height: 40px; border-radius: 50%;
  display: grid; place-items: center; flex-shrink: 0;
  background: linear-gradient(145deg, #1c3b2e, #0f2019);
  border: 1px solid rgba(61, 240, 165, .35);
  box-shadow: 0 0 0 3px rgba(61, 240, 165, .07), inset 0 0 18px rgba(61, 240, 165, .12);
  color: var(--green-soft); font-weight: 800; font-size: 16px; overflow: hidden;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.who__text { min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.eyebrow { color: var(--green); font-size: 9px; font-weight: 800; letter-spacing: .16em; text-transform: uppercase; }
.who__text strong { font-size: 14px; font-weight: 700; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.balance {
  display: flex; flex-direction: column; align-items: flex-end; gap: 2px; flex-shrink: 0;
  padding: 7px 12px; border-radius: 15px;
  background: linear-gradient(150deg, rgba(244, 207, 125, .13), rgba(244, 207, 125, .03));
  border: 1px solid rgba(244, 207, 125, .26);
  box-shadow: 0 0 24px rgba(244, 207, 125, .07);
}
.balance__label { font-size: 8px; letter-spacing: .16em; color: #b79a5c; font-weight: 800; }
.balance strong { display: flex; align-items: baseline; gap: 4px; font-family: Unbounded, Manrope, sans-serif; font-size: 15px; font-weight: 600; color: var(--gold); font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.balance em { font-style: normal; font-family: Manrope, sans-serif; font-size: 8.5px; font-weight: 800; letter-spacing: .06em; color: #b79a5c; }
.balance.is-bump { animation: bump .42s var(--ease); }
@keyframes bump { 0% { transform: scale(1); } 35% { transform: scale(1.06); } 100% { transform: scale(1); } }

/* ── Каркас вкладок ──────────────────────────────────── */
.app-viewport { flex: 1; position: relative; min-height: 0; overflow: hidden; }
.view { position: absolute; inset: 0; overflow-y: auto; overflow-x: hidden; -webkit-overflow-scrolling: touch; overscroll-behavior-y: contain; scrollbar-gutter: stable; }
.view[hidden] { display: none; }
.view__pad { padding: 18px 16px 30px; max-width: 560px; margin: 0 auto; display: flex; flex-direction: column; gap: 12px; animation: rise .3s var(--ease) both; }
@keyframes rise { from { opacity: 0; transform: translate3d(0, 12px, 0); } to { opacity: 1; transform: none; } }

.hero { padding: 2px 2px 4px; }
.card {
  position: relative;
  background: linear-gradient(158deg, rgba(255, 255, 255, .055), rgba(255, 255, 255, .015) 55%, rgba(61, 240, 165, .03));
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 16px;
  backdrop-filter: blur(18px);
  box-shadow: 0 18px 40px rgba(0, 0, 0, .35), inset 0 1px 0 rgba(255, 255, 255, .06);
}
.card::before {
  content: ''; position: absolute; inset: 0; border-radius: inherit; pointer-events: none;
  background: radial-gradient(120% 80% at 50% -30%, rgba(61, 240, 165, .09), transparent 60%);
  opacity: .8;
}
.card > * { position: relative; }
.card__head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.card__title { font-weight: 800; font-size: 14px; }
.card__note { font-size: 9px; letter-spacing: .14em; color: var(--muted); font-weight: 800; }

label { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin: 4px 0 9px; font-weight: 700; font-size: 12.5px; color: #dfeae4; }
label:not(:first-child) { margin-top: 18px; }
label span { font-size: 9px; letter-spacing: .1em; color: var(--muted); font-weight: 800; }

/* ── Поля и кнопки ───────────────────────────────────── */
.amount { display: flex; align-items: center; gap: 5px; padding: 5px; border-radius: 14px; background: rgba(4, 9, 7, .62); border: 1px solid var(--line); }
.amount input { flex: 1; min-width: 0; padding: 9px 10px; background: transparent; border: 0; outline: 0; color: var(--ink); font-weight: 700; font-variant-numeric: tabular-nums; }
.amount input::placeholder { color: #4f625b; font-weight: 500; }
.amount button, .presets button, .choices button {
  border-radius: 10px; padding: 10px 12px; font-size: 11.5px; font-weight: 800;
  background: rgba(255, 255, 255, .055); color: #a9bcb3;
  border: 1px solid transparent;
}
.presets, .choices { display: flex; gap: 6px; margin-top: 8px; }
.presets button, .choices button { flex: 1; }
.choices button.is-selected, .presets button.is-selected { background: rgba(61, 240, 165, .14); color: var(--green-soft); border-color: rgba(61, 240, 165, .35); }
@media (hover: hover) {
  .amount button:hover, .presets button:hover, .choices button:hover { background: rgba(255, 255, 255, .1); color: #fff; }
}

.btn { width: 100%; margin-top: 16px; padding: 16px; border-radius: 15px; font-weight: 800; font-size: 15px; letter-spacing: -.01em; }
.btn--primary { background: linear-gradient(100deg, #8dfbc6, #35e39a 55%, #22c98a); color: #042015; box-shadow: 0 10px 30px rgba(53, 227, 154, .25), inset 0 1px 0 rgba(255, 255, 255, .5); }
.btn--primary:disabled { box-shadow: none; }
.btn--cash { background: linear-gradient(100deg, #ffe4a6, #f4cf7d 60%, #d9ac52); color: #2a1f06; box-shadow: 0 10px 30px rgba(244, 207, 125, .22), inset 0 1px 0 rgba(255, 255, 255, .5); }
.btn[hidden] { display: none; }

/* ── Мины ────────────────────────────────────────────── */
.board-card { padding: 14px; }
.chip { padding: 6px 11px; border-radius: 99px; background: rgba(61, 240, 165, .09); border: 1px solid rgba(61, 240, 165, .22); color: var(--green-soft); font-size: 10px; font-weight: 800; letter-spacing: .08em; font-variant-numeric: tabular-nums; }
.mult { font-family: Unbounded, Manrope, sans-serif; font-size: 19px; font-weight: 600; color: var(--gold); font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 7px; margin: 14px 0 12px; }
.tile {
  position: relative; aspect-ratio: 1; border-radius: 13px;
  background: linear-gradient(150deg, #1b2b25, #121d19);
  border: 1px solid rgba(255, 255, 255, .07);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .05);
  display: grid; place-items: center; color: #55706a;
  will-change: transform;
}
.tile svg { width: 46%; height: 46%; opacity: 0; transform: scale(.5); transition: opacity .2s var(--ease), transform .28s var(--ease); }
.tile:active:not(:disabled) { transform: scale(.94); }
.tile.is-open {
  background: linear-gradient(150deg, #164b36, #0d2b1f);
  border-color: rgba(61, 240, 165, .55);
  color: var(--green);
  box-shadow: 0 0 22px rgba(61, 240, 165, .18), inset 0 0 18px rgba(61, 240, 165, .12);
  animation: pop .26s var(--ease);
}
.tile.is-bomb {
  background: linear-gradient(150deg, #5a2325, #331315);
  border-color: rgba(255, 111, 112, .6);
  color: #ff9b9b;
  box-shadow: 0 0 22px rgba(255, 111, 112, .2);
  animation: shake .32s var(--ease);
}
.tile.is-dim { opacity: .32; }
.tile.is-open svg, .tile.is-bomb svg { opacity: 1; transform: scale(1); }
@keyframes pop { 0% { transform: scale(.82); } 60% { transform: scale(1.06); } 100% { transform: scale(1); } }
@keyframes shake { 0%, 100% { transform: translate3d(0, 0, 0); } 25% { transform: translate3d(-3px, 0, 0); } 55% { transform: translate3d(3px, 0, 0); } 80% { transform: translate3d(-1px, 0, 0); } }
.board-foot { display: flex; justify-content: space-between; font-size: 11px; color: var(--muted); font-weight: 600; }

/* ── Кости ───────────────────────────────────────────── */
.dice-card { padding: 26px 18px 20px; text-align: center; }
.dice-number {
  font-family: Unbounded, Manrope, sans-serif; font-size: 52px; font-weight: 600;
  letter-spacing: -.05em; font-variant-numeric: tabular-nums; line-height: 1.05;
  color: var(--ink); transition: color .2s var(--ease), transform .2s var(--ease);
  text-shadow: 0 0 34px rgba(61, 240, 165, .12);
}
.dice-number.is-win { color: var(--green); text-shadow: 0 0 40px rgba(61, 240, 165, .4); }
.dice-number.is-loss { color: var(--red); text-shadow: 0 0 40px rgba(255, 111, 112, .32); }
.dice-number.is-rolling { color: #b8ccc3; }
.track { position: relative; height: 12px; margin-top: 22px; border-radius: 99px; overflow: hidden; background: linear-gradient(90deg, rgba(255, 111, 112, .28), rgba(255, 111, 112, .14)); border: 1px solid rgba(255, 255, 255, .06); }
.track__zone { position: absolute; top: 0; bottom: 0; width: 50%; left: 0; background: linear-gradient(90deg, #1c8f63, var(--green)); box-shadow: 0 0 20px rgba(61, 240, 165, .35); transition: width .22s var(--ease), left .22s var(--ease); }
.track__marker { position: absolute; top: -5px; bottom: -5px; width: 3px; border-radius: 2px; background: #fff; box-shadow: 0 0 12px rgba(255, 255, 255, .8); transform: translateX(-1.5px); transition: left .3s var(--ease); }
.track__scale { display: flex; justify-content: space-between; margin-top: 8px; font-size: 9px; font-weight: 700; color: var(--muted); font-variant-numeric: tabular-nums; }
input[type=range] { -webkit-appearance: none; appearance: none; width: 100%; height: 26px; background: transparent; margin: 2px 0 4px; }
input[type=range]::-webkit-slider-runnable-track { height: 6px; border-radius: 99px; background: linear-gradient(90deg, rgba(61, 240, 165, .5), rgba(61, 240, 165, .14)); }
input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 22px; height: 22px; margin-top: -8px; border-radius: 50%; background: linear-gradient(150deg, #d9fff0, var(--green)); border: 2px solid #082018; box-shadow: 0 0 16px rgba(61, 240, 165, .55); }
input[type=range]::-moz-range-track { height: 6px; border-radius: 99px; background: rgba(61, 240, 165, .3); }
input[type=range]::-moz-range-thumb { width: 20px; height: 20px; border-radius: 50%; background: var(--green); border: 2px solid #082018; }
.metrics { display: flex; justify-content: space-between; gap: 10px; margin-top: 14px; padding: 13px 14px; border-radius: 14px; background: rgba(4, 9, 7, .55); border: 1px solid var(--line); }
.metrics > div { display: flex; flex-direction: column; gap: 4px; }
.metrics > div:last-child { text-align: right; }
.metrics span { font-size: 8.5px; letter-spacing: .14em; color: var(--muted); font-weight: 800; }
.metrics strong { font-family: Unbounded, Manrope, sans-serif; font-size: 16px; font-weight: 600; color: var(--gold); font-variant-numeric: tabular-nums; }

/* ── Краш ────────────────────────────────────────────── */
.crash-strip { display: flex; gap: 6px; overflow: hidden; padding: 2px 0; }
.crash-strip span { flex-shrink: 0; padding: 6px 10px; border-radius: 9px; font-size: 10px; font-weight: 800; font-variant-numeric: tabular-nums; background: rgba(61, 240, 165, .1); color: var(--green-soft); border: 1px solid rgba(61, 240, 165, .2); animation: rise .3s var(--ease) both; }
.crash-strip span.low { background: rgba(255, 111, 112, .1); color: #ff9b9b; border-color: rgba(255, 111, 112, .22); }
.crash-strip span.high { background: rgba(244, 207, 125, .12); color: var(--gold); border-color: rgba(244, 207, 125, .3); }
.chart-card { height: 236px; padding: 0; overflow: hidden; }
.chart-card canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.chart-overlay { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; pointer-events: none; }
.chart-status { font-size: 9px; letter-spacing: .2em; font-weight: 800; color: var(--muted); transition: color .2s var(--ease); }
.chart-value { font-family: Unbounded, Manrope, sans-serif; font-size: 44px; font-weight: 600; letter-spacing: -.05em; font-variant-numeric: tabular-nums; transition: color .2s var(--ease); }
.chart-card.is-crashed .chart-value { color: var(--red); animation: crashFlash .5s var(--ease); }
.chart-card.is-crashed .chart-status { color: var(--red); }
.chart-card.is-crashed { border-color: rgba(255, 111, 112, .45); box-shadow: 0 0 40px rgba(255, 111, 112, .16), inset 0 0 40px rgba(255, 111, 112, .07); }
.chart-card.is-cashed .chart-value { color: var(--gold); }
@keyframes crashFlash { 0% { opacity: .2; transform: scale(1.12); } 100% { opacity: 1; transform: scale(1); } }

/* ── История и топ ───────────────────────────────────── */
.list { margin-top: 6px; }
.empty { padding: 22px 4px; text-align: center; color: var(--muted); font-size: 12px; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 11px 0; border-top: 1px solid var(--line); }
.row:first-child { border-top: 0; }
.row__left { display: flex; align-items: center; gap: 10px; min-width: 0; }
.row__icon { width: 32px; height: 32px; flex-shrink: 0; border-radius: 10px; display: grid; place-items: center; background: rgba(61, 240, 165, .1); color: var(--green-soft); font-size: 9px; font-weight: 800; letter-spacing: .04em; }
.row__icon.dice { background: rgba(244, 207, 125, .1); color: var(--gold); }
.row__icon.crash { background: rgba(120, 160, 255, .1); color: #9db6ff; }
.row__name { font-weight: 700; font-size: 12.5px; }
.row__sub { font-size: 10px; color: var(--muted); font-variant-numeric: tabular-nums; }
.row__right { text-align: right; flex-shrink: 0; font-variant-numeric: tabular-nums; }
.row__right b { display: block; font-size: 13px; font-weight: 800; }
.row__right b.up { color: var(--green); }
.row__right b.down { color: var(--red); }
.row__right small { font-size: 9.5px; color: var(--muted); font-weight: 700; }
.rank { width: 24px; height: 24px; flex-shrink: 0; border-radius: 8px; display: grid; place-items: center; font-size: 11px; font-weight: 800; background: rgba(255, 255, 255, .06); color: var(--muted); font-variant-numeric: tabular-nums; }
.rank.r1 { background: linear-gradient(150deg, #ffe6a8, #d9ac52); color: #2a1f06; box-shadow: 0 0 16px rgba(244, 207, 125, .3); }
.rank.r2 { background: linear-gradient(150deg, #e7eef0, #9fb1b6); color: #1a2426; }
.rank.r3 { background: linear-gradient(150deg, #e2b48d, #a8734a); color: #241408; }
.rank.me { outline: 1px solid rgba(61, 240, 165, .5); }
.row__you { font-size: 9px; color: var(--green); font-weight: 800; letter-spacing: .06em; margin-left: 6px; }

/* ── Нижняя навигация ────────────────────────────────── */
.tabbar {
  position: relative; flex-shrink: 0; z-index: 10;
  display: grid; grid-template-columns: repeat(var(--tabs), 1fr);
  padding: 6px 8px max(8px, var(--safe-bottom));
  background: rgba(9, 15, 13, .92);
  border-top: 1px solid var(--line);
  backdrop-filter: blur(20px);
}
.tabbar__pill {
  position: absolute; top: 6px; left: 8px; height: 50px;
  width: calc((100% - 16px) / var(--tabs));
  border-radius: 13px;
  background: linear-gradient(160deg, rgba(61, 240, 165, .16), rgba(61, 240, 165, .05));
  border: 1px solid rgba(61, 240, 165, .22);
  transform: translate3d(calc(var(--active) * 100%), 0, 0);
  transition: transform .26s var(--ease);
  will-change: transform;
}
.tab { position: relative; z-index: 1; height: 50px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; color: #6d817a; font-size: 9.5px; font-weight: 700; }
.tab svg { width: 21px; height: 21px; }
.tab.is-active { color: var(--green-soft); }
.tab:active { transform: scale(.94); }
body.kb-open .tabbar { display: none; }

/* ── Тост ────────────────────────────────────────────── */
.toast {
  position: fixed; z-index: 40; left: 50%; bottom: calc(84px + var(--safe-bottom));
  transform: translate3d(-50%, 12px, 0); opacity: 0; pointer-events: none;
  max-width: min(90vw, 420px); padding: 11px 18px; border-radius: 99px;
  background: #eaf7f0; color: #0a2318; font-weight: 800; font-size: 12.5px; text-align: center;
  box-shadow: 0 12px 34px rgba(0, 0, 0, .4);
  transition: opacity .22s var(--ease), transform .22s var(--ease);
}
.toast.is-show { opacity: 1; transform: translate3d(-50%, 0, 0); }
.toast.is-error { background: #ffd9d9; color: #3a0d0d; }
.toast.is-gold { background: linear-gradient(100deg, #ffe8b3, #f4cf7d); color: #2a1f06; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
