:root { color-scheme: dark; font-family: system-ui, Arial, sans-serif; background: #10071e; color: white; }
* { box-sizing: border-box; }
body { margin: 0; min-width: 280px; }
[hidden] { display: none !important; }
button { font: inherit; cursor: pointer; touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 3px solid #fff3a4; outline-offset: 4px; }
.game {
  --gold: #ffe57e; --accent: #64deff;
  position: relative; isolation: isolate; display: grid; place-items: center;
  min-height: 100svh; padding: 18px 10px max(27px, env(safe-area-inset-bottom)); overflow: hidden;
  background: #19102b url("assets/images/bg.webp") center / cover no-repeat;
}
.game-content { position: relative; z-index: 1; display: grid; width: 100%; justify-items: center; }
.logo {
  position: relative; z-index: 4; width: clamp(132px, 29svh, 215px);
  margin: 0 auto -17px; line-height: 0; pointer-events: none;
}
.logo img, .offer-logo { display: block; width: 100%; height: auto; filter: drop-shadow(0 5px 8px #11051dbb); }
.machine { position: relative; display: grid; justify-items: center; width: 100%; }
.board {
  position: relative; width: min(92vw, 105svh, 920px); aspect-ratio: 913 / 560;
  filter: drop-shadow(0 8px 15px #1200239c);
}
.board::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: url("assets/images/frame.webp") center / 100% 100% no-repeat;
}
.reels {
  position: absolute; inset: 4% 2.6%; display: grid; grid-template-columns: repeat(5,minmax(0,1fr));
  background: linear-gradient(#240e36,#561972 50%,#31103d);
}
.reel { position: relative; min-width: 0; overflow: hidden; }
.faces, .strip { position: absolute; inset: 0; display: grid; grid-template-rows: repeat(3,minmax(0,1fr)); }
.strip { display: none; grid-template-rows: none; grid-auto-rows: calc(100% / 3); will-change: transform; }
.symbol { display: grid; min-height: 0; place-items: center; }
.symbol img { width: 85%; height: 85%; object-fit: contain; user-select: none; }
.reel.rolling .faces { visibility: hidden; }
.reel.rolling .strip { display: grid; }
.reel.anticipating::after {
  content: ""; position: absolute; inset: 1px; pointer-events: none;
  box-shadow: inset 0 0 15px var(--accent), inset 0 0 3px 2px #fff4aa;
  animation: edge-glow .65s ease-in-out infinite alternate;
}
@keyframes edge-glow { from { opacity: .47; } }
.game[data-phase="won"] .faces [data-id="w"] img { animation: prize .85s ease-in-out 2; }
@keyframes prize { 44% { transform: scale(1.12); filter: brightness(1.25) drop-shadow(0 0 10px var(--accent)); } }
.controls { display: grid; grid-template-rows: auto minmax(15px,auto); justify-items: center; gap: 6px; z-index: 4; width: min(100%, 420px); margin-top: 9px; }
.action {
  min-width: min(226px, 75vw); max-width: 100%; min-height: 60px; padding: 12px 23px;
  border: 0; border-radius: 9px; color: #fff; font-size: clamp(21px, 3.8vw, 28px);
  font-weight: 950; line-height: 1.1; text-transform: uppercase; text-shadow: 0 2px 3px #022b54, 0 0 4px #022b54;
  background: url("assets/images/button-left.webp") left center / 94px 100% no-repeat,
    url("assets/images/button-right.webp") right center / 94px 100% no-repeat,
    url("assets/images/button-middle.webp") center / calc(100% - 178px) 100% no-repeat;
  filter: drop-shadow(0 4px 7px #140328aa);
  overflow-wrap: anywhere;
}
.action:not(:disabled):active { transform: translateY(1px) scale(.98); }
.action:disabled { cursor: default; opacity: .78; filter: saturate(.55); }
.status { min-height: 15px; margin: 0; color: #fff4dd; text-align: center; font-size: 11px; font-weight: 750; text-shadow: 0 1px 4px #000; }
.sound {
  position: absolute; z-index: 5; top: max(12px, env(safe-area-inset-top)); right: max(12px,env(safe-area-inset-right));
  width: 38px; height: 38px; padding: 7px; display: grid; place-items: center;
  color: var(--gold); border: 1px solid #f5d37799; border-radius: 50%; background: #180b33ce;
}
.sound svg { width: 100%; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.sound[aria-pressed="true"] .sound-off, .sound[aria-pressed="false"] .sound-on { display: none; }
.scene { position: absolute; inset: 0; pointer-events: none; overflow: clip; }
.scene img { position: absolute; display: block; object-fit: contain; user-select: none; }
.scene-hero {
  z-index: 2; left: max(-30px,calc(50% - 620px)); bottom: 2%; width: clamp(145px, 23vw, 318px); height: min(83svh,650px);
  object-position: bottom center; filter: drop-shadow(0 5px 12px #1c092266);
  animation: hover 4.7s ease-in-out infinite;
}
.scene-coin { width: clamp(94px,18vw,245px); animation: hover 5.6s ease-in-out infinite; }
.scene-coin.left { left: max(-50px,calc(50% - 690px)); bottom: 8%; }
.scene-coin.right { right: max(-44px,calc(50% - 690px)); top: 18%; animation-delay: -2.5s; }
@keyframes hover { 50% { transform: translateY(-9px) rotate(-1.4deg); } }
.scene-gem { width: clamp(49px,10vw,132px); animation: hover 5s ease-in-out infinite; }
.gem-3 { top: 6%; right: 25%; }
.gem-4 { top: 21%; right: 10%; animation-delay: -1.4s; }
.gem-5 { right: 0; top: 42%; animation-delay: -2.1s; }
.gem-6 { right: 12%; bottom: 11%; animation-delay: -3s; }
.gem-7 { left: 27%; bottom: 0; animation-delay: -2.6s; }
.scene-lightning { left: 11%; bottom: 17%; height: min(33svh,270px); mix-blend-mode: screen; animation: spark 3.2s linear infinite; }
@keyframes spark { 15%, 27%, 100% { opacity: 1; } 0%, 17%, 75% { opacity: .18; } }
footer { position: absolute; z-index: 4; bottom: max(6px,env(safe-area-inset-bottom)); inset-inline: 10px; text-align: center; color: #fff9dc; font-size: 10px; text-shadow: 0 1px 4px #000; }
.game[data-phase="final"] .game-content { visibility: hidden; }
#particles { position: absolute; z-index: 4; inset: 0; pointer-events: none; overflow: hidden; }
.rain-coin {
  position: absolute; top: -40px; width: var(--size); aspect-ratio: 1; border-radius: 50%;
  background: radial-gradient(circle at 37% 27%,#fff3a8,#ffce2a 47%,#9c5100 86%);
  box-shadow: inset 0 0 0 2px #ffda70; animation: rain var(--duration) linear forwards;
}
@keyframes rain { to { transform: translate(26px,115svh) rotate(420deg) scaleX(.53); } }

.offer {
  position: fixed; inset: 0; margin: auto; padding: 15px 12px 20px; isolation: isolate;
  width: min(100%, 690px); max-width: 100%; max-height: calc(100dvh - 20px);
  border: 0; background: none; color: #fff; text-align: center; overflow-x: hidden;
}
.offer::backdrop { background: #11061bbb; }
.offer-content { position: relative; display: grid; gap: 11px; justify-items: center; }
.offer-art { position: absolute; z-index: -2; inset: 7% -8% 0; background: url("assets/images/flare.webp") center / contain no-repeat; mix-blend-mode: screen; }
.offer-logo { width: min(62vw,245px); height: auto; }
.offer-panel { position: relative; display: grid; gap: 9px; place-items: center; width: min(100%,575px); padding: 12px 25px; }
.offer h2 { margin: 0; color: #fff4aa; font-size: clamp(23px,6vw,37px); line-height: 1.1; text-transform: uppercase; text-shadow: 0 3px #764007, 0 0 10px #b56d16; overflow-wrap: anywhere; }
.offer-label { margin: 0; font-size: clamp(13px,3.6vw,17px); font-weight: 780; color: #fff0dc; overflow-wrap: anywhere; }
.offer-amount { font: 950 clamp(37px,10vw,63px)/1.13 system-ui,sans-serif; color: #ffe362; text-shadow: 0 3px #9b4c05, 0 0 12px #f2b51c; overflow-wrap: anywhere; max-width: 100%; }
.offer-extra { margin: 2px 0 0; color: #fff2a6; font-size: clamp(14px,4.3vw,21px); line-height: 1.25; overflow-wrap: anywhere; }
.offer .action { margin-top: 3px; }
[data-pwa-help], [data-pwa-inapp] { max-width: 430px; margin: 0; color: #fff7d3; font: 14px/1.45 system-ui,sans-serif; }

.game.joker { --accent: #ef87ff; background-color: #26043b; }
.joker .logo { width: clamp(128px, 27svh, 200px); margin-bottom: -16px; }
.joker .board { width: min(96vw, 133svh, 1120px); aspect-ratio: 3016 / 1818; }
.joker .reels { inset: 6.7% 10.7% 30.8%; background: #5b087d url("assets/images/reel-bg.webp") center / cover; clip-path: polygon(2% 0,98% 0,100% 50%,98% 100%,2% 100%,0 50%); }
.joker .controls { position: absolute; top: 77.5%; margin-top: 0; }
.joker .scene-hero { left: max(-18px,calc(50% - 680px)); bottom: 8%; width: clamp(150px,25vw,350px); }
.joker .scene-coin.right { top: auto; bottom: 3%; }
.joker .scene-flare { left: 50%; top: 2%; width: min(58vw,650px); transform: translateX(-50%); opacity: .53; mix-blend-mode: screen; }
.joker.offer::backdrop { background: #240437c7; }
.joker .offer-panel {
  min-height: 188px; padding: 7px 5px 11px;
  border: solid transparent;
  border-width: 12px clamp(19px,6vw,36px) 65px;
  border-image: url("assets/images/offer-panel.webp") 8% 11% 33% 11% fill stretch;
}
.joker .offer-extra { color: #ceff8a; }
.big-win {
  margin: -2px 0 1px; color: #ffe46a; font: 950 clamp(29px,7vw,47px)/1.05 Georgia,serif;
  text-shadow: 0 3px #843907, 0 0 14px #ec5d17; letter-spacing: .03em; text-transform: uppercase;
}
.offer-treasure { position: absolute; z-index: 1; left: -1%; bottom: 4%; width: min(22vw,125px); pointer-events: none; }


@media (max-width: 991px) {
  .game { background-image: url("assets/images/bg-phone.webp"); padding-top: max(31px,env(safe-area-inset-top)); }
  .logo { width: min(57vw,225px,33svh); margin-bottom: -9px; }
  .board { width: min(91vw,53svh,490px); aspect-ratio: 737 / 714; }
  .board::after { background-image: url("assets/images/frame-phone.webp"); }
  .reels { inset: 4.3% 3%; grid-template-columns: repeat(3,minmax(0,1fr)); }
  .reel:nth-child(n+4) { display: none; }
  .controls { margin-top: 14px; }
  .action { min-height: 56px; font-size: clamp(20px,5.5vw,25px); }
  .scene-hero { z-index: 0; width: clamp(130px,36vw,215px); height: min(60svh,460px); left: -12px; bottom: 6%; opacity: .92; }
  .scene-coin { width: min(30vw,150px); }
  .scene-coin.left { left: -18px; bottom: 8%; }
  .scene-coin.right { right: -25px; top: 14%; }
  .scene-gem { width: min(17vw,90px); }
  .gem-3 { top: 17%; right: 11%; }
  .gem-4 { top: 29%; right: 0; }
  .gem-5 { right: -1%; top: 61%; }
  .gem-6 { right: 5%; bottom: 9%; }
  .gem-7 { left: 33%; bottom: 5%; }
  .scene-lightning { left: 13%; bottom: 19%; height: 27svh; }
  .sound { width: 34px; height: 34px; }
  .joker .logo { width: min(51vw,181px,29svh); margin-bottom: -8px; }
  .joker .board { width: min(96vw,56svh,510px); aspect-ratio: 870 / 846; }
  .joker .reels { inset: 6.4% 10.6% 29.6%; }
  .joker .controls { top: 76%; }
  .joker .scene-hero { left: -16px; bottom: 24%; width: clamp(125px,39vw,235px); }
  .joker .scene-coin.right { bottom: 12%; }
}
@media (max-height: 610px) and (max-width: 991px) {
  .joker .board { width: min(96vw,64svh,470px); }
  .board { width: min(92vw,58svh,460px); }
  .logo { width: min(49vw,175px,25svh); }
  .joker .logo { width: min(45vw,154px,26svh); }
  .controls { gap: 3px; }
  .action { min-height: 44px; font-size: 20px; padding-block: 6px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
}
