/* Стиль по референсу «Top coins»: глубокий синий фон с яркими голубыми засветами,
   тёмное стекло с бликующей кромкой, крупный белый заголовок, подписи разреженными капсами.
   Блюр только у того, под чем что-то прокручивается: шапка, нижняя панель, шторки, уведомление. */
:root {
  color-scheme: dark;
  --bg: #0a1730;
  --text: #ffffff;
  --hint: rgba(196, 210, 235, .62);
  --label: rgba(196, 210, 235, .55);
  --panel: linear-gradient(160deg, rgba(70, 92, 130, .5), rgba(22, 32, 56, .62) 45%, rgba(18, 28, 50, .66));
  --panel-flat: rgba(26, 38, 64, .6);
  --glass-strong: rgba(255, 255, 255, .14);
  --sep: rgba(255, 255, 255, .09);
  --bar: rgba(18, 30, 54, .62);
  --sheet: rgba(14, 24, 44, .8);
  --shadow: 0 1px 2px rgba(0, 6, 20, .25), 0 14px 34px rgba(0, 6, 20, .3);
  --accent: #2f8cff;
  --accent-2: #1d72ea;
  --link: #5aa8ff;
  --up: #3ddc84;
  --down: #ff5c63;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --side: max(16px, calc((100% - 488px) / 2));
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; min-height: 100%; }
body {
  color: var(--text); background: var(--bg);
  font: 16px/1.35 -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", Roboto, sans-serif;
  overscroll-behavior: none; user-select: none; -webkit-user-select: none;
}
/* голубые засветы, как на референсе */
body::before {
  content: ""; position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background:
    radial-gradient(42% 26% at 62% -2%, rgba(52, 145, 255, .95), transparent 72%),
    radial-gradient(26% 34% at -4% 48%, rgba(40, 125, 245, .6), transparent 72%),
    radial-gradient(24% 30% at 104% 58%, rgba(40, 125, 245, .55), transparent 72%),
    radial-gradient(46% 22% at 30% 104%, rgba(36, 115, 235, .5), transparent 72%);
}
button, input, select, textarea { font: inherit; color: inherit; }
button { background: none; border: 0; padding: 0; cursor: pointer; text-align: inherit; transition: transform .16s ease, opacity .16s, background .2s; }
button:active:not([disabled]) { transform: scale(.97); }
img { -webkit-user-drag: none; }

.hint { color: var(--hint); font-size: 14px; }
.empty { color: var(--hint); text-align: center; padding: 56px 16px; }
.star { width: 1em; height: 1em; fill: #ffc531; vertical-align: -0.12em; flex: none; }

/* ---------- материал: тёмное стекло + блик по кромке ---------- */
#bal, #tabs, .seg, .gift, .list, .btn.ghost, .amounts button, #toast {
  position: relative; background: var(--panel); box-shadow: var(--shadow);
}
#bal::before, #tabs::before, .seg::before, .gift::before, .list::before,
.btn.ghost::before, .amounts button::before, #toast::before {
  content: ""; position: absolute; inset: 0; border-radius: inherit; padding: 1.5px; pointer-events: none; z-index: 2;
  background: linear-gradient(155deg, rgba(255, 255, 255, .55), rgba(255, 255, 255, .1) 30%, rgba(255, 255, 255, .03) 60%, rgba(255, 255, 255, .22));
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor; mask-composite: exclude;
}

/* ---------- шапка ---------- */
#top {
  position: sticky; top: 0; z-index: 5; display: flex; align-items: center; justify-content: space-between;
  padding: 14px var(--side) 14px;
  background: linear-gradient(180deg, rgba(10, 23, 48, .72), rgba(10, 23, 48, .4));
  -webkit-backdrop-filter: blur(18px) saturate(160%); backdrop-filter: blur(18px) saturate(160%);
  -webkit-mask-image: linear-gradient(#000 78%, transparent); mask-image: linear-gradient(#000 78%, transparent);
}
#top h1 { margin: 0; font-size: 34px; font-weight: 700; letter-spacing: -.025em; }
#bal { display: flex; align-items: center; gap: 7px; padding: 6px 6px 6px 13px; border-radius: 22px; font-weight: 600; font-size: 16px; }
#bal .plus {
  width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; font-size: 19px; line-height: 1; color: #fff;
  background: linear-gradient(180deg, var(--accent), var(--accent-2)); box-shadow: inset 0 1px 0 rgba(255, 255, 255, .35);
}

#view { padding: 2px var(--side) calc(108px + var(--safe-b)); }

/* ---------- нижняя панель ---------- */
#tabs {
  position: fixed; z-index: 6; left: 12px; right: 12px; bottom: calc(10px + var(--safe-b));
  max-width: 496px; margin: 0 auto; display: flex; padding: 5px; border-radius: 30px;
  background: var(--bar);
  -webkit-backdrop-filter: blur(26px) saturate(180%); backdrop-filter: blur(26px) saturate(180%);
}
#tabs button {
  flex: 1; padding: 7px 0 6px; border-radius: 24px; display: flex; flex-direction: column; align-items: center; gap: 2px;
  font-size: 11px; font-weight: 500; color: var(--hint);
}
#tabs button.on { color: var(--text); background: var(--glass-strong); }
#tabs button.on svg { color: var(--link); }
#tabs svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- переключатель ---------- */
.seg { display: flex; gap: 2px; padding: 3px; margin: 0 0 14px; border-radius: 17px; overflow-x: auto; scrollbar-width: none; }
.seg::-webkit-scrollbar { display: none; }
.seg button { flex: 1 0 auto; padding: 8px 14px; border-radius: 14px; color: var(--hint); font-size: 15px; font-weight: 500; white-space: nowrap; text-align: center; }
.seg button.on { color: #fff; font-weight: 600; background: linear-gradient(180deg, var(--accent), var(--accent-2)); box-shadow: inset 0 1px 0 rgba(255, 255, 255, .3); }

/* ---------- карточки подарков ---------- */
.grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.gift { display: block; width: 100%; padding: 8px 8px 13px; border-radius: 24px; }
.pic {
  aspect-ratio: 1; border-radius: 17px; display: grid; place-items: center;
  background: radial-gradient(circle at 50% 42%, color-mix(in srgb, var(--rc, #fff) 30%, transparent), transparent 70%), rgba(255, 255, 255, .04);
}
.pic img { width: 78%; height: 78%; object-fit: contain; filter: drop-shadow(0 8px 10px rgba(0, 6, 20, .4)); }
.gift .nm { margin: 10px 5px 0; font-size: 17px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.gift .sub { margin: 1px 5px 0; font-size: 13px; color: var(--hint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.gift .price { margin: 8px 5px 0; font-size: 17px; font-weight: 700; }
.gift.out .pic img { filter: grayscale(1); opacity: .45; }
.grid.small { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 9px; }
.grid.small .gift { padding: 6px 6px 9px; border-radius: 20px; }
.grid.small .pic { border-radius: 14px; }
.grid.small .nm { font-size: 13px; margin-top: 5px; font-weight: 500; }
.grid.small .sub { font-size: 12px; }

/* ---------- списки ---------- */
.cap { margin: 26px 0 10px 6px; font-size: 12.5px; font-weight: 600; color: var(--label); text-transform: uppercase; letter-spacing: .12em; }
.list { border-radius: 24px; overflow: hidden; }
.row { display: flex; align-items: center; gap: 12px; padding: 12px 18px; width: 100%; min-height: 52px; }
.row + .row { border-top: 1px solid var(--sep); }
.row .grow { flex: 1; min-width: 0; }
.row .grow div { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .val { color: var(--text); font-weight: 600; white-space: nowrap; }
.row .act { color: var(--link); white-space: nowrap; font-weight: 600; }
.row .rank { width: 26px; text-align: center; color: var(--hint); font-size: 17px; font-variant-numeric: tabular-nums; flex: none; }
.row.me { background: rgba(47, 140, 255, .16); }
.note { margin: 9px 18px 0; font-size: 13px; color: var(--hint); }

/* задания */
.row.task { gap: 13px; }
.ticon {
  width: 40px; height: 40px; border-radius: 13px; flex: none; display: grid; place-items: center; color: #fff;
  background: linear-gradient(180deg, var(--accent), var(--accent-2)); box-shadow: inset 0 1px 0 rgba(255, 255, 255, .35);
}
.ticon svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.tbtn {
  flex: none; padding: 8px 15px; border-radius: 14px; font-size: 14px; font-weight: 600; color: #fff;
  background: linear-gradient(180deg, var(--accent), var(--accent-2)); box-shadow: inset 0 1px 0 rgba(255, 255, 255, .35);
}
.tbtn[disabled] { opacity: .5; }

.ava {
  width: 40px; height: 40px; border-radius: 50%; flex: none; object-fit: cover; display: grid; place-items: center;
  color: #10203a; font-weight: 700; box-shadow: 0 0 0 2px rgba(255, 255, 255, .14);
}
.ava.big { width: 70px; height: 70px; font-size: 27px; }
.who { display: flex; align-items: center; gap: 15px; padding: 6px 0 4px; }
.who b { font-size: 22px; display: block; }

/* ---------- кнопки ---------- */
.btn {
  position: relative; display: flex; align-items: center; justify-content: center; gap: 6px; width: 100%; padding: 15px; border-radius: 20px;
  color: #fff; font-size: 17px; font-weight: 600; text-align: center;
  background: linear-gradient(180deg, var(--accent), var(--accent-2));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .35), 0 6px 16px rgba(0, 6, 20, .3);
}
.btn.ghost { color: var(--text); }
.btn[disabled] { opacity: .45; }
.btns { display: flex; gap: 10px; margin-top: 18px; }

/* ---------- шторка ---------- */
.wrap {
  position: fixed; inset: 0; z-index: 20; display: flex; align-items: flex-end; justify-content: center;
  background: rgba(2, 8, 22, 0); transition: background .28s;
}
.wrap.open { background: rgba(2, 8, 22, .5); }
.sheet {
  width: 100%; max-width: 520px; max-height: 92%; overflow-y: auto; scrollbar-width: none;
  background: var(--sheet); border-radius: 32px 32px 0 0;
  -webkit-backdrop-filter: blur(32px) saturate(180%); backdrop-filter: blur(32px) saturate(180%);
  box-shadow: inset 0 1.5px 0 rgba(255, 255, 255, .32), 0 -12px 40px rgba(0, 6, 20, .4);
  padding: 8px 18px calc(22px + var(--safe-b));
  transform: translateY(100%); transition: transform .32s cubic-bezier(.2, .8, .2, 1);
}
.sheet::-webkit-scrollbar { display: none; }
.wrap.open .sheet { transform: none; }
.grab { width: 38px; height: 5px; border-radius: 3px; background: rgba(255, 255, 255, .25); margin: 0 auto 8px; }
.sheet h2 { margin: 4px 0 2px; font-size: 26px; text-align: center; letter-spacing: -.02em; }
.sheet .rar { text-align: center; font-size: 15px; font-weight: 500; }
.sheet .descr { margin: 12px 0 0; color: var(--hint); font-size: 15px; text-align: center; white-space: pre-wrap; }

/* вращаемый подарок */
.stage {
  position: relative; height: 262px; display: grid; place-items: center; perspective: 900px; touch-action: pan-y; cursor: grab;
  background: radial-gradient(circle at 50% 46%, color-mix(in srgb, var(--rc, #2f8cff) 30%, transparent), transparent 62%);
}
.stage::after {
  content: ""; position: absolute; left: 50%; bottom: 16px; width: 140px; height: 18px; margin-left: -70px; pointer-events: none;
  background: radial-gradient(closest-side, rgba(0, 6, 20, .5), transparent);
}
.spin { position: relative; transform-style: preserve-3d; will-change: transform; z-index: 1; }
.spin img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; pointer-events: none; }
.spin .face { backface-visibility: hidden; -webkit-backface-visibility: hidden; }
.spin .edge { filter: brightness(.55); }
.turnhint { text-align: center; font-size: 12px; color: var(--hint); margin-top: -4px; }

/* ---------- поля ---------- */
.field { display: block; margin-top: 12px; }
.field span { display: block; font-size: 12px; font-weight: 600; color: var(--label); text-transform: uppercase; letter-spacing: .1em; margin: 0 0 6px 6px; }
.inp {
  width: 100%; background: var(--panel-flat); border: 1px solid rgba(255, 255, 255, .14); border-radius: 16px; padding: 13px 15px;
  outline: none; user-select: text; -webkit-user-select: text; transition: border-color .15s, box-shadow .15s;
}
.inp::placeholder { color: var(--hint); }
.inp:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(47, 140, 255, .25); }
select.inp option { color: #111; }
textarea.inp { resize: none; height: 76px; }
.two { display: flex; gap: 10px; }
.two > * { flex: 1; min-width: 0; }
.check { display: flex; align-items: center; gap: 10px; margin-top: 14px; }
.check input { width: 20px; height: 20px; accent-color: var(--accent); }
.amounts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 14px; }
.amounts button { border-radius: 18px; padding: 16px 0; text-align: center; font-size: 17px; font-weight: 600; }

/* ---------- лаки-бай ---------- */
.wheel { width: 190px; height: 190px; margin: 10px auto 4px; position: relative; }
.wheel svg { width: 100%; height: 100%; display: block; }
.wheel .mid { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; }
.wheel .mid img { width: 92px; height: 92px; object-fit: contain; filter: drop-shadow(0 8px 10px rgba(0, 6, 20, .45)); }
.wheel .needle { transform-origin: 60px 60px; }
input[type=range] { width: 100%; accent-color: var(--accent); margin: 14px 0 2px; }
.lk { display: flex; justify-content: space-between; font-size: 15px; }
.res { text-align: center; min-height: 24px; margin-top: 10px; font-weight: 600; }

/* ---------- уведомление ---------- */
#toast {
  position: fixed; left: 16px; right: 16px; bottom: calc(102px + var(--safe-b)); z-index: 50; max-width: 440px; margin: 0 auto;
  padding: 13px 16px; border-radius: 22px; text-align: center; font-size: 15px; background: var(--bar);
  -webkit-backdrop-filter: blur(24px) saturate(180%); backdrop-filter: blur(24px) saturate(180%);
  opacity: 0; transform: translateY(10px); transition: .22s; pointer-events: none;
}
#toast.on { opacity: 1; transform: none; }

/* без поддержки blur — панели плотнее, чтобы текст читался */
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  :root { --bar: rgba(16, 28, 52, .97); --sheet: rgba(13, 22, 42, .98); }
  #top { background: var(--bg); -webkit-mask-image: none; mask-image: none; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
