﻿/* ─────────────────────────────────────────────────────────────────────────
   Стили мини-аппа «Развлечения». Тёмно-фиолетовая палитра бота + карточки
   в 3 колонки. Все эмодзи-монетки заменены на картинку приза (c15.png).
   ───────────────────────────────────────────────────────────────────────── */
:root {
  --bg1: #0f1020;
  --bg2: #1a1136;
  --card: #181a2e;
  --card-soft: rgba(40, 28, 90, .35);
  --line: rgba(161, 91, 255, .22);
  --line-strong: rgba(161, 91, 255, .55);
  --text: #f4f5ff;
  --muted: #9aa0c0;
  --muted-2: #6e7396;
  --accent: #8a5bff;
  --accent-2: #22d3ee;
  --gold: #ffd54a;
  --lime: #9be83f;
  --red: #ff5b7a;
  --radius: 16px;
  --radius-lg: 22px;
  --ease: cubic-bezier(.23, 1, .32, 1);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; margin: 0; padding: 0; }
html, body { height: 100%; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color: var(--text);
  background:
    radial-gradient(900px 500px at 15% -10%, rgba(138, 91, 255, .28), transparent 55%),
    radial-gradient(700px 500px at 110% 20%, rgba(34, 211, 238, .12), transparent 55%),
    var(--bg1);
  min-height: 100dvh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

#app {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  max-width: 520px;
  margin: 0 auto;
  padding-bottom: 68px;
}

/* ─── шапка ─────────────────────────────────────────────────────────── */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 14px 16px 10px;
  position: sticky;
  top: 0;
  background: linear-gradient(180deg, rgba(15, 16, 32, .95), rgba(15, 16, 32, .75) 80%, transparent);
  backdrop-filter: blur(6px);
  z-index: 10;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 17px; }
.brand-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--accent-2); box-shadow: 0 0 12px var(--accent-2); }
.balance {
  display: flex; align-items: center; gap: 6px;
  padding: 6px 14px; border-radius: 999px;
  background: rgba(255, 255, 255, .06);
  border: 1px solid var(--line);
  font-weight: 700; font-size: 14px;
  font-variant-numeric: tabular-nums;
}
.balance img { width: 20px; height: 20px; object-fit: contain; }

/* ─── контейнер экранов ─────────────────────────────────────────────── */
#screen-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 6px 14px 14px;
}
.screen { display: none; flex-direction: column; gap: 14px; }
.screen.active { display: flex; }

/* ─── карточки-разделы на главной ────────────────────────────────────── */
.section-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.section-card {
  border-radius: var(--radius-lg); padding: 18px 14px;
  border: 1px solid var(--line);
  background: linear-gradient(140deg, var(--card-soft), var(--card));
  cursor: pointer;
  transition: transform .12s var(--ease);
  display: flex; flex-direction: column; gap: 10px;
  min-height: 130px; justify-content: flex-end;
}
.section-card:active { transform: scale(.97); }
.section-card .ico { font-size: 40px; line-height: 1; }
.section-card .ttl { font-size: 15px; font-weight: 800; }
.section-card .sub { font-size: 11px; color: var(--muted); }

/* ─── таблетки-вкладки ──────────────────────────────────────────────── */
.tabs-pill {
  display: flex; gap: 6px; padding: 4px;
  background: rgba(255, 255, 255, .04);
  border: 1px solid var(--line);
  border-radius: 999px;
}
.tabs-pill button {
  flex: 1; padding: 9px 8px;
  border-radius: 999px; border: none; background: transparent;
  color: var(--muted); font: inherit; font-size: 13px; font-weight: 700;
  cursor: pointer;
  transition: background .15s var(--ease), color .15s var(--ease);
}
.tabs-pill button.active {
  background: linear-gradient(140deg, #7b31f0, #b45cff);
  color: #fff;
  box-shadow: 0 6px 16px rgba(123, 49, 240, .35);
}

/* ─── сетка карточек 3 колонки ──────────────────────────────────────── */
.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}
.grid-3 .cell {
  border-radius: 16px;
  padding: 8px 6px 10px;
  background: linear-gradient(160deg, var(--card-soft), var(--card));
  border: 1px solid var(--line);
  display: flex; flex-direction: column;
  gap: 6px;
  min-width: 0;
}
.cell .thumb {
  width: 100%;
  aspect-ratio: 1 / 1;
  display: flex; align-items: center; justify-content: center;
  background: rgba(0, 0, 0, .22);
  border-radius: 12px;
  overflow: hidden;
}
.cell .thumb img { width: 100%; height: 100%; object-fit: contain; }
.cell .name {
  font-size: 11.5px; font-weight: 800;
  text-align: center;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.cell .qty {
  font-size: 11px; color: var(--muted);
  text-align: center;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.cell .date {
  font-size: 10px;
  color: var(--gold);
  text-align: center;
  font-variant-numeric: tabular-nums;
  padding: 2px 4px;
  border-radius: 6px;
  background: rgba(255, 213, 74, .1);
}
.cell .price {
  display: flex; align-items: center; justify-content: center;
  gap: 4px; font-size: 11.5px; font-weight: 800; color: var(--gold);
}
.cell .price img { width: 14px; height: 14px; }
.cell .actions {
  display: flex; flex-direction: column; gap: 4px; margin-top: auto;
}
.cell button {
  border: none; border-radius: 10px;
  padding: 7px 4px; font: inherit; font-size: 11px; font-weight: 800;
  cursor: pointer;
  transition: transform .1s var(--ease);
  display: flex; align-items: center; justify-content: center; gap: 4px;
}
.cell button:active { transform: scale(.95); }
.btn-get { background: linear-gradient(180deg, #7df0ff, #22d3ee); color: #062b30; }
.btn-sell { background: linear-gradient(180deg, #ffe27a, #ffd54a); color: #3d2c00; }
.cell button img { width: 14px; height: 14px; }

/* ─── «Получить всё» ────────────────────────────────────────────────── */
.btn-wide {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; padding: 12px;
  border-radius: 14px; border: none;
  font: inherit; font-size: 14px; font-weight: 800;
  cursor: pointer;
  background: linear-gradient(140deg, #7b31f0, #b45cff);
  color: #fff;
  box-shadow: 0 8px 18px rgba(123, 49, 240, .35);
}
.btn-wide:active { transform: scale(.98); }

/* ─── история: карточка с двумя строками ───────────────────────────── */
.cell .status-line {
  display: flex; justify-content: space-between; gap: 4px;
  font-size: 10px; color: var(--muted);
  padding: 0 2px;
}
.cell .status-line b { color: var(--text); font-weight: 700; }

/* ─── разделители-подписи ──────────────────────────────────────────── */
.section-note {
  padding: 10px 14px;
  border-radius: 12px;
  background: rgba(138, 91, 255, .08);
  border: 1px solid var(--line);
  font-size: 12px; color: var(--muted); line-height: 1.4;
}

/* ─── пустое состояние ─────────────────────────────────────────────── */
.empty {
  padding: 28px 16px; text-align: center;
  color: var(--muted); font-size: 13px;
  border-radius: var(--radius);
  background: rgba(255, 255, 255, .03);
  border: 1px dashed var(--line);
}

/* ─── рулетка ──────────────────────────────────────────────────────── */
.reel-card {
  border-radius: var(--radius-lg);
  padding: 16px 0;
  background: linear-gradient(180deg, rgba(255, 255, 255, .07), rgba(255, 255, 255, .02));
  border: 1px solid var(--line);
  position: relative;
  overflow: hidden;
}
.reel { position: relative; height: 118px; overflow: hidden; }
.reel .track { display: flex; align-items: center; height: 100%; will-change: transform; }
.reel .item {
  flex: 0 0 auto;
  width: 96px; height: 96px; margin: 0 6px;
  border-radius: 18px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 6px;
  border: 1px solid rgba(255, 255, 255, .14);
  position: relative; overflow: hidden;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .18), 0 6px 14px rgba(0, 0, 0, .35);
  transition: transform .25s ease;
}
.reel .item .ico { width: 52px; height: 52px; display: flex; align-items: center; justify-content: center; font-size: 30px; }
.reel .item .ico img { width: 52px; height: 52px; object-fit: contain; border-radius: 10px; }
.reel .item .nm { font-size: 11px; font-weight: 700; text-align: center; padding: 0 6px; line-height: 1.1; color: #fff; }
.reel .item.win {
  transform: scale(1.08);
  box-shadow: 0 0 0 2px #fff, 0 0 24px var(--accent), inset 0 1px 0 rgba(255, 255, 255, .25);
}
.reel .marker {
  position: absolute; top: -4px; bottom: -4px; left: 50%;
  width: 3px; transform: translateX(-50%);
  background: linear-gradient(180deg, var(--accent-2), var(--accent));
  box-shadow: 0 0 16px var(--accent-2), 0 0 26px var(--accent);
  z-index: 5;
}
.reel .marker::before, .reel .marker::after {
  content: ""; position: absolute; left: 50%; transform: translateX(-50%);
  border-left: 8px solid transparent; border-right: 8px solid transparent;
}
.reel .marker::before { top: -2px; border-top: 11px solid var(--accent-2); }
.reel .marker::after { bottom: -2px; border-bottom: 11px solid var(--accent); }
.reel .fade { position: absolute; top: 0; bottom: 0; width: 74px; z-index: 4; pointer-events: none; }
.reel .fade.l { left: 0; background: linear-gradient(90deg, var(--card), transparent); }
.reel .fade.r { right: 0; background: linear-gradient(270deg, var(--card), transparent); }

.result {
  min-height: 46px; padding: 13px 16px;
  border-radius: 16px; font-size: 14px; font-weight: 700;
  text-align: center;
  background: rgba(255, 255, 255, .05);
  border: 1px solid var(--line);
}
.result.win { background: linear-gradient(120deg, rgba(138, 91, 255, .35), rgba(34, 211, 238, .25)); }
.result.lose { color: var(--muted); }
.result.gift { background: linear-gradient(120deg, rgba(255, 64, 129, .3), rgba(124, 77, 255, .3)); }

/* ─── счётчик прокрутов ─────────────────────────────────────────────── */
.spin-counters {
  display: grid; grid-template-columns: 1fr 1fr; gap: 8px;
  font-size: 11.5px;
}
.spin-counters .cnt {
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(255, 255, 255, .04);
  border: 1px solid var(--line);
  text-align: center;
}
.spin-counters .cnt .t { color: var(--muted-2); font-size: 10px; display: block; margin-bottom: 3px; text-transform: uppercase; letter-spacing: .06em; }
.spin-counters .cnt b { color: var(--text); font-weight: 800; font-size: 13px; }

/* ─── кнопки рулетки — цвета как раньше ───────────────────────────── */
.spin-buttons { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.spin-buttons button {
  padding: 14px 6px; border: none; border-radius: 16px;
  font: inherit; font-size: 15px; font-weight: 800;
  cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
}
.spin-buttons button .c {
  display: flex; align-items: center; gap: 3px;
  font-size: 11px; font-weight: 700; opacity: .85;
}
.spin-buttons button .c img { width: 14px; height: 14px; }
.spin-buttons button[data-m="1"] {
  background: linear-gradient(180deg, #ffe27a, #ffd54a);
  color: #3d2c00;
  box-shadow: 0 8px 18px rgba(255, 213, 74, .3);
}
.spin-buttons button[data-m="5"] {
  background: linear-gradient(180deg, #b69bff, #8a5bff);
  color: #fff;
  box-shadow: 0 8px 18px rgba(138, 91, 255, .35);
}
.spin-buttons button[data-m="10"] {
  background: linear-gradient(180deg, #7df0ff, #22d3ee);
  color: #062b30;
  box-shadow: 0 8px 18px rgba(34, 211, 238, .35);
}
.spin-buttons button:active { transform: translateY(2px) scale(.98); }
.spin-buttons button:disabled { filter: grayscale(.5) brightness(.85); opacity: .55; cursor: not-allowed; }

/* ─── кнопки «Получить / Продать» после спина ──────────────────────── */
.after-spin {
  display: grid; grid-template-columns: 1fr 1fr; gap: 8px;
  margin-top: 8px;
}
.after-spin button {
  padding: 14px 6px; border: none; border-radius: 14px;
  font: inherit; font-size: 14px; font-weight: 800;
  cursor: pointer;
}
.after-spin .keep { background: linear-gradient(180deg, #7df0ff, #22d3ee); color: #062b30; }
.after-spin .sell { background: linear-gradient(180deg, #ffe27a, #ffd54a); color: #3d2c00; }
.after-spin button:active { transform: scale(.97); }
.after-spin .timer { grid-column: 1 / -1; text-align: center; font-size: 11px; color: var(--muted); margin-top: 4px; }

/* ─── модал ────────────────────────────────────────────────────────── */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(8, 8, 18, .7);
  backdrop-filter: blur(4px);
  display: none; align-items: flex-end;
  z-index: 100;
}
.modal-backdrop.open { display: flex; }
.modal-sheet {
  width: 100%; max-width: 520px;
  margin: 0 auto;
  background: linear-gradient(180deg, #1c1d33, #15162a);
  border-radius: 22px 22px 0 0;
  padding: 20px 16px 26px;
  border: 1px solid var(--line);
}
.modal-sheet h3 { font-size: 15px; font-weight: 800; margin-bottom: 14px; text-align: center; }
.modal-sheet .opt {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 14px; margin-bottom: 8px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, .05);
  cursor: pointer;
  font: inherit; font-size: 14px; font-weight: 700;
  color: var(--text); width: 100%;
}
.modal-sheet .opt:active { transform: scale(.98); }
.modal-sheet .opt .price {
  display: flex; align-items: center; gap: 4px;
  color: var(--gold);
  font-variant-numeric: tabular-nums;
}
.modal-sheet .opt .price img { width: 16px; height: 16px; }
.modal-sheet .input-row { display: none; gap: 8px; margin-bottom: 8px; }
.modal-sheet .input-row.open { display: flex; }
.modal-sheet input {
  flex: 1; padding: 12px 14px;
  border-radius: 12px; border: 1px solid var(--line);
  background: rgba(138, 91, 255, .08);
  color: var(--text); font: inherit; font-size: 15px;
  outline: none;
}
.modal-sheet input:focus { border-color: var(--line-strong); }
.modal-sheet .hint-price {
  display: flex; align-items: center; justify-content: center; gap: 4px;
  margin-bottom: 8px;
  font-size: 12.5px; color: var(--gold); font-weight: 800;
  min-height: 18px;
}
.modal-sheet .hint-price img { width: 16px; height: 16px; }
.modal-sheet .cancel {
  width: 100%; padding: 12px;
  border-radius: 12px; border: 1px solid var(--line);
  background: rgba(255, 255, 255, .06);
  color: var(--text); font: inherit; font-size: 13px; font-weight: 800;
  cursor: pointer;
}

/* ─── нижнее меню ──────────────────────────────────────────────────── */
.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0;
  max-width: 520px; margin: 0 auto;
  display: grid; grid-template-columns: repeat(4, 1fr);
  background: linear-gradient(180deg, rgba(15, 16, 32, .85), rgba(15, 16, 32, 1));
  border-top: 1px solid var(--line);
  padding: 6px 8px calc(6px + env(safe-area-inset-bottom, 0));
  backdrop-filter: blur(12px);
  z-index: 20;
}
.tab {
  background: transparent; border: none; color: var(--muted);
  font: inherit; font-size: 11px; font-weight: 700;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 8px 4px; cursor: pointer;
  border-radius: 12px;
}
.tab .tab-icon { font-size: 20px; line-height: 1; }
.tab.active { color: var(--text); background: rgba(138, 91, 255, .18); }
.tab:active { transform: scale(.96); }

/* ─── тост ─────────────────────────────────────────────────────────── */
.toast {
  position: fixed; left: 50%; bottom: 90px;
  transform: translateX(-50%) translateY(20px);
  padding: 12px 18px; border-radius: 14px;
  background: rgba(30, 24, 60, .95);
  border: 1px solid var(--line-strong);
  font-size: 13px; font-weight: 700; color: #fff;
  opacity: 0; pointer-events: none;
  transition: opacity .2s, transform .2s;
  z-index: 200; max-width: 80vw; text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.err { border-color: rgba(255, 91, 122, .6); color: #ffc5cf; }
.toast.ok  { border-color: rgba(155, 232, 63, .6); color: #d8ffa8; }