/* Шрифты лежат у нас на сервере: не зависим от Google и быстрее грузится в любой стране */
@font-face { font-family: 'Golos Text'; src: url('/fonts/golos.woff') format('woff'); font-weight: 400 900; font-display: swap; }
@font-face { font-family: 'Pixelify Sans'; src: url('/fonts/pixelify.woff') format('woff'); font-weight: 400 700; font-display: swap; }

/* Brainrot Grader — тёмная пещера, золото и изумруд. Акцент только там, где действие или выигрыш. */
:root {
  --cave: #0c1110;
  --stone: #131a18;
  --stone-2: #19221f;
  --ridge: #243129;
  --ridge-2: #31423a;
  --text: #e6efe9;
  --muted: #8b9c94;
  --faint: #5a6a63;
  --crystal: #34e08a;
  --crystal-hi: #8ef5c0;
  --crystal-dim: rgba(52, 224, 138, 0.13);
  --gold: #e9b43a;
  --amber: #f2b33d;
  --ember: #ff5d5d;
  --pixel: 'Pixelify Sans', 'Golos Text', system-ui, sans-serif;
  --body: 'Golos Text', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --tab-h: 64px;
  --safe-b: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--cave); color: var(--text); }
body {
  font: 400 15px/1.45 var(--body);
  min-height: 100vh;
  overscroll-behavior-y: none;
  -webkit-font-smoothing: antialiased;
}
img { display: block; max-width: 100%; }
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; padding: 0; }
input { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--crystal); outline-offset: 2px; }
.hidden { display: none !important; }

/* ---------- Шапка ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 10px;
  padding: 10px 16px;
  background: rgba(12, 17, 16, 0.92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--ridge);
}
.logo { height: 30px; width: auto; image-rendering: pixelated; }
.topbar .spacer { flex: 1; }
.balance {
  display: flex; align-items: center; gap: 6px;
  height: 36px; padding: 0 4px 0 10px;
  background: var(--stone); border: 1px solid var(--ridge); border-radius: 10px;
  font: 700 15px/1 var(--body); font-variant-numeric: tabular-nums;
}
.coin { width: 16px; height: 16px; image-rendering: pixelated; flex: none; display: inline-block; vertical-align: -2px; }
/* монета внутри цены не должна наследовать размеры картинок карточек */
.price .coin, .balance .coin, .total .coin { width: 16px; height: 16px; margin: 0; }
.plus {
  width: 28px; height: 28px; border-radius: 7px;
  display: grid; place-items: center;
  background: var(--crystal); color: #062014; font: 700 20px/1 var(--body);
}
.plus:active { transform: scale(0.94); }
.avatar {
  width: 36px; height: 36px; border-radius: 50%; overflow: hidden; flex: none;
  background: var(--stone-2); border: 1px solid var(--ridge-2);
  display: grid; place-items: center; font-weight: 700; color: var(--muted);
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }

/* ---------- Каркас ---------- */
main { padding: 16px 16px calc(var(--tab-h) + var(--safe-b) + 24px); max-width: 560px; margin: 0 auto; }
h1, h2, h3 { margin: 0; font-weight: 700; }
h2 { font-size: 20px; margin: 22px 0 12px; }
.muted { color: var(--muted); }
.price { display: inline-flex; align-items: center; gap: 5px; font: 600 14px/1 var(--body); font-variant-numeric: tabular-nums; }

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: grid; grid-template-columns: repeat(3, 1fr);
  height: calc(var(--tab-h) + var(--safe-b)); padding-bottom: var(--safe-b);
  background: rgba(12, 17, 16, 0.96); border-top: 1px solid var(--ridge);
}
.tabbar a {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  color: var(--faint); text-decoration: none; font-size: 12px; font-weight: 500;
}
.tabbar a svg { width: 22px; height: 22px; }
.tabbar a.on { color: var(--crystal); }

.banner { border-radius: 16px; overflow: hidden; border: 1px solid var(--ridge); aspect-ratio: 16 / 9; background: var(--stone); }
.banner img { width: 100%; height: 100%; object-fit: cover; }

/* ---------- Кейсы ---------- */
.case-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.case-card {
  display: flex; flex-direction: column; align-items: center;
  padding: 14px 10px 12px; border-radius: 14px;
  background: linear-gradient(180deg, var(--stone-2), var(--stone));
  border: 1px solid var(--ridge); text-decoration: none; color: inherit;
}
.case-card:active { border-color: var(--ridge-2); transform: scale(0.98); }
.case-card img { width: 96px; height: 96px; image-rendering: pixelated; margin: 4px 0 10px; }
.case-card .name { font-weight: 600; font-size: 15px; }
.case-card .row { display: flex; justify-content: space-between; align-items: center; width: 100%; margin-top: 8px; font-size: 12px; }

.back { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 14px; margin-bottom: 8px; text-decoration: none; }
.case-head { display: flex; align-items: center; gap: 14px; }
.case-head img { width: 72px; height: 72px; image-rendering: pixelated; }
.case-head h1 { font-size: 22px; }

/* ---------- Рулетка ---------- */
.roulette {
  position: relative; margin: 18px -16px 0; height: 150px; overflow: hidden;
  background: var(--stone); border-top: 1px solid var(--ridge); border-bottom: 1px solid var(--ridge);
}
.roulette::before, .roulette::after {
  content: ''; position: absolute; top: 0; bottom: 0; width: 48px; z-index: 2; pointer-events: none;
}
.roulette::before { left: 0; background: linear-gradient(90deg, var(--stone), transparent); }
.roulette::after { right: 0; background: linear-gradient(-90deg, var(--stone), transparent); }
.marker { position: absolute; left: 50%; top: 0; bottom: 0; width: 2px; margin-left: -1px; z-index: 3; background: var(--crystal); box-shadow: 0 0 12px var(--crystal); }
.marker::before, .marker::after { content: ''; position: absolute; left: -6px; border: 7px solid transparent; }
.marker::before { top: 0; border-top-color: var(--crystal); }
.marker::after { bottom: 0; border-bottom-color: var(--crystal); }
.strip { display: flex; gap: 8px; padding: 15px 0; will-change: transform; transform: translate3d(0, 0, 0); }
.strip.spinning .r-card { filter: blur(1.6px); }
.r-card {
  flex: none; width: 104px; height: 120px; border-radius: 12px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  background: var(--stone-2); border: 1px solid var(--ridge); position: relative; overflow: hidden;
  transition: filter 0.5s, opacity 0.5s;
}
.r-card img { width: 64px; height: 64px; image-rendering: pixelated; }
.r-card .n { font-size: 11px; color: var(--muted); max-width: 92px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.r-card.faded { filter: blur(2.5px); opacity: 0.4; }
.r-card.win { border-color: var(--crystal); box-shadow: 0 0 0 1px var(--crystal), 0 0 24px rgba(52, 224, 138, 0.35); }
.r-card.win::after,
.shine::after {
  content: ''; position: absolute; inset: -40% -60%;
  background: linear-gradient(105deg, transparent 40%, rgba(255, 255, 255, 0.28) 50%, transparent 60%);
  animation: shine 2.2s ease-in-out infinite;
}
@keyframes shine { from { transform: translateX(-60%); } to { transform: translateX(60%); } }

.rar-common { --rar: #6b7c75; } .rar-rare { --rar: #4aa3ff; } .rar-epic { --rar: #b06cff; } .rar-legendary { --rar: #e9b43a; }
.r-card::before, .item::before { content: ''; position: absolute; left: 0; right: 0; bottom: 0; height: 3px; background: var(--rar, transparent); opacity: 0.85; }

/* ---------- Кнопки ---------- */
.btn {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; height: 52px; border-radius: 12px; font-weight: 700; font-size: 16px;
  background: var(--crystal); color: #062014;
}
.btn:active { transform: scale(0.985); }
.btn:disabled { background: var(--stone-2); color: var(--faint); cursor: not-allowed; transform: none; }
.btn.ghost { background: var(--stone-2); color: var(--text); border: 1px solid var(--ridge-2); }
.btn.danger { background: transparent; color: var(--ember); border: 1px solid rgba(255, 93, 93, 0.35); }
.btn.small { height: 40px; font-size: 14px; border-radius: 10px; }
.btn .price { font-size: 16px; }
.btn-row { display: flex; gap: 8px; }
.btn-row .btn { flex: 1; }
.open-btn { margin-top: 16px; }

/* ---------- Сетка предметов ---------- */
.items { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.item {
  position: relative; overflow: hidden; border-radius: 12px; padding: 10px 6px 10px;
  background: var(--stone); border: 1px solid var(--ridge);
  display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center;
}
.item img { width: 58px; height: 58px; image-rendering: pixelated; }
.item .n { font-size: 12px; line-height: 1.2; min-height: 2.4em; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.item .price { font-size: 13px; }
.item.sel { border-color: var(--crystal); background: linear-gradient(180deg, var(--crystal-dim), var(--stone)); }
.item.dim { opacity: 0.35; }
button.item:active, div.item[role=button]:active { transform: scale(0.97); }
div.item[role=button] { cursor: pointer; }
.qty { position: absolute; top: 6px; right: 6px; min-width: 22px; height: 22px; padding: 0 6px; border-radius: 11px; background: var(--crystal); color: #062014; font: 700 12px/22px var(--body); }
.minus { position: absolute; top: 6px; left: 6px; width: 22px; height: 22px; border-radius: 11px; background: var(--stone-2); border: 1px solid var(--ridge-2); font-weight: 700; line-height: 20px; }

/* Предмет на выводе: размыт, крутится загрузка, крестик для отмены */
.item.withdrawing > :not(.wd-layer) { filter: blur(3px); opacity: 0.6; }
.wd-layer { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; padding: 6px; font-size: 11px; color: var(--crystal-hi); }
.spinner { width: 28px; height: 28px; border-radius: 50%; border: 3px solid rgba(52, 224, 138, 0.2); border-top-color: var(--crystal); animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.wd-cancel { position: absolute; top: 4px; right: 4px; width: 24px; height: 24px; border-radius: 12px; background: rgba(12, 17, 16, 0.85); border: 1px solid var(--ridge-2); color: var(--text); font-size: 14px; line-height: 22px; }
.wd-ingame { padding: 6px 8px; border-radius: 8px; background: var(--crystal); color: #062014; font-weight: 700; font-size: 11px; }

/* ---------- Апгрейдер ---------- */
.ring-wrap { position: relative; width: 260px; height: 260px; margin: 6px auto 0; }
.ring-wrap svg { width: 100%; height: 100%; display: block; }
.ring-track { fill: none; stroke: var(--stone-2); stroke-width: 18; }
.ring-arc { fill: none; stroke-width: 18; stroke-linecap: butt; transition: stroke-dasharray 0.6s cubic-bezier(0.3, 0.8, 0.3, 1), stroke 0.4s; }
.ring-ticks line { stroke: var(--ridge-2); stroke-width: 2; }
.ring-center {
  position: absolute; inset: 52px; border-radius: 50%;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: radial-gradient(circle at 50% 35%, var(--stone-2), var(--cave));
  border: 1px solid var(--ridge); transition: background 0.5s, border-color 0.5s;
}
.ring-center .pct { font: 700 40px/1 var(--pixel); }
.ring-center .lbl { margin-top: 6px; font-size: 13px; color: var(--muted); }
.ring-center.won { background: radial-gradient(circle, rgba(52, 224, 138, 0.35), var(--cave)); border-color: var(--crystal); }
.ring-center.lost { background: radial-gradient(circle, rgba(255, 93, 93, 0.3), var(--cave)); border-color: var(--ember); }
.pointer { position: absolute; inset: 0; pointer-events: none; transform: rotate(0deg); }
.pointer::before {
  content: ''; position: absolute; left: 50%; top: -6px; margin-left: -9px;
  border: 9px solid transparent; border-top: 16px solid var(--crystal);
  filter: drop-shadow(0 0 6px rgba(52, 224, 138, 0.8));
}
.slots { display: grid; grid-template-columns: 1fr 22px 1fr; align-items: center; gap: 6px; margin-top: 14px; }
.slot { min-height: 128px; border-radius: 14px; border: 1px dashed var(--ridge-2); background: var(--stone); padding: 10px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; text-align: center; font-size: 12px; }
.slot.full { border-style: solid; }
.slot .imgs { display: flex; flex-wrap: wrap; justify-content: center; gap: 2px; }
.slot .imgs img { width: 40px; height: 40px; image-rendering: pixelated; }
.slot .imgs.one img { width: 64px; height: 64px; }
.slot .t { color: var(--muted); }
.arrow-between { color: var(--faint); text-align: center; }
.mults { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 14px 0; }
.chip { height: 44px; border-radius: 10px; background: var(--stone); border: 1px solid var(--ridge); display: flex; align-items: center; justify-content: center; gap: 6px; font-weight: 600; }
.chip small { color: var(--muted); font-weight: 500; }
.chip.on { border-color: var(--crystal); background: var(--crystal-dim); }
.seg { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 4px; margin: 18px 0 12px; border-radius: 12px; background: var(--stone); border: 1px solid var(--ridge); }
.seg button { height: 38px; border-radius: 9px; color: var(--muted); font-weight: 600; font-size: 14px; }
.seg button.on { background: var(--stone-2); color: var(--text); box-shadow: inset 0 0 0 1px var(--ridge-2); }

/* ---------- Профиль ---------- */
.panel { background: var(--stone); border: 1px solid var(--ridge); border-radius: 16px; padding: 16px; }
.panel + .panel { margin-top: 12px; }
.me { display: flex; align-items: center; gap: 14px; }
.me .avatar { width: 60px; height: 60px; font-size: 22px; }
.me .who { flex: 1; min-width: 0; }
.me .who b { display: block; font-size: 18px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.idline { display: inline-flex; gap: 6px; align-items: center; margin-top: 4px; font-size: 13px; color: var(--muted); }
.bal-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--ridge); }
.bal-big { font: 700 26px/1 var(--body); font-variant-numeric: tabular-nums; display: flex; align-items: center; gap: 8px; }
.bal-big .coin, .total b .coin { width: 22px; height: 22px; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 12px; }
.stat { background: var(--stone-2); border-radius: 10px; padding: 10px; }
.stat b { display: block; font: 700 18px/1.15 var(--body); font-variant-numeric: tabular-nums; }
.stat span { font-size: 12px; color: var(--muted); }
.reflink { display: flex; gap: 8px; margin-top: 12px; }
.reflink input { flex: 1; min-width: 0; height: 42px; padding: 0 12px; border-radius: 10px; background: var(--cave); border: 1px solid var(--ridge); color: var(--muted); font-size: 13px; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin: 22px 0 12px; }
.section-head h2 { margin: 0; }
.link-btn { color: var(--crystal); font-weight: 600; font-size: 14px; }
.empty { padding: 26px 16px; text-align: center; color: var(--muted); border: 1px dashed var(--ridge-2); border-radius: 14px; }
.empty .btn { margin-top: 12px; }

/* ---------- Нижние шторки ---------- */
.overlay { position: fixed; inset: 0; z-index: 40; background: rgba(0, 0, 0, 0.6); opacity: 0; transition: opacity 0.2s; }
.overlay.show { opacity: 1; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 41; max-height: 92vh; overflow-y: auto;
  max-width: 560px; margin: 0 auto;
  background: var(--stone); border: 1px solid var(--ridge); border-bottom: 0; border-radius: 20px 20px 0 0;
  padding: 18px 16px calc(18px + var(--safe-b));
  transform: translateY(100%); transition: transform 0.28s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.sheet.show { transform: translateY(0); }
.sheet-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.sheet-head h3 { font-size: 19px; }
.x { width: 34px; height: 34px; border-radius: 10px; background: var(--stone-2); border: 1px solid var(--ridge); font-size: 18px; line-height: 1; color: var(--muted); }
.field { display: block; margin-top: 12px; }
.field span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.field input { width: 100%; height: 48px; padding: 0 14px; border-radius: 12px; background: var(--cave); border: 1px solid var(--ridge); font-size: 16px; }
.field input:focus { border-color: var(--crystal); outline: none; }
.hint { font-size: 13px; color: var(--muted); margin: 10px 0 0; }
.note { margin-top: 12px; padding: 12px 14px; border-radius: 12px; background: var(--stone-2); border: 1px solid var(--ridge); font-size: 13px; color: var(--muted); }
.note.warn { border-color: rgba(242, 179, 61, 0.4); color: #f3d79a; }
.total { display: flex; justify-content: space-between; align-items: center; margin-top: 14px; padding: 14px; border-radius: 12px; background: var(--crystal-dim); border: 1px solid rgba(52, 224, 138, 0.35); }
.total b { font: 700 20px/1 var(--body); font-variant-numeric: tabular-nums; display: flex; align-items: center; gap: 6px; }
.sheet .btn { margin-top: 16px; }
.filters { display: grid; grid-template-columns: 1fr 1fr auto; gap: 8px; margin: 10px 0; }
.filters input { height: 40px; padding: 0 10px; border-radius: 10px; background: var(--cave); border: 1px solid var(--ridge); font-size: 14px; min-width: 0; }
.search { width: 100%; height: 42px; padding: 0 12px; border-radius: 10px; background: var(--cave); border: 1px solid var(--ridge); font-size: 15px; }
.sort { height: 40px; padding: 0 12px; border-radius: 10px; background: var(--stone-2); border: 1px solid var(--ridge); font-size: 13px; white-space: nowrap; }
.picked { position: sticky; bottom: calc(-18px - var(--safe-b)); margin: 12px -16px calc(-18px - var(--safe-b)); padding: 12px 16px calc(12px + var(--safe-b)); background: var(--stone); border-top: 1px solid var(--ridge); }
.picked .btn { margin-top: 0; }
.line { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--ridge); }
.line img { width: 40px; height: 40px; image-rendering: pixelated; }
.line .grow { flex: 1; min-width: 0; }
.line .grow b { display: block; font-weight: 600; font-size: 14px; }
.queue-num { font: 700 44px/1 var(--pixel); color: var(--crystal-hi); }
.timer { font: 700 30px/1 var(--pixel); }
.center { text-align: center; }

/* Результат кейса */
.result-card { position: relative; overflow: hidden; margin: 4px auto 0; width: 180px; padding: 18px 10px 14px; border-radius: 16px; background: linear-gradient(180deg, var(--stone-2), var(--stone)); border: 1px solid var(--crystal); box-shadow: 0 0 30px rgba(52, 224, 138, 0.25); text-align: center; }
.result-card img { width: 120px; height: 120px; margin: 0 auto 10px; image-rendering: pixelated; }
.result-card b { display: block; font-size: 16px; }
.result-card .price { margin-top: 8px; font-size: 18px; }

/* ---------- Уведомления сверху ---------- */
.toasts { position: fixed; top: 8px; left: 12px; right: 12px; z-index: 60; display: flex; flex-direction: column; gap: 8px; pointer-events: none; }
.toast {
  pointer-events: auto; max-width: 520px; margin: 0 auto; width: 100%;
  padding: 12px 14px; border-radius: 12px; font-size: 14px; font-weight: 500;
  background: #0f2a1d; border: 1px solid rgba(52, 224, 138, 0.55); color: #d6ffe9;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
  transform: translateY(-120%); opacity: 0; transition: transform 0.3s cubic-bezier(0.2, 0.8, 0.2, 1), opacity 0.3s;
}
.toast.show { transform: translateY(0); opacity: 1; }
.toast.err { background: #2a1111; border-color: rgba(255, 93, 93, 0.55); color: #ffdada; }

.skeleton { height: 160px; border-radius: 14px; background: linear-gradient(90deg, var(--stone), var(--stone-2), var(--stone)); background-size: 200% 100%; animation: sk 1.2s linear infinite; }
@keyframes sk { to { background-position: -200% 0; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; }
}

/* ---------- Технический перерыв / в разработке ---------- */
.closed {
  position: fixed; inset: 0; z-index: 100; background: var(--cave);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0;
  padding: 24px; text-align: center;
}
.closed img { width: 200px; image-rendering: pixelated; margin-bottom: 28px; }
.closed h1 { font-size: 22px; margin: 0 0 10px; display: flex; align-items: center; gap: 10px; }
.closed p { margin: 0; color: var(--muted); max-width: 320px; }
.closed .btn { width: auto; padding: 0 26px; margin-top: 26px; }
.closed-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--crystal); animation: blink 1.4s ease-in-out infinite; }
@keyframes blink { 50% { opacity: 0.25; } }
.mode-strip { position: sticky; top: 0; z-index: 30; padding: 8px 16px; background: #3a2a06; color: #f6d38d; font-size: 13px; text-align: center; border-bottom: 1px solid rgba(242, 179, 61, 0.4); }
