/* Capsule machine: layout, components and motion. Tokens live in theme.css. */

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

/* The explicit Animations control switches every animation and transition off. */
.motion-off *, .motion-off *::before, .motion-off *::after { animation: none !important; transition: none !important; }

html { background: var(--sky); }
body {
  position: relative;
  margin: 0;
  min-height: 100svh;
  color: var(--ink);
  background: var(--sky);
  font: 500 var(--text-md)/1.4 var(--font-ui);
  -webkit-font-smoothing: antialiased;
}
/* Pixel dither: an ordered checker that thins out in steps toward the floor. */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background: conic-gradient(var(--sky-pixel) 25%, transparent 0 50%, var(--sky-pixel) 0 75%, transparent 0) 0 0 / 6px 6px;
  -webkit-mask-image: linear-gradient(#000 0 14%, rgb(0 0 0 / .55) 14% 28%, rgb(0 0 0 / .25) 28% 42%, transparent 42%);
  mask-image: linear-gradient(#000 0 14%, rgb(0 0 0 / .55) 14% 28%, rgb(0 0 0 / .25) 28% 42%, transparent 42%);
}

button { font: inherit; color: inherit; }
button, a { -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
:focus-visible { outline: 3px solid var(--ink); outline-offset: 4px; }
svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.icon-library { position: absolute; width: 0; height: 0; overflow: hidden; }
h1, h2, p { margin: 0; }

.app { display: flex; flex-direction: column; min-height: 100svh; }

/* ---------- Top bar ---------- */
.topbar {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 16px;
  width: min(100%, var(--page-max));
  margin-inline: auto;
  padding: 16px 24px 6px;
}
.variants-link {
  justify-self: start;
  padding: 4px 2px;
  color: var(--ink);
  font-size: var(--text-sm);
  font-weight: 700;
  text-underline-offset: 3px;
}

.marquee {
  --bulb-on: var(--cream);
  --bulb-off: var(--tomato-dark);
  position: relative;
  z-index: 70; /* stays lit above the prize overlay */
  justify-self: center;
  padding: 17px 30px;
  background: var(--tomato);
  border: var(--outline);
  border-radius: 16px;
  box-shadow: var(--shadow-md);
}
.marquee-word {
  position: relative;
  color: var(--cream);
  font: var(--weight-led) 30px/1 var(--font-led);
  letter-spacing: .02em;
  text-shadow: var(--pixel-shadow);
}
.marquee-bulbs,
.marquee-bulbs::before,
.marquee-bulbs::after {
  position: absolute;
  inset: 3px 9px;
  pointer-events: none;
  background:
    radial-gradient(circle at 7px 50%, var(--bulb) 0 3px, var(--ink) 3px 4.4px, transparent 4.8px) var(--offset, 0) 0 / var(--gap) 10px repeat-x,
    radial-gradient(circle at 7px 50%, var(--bulb) 0 3px, var(--ink) 3px 4.4px, transparent 4.8px) var(--offset, 0) 100% / var(--gap) 10px repeat-x;
}
.marquee-bulbs { --bulb: var(--bulb-off); --gap: 14px; left: 50%; right: auto; width: calc(var(--bulbs, 6) * 28px); transform: translateX(-50%); }
.marquee-bulbs::before, .marquee-bulbs::after { content: ''; inset: 0; --bulb: var(--bulb-on); --gap: 28px; }
.marquee-bulbs::after { --offset: 14px; }
.marquee-bulbs::before { animation: chase 1.1s steps(1) infinite; }
.marquee-bulbs::after { opacity: 0; animation: chase 1.1s steps(1) infinite reverse; }
@keyframes chase { 0% { opacity: 1; } 50% { opacity: 0; } }

.marquee.is-wild { --bulb-on: var(--sunflower); animation: marquee-bump .32s steps(2) 7; }
.marquee.is-wild .marquee-bulbs::before,
.marquee.is-wild .marquee-bulbs::after { animation-duration: .16s; }
.marquee.is-wild .marquee-word { animation: word-flash .16s steps(1) infinite; }
@keyframes marquee-bump { 50% { transform: translateY(-3px) rotate(-1.5deg); } }
@keyframes word-flash { 50% { color: var(--sunflower); } }

.cabinet { position: relative; justify-self: end; display: flex; align-items: flex-start; gap: 14px; }
.arcade-button {
  display: grid;
  justify-items: center;
  gap: 5px;
  padding: 2px;
  border: 0;
  border-radius: var(--radius-sm);
  background: none;
  color: var(--ink);
  font-size: var(--text-xs);
  font-weight: 800;
  line-height: 1.1;
  cursor: pointer;
}
.arcade-cap {
  display: grid;
  place-items: center;
  width: var(--arcade-button);
  height: var(--arcade-button);
  border: var(--outline);
  border-radius: 50%;
  background: var(--silver);
  box-shadow: inset 0 -4px 0 rgb(29 29 53 / .18), 0 4px 0 var(--ink);
  transition: transform .08s, box-shadow .08s, background-color .12s;
}
.arcade-button[aria-pressed='true'] .arcade-cap { background: var(--sunflower); box-shadow: inset 0 -4px 0 var(--sunflower-dark), inset 0 0 0 4px rgb(255 255 255 / .35), 0 4px 0 var(--ink); }
.arcade-button-menu .arcade-cap { background: var(--white); }
.arcade-button:active .arcade-cap,
.arcade-button[aria-expanded='true'] .arcade-cap { transform: translateY(3px); box-shadow: inset 0 -2px 0 rgb(29 29 53 / .18), 0 1px 0 var(--ink); }
.arcade-label { white-space: nowrap; }

.menu-panel {
  position: absolute;
  z-index: 40;
  top: calc(100% + 10px);
  right: 0;
  display: grid;
  width: 210px;
  padding: 8px;
  background: var(--white);
  border: var(--outline);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
}
.menu-panel nav { display: grid; }
.menu-panel button,
.menu-variants {
  display: flex;
  align-items: center;
  min-height: 42px;
  padding: 8px 12px;
  border: 0;
  border-radius: var(--radius-sm);
  background: none;
  color: var(--ink);
  font-size: var(--text-md);
  font-weight: 700;
  text-align: left;
  cursor: pointer;
}
.menu-panel button:hover, .menu-variants:hover { background: #e8f5ff; }
.menu-panel :focus-visible { outline-offset: -3px; }
.menu-variants { margin-top: 6px; padding-top: 12px; border-top: var(--outline-thin); border-radius: 0 0 var(--radius-sm) var(--radius-sm); text-underline-offset: 3px; }

/* ---------- Arcade floor: tokens | machine | shelf ---------- */
.arcade {
  --u: min(4.6px, calc((100vw - 2 * var(--gutter)) / 100), calc((100svh - 190px) / 152));
  flex: 1;
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto minmax(260px, 1fr);
  align-items: center;
  gap: 40px;
  width: min(100%, var(--page-max));
  margin-inline: auto;
  padding: 10px 24px 24px;
}
.tokens h2, .shelf h2 { font-size: var(--text-lg); font-weight: 800; line-height: 1.2; }

/* Tokens */
.tokens { align-self: center; justify-self: end; width: min(100%, 280px); }
.token-list { display: grid; gap: 14px; margin: 14px 0 0; padding: 0; list-style: none; }
.token {
  display: grid;
  grid-template-columns: var(--coin) 1fr;
  align-items: center;
  gap: 14px;
  width: 100%;
  padding: 8px 10px 8px 8px;
  border: 0;
  border-radius: var(--radius-lg);
  background: none;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
}
.token:hover { background: rgb(255 255 255 / .22); }
.coin {
  position: relative;
  display: grid;
  place-items: center;
  width: var(--coin);
  height: var(--coin);
  border: var(--outline);
  border-radius: 50%;
  background: var(--c);
  box-shadow: inset 0 -5px 0 rgb(29 29 53 / .2), 0 4px 0 var(--ink);
  transition: transform .15s cubic-bezier(.3, 1.6, .5, 1);
}
.coin::before { content: ''; position: absolute; inset: 6px; border: 2px dashed rgb(29 29 53 / .5); border-radius: 50%; }
.coin-mark { position: relative; color: var(--white); font: var(--weight-led) calc(var(--coin) * .42)/1 var(--font-led); text-shadow: 2px 2px 0 var(--ink); }
.token:hover .coin { transform: translateY(-3px) rotate(-10deg); }
.token-text { min-width: 0; }
.token-name { display: block; font-size: 17px; font-weight: 800; line-height: 1.2; }
.token-state { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; margin-top: 3px; font-size: var(--text-sm); font-weight: 600; }
.tag { padding: 1px 9px 2px; border: var(--outline-thin); border-radius: var(--radius-pill); background: var(--sunflower); font-size: var(--text-xs); font-weight: 800; line-height: 1.3; }
.tag-replay { background: var(--white); }

.token.is-loaded .coin { background: rgb(255 255 255 / .25); border-style: dashed; box-shadow: none; }
.token.is-loaded .coin::before, .token.is-loaded .coin-mark { visibility: hidden; }
.token.is-empty .coin { filter: saturate(.2) brightness(1.08); }
.token.is-next .coin { box-shadow: inset 0 -5px 0 rgb(29 29 53 / .2), 0 4px 0 var(--ink), 0 0 0 5px var(--sunflower), 0 0 0 8px var(--ink); animation: coin-bob 1.6s ease-in-out infinite; }
@keyframes coin-bob { 50% { transform: translateY(-5px); } }
.token.is-refused .coin { animation: refuse .3s linear; }

/* ---------- Machine ---------- */
.machine-zone { display: grid; justify-items: center; gap: 14px; }
.machine { position: relative; display: flex; flex-direction: column; align-items: center; width: calc(100 * var(--u)); }

.dome { position: relative; width: calc(80 * var(--u)); height: calc(58 * var(--u)); overflow: hidden; }
.dome-glass {
  position: absolute;
  top: calc(4 * var(--u));
  left: 0;
  width: calc(80 * var(--u));
  height: calc(80 * var(--u));
  overflow: hidden;
  border: var(--outline);
  border-radius: 50%;
  background: var(--glass);
}
.dome-shine {
  position: absolute;
  z-index: 1;
  top: calc(12 * var(--u));
  left: calc(11 * var(--u));
  width: calc(22 * var(--u));
  height: calc(34 * var(--u));
  border-left: calc(2.4 * var(--u)) solid var(--glass-shine);
  border-radius: 50%;
  transform: rotate(18deg);
}
.dome-cap {
  position: absolute;
  top: 0;
  left: 50%;
  width: calc(14 * var(--u));
  height: calc(7 * var(--u));
  margin-left: calc(-7 * var(--u));
  border: var(--outline);
  border-radius: calc(7 * var(--u)) calc(7 * var(--u)) calc(1 * var(--u)) calc(1 * var(--u));
  background: var(--tomato);
}
.ball {
  --size: calc(15 * var(--u));
  position: absolute;
  left: calc(var(--x) * var(--u));
  top: calc(var(--y) * var(--u));
  width: var(--size);
  height: var(--size);
  border: var(--outline-thin);
  border-radius: 50%;
  background: linear-gradient(var(--c) 0 50%, rgb(255 255 255 / .82) 50%);
  box-shadow: inset calc(-1 * var(--u)) calc(-1 * var(--u)) 0 rgb(29 29 53 / .12);
  transform: rotate(var(--r, 0deg));
}
.ball::after { content: ''; position: absolute; top: 16%; left: 22%; width: 22%; height: 16%; border-radius: 50%; background: rgb(255 255 255 / .75); }
.ball:nth-child(1)  { --x: 5;  --y: 43; --c: #eb51d5; --r: 20deg; }
.ball:nth-child(2)  { --x: 18; --y: 46; --c: var(--sunflower); --r: -30deg; }
.ball:nth-child(3)  { --x: 32; --y: 45; --c: #57c6b4; --r: 160deg; }
.ball:nth-child(4)  { --x: 46; --y: 46; --c: #9c7de8; --r: 40deg; }
.ball:nth-child(5)  { --x: 59; --y: 43; --c: var(--tomato); --r: -70deg; }
.ball:nth-child(6)  { --x: 10; --y: 31; --c: var(--sky); --r: 110deg; }
.ball:nth-child(7)  { --x: 24; --y: 33; --c: #eb51d5; --r: -140deg; }
.ball:nth-child(8)  { --x: 38; --y: 32; --c: var(--sunflower); --r: 60deg; }
.ball:nth-child(9)  { --x: 52; --y: 33; --c: #57c6b4; --r: -20deg; }
.ball:nth-child(10) { --x: 64; --y: 30; --c: #9c7de8; --r: 190deg; }
.ball:nth-child(11) { --x: 17; --y: 20; --c: var(--tomato); --r: 30deg; }
.ball:nth-child(12) { --x: 31; --y: 19; --c: #9c7de8; --r: -60deg; }
.ball:nth-child(13) { --x: 45; --y: 20; --c: #eb51d5; --r: 130deg; }
.ball:nth-child(14) { --x: 57; --y: 18; --c: var(--sky); --r: -110deg; }
.ball:nth-child(15) { --x: 26; --y: 7;  --c: #57c6b4; --r: 80deg; }
.ball:nth-child(16) { --x: 42; --y: 6;  --c: var(--sunflower); --r: -10deg; }
.dome.is-churning .ball { animation: churn .34s ease-in-out 2 alternate; }
.dome.is-churning .ball:nth-child(odd) { animation-delay: .06s; }
.dome.is-churning .ball:nth-child(3n) { animation-name: churn-alt; }
@keyframes churn { to { transform: translate(calc(1.5 * var(--u)), calc(-3 * var(--u))) rotate(calc(var(--r, 0deg) + 50deg)); } }
@keyframes churn-alt { to { transform: translate(calc(-2 * var(--u)), calc(-2 * var(--u))) rotate(calc(var(--r, 0deg) - 60deg)); } }

.collar {
  position: relative;
  z-index: 1;
  width: calc(90 * var(--u));
  height: calc(8 * var(--u));
  margin-top: calc(-3 * var(--u));
  border: var(--outline);
  border-radius: calc(3 * var(--u));
  background: var(--silver);
  box-shadow: inset 0 calc(1.6 * var(--u)) 0 var(--silver-light), inset 0 calc(-1.6 * var(--u)) 0 var(--silver-dark);
}

.body {
  --booster: var(--silver-dark);
  width: 100%;
  height: calc(80 * var(--u));
  margin-top: calc(-1 * var(--u));
  padding: calc(4 * var(--u));
  border: var(--outline);
  border-radius: calc(6 * var(--u)) calc(6 * var(--u)) calc(3 * var(--u)) calc(3 * var(--u));
  background: var(--tomato);
  box-shadow: inset calc(1.4 * var(--u)) calc(1.4 * var(--u)) 0 var(--tomato-light), inset calc(-1.4 * var(--u)) 0 0 var(--tomato-dark), var(--shadow-lg);
}
.panel {
  display: grid;
  grid-template-columns: 1fr calc(34 * var(--u));
  grid-template-rows: calc(15 * var(--u)) auto 1fr;
  gap: calc(2.4 * var(--u)) calc(3 * var(--u));
  height: 100%;
  padding: calc(3 * var(--u));
  border: var(--outline);
  border-radius: calc(3.5 * var(--u));
  background: var(--cream);
  box-shadow: inset 0 calc(-1.4 * var(--u)) 0 var(--cream-shade);
}

.led {
  position: relative;
  display: flex;
  align-items: center;
  gap: calc(1.8 * var(--u));
  min-width: 0;
  padding: 0 calc(3 * var(--u));
  overflow: hidden;
  border: var(--outline);
  border-radius: calc(2 * var(--u));
  background: var(--led-bg);
  color: var(--led-on);
  font-family: var(--font-led);
  font-weight: var(--weight-led);
  white-space: nowrap;
}
.led::after {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(90deg, rgb(29 29 53 / .55) 1px, transparent 1px) 0 0 / 3px 3px,
    linear-gradient(rgb(29 29 53 / .55) 1px, transparent 1px) 0 0 / 3px 3px;
}
.led-count { font-size: calc(10 * var(--u)); line-height: 1; text-shadow: 0 0 10px rgb(255 204 41 / .55); }
.led-unit { font-size: max(12px, calc(4.4 * var(--u))); line-height: 1.1; text-shadow: 0 0 8px rgb(255 204 41 / .45); }
.led.is-idle .led-unit { animation: blink 1.2s steps(1) infinite; }
.led.is-bump .led-count { animation: led-bump .4s steps(3); }
@keyframes blink { 50% { opacity: .35; } }
@keyframes led-bump { 0% { transform: translateY(-30%); opacity: .3; } }

.slot {
  display: grid;
  place-items: center;
  justify-self: center;
  width: calc(15 * var(--u));
  height: 100%;
  border: var(--outline);
  border-radius: calc(2 * var(--u));
  background: var(--silver);
  box-shadow: inset calc(-.8 * var(--u)) calc(-1.2 * var(--u)) 0 var(--silver-dark), inset calc(.8 * var(--u)) calc(.8 * var(--u)) 0 var(--silver-light);
}
.slot-mouth { width: calc(2.6 * var(--u)); height: calc(9 * var(--u)); border-radius: 3px; background: var(--ink); }
.slot.is-loaded .slot-mouth { background: linear-gradient(var(--ink) 0 18%, var(--booster) 18% 82%, var(--ink) 82%); box-shadow: 0 0 0 2px var(--ink); }
.slot.is-flash { animation: slot-flash .35s steps(2) 2; }
@keyframes slot-flash { 50% { background: var(--sunflower); } }

.series {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: calc(1.8 * var(--u));
  min-width: 0;
  font-size: max(13px, calc(3.8 * var(--u)));
  font-weight: 800;
  line-height: 1.2;
}
.series-chip { flex: none; width: calc(4.4 * var(--u)); height: calc(4.4 * var(--u)); border: var(--outline-thin); border-radius: 50%; background: var(--booster); }
.series > span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.plate-label {
  padding: 1px calc(1.8 * var(--u)) 2px;
  border: var(--outline-thin);
  border-radius: calc(1.2 * var(--u));
  background: var(--silver);
  font-size: max(11px, calc(3 * var(--u)));
  font-weight: 800;
  line-height: 1.2;
}

/* Tray */
.tray { display: grid; justify-items: center; align-content: end; gap: calc(3.2 * var(--u)); min-width: 0; }
.tray-window {
  position: relative;
  display: grid;
  place-items: end center;
  width: calc(34 * var(--u));
  height: calc(24 * var(--u));
  margin-top: calc(2 * var(--u));
  padding-bottom: calc(1.4 * var(--u));
  overflow: hidden;
  border: var(--outline);
  border-radius: calc(7 * var(--u)) calc(7 * var(--u)) calc(3 * var(--u)) calc(3 * var(--u));
  background: #2b2b4b;
  box-shadow: inset 0 calc(2.4 * var(--u)) 0 rgb(0 0 0 / .3), 0 0 0 calc(1.6 * var(--u)) var(--silver), 0 0 0 calc(1.6 * var(--u) + 3px) var(--ink);
}
.tray-flap {
  position: absolute;
  z-index: 2;
  top: 0;
  left: 0;
  right: 0;
  height: 42%;
  border-bottom: var(--outline-thin);
  background: rgb(255 255 255 / .2);
  box-shadow: inset 0 -3px 0 rgb(255 255 255 / .25);
  transform-origin: top;
}
.tray.is-dropping .tray-flap { animation: flap .5s ease-out; }
@keyframes flap { 18% { transform: perspective(120px) rotateX(-75deg); } 60% { transform: perspective(120px) rotateX(12deg); } }
.tray-window::after {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0;
  background: radial-gradient(circle at 50% 70%, var(--white) 0 20%, transparent 55%);
}
.tray.is-open .tray-window::after { animation: flash .45s ease-out; }
/* Suspense scales with rarity: the tray glows while a capsule cracks. */
.tray[data-charge='1'] .tray-window { animation: glow-soft .45s ease-in-out infinite alternate; }
.tray[data-charge='2'] .tray-window { animation: glow-hard .2s steps(2) infinite; }
@keyframes glow-soft { to { background: #3c4d7e; box-shadow: inset 0 calc(2.4 * var(--u)) 0 rgb(0 0 0 / .3), 0 0 0 calc(1.6 * var(--u)) var(--silver), 0 0 0 calc(1.6 * var(--u) + 3px) var(--ink), 0 0 20px 8px rgb(154 207 240 / .9); } }
@keyframes glow-hard { 50% { background: #7a5c10; box-shadow: inset 0 calc(2.4 * var(--u)) 0 rgb(0 0 0 / .3), 0 0 0 calc(1.6 * var(--u)) var(--sunflower), 0 0 0 calc(1.6 * var(--u) + 3px) var(--ink), 0 0 30px 14px rgb(255 204 41 / .9); } }
@keyframes flash { 15% { opacity: 1; } }

.capsule {
  position: relative;
  z-index: 1;
  width: calc(17 * var(--u));
  height: calc(17 * var(--u));
  min-width: 44px;
  min-height: 44px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: none;
  cursor: pointer;
}
.capsule-top, .capsule-bottom {
  position: absolute;
  left: 0;
  right: 0;
  height: 52%;
  border: var(--outline);
  transition: transform .34s cubic-bezier(.2, .8, .3, 1), opacity .34s;
}
.capsule-top { top: 0; border-radius: 999px 999px 0 0; background: var(--booster); }
.capsule-top::after { content: ''; position: absolute; top: 18%; left: 20%; width: 24%; height: 26%; border-radius: 50%; background: rgb(255 255 255 / .7); }
.capsule-bottom { bottom: 0; border-radius: 0 0 999px 999px; background: var(--cream); }
.capsule:focus-visible { outline-color: var(--sunflower); outline-offset: 3px; }
.capsule.is-dropping { animation: capsule-drop .78s cubic-bezier(.35, .05, .45, 1) both; }
@keyframes capsule-drop {
  0% { transform: translateY(calc(-26 * var(--u))) rotate(-220deg); }
  46% { transform: translateY(0) rotate(-20deg); }
  62% { transform: translateY(calc(-6 * var(--u))) rotate(12deg); }
  78% { transform: translateY(0) rotate(0); }
  89% { transform: translateY(calc(-1.8 * var(--u))); }
  100% { transform: translateY(0); }
}
/* Rarity is felt before it is seen: rarer capsules rattle in the tray. */
.capsule.is-waiting[data-rank='1'] { animation: rattle-soft 2.4s ease-in-out .4s infinite; }
.capsule.is-waiting[data-rank='2'] { animation: rattle-hard 1.3s linear .2s infinite; }
.capsule.is-cracking { animation: rattle-crack .12s linear infinite; }
.capsule.is-cracking[data-rank='0'] { animation-duration: .2s; }
.capsule.is-open { animation: none; }
.capsule.is-open .capsule-top { transform: translate(calc(-7 * var(--u)), calc(-16 * var(--u))) rotate(-55deg); opacity: 0; }
.capsule.is-open .capsule-bottom { transform: translate(calc(6 * var(--u)), calc(6 * var(--u))) rotate(30deg); opacity: 0; }
@keyframes rattle-soft { 0%, 80%, 100% { transform: rotate(0); } 85% { transform: rotate(-9deg); } 90% { transform: rotate(8deg); } 95% { transform: rotate(-4deg); } }
@keyframes rattle-hard { 0%, 55%, 100% { transform: translate(0) rotate(0); } 60% { transform: translate(-2px, -3px) rotate(-12deg); } 67% { transform: translate(2px, 0) rotate(11deg); } 74% { transform: translate(-2px, -2px) rotate(-8deg); } 81% { transform: translate(1px, 0) rotate(6deg); } 88% { transform: rotate(-3deg); } }
@keyframes rattle-crack { 25% { transform: translate(-2px, -1px) rotate(-6deg); } 75% { transform: translate(2px, 0) rotate(6deg); } }
.capsule.is-refused { animation: refuse .3s linear; }

/* Crank */
.crank-housing { position: relative; display: grid; justify-items: center; align-content: end; gap: calc(1.6 * var(--u)); }
.crank-ring {
  position: absolute;
  top: calc(-1 * var(--u));
  left: 50%;
  width: calc(33 * var(--u));
  height: calc(33 * var(--u));
  margin-left: calc(-16.5 * var(--u));
  border: var(--outline);
  border-radius: 50%;
  background: repeating-conic-gradient(var(--silver) 0 11deg, var(--silver-dark) 11deg 15deg);
}
.crank-ring::after { content: ''; position: absolute; inset: calc(2.4 * var(--u)); border: var(--outline-thin); border-radius: 50%; background: var(--silver); }
.crank {
  position: relative;
  width: calc(27 * var(--u));
  height: calc(27 * var(--u));
  min-width: 48px;
  min-height: 48px;
  padding: 0;
  border: var(--outline);
  border-radius: 50%;
  background: var(--sunflower);
  box-shadow: inset calc(-1.2 * var(--u)) calc(-1.6 * var(--u)) 0 var(--sunflower-dark), inset calc(1.2 * var(--u)) calc(1.2 * var(--u)) 0 rgb(255 255 255 / .45);
  cursor: grab;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  transform: rotate(var(--turn, 0deg));
  transition: transform .16s cubic-bezier(.3, 1.5, .55, 1);
}
.crank.is-dragging { cursor: grabbing; transition: none; }
.crank.is-snap { transition: none; }
.crank.is-spring { transition: transform .45s cubic-bezier(.3, 1.6, .5, 1); }
.crank-grip {
  position: absolute;
  top: calc(1.8 * var(--u));
  bottom: calc(1.8 * var(--u));
  left: 50%;
  width: calc(7.4 * var(--u));
  margin-left: calc(-3.7 * var(--u));
  border: var(--outline);
  border-radius: calc(3.7 * var(--u));
  background: var(--sunflower);
  box-shadow: inset calc(1 * var(--u)) 0 0 rgb(255 255 255 / .55), calc(1 * var(--u)) calc(1 * var(--u)) 0 var(--sunflower-dark);
}
.crank-hub { position: absolute; top: 50%; left: 50%; width: calc(6 * var(--u)); height: calc(6 * var(--u)); margin: calc(-3 * var(--u)) 0 0 calc(-3 * var(--u)); border: var(--outline-thin); border-radius: 50%; background: var(--silver); }
.crank-housing.is-ready .crank:not(.is-dragging) { animation: nudge 2.6s ease-in-out 1s infinite; }
@keyframes nudge { 0%, 70%, 100% { transform: rotate(0); } 78% { transform: rotate(24deg); } 86% { transform: rotate(-4deg); } 92% { transform: rotate(6deg); } }
.crank.is-refused { animation: refuse .3s linear; }
@keyframes refuse { 25% { translate: -4px 0; } 50% { translate: 4px 0; } 75% { translate: -2px 0; } }

.base {
  width: calc(94 * var(--u));
  height: calc(6 * var(--u));
  margin-top: -3px;
  border: var(--outline);
  border-radius: 0 0 calc(3 * var(--u)) calc(3 * var(--u));
  background: var(--tomato-dark);
  box-shadow: var(--shadow-md);
}

.hint { max-width: calc(100 * var(--u)); min-height: 2.8em; font-size: var(--text-md); font-weight: 700; line-height: 1.4; text-align: center; text-wrap: balance; }

/* ---------- Prize shelf ---------- */
.shelf {
  display: grid;
  grid-template-areas: 'head' 'slots' 'actions';
  gap: 14px;
  align-self: center;
  justify-self: start;
  width: min(100%, 300px);
}
.shelf-head { grid-area: head; display: grid; gap: 2px; }
.shelf-note { font-size: var(--text-sm); font-weight: 600; }
.shelf-slots { grid-area: slots; display: grid; gap: 14px; margin: 0; padding: 0; list-style: none; }
.shelf-actions { grid-area: actions; display: flex; flex-wrap: wrap; gap: 10px; }
.prize-slot {
  position: relative;
  display: grid;
  grid-template-columns: 70px 1fr;
  align-items: end;
  gap: 14px;
  padding: 0 4px 12px;
}
.prize-slot::after {
  content: '';
  position: absolute;
  left: -4px;
  right: -4px;
  bottom: 0;
  height: 12px;
  border: var(--outline);
  border-radius: 4px;
  background: var(--silver);
  box-shadow: inset 0 3px 0 var(--silver-light), 0 4px 0 var(--ink);
}
.mini {
  display: block;
  aspect-ratio: 5 / 7;
  margin-bottom: -1px;
  padding: 4px;
  border: var(--outline);
  border-radius: 8px;
  background: var(--rc, var(--white));
}
.mini-art { display: block; width: 100%; height: 100%; overflow: hidden; border: var(--outline-thin); border-radius: 4px; background: var(--white); }
.mini-art img { display: block; width: 100%; height: 100%; object-fit: contain; }
.mini-art[data-art='king'] img { object-fit: cover; object-position: 50% 10%; }
.mini-art[data-art='chill-guy'] { background: #888e72; }
.mini-art[data-art='chill-guy'] img { object-fit: cover; }
.slot-text { min-width: 0; padding-bottom: 6px; }
.slot-text strong { display: block; font-size: var(--text-md); font-weight: 800; line-height: 1.2; }
.slot-text span { display: block; font-size: var(--text-sm); font-weight: 600; }
.prize-slot.is-empty .mini { display: grid; place-items: center; background: rgb(255 255 255 / .2); border-style: dashed; }
.prize-slot.is-empty .mini::before { content: '?'; color: rgb(29 29 53 / .55); font: var(--weight-led) 24px/1 var(--font-led); }
.prize-slot.is-empty .slot-text { color: rgb(29 29 53 / .75); }
.prize-slot.is-blank .slot-text { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.prize-slot.is-new .mini { animation: land .45s cubic-bezier(.3, 1.6, .5, 1); }
.prize-slot.is-new:nth-child(2) .mini { animation-delay: .12s; }
.prize-slot.is-new:nth-child(3) .mini { animation-delay: .24s; }
@keyframes land { 0% { transform: translateY(-40%) scale(.5); } }

/* ---------- Buttons ---------- */
.btn {
  min-height: var(--tap);
  padding: 10px 20px;
  border: var(--outline);
  border-radius: var(--radius-md);
  color: var(--ink);
  font: 800 var(--text-md)/1.15 var(--font-ui);
  box-shadow: 0 4px 0 var(--ink);
  cursor: pointer;
  transition: transform .08s, box-shadow .08s;
}
.btn:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--ink); }
.btn-primary { background: var(--sunflower); }
.btn-secondary { background: var(--white); }

/* ---------- Prize overlay ---------- */
.prize {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 90px 16px 24px;
  overflow: hidden auto;
  background: var(--dim);
  transition: background-color .3s;
}
.prize.is-leaving { background-color: transparent; }
.prize-stage { position: relative; display: grid; justify-items: center; gap: 18px; width: 100%; }
.prize-shout {
  color: var(--white);
  font: var(--weight-led) 34px/1 var(--font-led);
  text-align: center;
  text-shadow: var(--pixel-shadow);
  animation: shout-pop .35s cubic-bezier(.3, 1.6, .5, 1) both;
}
.prize[data-rank='1'] .prize-shout { color: #9acff0; font-size: 52px; }
.prize[data-rank='2'] .prize-shout { color: var(--sunflower); font-size: clamp(58px, 11vw, 118px); text-shadow: var(--pixel-shadow-big); animation: none; }
.prize-shout .ch { display: inline-block; animation: letter-hop .6s cubic-bezier(.3, 1.8, .5, 1) both; animation-delay: calc(var(--i) * 55ms); }
@keyframes shout-pop { 0% { transform: scale(.4); opacity: 0; } }
@keyframes letter-hop { 0% { transform: translateY(60%) scale(.3); opacity: 0; } 60% { transform: translateY(-18%) scale(1.1); opacity: 1; } }

.prize-card-wrap { position: relative; }
.prize-card {
  --rc: var(--white);
  position: relative;
  display: grid;
  gap: 10px;
  width: min(300px, 72vw);
  padding: 12px 12px 16px;
  border: var(--outline);
  border-radius: 16px;
  background: var(--rc);
  box-shadow: var(--shadow-lg);
  transform-origin: center;
}
.prize[data-rank='0'] .prize-card { animation: pop-small .38s cubic-bezier(.3, 1.6, .5, 1) both; }
.prize[data-rank='1'] .prize-card { animation: pop-mid .6s cubic-bezier(.3, 1.5, .5, 1) both; }
.prize[data-rank='2'] .prize-card { animation: pop-big 1s cubic-bezier(.25, 1.3, .45, 1) both; }
@keyframes pop-small { 0% { transform: scale(.6) translateY(30%); opacity: 0; } }
@keyframes pop-mid { 0% { transform: scale(.3) rotate(-14deg) translateY(40%); opacity: 0; } 60% { transform: scale(1.06) rotate(3deg); opacity: 1; } }
@keyframes pop-big { 0% { transform: scale(.1) translateY(60%) rotateY(720deg); opacity: 0; } 55% { transform: scale(1.14) rotateY(0); opacity: 1; } 75% { transform: scale(.97); } }
.prize-card.is-settled { animation: none !important; }
.prize-card.is-leaving { transition: transform .45s cubic-bezier(.45, 0, .6, 1), opacity .45s ease-in; transform: translate(var(--dx), var(--dy)) scale(var(--s)) rotate(8deg); opacity: .5; }
.prize.is-leaving .prize-shout, .prize.is-leaving .prize-actions, .prize.is-leaving .spark { opacity: 0; transition: opacity .2s; }

.card-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: var(--text-sm); font-weight: 800; }
.card-rarity { padding: 1px 10px 2px; border: var(--outline-thin); border-radius: var(--radius-pill); background: var(--white); }
.card-serial { font-variant-numeric: tabular-nums; }
.card-art { aspect-ratio: 4 / 3; overflow: hidden; border: var(--outline); border-radius: 10px; background: var(--white); }
.card-art img { display: block; width: 100%; height: 100%; object-fit: contain; }
.card-art[data-art='king'] img { object-fit: cover; object-position: 50% 20%; }
.card-art[data-art='chill-guy'] { background: #888e72; }
.card-name { font-size: var(--text-xl); font-weight: 800; line-height: 1.12; }
.card-desc { font-size: 15px; line-height: 1.4; }

.prize-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 12px; }
.prize-actions .btn-primary { min-width: 150px; }
.prize :focus-visible { outline-color: var(--white); }

.spark { position: absolute; display: none; width: 22px; height: 22px; background: var(--rare-spark); clip-path: polygon(50% 0, 60% 40%, 100% 50%, 60% 60%, 50% 100%, 40% 60%, 0 50%, 40% 40%); animation: twinkle 1.1s steps(3) infinite both; }
.prize[data-rank='1'] .spark, .prize[data-rank='2'] .spark { display: block; }
.prize[data-rank='2'] .spark { background: var(--sunflower); width: 28px; height: 28px; }
.spark:nth-of-type(1) { top: -6%; left: -14%; animation-delay: .1s; }
.spark:nth-of-type(2) { top: 12%; right: -16%; animation-delay: .35s; width: 16px; height: 16px; }
.spark:nth-of-type(3) { top: 46%; left: -18%; animation-delay: .6s; width: 14px; height: 14px; }
.spark:nth-of-type(4) { top: 62%; right: -14%; animation-delay: .2s; }
.spark:nth-of-type(5) { bottom: -5%; left: 8%; animation-delay: .5s; width: 16px; height: 16px; }
.spark:nth-of-type(6) { bottom: -8%; right: 12%; animation-delay: .8s; }
.spark:nth-of-type(7) { top: -9%; right: 18%; animation-delay: .7s; width: 14px; height: 14px; }
.spark:nth-of-type(8) { top: 28%; left: -8%; animation-delay: .95s; width: 12px; height: 12px; }
@keyframes twinkle { 0%, 100% { transform: scale(.3); opacity: .2; } 50% { transform: scale(1); opacity: 1; } }

.prize-rays {
  position: absolute;
  top: 50%;
  left: 50%;
  display: none;
  width: 160vmax;
  height: 160vmax;
  margin: -80vmax 0 0 -80vmax;
  pointer-events: none;
  background: repeating-conic-gradient(rgb(255 204 41 / .26) 0 9deg, transparent 9deg 18deg);
  -webkit-mask-image: radial-gradient(circle, #000 8%, transparent 42%);
  mask-image: radial-gradient(circle, #000 8%, transparent 42%);
  animation: spin 14s linear infinite;
}
.prize[data-rank='2'] .prize-rays { display: block; }
@keyframes spin { to { transform: rotate(1turn); } }

.is-shaking { animation: shake .5s linear; }
@keyframes shake {
  10% { transform: translate(-8px, 3px); } 20% { transform: translate(7px, -5px); } 30% { transform: translate(-6px, -2px); }
  40% { transform: translate(6px, 4px); } 50% { transform: translate(-4px, -3px); } 60% { transform: translate(4px, 2px); }
  70% { transform: translate(-3px, 1px); } 80% { transform: translate(2px, -1px); } 90% { transform: translate(-1px, 0); }
}

/* Pixel confetti: square DOM pixels falling in steps, removed after the jackpot. */
.confetti { position: fixed; inset: 0; z-index: 80; overflow: hidden; pointer-events: none; }
.confetti i {
  position: absolute;
  top: -24px;
  left: var(--x);
  width: var(--s);
  height: var(--s);
  background: var(--c);
  box-shadow: 2px 2px 0 var(--ink);
  animation: pixel-fall var(--d) steps(22) var(--delay) forwards;
}
@keyframes pixel-fall { to { transform: translate(var(--dx), calc(100vh + 40px)); } }

/* Coins flying between the purse and the slot */
.coin-flyer { position: fixed; z-index: 30; margin: 0; pointer-events: none; }
.coin-flyer.is-in { animation: coin-in .52s cubic-bezier(.45, 0, .6, 1) forwards; }
.coin-flyer.is-out { animation: coin-out .46s cubic-bezier(.3, 0, .5, 1) forwards; }
@keyframes coin-in {
  0% { transform: translate(0, 0) scale(1); }
  65% { transform: translate(var(--dx), calc(var(--dy) - 48px)) scale(var(--s)) rotate(240deg); }
  100% { transform: translate(var(--dx), var(--dy)) scale(var(--s)) rotate(360deg) scaleX(.12); opacity: .6; }
}
@keyframes coin-out {
  0% { transform: translate(var(--dx), var(--dy)) scale(var(--s)) scaleX(.12); }
  35% { transform: translate(var(--dx), calc(var(--dy) - 40px)) scale(var(--s)); }
  100% { transform: translate(0, 0) scale(1) rotate(-360deg); }
}

/* Toast created by the shared kit */
.toast {
  position: fixed;
  z-index: 90;
  top: 16px;
  left: 50%;
  width: max-content;
  max-width: calc(100vw - 32px);
  padding: 10px 16px;
  border: var(--outline);
  border-radius: var(--radius-md);
  background: var(--white);
  box-shadow: var(--shadow-sm);
  font-size: var(--text-sm);
  font-weight: 700;
  text-align: center;
  transform: translateX(-50%);
}

.visually-hidden { position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- Narrower screens: tokens row, machine, shelf ---------- */
@media (max-width: 999px) {
  .arcade {
    --u: min(5px, calc((100vw - 2 * var(--gutter)) / 100), calc((100svh - 440px) / 152));
    grid-template-columns: minmax(0, 1fr);
    align-content: start;
    justify-items: center;
    gap: 14px;
    padding: 8px var(--gutter) 20px;
  }
  .tokens, .shelf { justify-self: stretch; width: 100%; max-width: 620px; margin-inline: auto; }
  .token-list { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-top: 8px; }
  .shelf { grid-template-areas: 'head actions' 'slots slots'; grid-template-columns: 1fr auto; align-items: end; gap: 10px 16px; }
  .shelf-slots { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
  .prize-slot { grid-template-columns: 48px minmax(0, 1fr); gap: 10px; }
  .slot-text strong { font-size: var(--text-sm); }
  .slot-text span { font-size: var(--text-xs); }
  :root { --coin: 50px; }
  .token { gap: 10px; }
  .token-name { font-size: 15px; }
}

@media (max-width: 699px) {
  :root { --coin: 40px; --arcade-button: 40px; }
  .topbar { grid-template-columns: 1fr auto; gap: 10px; padding: 10px var(--gutter) 2px; }
  .variants-link { display: none; }
  .marquee { justify-self: start; padding: 12px 16px; border-radius: 12px; box-shadow: var(--shadow-sm); }
  .marquee-word { font-size: 21px; }
  .marquee-bulbs { --bulbs: 4; top: 2px; bottom: 2px; }
  .cabinet { gap: 8px; }
  .arcade-label,
  .tokens h2, .shelf-head, .slot-text { position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .arcade { --u: min(calc((100vw - 2 * var(--gutter)) / 100), calc((100svh - 330px) / 152)); gap: 8px; padding-top: 4px; padding-bottom: 12px; }

  /* Tokens: coin on top, name and state under it */
  .token-list { margin-top: 0; gap: 6px; }
  .token { position: relative; grid-template-columns: minmax(0, 1fr); justify-items: center; gap: 5px; padding: 4px 2px 6px; border-radius: var(--radius-md); text-align: center; }
  .token-name { font-size: 13px; line-height: 1.15; }
  .token-state { justify-content: center; margin-top: 1px; font-size: var(--text-xs); line-height: 1.2; }
  .token .tag { position: absolute; top: 30px; left: calc(50% + 8px); padding: 0 6px 1px; font-size: 11px; }
  .coin::before { inset: 4px; }
  .token.is-next .coin { box-shadow: inset 0 -4px 0 rgb(29 29 53 / .2), 0 3px 0 var(--ink), 0 0 0 4px var(--sunflower), 0 0 0 6px var(--ink); }

  .machine-zone { gap: 6px; }
  .hint { min-height: 2.8em; font-size: var(--text-sm); }

  /* Shelf: one compact row of trophies beside the action */
  .shelf { grid-template-areas: 'slots actions'; grid-template-columns: minmax(0, auto) auto; justify-content: space-between; align-items: end; gap: 12px; }
  .shelf-actions { justify-content: end; padding-bottom: 6px; }
  .shelf-actions .btn { min-height: 44px; padding: 8px 12px; font-size: var(--text-sm); border-radius: 12px; white-space: nowrap; }
  .shelf-slots { position: relative; grid-template-columns: repeat(3, minmax(0, 46px)); gap: 8px; padding: 0 6px 10px; }
  .shelf-slots::after { content: ''; position: absolute; left: 0; right: 0; bottom: 0; height: 11px; border: var(--outline); border-radius: 4px; background: var(--silver); box-shadow: inset 0 3px 0 var(--silver-light), 0 3px 0 var(--ink); }
  .prize-slot { display: block; padding: 0; }
  .prize-slot::after { display: none; }
  .mini { padding: 2px; border-radius: 6px; }
  .mini-art { border-width: 1.5px; border-radius: 3px; }
  .prize-slot.is-empty .mini::before { font-size: 17px; }

  .prize { padding: 70px 16px 20px; }
  .prize-stage { gap: 14px; }
  .prize[data-rank='1'] .prize-shout { font-size: 40px; }
  .prize-card { width: min(270px, 74vw); padding: 10px 10px 14px; gap: 8px; }
  .card-name { font-size: 22px; }
  .card-desc { font-size: var(--text-sm); }
}
