:root{
  --cell: 120px;      /* высота одной ячейки */
  --reelW: 140px;     /* ширина барабана */
  --img: 96px;        /* размер картинки */

  --bg1: #04110a;
  --bg2: #010604;

  --panel1: rgba(8, 30, 18, .92);
  --panel2: rgba(3, 12, 7, .92);

  --neon: #00ff88;
  --neon2: #00c36a;
  --gold: #d6ff9a;
}

*{ box-sizing:border-box; }

/* ✅ для мобилок/высоты экрана */
html, body{ height:100%; }

body{
  margin:0;

  /* ✅ 100vh на мобилках часто “врет”, поэтому добавили svh/dvh */
  min-height: 100svh;
  height: 100dvh;

  display:flex;
  align-items:center;
  justify-content:center;

  font-family: Arial, sans-serif;
  color:#eafff3;

  /* “казино фон”: глубина + пятна + шум */
  background:
    radial-gradient(circle at 20% 10%, rgba(0,255,136,.18), transparent 40%),
    radial-gradient(circle at 80% 20%, rgba(0,195,106,.12), transparent 50%),
    radial-gradient(circle at 65% 85%, rgba(214,255,154,.10), transparent 45%),
    radial-gradient(circle at center, var(--bg1), var(--bg2) 72%);

  /* ✅ чтобы страница не скроллилась/не “резинила” на телефоне */
  overflow:hidden;
  overscroll-behavior: none;
  touch-action: manipulation;
}

/* немного “частиц” на фоне */
body::before{
  content:"";
  position:fixed;
  inset:-40px;
  background:
    radial-gradient(circle, rgba(0,255,136,.18) 0 1px, transparent 2px) 0 0 / 60px 60px,
    radial-gradient(circle, rgba(0,195,106,.14) 0 1px, transparent 2px) 20px 30px / 70px 70px;
  opacity:.25;
  filter: blur(.3px);
  pointer-events:none;
}

/* мягкое свечение снизу */
body::after{
  content:"";
  position:fixed;
  left:50%;
  bottom:-220px;
  width:900px;
  height:500px;
  transform:translateX(-50%);
  background: radial-gradient(circle, rgba(0,255,136,.18), transparent 70%);
  filter: blur(18px);
  pointer-events:none;
}

.slot-wrapper{
  text-align:center;
  transform: translateZ(0);
}

.slot{
  position:relative;
  display:flex;
  gap:22px;
  padding:30px 34px;
  border-radius:34px;

  /* стеклянная панель */
  background: linear-gradient(180deg, var(--panel1), var(--panel2));
  box-shadow:
    0 30px 90px rgba(0,0,0,.7),
    0 0 80px rgba(0,255,136,.18),
    inset 0 1px 0 rgba(255,255,255,.06);

  overflow:hidden;
}

/* блики/лучи на панели */
.slot::before{
  content:"";
  position:absolute;
  inset:-80px;
  background:
    radial-gradient(circle at 20% 30%, rgba(0,255,136,.18), transparent 35%),
    radial-gradient(circle at 80% 70%, rgba(0,195,106,.14), transparent 40%),
    linear-gradient(135deg, rgba(255,255,255,.08), transparent 45%);
  filter: blur(8px);
  pointer-events:none;
}

/* неоновая окантовка */
.slot::after{
  content:"";
  position:absolute;
  inset:0;
  border-radius:34px;
  box-shadow:
    0 0 0 1px rgba(0,255,136,.20),
    0 0 30px rgba(0,255,136,.14),
    inset 0 0 0 1px rgba(255,255,255,.04);
  pointer-events:none;
}

.reel{
  position:relative;
  width:var(--reelW);
  height:calc(var(--cell) * 3);
  overflow:hidden;
  border-radius:22px;

  background: linear-gradient(180deg, rgba(12,48,28,.92), rgba(0,0,0,.94));
  box-shadow:
    inset 0 0 0 1px rgba(0,255,136,.18),
    inset 0 0 38px rgba(0,0,0,.85),
    0 14px 36px rgba(0,0,0,.65);
}

/* стекло + затемнение сверху/снизу */
.reel::before{
  content:"";
  position:absolute;
  inset:0;
  background:
    linear-gradient(to bottom,
      rgba(0,0,0,.92) 0%,
      rgba(0,0,0,0) 30%,
      rgba(0,0,0,0) 70%,
      rgba(0,0,0,.95) 100%),
    linear-gradient(135deg, rgba(255,255,255,.10), transparent 40%);
  pointer-events:none;
  z-index:3;
}

/* центральная рамка — главный “слот” */
.reel::after{
  content:"";
  position:absolute;
  left:10px;
  right:10px;
  top:var(--cell);
  height:var(--cell);
  border-radius:18px;
  box-shadow:
    inset 0 0 0 2px rgba(0,255,136,.35),
    inset 0 0 24px rgba(0,255,136,.12),
    0 0 34px rgba(0,255,136,.18);
  pointer-events:none;
  z-index:4;
}

.reel-track{
  will-change: transform, filter;
  transform: translate3d(0,0,0);
}

.symbol{
  /* ✅ важно, иначе .symbol::before (absolute) позиционируется неправильно */
  position: relative;

  width:var(--reelW);
  height:var(--cell);
  display:flex;
  align-items:center;
  justify-content:center;
  user-select:none;
  backface-visibility:hidden;
}

/* лёгкая “вставка” под символом для ощущения ячейки */
.symbol::before{
  content:"";
  position:absolute;
  width: calc(var(--reelW) - 22px);
  height: calc(var(--cell) - 22px);
  border-radius:16px;
  background: radial-gradient(circle at 30% 25%, rgba(255,255,255,.05), rgba(0,0,0,.25));
  opacity:.35;
  pointer-events:none;
}

/* картинка */
.symbol img{
  width:var(--img);
  height:var(--img);
  object-fit:contain;
  filter: drop-shadow(0 14px 14px rgba(0,0,0,.55));
  transform: translateZ(0);
  z-index:2;
}

/* motion blur во время вращения */
.reel-track.spinning{
  filter: blur(1.9px) contrast(1.08) saturate(1.25);
}

/* сообщение */
.result{
  margin-top:14px;
  min-height:42px;
  font-size:20px;
  letter-spacing:.4px;
  opacity:.95;
  display:flex;
  align-items:center;
  justify-content:center;
}

/* красивый WIN */
.result.win{
  color: var(--gold);
  font-weight: 800;
  text-shadow:
    0 0 12px rgba(0,255,136,.25),
    0 0 26px rgba(0,255,136,.18);
}

/* “плашка” WIN как в автомате */
.result.win::before{
  content:"";
  display:inline-block;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  margin-right:10px;
  background: var(--neon);
  box-shadow: 0 0 16px rgba(0,255,136,.55);
}

.result.win::after{
  content:"";
  display:inline-block;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  margin-left:10px;
  background: var(--neon);
  box-shadow: 0 0 16px rgba(0,255,136,.55);
}

.reel.winflash::after{
  animation: flash .9s ease-in-out;
}
@keyframes flash{
  0%,100%{ box-shadow: inset 0 0 0 2px rgba(0,255,136,.35), inset 0 0 24px rgba(0,255,136,.12), 0 0 34px rgba(0,255,136,.18); }
  50%{ box-shadow: inset 0 0 0 2px rgba(214,255,154,.55), inset 0 0 36px rgba(0,255,136,.22), 0 0 60px rgba(0,255,136,.35); }
}

/* ====== КНОПКА "НАЗАД" (сверху) ====== */
.back-btn{
  position: fixed;
  top: calc(14px + env(safe-area-inset-top));   /* ✅ safe-area */
  left: calc(14px + env(safe-area-inset-left)); /* ✅ safe-area */
  z-index: 10;

  display: inline-flex;
  align-items: center;
  gap: 10px;

  padding: 10px 14px;
  border-radius: 999px;
  border: 1px solid rgba(0,255,136,.28);

  background: linear-gradient(180deg, rgba(8,30,18,.78), rgba(3,12,7,.78));
  color: #eafff3;

  box-shadow:
    0 12px 30px rgba(0,0,0,.45),
    0 0 22px rgba(0,255,136,.14),
    inset 0 1px 0 rgba(255,255,255,.06);

  cursor: pointer;
  user-select: none;
  -webkit-tap-highlight-color: transparent;

  transition: transform .12s ease, filter .12s ease, border-color .12s ease;
}

.back-btn:hover{ filter: brightness(1.06); border-color: rgba(0,255,136,.4); }
.back-btn:active{ transform: translateY(1px) scale(.98); }

.back-ico{
  width: 30px;
  height: 30px;
  display:grid;
  place-items:center;
  border-radius: 50%;

  background: radial-gradient(circle at 30% 30%, rgba(255,255,255,.10), rgba(0,0,0,.25));
  box-shadow:
    inset 0 0 0 1px rgba(0,255,136,.25),
    0 0 18px rgba(0,255,136,.14);
  font-size: 18px;
  line-height: 1;
}

.back-text{
  font-size: 14px;
  letter-spacing: .2px;
  opacity: .95;
}

/* ====== КРАСИВАЯ КНОПКА SPIN ====== */
.spin-btn{
  margin-top: 22px;
  padding: 18px 78px;
  font-size: 22px;
  font-weight: 900;
  letter-spacing: 2px;
  text-transform: uppercase;

  border: 0;
  border-radius: 999px;
  cursor: pointer;

  color: #02140b;
  background:
    radial-gradient(circle at 30% 25%, rgba(255,255,255,.35), transparent 40%),
    linear-gradient(45deg, var(--neon), var(--neon2));

  box-shadow:
    0 18px 55px rgba(0,255,136,.22),
    0 0 55px rgba(0,255,136,.38),
    inset 0 1px 0 rgba(255,255,255,.22),
    inset 0 -10px 18px rgba(0,0,0,.22);

  position: relative;
  overflow: hidden;

  transition: transform .14s ease, filter .14s ease;
  -webkit-tap-highlight-color: transparent;
}

.spin-btn::before{
  content:"";
  position:absolute;
  inset: -2px;
  border-radius: inherit;
  padding: 2px;

  background: linear-gradient(90deg,
    rgba(214,255,154,.65),
    rgba(0,255,136,.55),
    rgba(0,195,106,.55),
    rgba(214,255,154,.65)
  );

  -webkit-mask:
    linear-gradient(#000 0 0) content-box,
    linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
          mask-composite: exclude;

  opacity: .55;
  pointer-events:none;
}

.spin-btn::after{
  content:"";
  position:absolute;
  top:-40%;
  left:-30%;
  width: 60%;
  height: 180%;
  transform: rotate(18deg);

  background: linear-gradient(90deg,
    transparent,
    rgba(255,255,255,.28),
    transparent
  );

  filter: blur(2px);
  opacity: .55;
  transition: transform .65s ease;
  pointer-events:none;
}

.spin-btn:hover{
  filter: brightness(1.06) saturate(1.08);
}

.spin-btn:hover::after{
  transform: translateX(220%) rotate(18deg);
}

.spin-btn:active{
  transform: translateY(1px) scale(.99);
}

.spin-btn:disabled{
  opacity: .55;
  cursor:not-allowed;
  filter: grayscale(.15);
}

/* лёгкое “дыхание” когда можно нажимать */
@media (prefers-reduced-motion: no-preference){
  .spin-btn:not(:disabled){
    animation: pulseGlow 2.1s ease-in-out infinite;
  }
  @keyframes pulseGlow{
    0%,100%{ box-shadow: 0 18px 55px rgba(0,255,136,.18), 0 0 55px rgba(0,255,136,.30), inset 0 1px 0 rgba(255,255,255,.22), inset 0 -10px 18px rgba(0,0,0,.22); }
    50%{    box-shadow: 0 22px 65px rgba(0,255,136,.26), 0 0 70px rgba(0,255,136,.42), inset 0 1px 0 rgba(255,255,255,.22), inset 0 -10px 18px rgba(0,0,0,.22); }
  }
}

@media (max-width: 900px){

  .slot-wrapper{
    padding: 36px 10px 10px;
    gap: 6px;
  }

  .slot{
    padding: 8px 8px;
    gap: 8px;
    border-radius: 16px;
  }

  :root{
    --reelW: calc((100vw - 20px - 16px - (2 * 8px)) / 3);
    --cell: clamp(110px, 14svh, 150px);
    --img:  clamp(80px,  10svh, 120px);
  }

  .spin-btn{
    padding: 16px 0;
    font-size: 20px;
    margin-top: 2px;

    /* ✅ сделаем удобно на телефоне */
    width: 100%;
  }

  .result{
    font-size: 18px;
    min-height: 24px;
  }
}
