/* ==========================================================================
   Monaco Casino — мини-апп. Мобайл-фёрст: весь интерфейс рассчитан на
   вертикальный экран телефона внутри Telegram, десктоп получает ту же
   колонку по центру.
   ========================================================================== */

:root {
  --gold-1: #ffe58a;
  --gold-2: #f7c948;
  --gold-3: #d09a1a;

  --bg-0: #07060f;
  --bg-1: #0e0b1d;
  --surface: rgba(255, 255, 255, 0.055);
  --surface-2: rgba(255, 255, 255, 0.09);
  --line: rgba(255, 255, 255, 0.11);
  --line-strong: rgba(255, 255, 255, 0.2);

  --text: #f4f2ff;
  --text-dim: #a8a3c4;
  --text-mute: #6f6a90;

  --win: #34d399;
  --lose: #fb7185;

  --game-bg: #1b0b3a;
  --game-accent: var(--gold-2);
  --game-glow: #8b5cf6;

  --r-sm: 10px;
  --r-md: 16px;
  --r-lg: 22px;
  --r-xl: 28px;

  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);

  --nav-h: 64px;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  height: 100%;
  overscroll-behavior: none;
}

body {
  background: var(--bg-0);
  color: var(--text);
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Segoe UI', Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  user-select: none;
}

button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; }
::-webkit-scrollbar { width: 0; height: 0; }

/* ------------------------------- каркас ---------------------------------- */

#app {
  position: relative;
  max-width: 560px;
  /* Ровно высота экрана: игровой экран не скроллится, прокрутка живёт
     внутри .scroll на остальных вкладках. */
  height: 100%;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  isolation: isolate;
}

/* Фон: два цветных пятна + виньетка. Меняется вместе с темой игры. */
#backdrop {
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(90% 60% at 15% -5%, color-mix(in srgb, var(--game-glow) 40%, transparent), transparent 60%),
    radial-gradient(80% 55% at 95% 8%, color-mix(in srgb, var(--game-accent) 22%, transparent), transparent 62%),
    linear-gradient(180deg, var(--game-bg) 0%, var(--bg-0) 62%);
  transition: background 0.6s var(--ease);
}
/* За рамой корпуса — его же размытая копия: пустые поля по бокам на широких
   и низких экранах выглядят подсветкой, а не дырой. */
#backdrop.has-art::before {
  content: '';
  position: absolute;
  inset: -8%;
  background: var(--cabinet) center / cover no-repeat;
  filter: blur(34px) brightness(0.42) saturate(1.25);
  transform: scale(1.08);
}
#backdrop::after {
  content: '';
  position: absolute;
  inset: 0;
  background-image: radial-gradient(rgba(255, 255, 255, 0.045) 1px, transparent 1px);
  background-size: 3px 3px;
  opacity: 0.5;
}

.screen { display: none; flex-direction: column; flex: 1; min-height: 0; }
.screen.active { display: flex; }

.pad { padding: 0 14px; }
.scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: calc(var(--nav-h) + var(--safe-b) + 34px);
}

/* ------------------------------- шапка ----------------------------------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: calc(var(--safe-t) + 12px) 14px 12px;
  background: linear-gradient(180deg, rgba(7, 6, 15, 0.92), rgba(7, 6, 15, 0.62) 70%, transparent);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

.brand { display: flex; align-items: center; gap: 9px; margin-right: auto; min-width: 0; }
.brand-mark {
  width: 34px; height: 34px;
  display: grid; place-items: center;
  border-radius: 11px;
  font-size: 18px;
  background: linear-gradient(145deg, var(--gold-1), var(--gold-3));
  box-shadow: 0 4px 16px rgba(247, 201, 72, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.6);
}
.brand-text { line-height: 1.1; min-width: 0; }
.brand-text b { display: block; font-size: 14px; letter-spacing: 0.08em; }
.brand-text span { font-size: 10.5px; color: var(--text-mute); letter-spacing: 0.16em; text-transform: uppercase; }

.balance-chip {
  display: flex; align-items: center; gap: 7px;
  padding: 8px 13px;
  border-radius: 999px;
  border: 1px solid rgba(247, 201, 72, 0.32);
  background: linear-gradient(135deg, rgba(247, 201, 72, 0.18), rgba(247, 201, 72, 0.05));
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  white-space: nowrap;
  transition: transform 0.2s var(--ease);
}
.balance-chip.bump { animation: chipBump 0.5s var(--ease); }
@keyframes chipBump {
  0% { transform: scale(1); }
  35% { transform: scale(1.12); box-shadow: 0 0 24px rgba(247, 201, 72, 0.5); }
  100% { transform: scale(1); }
}
.balance-chip i { font-style: normal; font-size: 14px; }

.icon-btn {
  width: 38px; height: 38px;
  display: grid; place-items: center;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--surface);
  font-size: 16px;
  transition: transform 0.15s var(--ease), background 0.2s;
}
.icon-btn:active { transform: scale(0.92); background: var(--surface-2); }

/* ------------------------------- лобби ----------------------------------- */

.hero {
  position: relative;
  margin: 4px 14px 16px;
  padding: 18px;
  border-radius: var(--r-xl);
  border: 1px solid var(--line);
  background: linear-gradient(140deg, rgba(255, 255, 255, 0.1), rgba(255, 255, 255, 0.02));
  overflow: hidden;
}
.hero::before {
  content: '';
  position: absolute;
  top: -60%; right: -25%;
  width: 260px; height: 260px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(247, 201, 72, 0.35), transparent 65%);
  pointer-events: none;
}
.hero h1 { margin: 0 0 4px; font-size: 21px; letter-spacing: -0.01em; }
.hero p { margin: 0 0 14px; color: var(--text-dim); font-size: 13px; }
.hero-actions { display: flex; gap: 9px; }

.section-title {
  display: flex; align-items: baseline; gap: 8px;
  margin: 20px 14px 11px;
  font-size: 12px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-mute);
}
.section-title::after { content: ''; flex: 1; height: 1px; background: var(--line); }

.games {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 11px;
  padding: 0 14px;
}

.game-card {
  position: relative;
  display: flex;
  flex-direction: column;
  padding: 12px;
  border-radius: var(--r-lg);
  border: 1px solid var(--line);
  background: linear-gradient(160deg, var(--c1), var(--c2));
  overflow: hidden;
  text-align: left;
  transition: transform 0.18s var(--ease), box-shadow 0.25s;
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.4);
}
.game-card:active { transform: scale(0.96); }
.game-card::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, transparent 40%, rgba(0, 0, 0, 0.55));
  pointer-events: none;
}
.game-card.has-art {
  background-image: var(--cover);
  background-size: cover;
  background-position: center 30%;
}
.game-card.has-art::after { background: linear-gradient(180deg, rgba(0, 0, 0, 0.05) 30%, rgba(0, 0, 0, 0.72)); }
.game-card.has-art .game-art .sym { filter: drop-shadow(0 8px 14px rgba(0, 0, 0, 0.6)); }
.game-card.has-art .game-art .sym--tile { background: none; box-shadow: none; }
.game-card.has-art .game-art .sym--tile img { width: 100%; height: 100%; }
.game-art {
  position: relative;
  height: 86px;
  display: grid;
  place-items: center;
  margin-bottom: 8px;
}
.game-art .sym { position: absolute; filter: drop-shadow(0 6px 12px rgba(0, 0, 0, 0.45)); }
.game-art .sym:nth-child(1) { transform: translate(-34px, 10px) rotate(-18deg) scale(0.82); opacity: 0.85; }
.game-art .sym:nth-child(2) { transform: translate(34px, 10px) rotate(18deg) scale(0.82); opacity: 0.85; }
.game-art .sym:nth-child(3) { transform: translateY(-8px) scale(1.18); z-index: 2; }

.game-card b { position: relative; z-index: 3; font-size: 13.5px; letter-spacing: -0.01em; }
.game-card small { position: relative; z-index: 3; color: rgba(255, 255, 255, 0.72); font-size: 11px; }
.game-meta {
  position: relative; z-index: 3;
  display: flex; gap: 4px; margin-top: 8px;
  flex-wrap: nowrap; overflow: hidden;
}
.tag {
  flex: none;
  padding: 3px 6px;
  border-radius: 7px;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.04em;
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(255, 255, 255, 0.16);
}
.tag.gold { color: #ffe9a8; border-color: rgba(247, 201, 72, 0.45); background: rgba(247, 201, 72, 0.16); }
.badge-fs {
  position: absolute; top: 9px; right: 9px; z-index: 4;
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 10px; font-weight: 800;
  background: linear-gradient(135deg, #34d399, #059669);
  box-shadow: 0 3px 12px rgba(16, 185, 129, 0.5);
  animation: pulse 1.6s ease-in-out infinite;
}
@keyframes pulse { 50% { opacity: 0.62; } }

/* ------------------------------- кнопки ---------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 13px 18px;
  border-radius: var(--r-md);
  font-weight: 700;
  font-size: 14px;
  letter-spacing: 0.01em;
  border: 1px solid transparent;
  transition: transform 0.14s var(--ease), filter 0.2s, opacity 0.2s;
  white-space: nowrap;
}
.btn:active { transform: scale(0.96); }
.btn[disabled] { opacity: 0.45; pointer-events: none; }
.btn--block { width: 100%; }

.btn--gold {
  color: #2a1a00;
  background: linear-gradient(140deg, var(--gold-1), var(--gold-2) 45%, var(--gold-3));
  box-shadow: 0 6px 20px rgba(247, 201, 72, 0.36), inset 0 1px 0 rgba(255, 255, 255, 0.65);
}
.btn--violet {
  background: linear-gradient(140deg, #a78bfa, #7c3aed 60%, #5b21b6);
  box-shadow: 0 6px 20px rgba(124, 58, 237, 0.42), inset 0 1px 0 rgba(255, 255, 255, 0.28);
}
.btn--green {
  background: linear-gradient(140deg, #6ee7b7, #10b981 60%, #047857);
  box-shadow: 0 6px 20px rgba(16, 185, 129, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.28);
}
.btn--pink {
  background: linear-gradient(140deg, #f9a8d4, #ec4899 60%, #be185d);
  box-shadow: 0 6px 20px rgba(236, 72, 153, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.28);
}
.btn--blue {
  background: linear-gradient(140deg, #7dd3fc, #0ea5e9 60%, #0369a1);
  box-shadow: 0 6px 20px rgba(14, 165, 233, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.28);
}
.btn--ghost { background: var(--surface); border-color: var(--line); }

/* ------------------------------- нижняя навигация ------------------------ */

.nav {
  position: fixed;
  left: 50%;
  bottom: calc(var(--safe-b) + 10px);
  transform: translateX(-50%);
  z-index: 40;
  width: min(532px, calc(100% - 28px));
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  padding: 6px;
  border-radius: 20px;
  border: 1px solid var(--line);
  background: rgba(16, 13, 30, 0.86);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  box-shadow: 0 12px 34px rgba(0, 0, 0, 0.55);
}
.nav.hidden { display: none; }
.nav button {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 8px 4px;
  border-radius: 14px;
  font-size: 10px;
  color: var(--text-mute);
  transition: color 0.2s, background 0.2s;
}
.nav button i { font-style: normal; font-size: 18px; line-height: 1; }
.nav button.on {
  color: #1c1206;
  background: linear-gradient(140deg, var(--gold-1), var(--gold-2));
  font-weight: 700;
}

/* ------------------------------- игровой экран --------------------------- */

#screen-game { position: relative; }

.game-top {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: calc(var(--safe-t) + 10px) 12px 8px;
}
.game-title { margin-right: auto; min-width: 0; }
.game-title b,
.game-title span { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.game-title b { font-size: 14px; }
.game-title span { font-size: 10.5px; color: var(--text-mute); }

.fs-banner {
  margin: 0 12px 8px;
  padding: 9px 14px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 12.5px;
  font-weight: 700;
  background: linear-gradient(120deg, rgba(52, 211, 153, 0.28), rgba(16, 185, 129, 0.12));
  border: 1px solid rgba(52, 211, 153, 0.4);
}
.fs-banner .mult { color: #fde68a; }
.fs-banner[hidden] { display: none; }

/* Поле барабанов: вписывается и по ширине, и по высоте — на любом экране. */
.reel-wrap {
  flex: 1;
  min-height: 0;
  overflow: hidden;
  display: grid;
  place-items: center;
  padding: 0 10px;
}
/* Рама — «корпус автомата»: занимает всё свободное место. Сверху шильдик
   с названием, снизу характеристики, барабаны по центру. Так экран не
   пустует даже на низких сетках 5x3. */
.reel-frame {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  padding: 10px;
  border-radius: var(--r-lg);
  border: 1px solid var(--line-strong);
  background:
    linear-gradient(180deg, rgba(0, 0, 0, 0.55), rgba(0, 0, 0, 0.34)),
    radial-gradient(80% 60% at 50% 0%, color-mix(in srgb, var(--game-glow) 30%, transparent), transparent);
  box-shadow: 0 18px 44px rgba(0, 0, 0, 0.55), inset 0 1px 0 rgba(255, 255, 255, 0.09);
  overflow: hidden;
}
.reel-frame::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  padding: 1px;
  background: linear-gradient(150deg, color-mix(in srgb, var(--game-accent) 65%, transparent), transparent 45%);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  pointer-events: none;
}

.stage { flex: 1; min-height: 0; display: grid; place-items: center; }

.stage-plate {
  position: relative;
  flex: none;
  padding: 7px 12px 9px;
  text-align: center;
  font-size: clamp(13px, 4.4vw, 19px);
  font-weight: 900;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  background: linear-gradient(180deg, #fff, color-mix(in srgb, var(--game-accent) 85%, #b45309));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.6));
}
.stage-plate::after {
  content: '';
  display: block;
  width: 54%;
  height: 2px;
  margin: 7px auto 0;
  border-radius: 2px;
  background: linear-gradient(90deg, transparent, color-mix(in srgb, var(--game-accent) 70%, transparent), transparent);
}

.stage-chips {
  position: relative;
  flex: none;
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 5px;
  padding: 10px 4px 2px;
}
.stage-chips span {
  padding: 4px 9px;
  border-radius: 8px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.03em;
  color: var(--text-dim);
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.35);
}
.stage-chips span.hot { color: #fde68a; border-color: rgba(247, 201, 72, 0.4); background: rgba(247, 201, 72, 0.12); }

.grid {
  position: relative;
  display: grid;
  gap: var(--gap, 4px);
  grid-template-columns: repeat(var(--cols), 1fr);
  grid-template-rows: repeat(var(--rows), 1fr);
}

.cell {
  position: relative;
  display: grid;
  place-items: center;
  /* Иначе grid-ячейка не сможет стать меньше своей картинки (автоминимум
     по содержимому) и ряды вылезут за пределы сетки. */
  min-width: 0;
  min-height: 0;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.035);
  overflow: hidden;
}
.cell > .sym { width: 94%; height: 94%; }

/* Отдача в момент остановки барабана — «удар» ленты об ограничитель. */
.cell.land > .sym { animation: land 0.26s var(--ease) both; animation-delay: var(--land-delay, 0ms); }
@keyframes land {
  0% { transform: translateY(-9%) scale(1.06); }
  55% { transform: translateY(3%) scale(0.97); }
  100% { transform: none; }
}

.cell.drop > .sym { animation: dropIn 0.34s var(--ease) backwards; }
@keyframes dropIn {
  from { transform: translateY(-160%) scale(0.8); opacity: 0; }
  to { transform: none; opacity: 1; }
}

.cell.win { background: rgba(255, 255, 255, 0.1); }
.cell.win > .sym { animation: winPulse 0.62s ease-in-out infinite alternate; z-index: 2; }
@keyframes winPulse {
  from { transform: scale(1); filter: drop-shadow(0 0 0 transparent); }
  to { transform: scale(1.14); filter: drop-shadow(0 0 12px var(--s1)); }
}
.cell.win::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  border: 2px solid var(--game-accent);
  box-shadow: 0 0 18px color-mix(in srgb, var(--game-accent) 75%, transparent);
  animation: pulse 0.9s ease-in-out infinite;
}

.cell.dim > .sym { opacity: 0.45; filter: grayscale(0.35); transition: opacity 0.25s, filter 0.25s; }
.cell.pop > .sym { animation: popOut 0.28s var(--ease) forwards; }
@keyframes popOut {
  40% { transform: scale(1.25); }
  to { transform: scale(0.2) rotate(20deg); opacity: 0; }
}

.cell.scatter::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  border: 2px solid #fde68a;
  box-shadow: 0 0 22px rgba(253, 230, 138, 0.75);
  animation: pulse 0.8s ease-in-out infinite;
}

/* Барабан в движении: лента символов, которая уезжает вверх. */
.spinner {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  gap: var(--gap, 4px);
  will-change: transform;
}
.spinner .sym { flex: 0 0 var(--cell-h); }

.reel-col {
  position: absolute;
  top: 0;
  bottom: 0;
  overflow: hidden;
  border-radius: 12px;
}

/* Множители-сферы Divine Tumble */
.orb {
  position: absolute;
  z-index: 6;
  display: grid;
  place-items: center;
  border-radius: 50%;
  font-weight: 900;
  font-size: clamp(9px, 2.6vw, 13px);
  color: #2a1400;
  background: radial-gradient(circle at 32% 28%, #fff6c9, var(--gold-2) 42%, #b45309);
  box-shadow: 0 0 20px rgba(247, 201, 72, 0.8), inset 0 -3px 8px rgba(0, 0, 0, 0.35);
  animation: orbIn 0.4s var(--ease) backwards;
  pointer-events: none;
}
@keyframes orbIn {
  from { transform: scale(0) rotate(-90deg); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

/* --------------------------- панель управления --------------------------- */

.controls {
  padding: 10px 12px calc(var(--safe-b) + 12px);
  display: flex;
  flex-direction: column;
  gap: 9px;
}

.winbar {
  min-height: 34px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.32);
  font-weight: 800;
  font-size: 15px;
  font-variant-numeric: tabular-nums;
  transition: color 0.2s, border-color 0.3s;
}
.winbar.hit { color: var(--gold-2); border-color: rgba(247, 201, 72, 0.5); }
.winbar small { color: var(--text-mute); font-weight: 600; font-size: 12px; }

.bet-row { display: grid; grid-template-columns: 46px 1fr 46px auto; gap: 8px; align-items: stretch; }
.step {
  border-radius: 13px;
  border: 1px solid var(--line);
  background: var(--surface);
  font-size: 20px;
  font-weight: 700;
  transition: transform 0.14s var(--ease);
}
.step:active { transform: scale(0.9); }
.step[disabled] { opacity: 0.35; }

.bet-display {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border-radius: 13px;
  border: 1px solid var(--line);
  background: var(--surface);
  line-height: 1.1;
}
.bet-display span { font-size: 9.5px; letter-spacing: 0.13em; text-transform: uppercase; color: var(--text-mute); }
.bet-display b { font-size: 16px; font-variant-numeric: tabular-nums; }

.spin-btn {
  position: relative;
  width: 74px;
  aspect-ratio: 1;
  align-self: center;
  border-radius: 50%;
  color: #2a1a00;
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.05em;
  background: linear-gradient(150deg, var(--gold-1), var(--gold-2) 45%, var(--gold-3));
  box-shadow: 0 8px 24px rgba(247, 201, 72, 0.45), inset 0 2px 0 rgba(255, 255, 255, 0.7);
  transition: transform 0.14s var(--ease), filter 0.2s;
}
.spin-btn:active { transform: scale(0.93); }
.spin-btn[disabled] { filter: grayscale(0.5) brightness(0.8); opacity: 0.7; pointer-events: none; }
.spin-btn.busy::after {
  content: '';
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  border: 2px solid transparent;
  border-top-color: var(--gold-1);
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.spin-btn.free { background: linear-gradient(150deg, #a7f3d0, #10b981 50%, #047857); color: #052e1a; font-size: 10px; }

.tool-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.tool {
  padding: 9px 6px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--surface);
  font-size: 11px;
  font-weight: 600;
  display: flex; align-items: center; justify-content: center; gap: 5px;
  transition: transform 0.14s var(--ease), border-color 0.2s, color 0.2s;
}
.tool:active { transform: scale(0.95); }
.tool.on { color: var(--gold-2); border-color: rgba(247, 201, 72, 0.5); background: rgba(247, 201, 72, 0.12); }
.tool[disabled] { opacity: 0.4; pointer-events: none; }

/* ------------------------------- оверлеи --------------------------------- */

.overlay {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(4, 3, 10, 0.78);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  animation: fade 0.25s ease;
}
.overlay[hidden] { display: none; }
@keyframes fade { from { opacity: 0; } }

.bigwin {
  text-align: center;
  animation: bigwinIn 0.5s var(--ease);
}
@keyframes bigwinIn {
  from { transform: scale(0.6) translateY(30px); opacity: 0; }
}
.bigwin em {
  display: block;
  font-style: normal;
  font-size: 13px;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: var(--gold-2);
  margin-bottom: 6px;
}
.bigwin strong {
  display: block;
  font-size: clamp(38px, 13vw, 62px);
  line-height: 1.05;
  font-variant-numeric: tabular-nums;
  background: linear-gradient(180deg, #fff8dc, var(--gold-2) 55%, var(--gold-3));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 6px 20px rgba(247, 201, 72, 0.55));
}
.bigwin span { display: block; margin-top: 4px; color: var(--text-dim); font-size: 14px; }

.fs-intro { text-align: center; animation: bigwinIn 0.5s var(--ease); }
.fs-intro .big { font-size: clamp(44px, 15vw, 70px); font-weight: 900; color: var(--win); line-height: 1; }
.fs-intro .lbl { font-size: 15px; letter-spacing: 0.2em; text-transform: uppercase; color: var(--text-dim); margin-top: 8px; }

/* нижний лист (таблица выплат, покупка бонуса) */
.sheet-back {
  position: fixed;
  inset: 0;
  z-index: 70;
  background: rgba(4, 3, 10, 0.7);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  animation: fade 0.2s ease;
}
.sheet-back[hidden] { display: none; }
.sheet {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  max-width: 560px;
  margin: 0 auto;
  max-height: 82vh;
  overflow-y: auto;
  padding: 16px 16px calc(var(--safe-b) + 20px);
  border-radius: var(--r-xl) var(--r-xl) 0 0;
  border-top: 1px solid var(--line-strong);
  background: linear-gradient(180deg, #171331, #0b0917);
  animation: sheetUp 0.32s var(--ease);
}
@keyframes sheetUp { from { transform: translateY(100%); } }
.sheet h3 { margin: 4px 0 14px; font-size: 17px; }
.sheet-grip {
  width: 40px; height: 4px;
  border-radius: 2px;
  background: var(--line-strong);
  margin: 0 auto 12px;
}

.pay-row {
  display: grid;
  grid-template-columns: 46px 1fr auto;
  gap: 11px;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.055);
}
.pay-row .sym { width: 42px; height: 42px; }
.pay-row b { font-size: 13px; }
.pay-row small { display: block; color: var(--text-mute); font-size: 11px; }
.pay-row .vals { text-align: right; font-variant-numeric: tabular-nums; font-size: 12px; color: var(--gold-2); font-weight: 700; }
.pay-row .vals span { display: block; }

/* ------------------------------- карточки -------------------------------- */

.card {
  margin: 0 14px 12px;
  padding: 16px;
  border-radius: var(--r-lg);
  border: 1px solid var(--line);
  background: var(--surface);
}
.card--gold {
  border-color: rgba(247, 201, 72, 0.3);
  background: linear-gradient(150deg, rgba(247, 201, 72, 0.16), rgba(247, 201, 72, 0.03));
}

.profile { display: flex; align-items: center; gap: 13px; }
.avatar {
  width: 56px; height: 56px;
  flex: none;
  display: grid; place-items: center;
  border-radius: 18px;
  font-size: 22px; font-weight: 800;
  color: #2a1a00;
  background: linear-gradient(145deg, var(--gold-1), var(--gold-3));
  box-shadow: 0 6px 18px rgba(247, 201, 72, 0.35);
}
.profile-info { min-width: 0; flex: 1; }
.profile-info b { display: block; font-size: 16px; }
.profile-info small { color: var(--text-mute); font-size: 12px; }

.level { margin-top: 12px; }
.level-head { display: flex; justify-content: space-between; font-size: 11.5px; color: var(--text-dim); margin-bottom: 6px; }
.level-bar { height: 7px; border-radius: 4px; background: rgba(0, 0, 0, 0.4); overflow: hidden; }
.level-bar i {
  display: block; height: 100%;
  border-radius: 4px;
  background: linear-gradient(90deg, var(--gold-3), var(--gold-1));
  transition: width 0.7s var(--ease);
}

.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 9px; margin: 0 14px 12px; }
.stat {
  padding: 13px;
  border-radius: var(--r-md);
  border: 1px solid var(--line);
  background: var(--surface);
}
.stat span { display: block; font-size: 10.5px; letter-spacing: 0.09em; text-transform: uppercase; color: var(--text-mute); }
.stat b { display: block; margin-top: 3px; font-size: 17px; font-variant-numeric: tabular-nums; }
.stat b.pos { color: var(--win); }
.stat b.neg { color: var(--lose); }

.list { margin: 0 14px; }
.row {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 11px 13px;
  margin-bottom: 7px;
  border-radius: var(--r-md);
  border: 1px solid var(--line);
  background: var(--surface);
}
.row .who { flex: 1; min-width: 0; }
.row .who b { display: block; font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .who small { color: var(--text-mute); font-size: 11px; }
.row .val { font-weight: 800; font-variant-numeric: tabular-nums; font-size: 14px; }
.row .val.pos { color: var(--win); }
.row .val.neg { color: var(--text-mute); }
.row.me { border-color: rgba(247, 201, 72, 0.45); background: rgba(247, 201, 72, 0.1); }
.place {
  width: 30px; height: 30px;
  flex: none;
  display: grid; place-items: center;
  border-radius: 10px;
  font-weight: 800; font-size: 13px;
  background: rgba(0, 0, 0, 0.35);
}
.place.p1 { background: linear-gradient(145deg, #ffe58a, #d09a1a); color: #2a1a00; }
.place.p2 { background: linear-gradient(145deg, #e5e7eb, #94a3b8); color: #1f2937; }
.place.p3 { background: linear-gradient(145deg, #fdba74, #b45309); color: #2a1200; }

/* пакеты пополнения */
.packs { display: grid; gap: 10px; margin: 0 14px; }
.pack {
  position: relative;
  display: flex;
  align-items: center;
  gap: 13px;
  padding: 14px;
  border-radius: var(--r-lg);
  border: 1px solid var(--line);
  background: var(--surface);
  text-align: left;
  transition: transform 0.15s var(--ease), border-color 0.2s;
  overflow: hidden;
}
.pack:active { transform: scale(0.975); }
.pack.hot { border-color: rgba(247, 201, 72, 0.45); background: linear-gradient(120deg, rgba(247, 201, 72, 0.16), var(--surface)); }
.pack-icon {
  width: 46px; height: 46px;
  flex: none;
  display: grid; place-items: center;
  border-radius: 14px;
  font-size: 22px;
  background: rgba(0, 0, 0, 0.35);
}
.pack-body { flex: 1; min-width: 0; }
.pack-body b { display: block; font-size: 15px; font-variant-numeric: tabular-nums; }
.pack-body small { color: var(--text-mute); font-size: 11.5px; }
.pack-price {
  padding: 8px 12px;
  border-radius: 11px;
  font-weight: 800;
  font-size: 13px;
  white-space: nowrap;
  background: linear-gradient(140deg, var(--gold-1), var(--gold-3));
  color: #2a1a00;
}
.pack-bonus {
  position: absolute;
  top: 0; right: 0;
  padding: 3px 9px 4px 10px;
  border-radius: 0 calc(var(--r-lg) - 1px) 0 12px;
  font-size: 10px;
  font-weight: 800;
  background: linear-gradient(135deg, #34d399, #059669);
}

.note {
  margin: 12px 14px;
  padding: 12px 14px;
  border-radius: var(--r-md);
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.25);
  color: var(--text-mute);
  font-size: 11.5px;
  line-height: 1.5;
}

.empty { text-align: center; color: var(--text-mute); padding: 34px 20px; font-size: 13px; }

/* тост */
#toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--nav-h) + var(--safe-b) + 26px);
  transform: translate(-50%, 20px);
  z-index: 90;
  padding: 11px 18px;
  border-radius: 14px;
  border: 1px solid var(--line-strong);
  background: rgba(20, 16, 38, 0.96);
  backdrop-filter: blur(12px);
  font-size: 13px;
  font-weight: 600;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s, transform 0.25s var(--ease);
  max-width: calc(100% - 40px);
  text-align: center;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }
#toast.err { border-color: rgba(251, 113, 133, 0.5); color: #fecdd3; }

/* заставка */
#splash {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  background: var(--bg-0);
  transition: opacity 0.4s;
}
#splash.gone { opacity: 0; pointer-events: none; }
#splash .logo {
  width: 78px; height: 78px;
  display: grid; place-items: center;
  border-radius: 26px;
  font-size: 38px;
  background: linear-gradient(145deg, var(--gold-1), var(--gold-3));
  box-shadow: 0 12px 40px rgba(247, 201, 72, 0.45);
  animation: logoIn 1.1s var(--ease) infinite alternate;
}
@keyframes logoIn { to { transform: translateY(-8px) scale(1.04); } }

/* ------------------------------- символы --------------------------------- */

.sym {
  position: relative;
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  border-radius: 11px;
}
/* Плашка нужна только вне барабанов — на обложках и в таблице выплат. */
.sym--tile {
  background: linear-gradient(160deg, rgba(255, 255, 255, 0.16), rgba(255, 255, 255, 0.02));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.22);
}
.sym svg { width: 92%; height: 92%; overflow: visible; filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.5)); }
.sym--tile svg { width: 76%; height: 76%; }
.sym--royal span {
  font-size: clamp(17px, 6vw, 34px);
  font-weight: 900;
  letter-spacing: -0.03em;
  background: linear-gradient(180deg, var(--s1), var(--s2));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.75)) drop-shadow(0 0 10px color-mix(in srgb, var(--s2) 55%, transparent));
}
.sym--sm { width: 46px; height: 46px; }
.sym--sm.sym--royal span { font-size: 20px; }

/* Экраны пониже (iPhone SE и подобные) — ужимаем вертикальные отступы. */
@media (max-height: 700px) {
  .controls { gap: 7px; padding-top: 7px; }
  .spin-btn { width: 66px; }
  .hero { padding: 15px; }
  .game-art { height: 66px; }
}
@media (max-height: 680px) {
  .tool-row { display: none; }
  .winbar { min-height: 28px; font-size: 13px; }
}

/* ==========================================================================
   Эффекты: подогрев барабана, искры, тряска, вспышка, дождь из монет
   ========================================================================== */

/* «Подогрев» — барабан, который может добить скаттеры до бонуса. */
.reel-col.tease::after {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 3;
  border-radius: 12px;
  border: 2px solid rgba(253, 230, 138, 0.85);
  box-shadow: inset 0 0 34px rgba(253, 230, 138, 0.5), 0 0 20px rgba(253, 230, 138, 0.35);
  animation: teasePulse 0.42s ease-in-out infinite alternate;
  pointer-events: none;
}
@keyframes teasePulse {
  from { opacity: 0.45; }
  to { opacity: 1; }
}

/* Искры из выигравших клеток. */
.spark {
  position: absolute;
  z-index: 7;
  width: 7px;
  height: 7px;
  margin: -3.5px 0 0 -3.5px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #fffbe6, var(--game-accent) 55%, transparent 72%);
  pointer-events: none;
  animation: sparkFly 0.62s ease-out forwards;
}
@keyframes sparkFly {
  0% { transform: translate(0, 0) scale(0.3); opacity: 0; }
  15% { opacity: 1; }
  100% { transform: translate(var(--dx), var(--dy)) scale(var(--s)); opacity: 0; }
}

/* Тряска корпуса на крупном выигрыше. */
.reel-frame.shaking { animation: shake 0.42s ease-in-out; }
@keyframes shake {
  0%, 100% { transform: translate(0, 0) rotate(0deg); }
  15% { transform: translate(calc(-4px * var(--shake, 1)), calc(2px * var(--shake, 1))) rotate(-0.4deg); }
  35% { transform: translate(calc(5px * var(--shake, 1)), calc(-2px * var(--shake, 1))) rotate(0.5deg); }
  55% { transform: translate(calc(-3px * var(--shake, 1)), calc(-2px * var(--shake, 1))) rotate(-0.3deg); }
  78% { transform: translate(calc(3px * var(--shake, 1)), calc(1px * var(--shake, 1))) rotate(0.2deg); }
}

/* Вспышка рамки в момент запуска бонуса. */
.reel-frame.flash::after {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 8;
  border-radius: inherit;
  pointer-events: none;
  background: radial-gradient(circle at 50% 50%, rgba(255, 255, 255, 0.85), rgba(253, 230, 138, 0.35) 45%, transparent 70%);
  animation: frameFlash 0.7s ease-out forwards;
}
@keyframes frameFlash {
  0% { opacity: 0; transform: scale(0.85); }
  25% { opacity: 1; }
  100% { opacity: 0; transform: scale(1.06); }
}

/* Дождь из монет поверх экрана крупного выигрыша. */
.coins {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}
.coins i {
  position: absolute;
  top: -8%;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: radial-gradient(circle at 34% 30%, #fff7cf, var(--gold-2) 48%, #a16207);
  box-shadow: 0 0 12px rgba(247, 201, 72, 0.6), inset 0 -3px 5px rgba(0, 0, 0, 0.3);
  animation: coinFall linear forwards;
}
@keyframes coinFall {
  0% { transform: translateY(0) rotate(0deg) scale(var(--cs, 1)); opacity: 0; }
  10% { opacity: 1; }
  100% { transform: translateY(115vh) rotate(var(--spin, 540deg)) scale(var(--cs, 1)); opacity: 0.9; }
}

/* Пульс выигрыша на счётчике. */
.winbar.pop { animation: winbarPop 0.4s var(--ease); }
@keyframes winbarPop {
  0% { transform: scale(1); }
  45% { transform: scale(1.07); }
  100% { transform: scale(1); }
}

/* Растровая графика символов — подключается, когда она сгенерирована. */
.sym--art img {
  width: 106%;
  height: 106%;
  max-width: none;
  object-fit: contain;
  filter: drop-shadow(0 2px 5px rgba(0, 0, 0, 0.55));
  pointer-events: none;
  -webkit-user-drag: none;
}
.sym--tile.sym--art img { width: 82%; height: 82%; }

/* Нарисованный корпус автомата подкладывается под барабаны. */
.reel-frame.has-art::before {
  background-image: var(--cabinet);
  background-size: cover;
  background-position: center;
  opacity: 1;
  -webkit-mask: none;
  mask: none;
  padding: 0;
}

/* ==========================================================================
   Divine Tumble: нарисованные сферы, молнии, вспышка перед каскадом, фон
   ========================================================================== */

.orb--art {
  background: none;
  background-size: cover;
  background-position: center;
  box-shadow: 0 0 22px rgba(247, 201, 72, 0.7);
}
.orb b {
  position: relative;
  z-index: 1;
  font-weight: 900;
  color: #fff;
  text-shadow: 0 0 6px #000, 0 1px 2px #000, 0 0 14px rgba(0, 0, 0, 0.8);
  font-size: clamp(10px, 3vw, 15px);
}
.orb--art b { transform: translateY(1px); }

/* Молнии: два слоя — широкое свечение и тонкая белая сердцевина. */
.bolts {
  position: absolute;
  left: 0;
  width: 100%;
  z-index: 8;
  pointer-events: none;
  overflow: visible;
}
.bolts path {
  fill: none;
  stroke-linejoin: round;
  stroke-linecap: round;
  animation: boltFlash 0.5s ease-out forwards;
}
.bolt-glow { stroke: #c4b5fd; stroke-width: 9; opacity: 0.85; filter: blur(3px); }
.bolt-core { stroke: #fff; stroke-width: 2.5; filter: drop-shadow(0 0 6px #fde68a); }
@keyframes boltFlash {
  0% { opacity: 0; }
  8% { opacity: 1; }
  30% { opacity: 0.7; }
  45% { opacity: 1; }
  100% { opacity: 0; }
}

/* Вспышка на клетке за миг до выбивания символа. */
.cell.zap::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 3;
  border-radius: inherit;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.95), rgba(255, 255, 255, 0.35) 55%, transparent 75%);
  animation: zap 0.16s ease-out forwards;
  pointer-events: none;
}
@keyframes zap {
  from { opacity: 0; transform: scale(0.6); }
  40% { opacity: 1; }
  to { opacity: 0; transform: scale(1.25); }
}

/* С нарисованным корпусом плашки клеток почти невидимы — фон уже нарисован. */
.reel-frame.has-art .cell { background: transparent; }
.reel-frame.has-art .cell.win { background: rgba(255, 255, 255, 0.1); }
.reel-frame.has-art .cell.dim > .sym { opacity: 0.38; }
.reel-frame.has-art::before { opacity: 1; }

/* Живой фон: две сетки медленно плывущих искр поверх корпуса. */
/* Сетка ложится ровно в измеренное окно корпуса; чуть внутрь, чтобы не касаться рамки. */
.reel-frame.has-art .stage {
  position: relative;
  overflow: hidden;
  padding: 1.2% calc(var(--win-r, 6%) + 1%) 1.2% calc(var(--win-l, 6%) + 1%);
}
/* На нарисованном окне символ может выходить за клетку: плашек нет, тесниться незачем. */
.reel-frame.has-art .cell { overflow: visible; }
.reel-frame.has-art .cell > .sym--art img { width: 122%; height: 122%; }
.reel-frame.has-art .spinner .sym--art img { width: 118%; height: 118%; }
.reel-frame.has-art .stage-plate { height: var(--win-t, 12%); padding: 0; visibility: hidden; }
.reel-frame.has-art .stage-plate::after { display: none; }
.reel-frame.has-art .stage-chips { height: var(--win-b, 12%); min-height: 34px; align-items: center; padding: 0 6px; }
.reel-frame.has-art .stage > .grid { position: relative; z-index: 1; }
.reel-frame.has-art .stage::before,
.reel-frame.has-art .stage::after {
  content: '';
  position: absolute;
  inset: -20%;
  pointer-events: none;
  background-image:
    radial-gradient(circle, rgba(255, 244, 200, 0.9) 0 1px, transparent 2px),
    radial-gradient(circle, rgba(196, 181, 253, 0.8) 0 1.4px, transparent 2.6px);
  background-size: 140px 140px, 220px 220px;
  background-position: 0 0, 60px 40px;
  opacity: 0.35;
  animation: drift 26s linear infinite;
}
.reel-frame.has-art .stage::after {
  background-size: 90px 90px, 170px 170px;
  animation-duration: 40s;
  animation-direction: reverse;
  opacity: 0.22;
}
@keyframes drift {
  from { transform: translate3d(0, 0, 0); }
  to { transform: translate3d(-40px, -90px, 0); }
}
