/* Polish layer: case-opening effects, demo spins, home page games row + top drops, focus styles.
   Loaded after style.css and the game stylesheets. */

/* ------------------------------------------------------------------ reel: special tiles */
/* min-width/height 0: a long item name must not stretch its tile (flex items default to min-content) */
.reel-tile { position: relative; min-width: 0; min-height: 0; }
.reel-tile .item { min-width: 0; }

.rare-tile {
  border-color: rgba(228, 174, 57, .55);
  background:
    radial-gradient(80% 65% at 50% 42%, rgba(255, 214, 107, .38), transparent 70%),
    repeating-conic-gradient(from 0deg at 50% 42%, rgba(255, 215, 110, .09) 0 7deg, transparent 7deg 18deg),
    linear-gradient(180deg, #3b2b0c, #1a1306);
}
.rare-tile .item-img { filter: drop-shadow(0 0 10px rgba(255, 200, 80, .75)); }
.rare-tile .item-weapon { color: #c9a24e; }
.rare-tile .item-skin { color: #ffd66b; white-space: normal; line-height: 1.15; font-size: 12.5px; }
.rare-star {
  display: block; height: 80%; aspect-ratio: 1; margin: auto;
  clip-path: polygon(50% 0%, 61.8% 35.4%, 100% 35.4%, 69.1% 57.3%, 80.9% 92.7%, 50% 70.8%, 19.1% 92.7%, 30.9% 57.3%, 0% 35.4%, 38.2% 35.4%);
  background: linear-gradient(160deg, #fff5cf 0%, #ffd66b 32%, #e4ae39 62%, #9c6a14 100%);
}
.rare-star.sm { display: inline-block; height: 22px; width: 22px; margin: 0; vertical-align: -3px; filter: none; }
.blank-tile .blank-mark { font: 40px/1 var(--display); color: var(--dim); }

/* ------------------------------------------------------------------ reel: tension + landing */
.reel .reel-marker { transition: box-shadow .3s; }
.reel .reel-fade { transition: box-shadow .5s; }
.reel.tension .reel-marker { animation: rdMarker .42s ease-in-out infinite alternate; }
.reel.tension .reel-fade { box-shadow: inset 0 0 70px 6px rgba(0, 0, 0, .6); }
@keyframes rdMarker {
  from { box-shadow: 0 0 12px var(--gold); }
  to { box-shadow: 0 0 20px 2px #ffd66b, 0 0 44px rgba(255, 214, 107, .55); }
}

.reel .reel-tile { transition: opacity .35s, filter .35s; }
.reel.landed .reel-tile:not(.win) { opacity: .42; }
.reel.landed .reel-tile.win .item { animation: rdLand .7s cubic-bezier(.2, .9, .3, 1.25); }
@keyframes rdLand {
  0% { transform: scale(1); box-shadow: 0 0 0 0 var(--c); }
  35% { transform: scale(1.1); box-shadow: 0 0 38px 6px var(--c), inset 0 0 0 1px var(--c); }
  100% { transform: scale(1.04); box-shadow: 0 0 26px -2px var(--c), inset 0 0 0 1px var(--c); }
}

/* Rarity-coloured light sweep over the winning tile */
.reel-sweep {
  position: absolute; inset: 0; z-index: 2; pointer-events: none; opacity: 0;
  background: linear-gradient(105deg, transparent 22%, color-mix(in srgb, var(--c) 70%, transparent) 42%,
    rgba(255, 255, 255, .8) 50%, color-mix(in srgb, var(--c) 70%, transparent) 58%, transparent 78%);
  mix-blend-mode: screen;
  animation: rdSweep 1s .12s cubic-bezier(.3, .6, .3, 1) 2;
}
@keyframes rdSweep {
  0% { transform: translateX(-130%); opacity: 0; }
  15% { opacity: .9; }
  100% { transform: translateX(130%); opacity: 0; }
}

/* ------------------------------------------------------------------ reel: rare special reveal */
.reel.revealing { border-color: rgba(228, 174, 57, .7); box-shadow: 0 0 44px -8px rgba(228, 174, 57, .7); }
.reel.revealing .reel-tile:not(.win) { opacity: .16; filter: grayscale(.7); }
.reel.landed .reel-tile.win.rare-charge .item { animation: rdCharge .9s ease-in forwards; }
@keyframes rdCharge {
  0% { transform: scale(1.04); box-shadow: 0 0 20px rgba(228, 174, 57, .8); }
  55% { transform: scale(1.09) rotate(0); }
  65% { transform: scale(1.1) rotate(-1.6deg); }
  75% { transform: scale(1.11) rotate(1.6deg); }
  85% { transform: scale(1.12) rotate(-1deg); }
  100% { transform: scale(1.14) rotate(0); box-shadow: 0 0 54px 12px #ffd66b, inset 0 0 30px rgba(255, 214, 107, .6); }
}
.reel.landed .reel-tile.win.flip-out .item { animation: rdFlipOut .18s ease-in forwards; }
@keyframes rdFlipOut {
  from { transform: perspective(700px) scale(1.14) rotateY(0); }
  to { transform: perspective(700px) scale(1.22) rotateY(90deg); filter: brightness(2); }
}
.reel.landed .reel-tile.win.flip-in .item { animation: rdFlipIn .52s cubic-bezier(.2, .9, .3, 1.3) both; }
@keyframes rdFlipIn {
  0% { transform: perspective(700px) scale(1.3) rotateY(-90deg); filter: brightness(2.2); }
  60% { transform: perspective(700px) scale(1.12) rotateY(8deg); filter: brightness(1.2); }
  100% { transform: scale(1.04); filter: none; }
}
.reel .reel-tile.rare-won .item { border-color: #ffd66b; box-shadow: 0 0 36px 2px rgba(255, 214, 107, .75), inset 0 0 0 1px #ffd66b; }

.reel-burst {
  position: absolute; left: 50%; top: 50%; width: 420px; height: 420px; margin: -210px 0 0 -210px;
  border-radius: 50%; pointer-events: none; transition: opacity 1.2s;
  background: radial-gradient(closest-side, rgba(255, 236, 170, .95), rgba(255, 196, 70, .55) 34%, rgba(228, 174, 57, .16) 64%, transparent);
  animation: rdBurst .6s cubic-bezier(.2, .8, .2, 1) backwards;
}
.reel-burst::before {
  content: ''; position: absolute; inset: -25%; border-radius: 50%;
  background: repeating-conic-gradient(from 0deg, rgba(255, 222, 130, .38) 0 6deg, transparent 6deg 18deg);
  -webkit-mask: radial-gradient(closest-side, #000 18%, transparent 74%);
  mask: radial-gradient(closest-side, #000 18%, transparent 74%);
  animation: rdRays 7s linear infinite;
}
.reel-burst.fade { opacity: .35; }
@keyframes rdBurst { from { transform: scale(.15); opacity: 0; } 60% { opacity: 1; } to { transform: scale(1); opacity: 1; } }
@keyframes rdRays { to { transform: rotate(360deg); } }
.reel-flash {
  position: absolute; inset: 0; z-index: 4; pointer-events: none;
  background: radial-gradient(circle at 50% 50%, rgba(255, 255, 255, .95), rgba(255, 214, 107, .6) 28%, transparent 70%);
  animation: rdFlash .5s ease-out forwards;
}
@keyframes rdFlash { from { opacity: 1; } to { opacity: 0; } }

/* ------------------------------------------------------------------ case page */
.opener-note { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin-top: 10px; font-size: 12.5px; color: var(--dim); }
.opener-note a { color: var(--muted); }
.opener-note a:hover { color: var(--text); }
.demo-btn { border-style: dashed; }
/* the sticky header must not cover reels / results scrolled into view */
.opener .reels, .opener .results { scroll-margin-top: 84px; scroll-margin-bottom: 16px; }

/* Demo spins: every reel is labelled, results can't be sold */
.reels.demo .reel::after {
  content: 'DEMO'; position: absolute; top: 8px; left: 10px; z-index: 5; pointer-events: none;
  padding: 2px 8px; border-radius: 6px; background: rgba(0, 0, 0, .6); border: 1px solid rgba(228, 174, 57, .5);
  font: 11px/1.4 var(--display); letter-spacing: .2em; color: var(--gold);
}
.demo-banner {
  display: flex; gap: 10px; align-items: center; justify-content: center; flex-wrap: wrap; text-align: center;
  max-width: 760px; margin: 0 auto 14px; padding: 8px 14px; border-radius: 10px;
  background: rgba(228, 174, 57, .07); border: 1px dashed rgba(228, 174, 57, .5); font-size: 13.5px; color: var(--muted);
}
.demo-banner b { font-family: var(--display); font-weight: 400; color: var(--gold); letter-spacing: .15em; }
.item.demo-item { border-style: dashed; }
.demo-tag {
  position: absolute; top: 7px; right: 8px; z-index: 3; padding: 1px 7px; border-radius: 6px;
  background: rgba(228, 174, 57, .16); color: var(--gold); font: 10.5px/1.5 var(--display); letter-spacing: .15em;
}

.results .item.rare-result { border-color: #ffd66b; box-shadow: 0 0 34px -4px rgba(255, 214, 107, .75), inset 0 0 0 1px rgba(255, 214, 107, .5); }
.results .item.big-result { border-color: color-mix(in srgb, var(--c) 70%, var(--line)); box-shadow: 0 0 28px -6px var(--c); }
.results .item.sold { opacity: .35; }
.results .sold-tag { margin-left: auto; }
.results .item:nth-child(2) { animation-delay: .06s; }
.results .item:nth-child(3) { animation-delay: .12s; }
.results .item:nth-child(4) { animation-delay: .18s; }
.results .item:nth-child(5) { animation-delay: .24s; }
.results .item { animation-fill-mode: backwards; }

.rare-head h2 { display: inline-flex; align-items: center; gap: 8px; color: var(--gold); }

/* ------------------------------------------------------------------ home: games row */
.home-block { margin-bottom: 26px; }
.home-block .section-head h2 { display: inline-flex; align-items: center; gap: 9px; }
.home-block .section-head .live-dot { margin: 0; }
.games-row { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px; }
.game-card {
  --g1: #ef3b3b; --g2: #4a0d12;
  position: relative; overflow: hidden; isolation: isolate; display: flex; flex-direction: column; gap: 2px;
  min-height: 136px; padding: 14px 14px 12px; border-radius: 14px; color: #fff;
  /* plain fallbacks first: browsers without color-mix() drop the whole declaration that uses it */
  background: linear-gradient(150deg, var(--g2), #120c0e 78%);
  background:
    radial-gradient(120% 90% at 100% 0%, color-mix(in srgb, var(--g1) 50%, transparent), transparent 62%),
    linear-gradient(150deg, var(--g2), #120c0e 78%);
  border: 1px solid var(--line);
  border: 1px solid color-mix(in srgb, var(--g1) 32%, var(--line));
  transition: transform .18s, box-shadow .18s, border-color .18s;
}
.game-card::after {
  content: ''; position: absolute; inset: 0; z-index: -1;
  background: linear-gradient(115deg, transparent 35%, rgba(255, 255, 255, .1) 50%, transparent 65%);
  transform: translateX(-100%); transition: transform .6s;
}
.game-card:hover, .game-card:focus-visible {
  color: #fff; transform: translateY(-3px); border-color: color-mix(in srgb, var(--g1) 70%, transparent);
  box-shadow: 0 14px 30px -14px color-mix(in srgb, var(--g1) 85%, transparent);
}
.game-card:hover::after, .game-card:focus-visible::after { transform: translateX(100%); }
.gc-icon {
  width: 44px; height: 44px; display: grid; place-items: center; border-radius: 12px; margin-bottom: auto;
  background: rgba(0, 0, 0, .35); color: #fff;
  background: color-mix(in srgb, var(--g1) 28%, rgba(0, 0, 0, .35)); color: color-mix(in srgb, var(--g1) 35%, #fff);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .08), 0 6px 18px -8px var(--g1);
  transition: transform .25s;
}
.gc-icon svg { width: 24px; height: 24px; }
.gc-bg { position: absolute; right: -14px; bottom: -18px; z-index: -1; width: 112px; height: 112px; color: var(--g1); opacity: .16; transform: rotate(-14deg); transition: transform .35s, opacity .35s; pointer-events: none; }
.gc-bg svg { width: 100%; height: 100%; }
.game-card:hover .gc-bg, .game-card:focus-visible .gc-bg { opacity: .26; transform: rotate(-4deg) scale(1.06); }
.game-card:hover .gc-icon { transform: rotate(-6deg) scale(1.08); }
.gc-name { font-family: var(--display); font-size: 16px; letter-spacing: .02em; margin-top: 12px; }
.gc-text { font-size: 12.5px; line-height: 1.3; color: rgba(255, 255, 255, .72); }
.gc-tag {
  position: absolute; top: 12px; right: 12px; padding: 2px 8px; border-radius: 99px;
  background: rgba(0, 0, 0, .35); border: 1px solid color-mix(in srgb, var(--g1) 60%, transparent);
  font-size: 10.5px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: color-mix(in srgb, var(--g1) 30%, #fff);
}
.gc-go { position: absolute; right: 12px; bottom: 11px; font-size: 12px; font-weight: 700; opacity: 0; transform: translateX(-4px); transition: opacity .2s, transform .2s; }
.game-card:hover .gc-go, .game-card:focus-visible .gc-go { opacity: 1; transform: none; }

/* ------------------------------------------------------------------ home: top drops today */
.top-drops {
  display: grid; grid-auto-flow: column; grid-auto-columns: minmax(150px, 1fr); gap: 10px;
  overflow-x: auto; padding-bottom: 6px; scroll-snap-type: x proximity; scrollbar-width: thin;
}
.top-drop {
  --c: #b0c3d9; position: relative; overflow: hidden; min-width: 0; padding: 10px 10px 9px; border-radius: 12px;
  border: 1px solid var(--line); scroll-snap-align: start; animation: pop .4s cubic-bezier(.2, .9, .3, 1.3) backwards;
  background: var(--panel);
  background: radial-gradient(110% 80% at 50% 100%, color-mix(in srgb, var(--c) 30%, transparent), transparent 70%), var(--panel);
}
.top-drop::after { content: ''; position: absolute; left: 0; right: 0; bottom: 0; height: 2px; background: var(--c); box-shadow: 0 0 12px var(--c); }
.top-drop.first { border-color: color-mix(in srgb, var(--c) 60%, var(--line)); box-shadow: 0 0 26px -10px var(--c); }
.td-rank { position: absolute; top: 8px; left: 10px; font: 12px var(--display); color: var(--dim); }
.top-drop.first .td-rank { color: var(--gold); }
.td-img { aspect-ratio: 4 / 3; display: grid; place-items: center; margin: 4px 0 4px; }
.td-img img { width: 100%; height: 100%; object-fit: contain; filter: drop-shadow(0 6px 10px rgba(0, 0, 0, .5)); }
.td-weapon, .td-skin { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.td-weapon { font-size: 11.5px; color: var(--muted); }
.td-skin { font-size: 13px; font-weight: 600; }
.td-price { margin-top: 4px; font-weight: 700; font-size: 14px; }
.td-user { display: flex; align-items: center; gap: 6px; margin-top: 6px; font-size: 12px; min-width: 0; }
.td-user .avatar { width: 20px; height: 20px; min-width: 20px; font-size: 10px; }
.td-user a, .td-user span:not(.avatar) { color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.td-user a:hover { color: var(--accent-hi); }
.td-user small { margin-left: auto; max-width: 48%; color: var(--dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top-empty { grid-column: 1 / -1; padding: 22px; text-align: center; color: var(--muted); border: 1px dashed var(--line2); border-radius: 12px; }

/* ------------------------------------------------------------------ home: case sections */
.case-section { content-visibility: auto; contain-intrinsic-size: auto 560px; }
.link-btn { background: none; border: 0; padding: 0; font: inherit; color: var(--accent); cursor: pointer; text-align: right; }
.link-btn:hover { color: var(--accent-hi); }
.cases-more { display: flex; justify-content: center; margin: 18px 0 6px; }
.results-count { margin: 0 0 10px; font-size: 13px; }

/* ------------------------------------------------------------------ LIVE bar: drops held back until their reel stops */
.live-item.pd-held { display: none !important; }

/* ------------------------------------------------------------------ keyboard focus + screen readers */
.rd-sr { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.toggle { position: relative; }
.toggle input { display: block; position: absolute; width: 1px; height: 1px; margin: 0; opacity: 0; pointer-events: none; }
.toggle input:focus-visible + .sw { outline: 2px solid var(--accent-hi); outline-offset: 2px; }
.game-card:focus-visible, .case-card:focus-visible, .chip:focus-visible, .qty button:focus-visible,
.link-btn:focus-visible, .td-user a:focus-visible {
  outline: 2px solid var(--accent-hi); outline-offset: 2px;
}

/* ------------------------------------------------------------------ responsive */
@media (max-width: 1100px) {
  .games-row { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
@media (max-width: 900px) {
  .games-row {
    grid-template-columns: none; grid-auto-flow: column; grid-auto-columns: 158px;
    overflow-x: auto; scroll-snap-type: x mandatory; padding-bottom: 6px; scrollbar-width: thin;
  }
  .game-card { scroll-snap-align: start; min-height: 128px; }
}
@media (max-width: 640px) {
  /* 2-5 reels on a phone: compact rows that fit on one screen (2 = 1 row, 3 = 1 row, 4 = 2x2, 5 = 3 + 2 centred) */
  .reels.multi { gap: 6px; }
  .reels.multi[data-count="2"], .reels.multi[data-count="4"] { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; }
  .reels.multi[data-count="3"] { grid-template-columns: repeat(3, minmax(0, 1fr)) !important; }
  .reels.multi[data-count="5"] { grid-template-columns: repeat(6, minmax(0, 1fr)) !important; }
  .reels.multi[data-count="5"] > .reel { grid-column: span 2; }
  .reels.multi[data-count="5"] > .reel:nth-child(4) { grid-column: 2 / span 2; }
  .reels.multi .reel.vertical { height: 250px; }
  .reels.multi .reel.vertical .reel-tile { flex-basis: 100px; }
  .reels.multi .reel.vertical .item { height: 100px; padding: 13px 4px 6px; }
  .reels.multi .reel.vertical .item-img, .reels.multi .reel.vertical .item-img img { height: 48px; }
  .reels.multi .reel.vertical .item-weapon { font-size: 10px; }
  .reels.multi .reel.vertical .item-skin { font-size: 11px; }
  .reels.multi .reel-tag { font-size: 9px; top: 3px; left: 5px; }
  .reels.multi .rare-tile .item-weapon { display: none; }
  .reels.demo .reel::after { top: 4px; left: 4px; padding: 1px 5px; font-size: 9px; letter-spacing: .12em; }
  .top-drops { grid-auto-columns: 138px; }
  .opener-note span[aria-hidden] { display: none; }
  .opener-note { flex-direction: column; align-items: center; gap: 2px; }
  .opener-controls .btn-lg { flex: 1 1 auto; }
  .reel-burst { width: 300px; height: 300px; margin: -150px 0 0 -150px; }
  .gc-go { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .reel.tension .reel-marker, .reel-burst::before, .reel-sweep, .top-drop { animation: none !important; }
  .reel.landed .reel-tile.win .item, .reel.landed .reel-tile.win.rare-charge .item { animation-duration: .01s !important; }
  .game-card, .game-card::after, .gc-icon { transition: none !important; }
}
