/* Fail or Not — «Neon Opulence» */
@property --ang { syntax: '<angle>'; inherits: false; initial-value: 0deg; }

:root {
  --bg: #07020F;
  --ink: #FFFFFF;
  --ink2: rgba(255, 255, 255, .74);
  --ink3: rgba(255, 255, 255, .48);
  --a1: #00E5FF; --a2: #3B82F6;
  --b1: #FF2BD6; --b2: #8B5CF6;
  --g1: #FFF3B0; --g2: #FFC53D; --g3: #B8860B;
  --lose: #FF3B5C;
  --glass: rgba(14, 6, 30, .58);
  --line: rgba(255, 255, 255, .16);
  --ff-d: 'Unbounded', 'Arial Black', system-ui, sans-serif;
  --ff: 'Inter', system-ui, -apple-system, sans-serif;
  --spring: cubic-bezier(.2, 1.4, .4, 1);
  --out: cubic-bezier(.16, 1, .3, 1);
  --sat: env(safe-area-inset-top, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
  --gold: linear-gradient(180deg, #FFFBE6 0%, #FFE27A 30%, #FFC53D 52%, #B8860B 72%, #FFE9A0 100%);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--ink); overflow: hidden; overscroll-behavior: none; }
body { font-family: var(--ff); -webkit-font-smoothing: antialiased; display: grid; place-items: center; user-select: none; -webkit-user-select: none; }
button { font: inherit; color: inherit; border: 0; background: none; padding: 0; cursor: pointer; touch-action: manipulation; }
[hidden] { display: none !important; }
.num { font-variant-numeric: tabular-nums; }

/* фон вокруг сцены на десктопе */
.ambient { position: fixed; inset: 0; overflow: hidden; filter: blur(80px) saturate(140%); opacity: .5; }
.ambient i { position: absolute; border-radius: 50%; width: 60vmax; height: 60vmax; mix-blend-mode: screen; animation: drift 18s ease-in-out infinite alternate; }
.ambient i:nth-child(1) { background: radial-gradient(circle, var(--b1), transparent 65%); left: -15%; top: -20%; }
.ambient i:nth-child(2) { background: radial-gradient(circle, var(--a1), transparent 65%); right: -20%; top: 20%; animation-delay: -6s; }
.ambient i:nth-child(3) { background: radial-gradient(circle, var(--b2), transparent 65%); left: 10%; bottom: -30%; animation-delay: -11s; }
@keyframes drift { to { transform: translate(8%, 6%) scale(1.15); } }

/* сцена 9:16 */
#stage { position: relative; overflow: hidden; overflow: clip; isolation: isolate; background: #000; width: 100vw; height: 100dvh; }
@media (min-aspect-ratio: 10/16) {
  #stage { height: min(96dvh, calc(100vw * 16 / 9)); width: calc(min(96dvh, calc(100vw * 16 / 9)) * 9 / 16); border-radius: 30px;
    box-shadow: 0 0 0 1px rgba(255,255,255,.08), 0 30px 120px rgba(255, 43, 214, .25), 0 0 200px rgba(0, 229, 255, .12); }
}

/* видео + стоп-кадр с блюром */
#screen { position: absolute; inset: 0; z-index: 0; overflow: hidden; transition: filter .7s var(--out), transform .9s var(--out); }
#screen video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: 0; pointer-events: none; }
#screen video.on { opacity: 1; }
#screen.square video { object-fit: contain; transform: scale(1.32); transform-origin: 50% 42%; }
.bgfill { position: absolute; inset: -40px; background: #000 center/cover no-repeat; filter: blur(28px) brightness(.55) saturate(1.4); opacity: 0; }
#screen.square .bgfill { opacity: 1; }
#screen.frozen { filter: blur(7px) saturate(1.25) brightness(.62); transform: scale(1.06); }
#screen.waiting { filter: blur(11px) saturate(1.5) brightness(.45) hue-rotate(-12deg); transform: scale(1.09); }
#screen.shake { animation: shake .45s cubic-bezier(.36,.07,.19,.97); }
@keyframes shake { 10%,90% { translate: -2px 0 } 20%,80% { translate: 4px 1px } 30%,50%,70% { translate: -7px -1px } 40%,60% { translate: 7px 1px } }

.scan { position: absolute; inset: 0; z-index: 1; pointer-events: none; opacity: 0; transition: opacity .4s;
  background: repeating-linear-gradient(180deg, rgba(255,255,255,.05) 0 1px, transparent 1px 4px),
              linear-gradient(180deg, transparent 0%, rgba(0,229,255,.18) 48%, rgba(255,43,214,.18) 52%, transparent 100%);
  background-size: 100% 100%, 100% 220%; animation: scan 1.6s linear infinite; }
.scan.on { opacity: 1; }
@keyframes scan { from { background-position: 0 0, 0 120%; } to { background-position: 0 0, 0 -120%; } }

.vignette { position: absolute; inset: 0; z-index: 1; pointer-events: none; transition: opacity .4s;
  background: linear-gradient(180deg, rgba(7,2,15,.6) 0%, transparent 16%, transparent 58%, rgba(7,2,15,.85) 100%); }
.vignette.win { box-shadow: inset 0 0 120px 30px rgba(255,197,61,.75); animation: pulseIn 1.4s var(--out) both; }
.vignette.lose { box-shadow: inset 0 0 120px 30px rgba(255,59,92,.7); animation: pulseIn 1.4s var(--out) both; }
@keyframes pulseIn { 0% { opacity: 0 } 15% { opacity: 1 } 100% { opacity: .55 } }

.flash { position: absolute; inset: 0; z-index: 3; pointer-events: none; opacity: 0; background: #fff; }
.flash.go { animation: flash .5s ease-out; }
.flash.gold { background: radial-gradient(circle at 50% 45%, #FFF3B0, rgba(255,197,61,.5) 50%, transparent 80%); }
.flash.red { background: radial-gradient(circle at 50% 45%, rgba(255,59,92,.8), transparent 75%); }
@keyframes flash { 0% { opacity: .85 } 100% { opacity: 0 } }
#fx { position: absolute; inset: 0; width: 100%; height: 100%; z-index: 30; pointer-events: none; }

/* HUD */
.hud { position: absolute; z-index: 20; top: calc(14px + var(--sat)); left: 14px; right: 14px; display: flex; align-items: center; gap: 10px; }
.wallet { display: flex; align-items: center; gap: 8px; padding: 7px 14px 7px 7px; border-radius: 99px; background: var(--glass);
  backdrop-filter: blur(14px) saturate(160%); -webkit-backdrop-filter: blur(14px) saturate(160%); border: 1px solid var(--line); font-family: var(--ff-d); font-weight: 800; font-size: 15px; }
.wallet.bump { animation: bump .6s var(--spring); }
.wallet.drop { animation: drop .5s ease; }
@keyframes bump { 40% { transform: scale(1.18); box-shadow: 0 0 30px rgba(255,197,61,.8); } }
@keyframes drop { 30% { transform: translateY(3px); color: var(--lose); } }
.coin { width: 22px; height: 22px; border-radius: 50%; background: radial-gradient(circle at 35% 30%, #FFF6C8, #FFD24D 40%, #E0A21A 70%, #8A5A00); box-shadow: inset 0 0 0 2px rgba(120,70,0,.45), 0 0 12px rgba(255,197,61,.6); }
.rounds { display: flex; gap: 6px; margin-left: auto; }
.rounds i { width: 22px; height: 6px; border-radius: 3px; background: rgba(255,255,255,.22); transition: background .3s, box-shadow .3s; }
.rounds i.cur { background: #fff; box-shadow: 0 0 10px #fff; }
.rounds i.win { background: var(--g2); box-shadow: 0 0 10px var(--g2); }
.rounds i.lose { background: var(--lose); }
.tour { font: 800 10px/1 var(--ff-d); letter-spacing: .08em; padding: 6px 8px; border-radius: 6px; background: rgba(255,255,255,.12); color: var(--ink2); }

/* билет ставки во время исхода */
.ticket { position: absolute; z-index: 20; top: calc(62px + var(--sat)); left: 14px; display: grid; grid-template-columns: auto auto; column-gap: 10px; align-items: center;
  padding: 10px 14px; border-radius: 16px; background: var(--glass); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); border: 1px solid var(--line);
  animation: slideIn .5s var(--spring) both; }
.ticket.a { border-color: rgba(0,229,255,.6); box-shadow: 0 0 24px rgba(0,229,255,.25); }
.ticket.b { border-color: rgba(255,43,214,.6); box-shadow: 0 0 24px rgba(255,43,214,.25); }
.t-label { grid-column: 1 / -1; font-size: 10px; letter-spacing: .12em; text-transform: uppercase; color: var(--ink3); }
.t-pick { font: 800 14px var(--ff-d); }
.t-amt { font-size: 12px; color: var(--ink2); grid-column: 1; }
.t-state { grid-column: 2; grid-row: 2 / 4; display: flex; gap: 3px; }
.t-state i { width: 6px; height: 6px; border-radius: 50%; background: #fff; animation: dots 1s infinite; }
.t-state i:nth-child(2) { animation-delay: .15s } .t-state i:nth-child(3) { animation-delay: .3s }
@keyframes dots { 0%,100% { opacity: .25; transform: scale(.7) } 50% { opacity: 1; transform: scale(1) } }
.ticket.won { border-color: var(--g2); box-shadow: 0 0 30px rgba(255,197,61,.6); }
.ticket.lost { border-color: var(--lose); opacity: .8; }
.ticket.won .t-state, .ticket.lost .t-state { display: none; }
@keyframes slideIn { from { transform: translateX(-120%); } }

/* «СТОП-КАДР» */
.freeze-tag { position: absolute; z-index: 15; inset: 0; display: grid; place-items: center; pointer-events: none; top: -26%; }
.freeze-tag span { font: 900 clamp(26px, 9vw, 40px)/1 var(--ff-d); letter-spacing: .04em; padding: 10px 18px; border: 3px solid #fff; border-radius: 10px;
  transform: rotate(-6deg); text-shadow: 0 0 20px rgba(255,255,255,.7); box-shadow: 0 0 30px rgba(255,255,255,.4), inset 0 0 20px rgba(255,255,255,.25);
  animation: stamp .55s var(--spring) both, fadeOut .4s 1.1s forwards; }
@keyframes stamp { from { transform: rotate(-6deg) scale(2.6); opacity: 0; } }
@keyframes fadeOut { to { opacity: 0; transform: rotate(-6deg) scale(.9); } }

/* панель ставки */
.bet { position: absolute; z-index: 20; left: 0; right: 0; bottom: 0; padding: 18px 16px calc(18px + var(--sab)); animation: rise .6s var(--spring) both; }
.bet.closing { animation: sink .45s var(--out) forwards; }
@keyframes rise { from { transform: translateY(105%); } }
@keyframes sink { to { transform: translateY(110%); opacity: 0; } }
.timer { height: 4px; border-radius: 2px; background: rgba(255,255,255,.15); overflow: hidden; margin: 0 4px 16px; }
.timer i { display: block; height: 100%; width: 100%; background: linear-gradient(90deg, var(--a1), var(--b1)); transform-origin: left; }
.q-kicker { margin: 0; text-align: center; font: 700 11px var(--ff-d); letter-spacing: .2em; text-transform: uppercase; color: var(--g2); }
.q { margin: 8px 0 18px; text-align: center; font: 900 clamp(22px, 7.2vw, 30px)/1.12 var(--ff-d); text-shadow: 0 2px 24px rgba(0,0,0,.6); }
.opts { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.opt { position: relative; display: grid; gap: 4px; justify-items: center; padding: 16px 10px 14px; border-radius: 22px; overflow: hidden;
  background: var(--glass); backdrop-filter: blur(16px) saturate(170%); -webkit-backdrop-filter: blur(16px) saturate(170%);
  transition: transform .2s var(--spring), opacity .3s, filter .3s; animation: optIn .6s var(--spring) both; }
.opt.b { animation-delay: .08s; }
@keyframes optIn { from { transform: translateY(30px) scale(.9); opacity: 0; } }
.opt::before { content: ''; position: absolute; inset: 0; border-radius: inherit; padding: 2px; pointer-events: none;
  background: conic-gradient(from var(--ang), var(--c1), var(--c2), var(--c1)); animation: spin 3s linear infinite;
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0); -webkit-mask-composite: xor; mask-composite: exclude; }
.opt::after { content: ''; position: absolute; inset: 0; background: radial-gradient(120% 90% at 50% 0%, var(--glow), transparent 70%); opacity: .35; pointer-events: none; }
.opt.a { --c1: var(--a1); --c2: var(--a2); --glow: rgba(0,229,255,.55); }
.opt.b { --c1: var(--b1); --c2: var(--b2); --glow: rgba(255,43,214,.55); }
@keyframes spin { to { --ang: 360deg; } }
.opt:active { transform: scale(.95); }
.o-key { font: 800 10px var(--ff-d); letter-spacing: .1em; width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; background: var(--c1); color: #07020F; }
.o-label { font: 800 15px/1.15 var(--ff-d); text-align: center; min-height: 2.3em; display: grid; place-items: center; }
.o-mult { font: 900 26px/1 var(--ff-d); background: linear-gradient(180deg, #fff, var(--c1)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.o-win { font-size: 12px; color: var(--ink2); }
.opt.picked { transform: scale(1.06); filter: brightness(1.25); box-shadow: 0 0 40px var(--glow); }
.opt.picked::after { opacity: .8; }
.opt.dim { opacity: .25; filter: grayscale(.8); transform: scale(.94); }
.chips { display: flex; justify-content: center; gap: 8px; margin-top: 16px; }
.chip { min-width: 58px; padding: 9px 10px; border-radius: 99px; font: 800 13px var(--ff-d); background: rgba(255,255,255,.08); border: 1px solid var(--line); transition: all .2s var(--spring); }
.chip.on { background: var(--gold); color: #3A2400; border-color: transparent; transform: translateY(-3px); box-shadow: 0 6px 20px rgba(255,197,61,.5); }
.chip:disabled { opacity: .3; }

/* ожидание исхода */
.wait { position: absolute; z-index: 20; inset: 0; display: grid; place-content: center; justify-items: center; gap: 10px; animation: fadeIn .35s both; }
.wait.leaving { animation: fadeOutW .35s forwards; }
@keyframes fadeIn { from { opacity: 0; transform: scale(.92); } }
@keyframes fadeOutW { to { opacity: 0; transform: scale(1.15); } }
.orb { position: relative; width: 150px; height: 150px; display: grid; place-items: center; margin-bottom: 8px; }
.ring { position: absolute; inset: 0; border-radius: 50%; padding: 4px; background: conic-gradient(from var(--ang), transparent 0 20%, var(--a1) 45%, var(--b1) 70%, transparent 90%);
  -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 5px), #000 calc(100% - 4px)); mask: radial-gradient(farthest-side, transparent calc(100% - 5px), #000 calc(100% - 4px));
  animation: spin .9s linear infinite; filter: drop-shadow(0 0 10px var(--b1)); }
.ring.r2 { inset: 16px; animation-duration: 1.6s; animation-direction: reverse; background: conic-gradient(from var(--ang), transparent 0 40%, var(--g2) 70%, transparent 95%); filter: drop-shadow(0 0 8px var(--g2)); }
.core { display: flex; align-items: baseline; font: 900 34px var(--ff-d); text-shadow: 0 0 20px rgba(255,255,255,.6); }
.core small { font-size: 14px; margin-left: 2px; color: var(--ink2); }
.w-title { margin: 0; font: 900 22px var(--ff-d); letter-spacing: .02em; }
.w-step { margin: 0; font-size: 14px; color: var(--ink2); min-height: 1.3em; animation: stepIn .3s both; }
@keyframes stepIn { from { opacity: 0; transform: translateY(6px); } }
.w-bar { width: 200px; height: 4px; border-radius: 2px; background: rgba(255,255,255,.15); overflow: hidden; margin-top: 6px; }
.w-bar i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--a1), var(--b1), var(--g2)); box-shadow: 0 0 12px var(--b1); }

/* результат */
.result { position: absolute; z-index: 22; left: 0; right: 0; top: 50%; text-align: center; pointer-events: none; animation: resIn .7s var(--spring) both; }
.result.leaving { animation: resOut .5s forwards; }
@keyframes resIn { from { transform: translateY(-50%) scale(.3); opacity: 0; } to { transform: translateY(-50%); } }
@keyframes resOut { from { transform: translateY(-50%); } to { transform: translateY(-80%) scale(.8); opacity: 0; } }
.r-kicker { margin: 0; font: 900 clamp(26px, 9vw, 40px)/1 var(--ff-d); letter-spacing: .02em; }
.r-amt { margin: 6px 0 4px; font: 900 clamp(46px, 17vw, 76px)/1 var(--ff-d); }
.r-sub { margin: 0; font-size: 15px; color: var(--ink2); }
.result.win .r-kicker, .result.win .r-amt { background: var(--gold); -webkit-background-clip: text; background-clip: text; color: transparent; filter: drop-shadow(0 4px 20px rgba(255,197,61,.6)) drop-shadow(0 2px 0 #6B4500); }
.result.lose .r-kicker { color: var(--lose); text-shadow: 0 0 30px rgba(255,59,92,.7); }
.result.lose .r-amt { color: #fff; opacity: .9; text-shadow: 0 4px 24px rgba(0,0,0,.7); }
.result.skip .r-kicker { font-size: 26px; color: var(--ink2); }

/* дальше */
.next { position: absolute; z-index: 24; left: 16px; right: 16px; bottom: calc(20px + var(--sab)); height: 58px; border-radius: 18px; overflow: hidden;
  background: rgba(255,255,255,.12); border: 1px solid var(--line); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); font: 800 16px var(--ff-d);
  letter-spacing: .06em; text-transform: uppercase; animation: rise .5s var(--spring) both; }
.next span { position: relative; z-index: 1; }
.next i { position: absolute; inset: 0; background: linear-gradient(90deg, rgba(0,229,255,.5), rgba(255,43,214,.5)); transform-origin: left; transform: scaleX(0); }

/* лобби / финал */
.lobby, .final { position: absolute; inset: 0; z-index: 40; display: grid; place-items: center; text-align: center; padding: 24px 22px calc(24px + var(--sab)); background: rgba(7,2,15,.55); }
.lobby.leaving { animation: fadeOutW .5s forwards; }
.lobby-bg { position: absolute; inset: -30px; background: center/cover no-repeat; filter: blur(14px) brightness(.5) saturate(1.4); z-index: -1; }
.lobby-in { display: grid; justify-items: center; gap: 14px; }
.l-kicker { margin: 0; font: 700 11px var(--ff-d); letter-spacing: .22em; text-transform: uppercase; color: var(--g2); }
.logo { margin: 0; font: 900 clamp(48px, 17vw, 74px)/.92 var(--ff-d); letter-spacing: -.02em;
  background: linear-gradient(180deg, #fff 0%, #FFD6F6 45%, #FF7AE6 65%, #B07CFF 100%); -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 0 30px rgba(255,43,214,.55)); }
.logo em { font-style: normal; font-size: .5em; vertical-align: middle; background: var(--gold); -webkit-background-clip: text; background-clip: text; }
.l-tag { margin: 0; max-width: 300px; color: var(--ink2); font-size: 15px; line-height: 1.4; }
.l-how { list-style: none; margin: 8px 0; padding: 0; display: grid; gap: 8px; text-align: left; }
.l-how li { display: flex; align-items: center; gap: 12px; font-size: 15px; }
.l-how b { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; font: 800 12px var(--ff-d); background: rgba(255,255,255,.1); border: 1px solid var(--line); }
.play { position: relative; margin-top: 10px; width: min(300px, 80vw); height: 64px; border-radius: 20px; font: 900 20px var(--ff-d); letter-spacing: .06em; text-transform: uppercase; color: #2A1800;
  background: var(--gold); box-shadow: 0 10px 40px rgba(255,197,61,.45), inset 0 -4px 0 rgba(120,70,0,.35), inset 0 2px 0 rgba(255,255,255,.7); animation: breathe 2.2s ease-in-out infinite; }
.play:active { transform: scale(.96); }
@keyframes breathe { 50% { box-shadow: 0 10px 60px rgba(255,197,61,.75), inset 0 -4px 0 rgba(120,70,0,.35), inset 0 2px 0 rgba(255,255,255,.7); } }
.l-bal { margin: 0; font-size: 13px; color: var(--ink3); }
.final { align-content: center; gap: 12px; background: rgba(7,2,15,.72); backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px); animation: fadeIn .5s both; }
.f-title { margin: 0; font: 900 clamp(52px, 18vw, 80px)/1 var(--ff-d); background: var(--gold); -webkit-background-clip: text; background-clip: text; color: transparent; }
.f-title.neg { background: none; color: var(--lose); }
.f-sub { margin: 0; color: var(--ink2); }
.f-list { display: grid; gap: 8px; width: min(320px, 86vw); margin: 10px 0; }
.f-row { display: flex; justify-content: space-between; align-items: center; padding: 12px 14px; border-radius: 14px; background: rgba(255,255,255,.07); border: 1px solid var(--line); font-size: 14px; text-align: left; }
.f-row b { font-family: var(--ff-d); }
.f-row .w { color: var(--g2); } .f-row .l { color: var(--lose); }

.loading { position: absolute; inset: 0; z-index: 50; display: grid; place-items: center; background: var(--bg); transition: opacity .4s; }
.loading.done { opacity: 0; pointer-events: none; }
.loading i { width: 40px; height: 40px; border-radius: 50%; border: 3px solid rgba(255,255,255,.15); border-top-color: var(--b1); animation: spin2 .8s linear infinite; }
@keyframes spin2 { to { transform: rotate(360deg); } }

@media (prefers-reduced-motion: reduce) { .opt::before, .ring, .scan { animation-duration: 6s; } }
