:root {
  --red: #d4231b;
  --red-hi: #ee4034;
  --red-lo: #8f130f;
  --ink: #0a0d1a;
  --deep: #0d1330;
  --amber: #ffb000;
  --amber-hot: #ff7a00;
  --cream: #fff1c9;
  --chrome-1: #f6f8fb;
  --chrome-2: #9aa4b3;
  --chrome-3: #5b6472;
  --ease: cubic-bezier(.2, .9, .2, 1);
  --display: 'Bungee', 'Arial Black', sans-serif;
  --mono: 'Chivo Mono', ui-monospace, Consolas, monospace;
  --led: 'DSEG7', 'Chivo Mono', ui-monospace, monospace;
}

@font-face {
  font-family: 'DSEG7';
  src: url('https://cdn.jsdelivr.net/npm/dseg@0.46.0/fonts/DSEG7-Classic/DSEG7Classic-Bold.woff2') format('woff2');
  font-display: swap;
}

*, *::before, *::after { box-sizing: border-box; }
html { scrollbar-color: var(--red) var(--ink); }
body {
  margin: 0;
  background: var(--ink);
  color: var(--cream);
  font-family: var(--mono);
  min-height: 100vh;
  overflow-x: hidden;
}
::selection { background: var(--amber); color: #2a0906; }
:focus-visible { outline: 3px solid var(--amber); outline-offset: 3px; }
button { font: inherit; color: inherit; cursor: pointer; }
::-webkit-scrollbar { width: 12px; }
::-webkit-scrollbar-track { background: var(--ink); }
::-webkit-scrollbar-thumb { background: linear-gradient(90deg, var(--red-lo), var(--red)); border-radius: 8px; border: 2px solid var(--ink); }

/* ---------- room ---------- */
.room {
  position: fixed; inset: 0; z-index: -1;
  background:
    radial-gradient(60% 40% at 50% 100%, rgba(212, 35, 27, .28), transparent 70%),
    radial-gradient(40% 30% at 15% 0%, rgba(255, 176, 0, .07), transparent 70%),
    repeating-linear-gradient(90deg, rgba(255, 255, 255, .025) 0 1px, transparent 1px 96px),
    repeating-linear-gradient(0deg, rgba(255, 255, 255, .02) 0 1px, transparent 1px 96px),
    linear-gradient(#0a0d1a, #070915);
}

.stage { padding: clamp(10px, 2vw, 28px) clamp(8px, 2vw, 24px) 0; }
.machine {
  position: relative;
  max-width: 1320px;
  margin: 0 auto;
  padding: 18px 18px 26px;
  border-radius: 34px 34px 12px 12px;
  background:
    radial-gradient(circle at 14px 14px, #ffd9d3 0 2px, #7a0f0b 3px 4px, transparent 5px) 0 0 / 100% 100% no-repeat,
    linear-gradient(90deg, var(--red-lo), var(--red) 8%, var(--red-hi) 50%, var(--red) 92%, var(--red-lo));
  box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, .35),
    inset 0 -10px 30px rgba(0, 0, 0, .35),
    0 30px 80px rgba(0, 0, 0, .6),
    0 0 120px rgba(212, 35, 27, .25);
  transform-origin: 50% 100%;
}

/* ---------- sign ---------- */
.cap {
  position: relative;
  margin: 0 0 18px;
  padding: 26px 20px 18px;
  text-align: center;
  border-radius: 20px 20px 8px 8px;
  background: linear-gradient(#fff6d0, #ffd15c 60%, #ffb92a);
  box-shadow: inset 0 0 0 5px #9d1610, inset 0 0 40px rgba(255, 140, 0, .55), 0 0 40px rgba(255, 190, 60, .35);
  overflow: hidden;
}
.cap::before, .cap::after {
  content: ""; position: absolute; left: 14px; right: 14px; height: 14px;
  background: radial-gradient(circle, #fff 28%, #ffb000 40%, transparent 46%) 0 50% / 28px 14px repeat-x;
}
.cap::before { top: 10px; animation: bulbs 1s steps(1) infinite; }
.cap::after { bottom: 8px; animation: bulbs 1s steps(1) infinite reverse; }
.bulbs { position: absolute; inset: 0; background: radial-gradient(60% 120% at 50% 0, rgba(255, 255, 255, .8), transparent 70%); pointer-events: none; }
@keyframes bulbs { 0% { opacity: 1; } 50% { opacity: .3; } }
.cap h1 {
  position: relative;
  margin: 0;
  font: 400 clamp(28px, 6vw, 84px)/1 var(--display);
  letter-spacing: -.02em;
  color: var(--red);
  text-transform: uppercase;
  text-shadow: 0 3px 0 #7a0f0b, 0 8px 0 rgba(122, 15, 11, .25);
  -webkit-text-stroke: 2px #7a0f0b;
  paint-order: stroke fill;
  text-wrap: balance;
}
.cap h1 span { display: inline-block; animation: hop 3.6s var(--ease) infinite; animation-delay: calc(var(--i) * 45ms); }
@keyframes hop { 0%, 12%, 100% { transform: translateY(0); } 6% { transform: translateY(-.14em) rotate(-3deg); } }
.cap p { position: relative; margin: 10px 0 0; font: 700 clamp(11px, 1.4vw, 15px)/1.3 var(--mono); text-transform: uppercase; letter-spacing: .08em; color: #7a0f0b; }

/* ---------- body ---------- */
.body { display: grid; grid-template-columns: minmax(0, 1fr) 330px; gap: 18px; align-items: start; }
.bezel {
  padding: 9px; border-radius: 16px;
  background: linear-gradient(135deg, var(--chrome-1), var(--chrome-2) 35%, #e4e9ef 55%, var(--chrome-3));
  box-shadow: 0 4px 0 #6b0e0a, inset 0 0 0 1px rgba(255, 255, 255, .6);
}
.glass {
  position: relative; overflow: hidden; border-radius: 9px;
  background: linear-gradient(#0f1740, #070a1c 70%);
  box-shadow: inset 0 0 40px #000, inset 0 0 0 2px #000;
}
.grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); container-type: inline-size; }
.glare {
  position: absolute; inset: 0; pointer-events: none; z-index: 5;
  background:
    radial-gradient(360px 360px at var(--mx, 50%) var(--my, 30%), rgba(255, 255, 255, .11), transparent 70%),
    linear-gradient(112deg, transparent 0 32%, rgba(255, 255, 255, .06) 34%, transparent 42%, transparent 60%, rgba(255, 255, 255, .05) 62%, transparent 68%);
  mix-blend-mode: screen;
}

/* ---------- cells ---------- */
.cell {
  position: relative;
  height: 14.6cqw;
  display: flex; flex-direction: column; justify-content: flex-end; align-items: center;
  border-right: 1px solid rgba(255, 255, 255, .05);
  transition: filter .5s, opacity .5s;
}
.cell::before {
  content: ""; position: absolute; top: 0; left: 6%; right: 6%; height: .5cqw;
  background: #d3e7ff; border-radius: 4px;
  box-shadow: 0 0 2.2cqw .8cqw rgba(140, 190, 255, .35);
}
.cell.dim { filter: brightness(.28) saturate(.2) blur(.6px); }
.cell.sel::after {
  content: ""; position: absolute; inset: 4% 3% 0; border: .4cqw solid var(--amber); border-radius: 1.2cqw;
  box-shadow: 0 0 3cqw var(--amber), inset 0 0 3cqw rgba(255, 176, 0, .35); animation: pulse .5s ease-in-out infinite alternate; pointer-events: none;
}
.cell.flash::after {
  content: ""; position: absolute; inset: 4% 3% 0; background: rgba(255, 176, 0, .28); border: .3cqw solid var(--amber); border-radius: 1.2cqw; pointer-events: none;
}
@keyframes pulse { to { opacity: .45; } }

.pack {
  position: relative; display: block;
  width: 10.2cqw; height: 9.6cqw;
  margin: 0 0 -.3cqw; padding: 0; border: 0;
  background: var(--c, #ffb43a);
  border-radius: .5cqw;
  text-align: left;
  transform: rotate(var(--r, 0deg));
  transition: transform .35s var(--ease), filter .3s;
  box-shadow: inset 0 0 0 .18cqw rgba(0, 0, 0, .25), inset 0 -1.4cqw 1.6cqw rgba(0, 0, 0, .25), 0 .5cqw 1cqw rgba(0, 0, 0, .55);
  overflow: hidden;
  color: #1b0a06;
}
.pack::before { /* crimp */
  content: ""; position: absolute; top: 0; left: 0; right: 0; height: 1cqw;
  background: repeating-linear-gradient(90deg, rgba(0, 0, 0, .3) 0 .25cqw, rgba(255, 255, 255, .28) .25cqw .6cqw);
}
.pack::after { /* gloss */
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(115deg, transparent 30%, rgba(255, 255, 255, .5) 46%, transparent 60%) -160% 0 / 250% 100% no-repeat;
  transition: background-position .8s var(--ease);
  pointer-events: none;
}
.pack:hover, .pack:focus-visible { transform: translateY(-.8cqw) rotate(calc(var(--r, 0deg) * -1 - 1.5deg)) scale(1.06); z-index: 3; }
.pack:hover::after, .pack:focus-visible::after { background-position: 160% 0; }
.pack .win { position: absolute; left: .9cqw; right: .9cqw; top: 1.5cqw; height: 4.9cqw; overflow: hidden; border: .22cqw solid var(--cream); border-radius: .3cqw; background: #111; }
.pack .win img { width: 100%; height: 100%; object-fit: cover; object-position: top; display: block; }
.pack .nm { position: absolute; left: .9cqw; right: .9cqw; top: 6.8cqw; font: 400 1.25cqw/1.1 var(--display); text-transform: uppercase; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; letter-spacing: -.01em; }
.pack .tag { position: absolute; right: .6cqw; bottom: .5cqw; padding: .1cqw .5cqw; border-radius: .3cqw; background: #14090a; color: var(--amber); font: 700 1.2cqw/1.4 var(--mono); }

.coil {
  position: relative; z-index: 2; width: 12cqw; height: 1.1cqw; border-radius: 1cqw;
  background: repeating-linear-gradient(78deg, #dfe6ee 0 .32cqw, #4b5563 .32cqw .7cqw);
  box-shadow: 0 .3cqw .6cqw rgba(0, 0, 0, .6);
  background-position-x: 0;
}
.coil.turn { animation: coil .9s linear; }
@keyframes coil { to { background-position-x: 9cqw; } }
.plate {
  width: 100%; height: 2.6cqw; display: flex; align-items: center; justify-content: center; gap: .8cqw;
  background: linear-gradient(#c8d0da, #7a8492 60%, #59616f);
  font: 700 1.25cqw var(--mono); color: #1b2230; letter-spacing: .06em;
  border-top: 1px solid #fff9;
}
.plate b { background: #14090a; color: var(--amber); padding: 0 .6cqw; border-radius: .3cqw; }
.cell.gone .pack { visibility: hidden; }
.cell.sold .plate b { color: #ff4a3a; }
.cell.sold .coil { opacity: .8; }

.grid.attract .cell { animation: wave 2.2s ease-in-out infinite; animation-delay: calc((var(--x) + var(--y)) * 120ms); }
@keyframes wave { 0%, 100% { filter: none; } 8% { filter: brightness(1.7) saturate(1.3); } 18% { filter: none; } }

/* ---------- panel ---------- */
.panel {
  position: sticky; top: 10px;
  display: flex; flex-direction: column; gap: 12px;
  min-height: 600px; height: calc(100vh - 20px);
  padding: 14px;
  border-radius: 14px;
  background: linear-gradient(160deg, #a8161a, #7c0f0c);
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, .18), inset 0 -12px 24px rgba(0, 0, 0, .35), 0 4px 0 #5e0a08;
}
.led {
  display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; align-items: end;
  padding: 10px 12px; border-radius: 10px;
  background: #170500;
  box-shadow: inset 0 3px 12px #000, 0 0 0 3px #3a120d, 0 1px 0 3px rgba(255, 255, 255, .15);
}
.digits, .count { position: relative; font: 700 44px/1 var(--led); color: var(--amber); text-shadow: 0 0 10px var(--amber-hot); letter-spacing: .04em; }
.digits::before, .count::before { content: "88"; position: absolute; left: 0; color: rgba(255, 157, 0, .09); text-shadow: none; z-index: -1; }
.count { font-size: 24px; color: #ff6a3a; text-shadow: 0 0 8px #ff3d0a; }
.count::before { content: "88"; }
.msg { grid-column: 1 / -1; overflow: hidden; white-space: nowrap; border-top: 1px dashed rgba(255, 176, 0, .25); padding-top: 6px; height: 26px; }
.msg span { display: inline-block; font: 700 13px/18px var(--mono); text-transform: uppercase; letter-spacing: .06em; color: var(--amber); text-shadow: 0 0 8px rgba(255, 122, 0, .8); animation: scroll var(--dur, 14s) linear infinite; padding-left: 100%; }
.msg span.still { animation: none; padding-left: 0; }
@keyframes scroll { to { transform: translateX(-100%); } }
.led.tilt { animation: tilt .3s steps(2) infinite; }
.led.tilt .digits { color: #ff3a2a; text-shadow: 0 0 12px #f00; }
@keyframes tilt { 50% { background: #3a0500; } }

.keys { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.letters, .nums { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; align-content: start; }
.key {
  height: 38px; border: 0; border-radius: 8px;
  font: 400 17px var(--display); color: #221410;
  background: linear-gradient(#fdfdfd, #b4bcc7);
  box-shadow: 0 4px 0 #59616f, 0 6px 8px rgba(0, 0, 0, .4);
  transition: transform .08s, box-shadow .08s, background .2s;
}
.key:active, .key.hit { transform: translateY(3px); box-shadow: 0 1px 0 #59616f, 0 2px 4px rgba(0, 0, 0, .4); }
.key.on { background: linear-gradient(#fff2b0, var(--amber)); box-shadow: 0 4px 0 #a86b00, 0 0 14px var(--amber); }
.key.clr { font-size: 11px; font-family: var(--mono); font-weight: 700; color: #7a0f0b; }

.filters { display: grid; gap: 8px; }
.chips { display: flex; flex-wrap: wrap; gap: 5px; }
.chip {
  padding: 5px 8px 5px 18px; position: relative;
  font: 700 10px/1.2 var(--mono); text-transform: uppercase; letter-spacing: .05em;
  background: #3a0b09; color: #ffcabc; border: 1px solid #a02b21; border-radius: 6px;
  transition: background .2s, color .2s;
}
.chip::before { content: ""; position: absolute; left: 6px; top: 50%; width: 6px; height: 6px; margin-top: -3px; border-radius: 50%; background: #5a1a14; }
.chip[aria-pressed="true"] { background: #2a0906; color: var(--amber); border-color: var(--amber); }
.chip[aria-pressed="true"]::before { background: var(--amber); box-shadow: 0 0 8px var(--amber); }

.coinrow { display: grid; grid-template-columns: auto 1fr auto; gap: 10px; align-items: center; }
.coin {
  position: relative; z-index: 60; width: 46px; height: 46px; border-radius: 50%;
  display: grid; place-items: center;
  font: 400 22px var(--display); color: #7a5200;
  background: radial-gradient(circle at 30% 28%, #fff7c2, #f0b800 50%, #8a6100);
  box-shadow: inset 0 0 0 4px rgba(255, 244, 170, .5), inset 0 0 0 6px rgba(120, 80, 0, .35), 0 4px 8px rgba(0, 0, 0, .5);
  cursor: grab; touch-action: none; user-select: none;
  transition: transform .5s var(--ease);
}
.coin.drag { cursor: grabbing; transition: none; }
.coin.spin { animation: coinbob 2.4s ease-in-out infinite; }
@keyframes coinbob { 50% { transform: translateY(-4px) rotateY(180deg); } }
.slotwrap { display: grid; gap: 4px; font: 700 9px/1.2 var(--mono); text-transform: uppercase; letter-spacing: .05em; color: #ffcabc; }
.slot { height: 12px; border-radius: 8px; background: #000; box-shadow: 0 0 0 3px #c9d0da, 0 0 0 4px #59616f, 0 0 14px rgba(255, 176, 0, .55); }
.slot.hot { animation: slothot .4s ease-in-out infinite alternate; }
@keyframes slothot { to { box-shadow: 0 0 0 3px #fff, 0 0 0 4px #59616f, 0 0 26px var(--amber); } }
.sound { grid-column: 1 / -1; justify-self: start; padding: 4px 8px; background: transparent; border: 1px solid rgba(255, 255, 255, .3); border-radius: 6px; font: 700 10px var(--mono); text-transform: uppercase; color: #ffcabc; }
.sound[aria-pressed="true"] { color: var(--amber); border-color: var(--amber); }

/* ---------- tray ---------- */
.tray {
  position: relative; flex: 1; min-height: 130px; overflow: hidden;
  border-radius: 10px;
  background: linear-gradient(#020204, #14090a);
  box-shadow: inset 0 8px 20px #000, 0 0 0 4px #c9d0da, 0 0 0 6px #59616f;
}
.tray-in { position: absolute; inset: 0; }
.tray-label { position: absolute; left: 0; right: 0; top: 8px; text-align: center; font: 700 10px var(--mono); text-transform: uppercase; letter-spacing: .2em; color: rgba(255, 255, 255, .25); }
.flap {
  position: absolute; left: 0; right: 0; bottom: 0; height: 34%;
  background: linear-gradient(rgba(255, 255, 255, .1), rgba(255, 255, 255, .03));
  border-top: 2px solid rgba(255, 255, 255, .25);
  backdrop-filter: blur(1px);
  transform-origin: 50% 0; pointer-events: none;
}
.tray.hit { animation: hit .25s; }
.tray.ready .tray-label { color: var(--amber); animation: pulse .6s ease-in-out infinite alternate; }
@keyframes hit { 30% { transform: translateY(3px); } }

/* ---------- ticker & footer ---------- */
.belt { overflow: hidden; margin: 44px 0 0; padding: 18px 0; border-block: 2px solid var(--red); background: rgba(212, 35, 27, .08); }
.belt-track { display: flex; width: max-content; animation: belt 60s linear infinite; }
.belt:hover .belt-track { animation-play-state: paused; }
.belt a { display: inline-flex; align-items: center; gap: 22px; padding-right: 22px; white-space: nowrap; font: 400 clamp(22px, 3.4vw, 44px)/1 var(--display); text-transform: uppercase; color: transparent; -webkit-text-stroke: 1.5px var(--cream); text-decoration: none; transition: color .2s, -webkit-text-stroke-color .2s; }
.belt a::after { content: ""; width: .5em; height: .5em; background: var(--red); border-radius: 50%; }
.belt a:hover, .belt a:focus-visible { color: var(--amber); -webkit-text-stroke-color: var(--amber); }
@keyframes belt { to { transform: translateX(-50%); } }
.foot { padding: 26px 16px 60px; text-align: center; font: 400 12px/1.7 var(--mono); color: rgba(255, 241, 201, .55); }
.foot b { color: var(--amber); }
.feet { position: absolute; left: 0; right: 0; bottom: -14px; display: flex; justify-content: space-between; padding: 0 40px; pointer-events: none; }
.feet i { width: 90px; height: 16px; background: #1a1a20; border-radius: 0 0 8px 8px; }

/* ---------- fx & modal ---------- */
.fx { position: fixed; inset: 0; z-index: 50; pointer-events: none; }
.pkwrap { position: fixed; container-type: inline-size; pointer-events: none; will-change: transform; }
.pkwrap .pack { position: absolute; left: 0; top: 0; margin: 0; pointer-events: none; }
.pkwrap.landed { position: absolute; }
.pkwrap.landed .pack { pointer-events: auto; }
.pkwrap.landed:last-child .pack { animation: packglow .8s ease-in-out infinite alternate; }
@keyframes packglow { to { box-shadow: inset 0 0 0 .18cqw rgba(0,0,0,.25), 0 0 3cqw .6cqw var(--amber); } }
.spark { position: fixed; width: 8px; height: 8px; border-radius: 2px; pointer-events: none; }

.modal { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: clamp(8px, 2vw, 28px); background: rgba(6, 8, 18, .86); backdrop-filter: blur(10px); }
.modal[hidden] { display: none; }
.sheet {
  width: min(1180px, 100%); max-height: 100%; display: flex; flex-direction: column; gap: 12px;
  padding: 14px; border-radius: 18px;
  background: linear-gradient(160deg, var(--red-hi), var(--red-lo));
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, .25), 0 40px 120px rgba(0, 0, 0, .7);
}
.sheet-top { display: flex; flex-wrap: wrap; gap: 10px 20px; align-items: center; justify-content: space-between; }
.sheet h2 { margin: 0; font: 400 clamp(20px, 3.2vw, 40px)/1.05 var(--display); text-transform: uppercase; color: var(--cream); text-shadow: 0 3px 0 #6b0e0a; text-wrap: balance; }
.sheet-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.btn { display: inline-block; padding: 12px 18px; border: 0; border-radius: 10px; font: 400 15px var(--display); text-transform: uppercase; text-decoration: none; letter-spacing: .02em; transition: transform .1s, box-shadow .1s; }
.btn.go { background: linear-gradient(#fff2b0, var(--amber)); color: #2a0906; box-shadow: 0 5px 0 #a86b00, 0 0 24px rgba(255, 176, 0, .5); }
.btn.again { background: linear-gradient(#fdfdfd, #b4bcc7); color: #221410; box-shadow: 0 5px 0 #59616f; }
.btn:active { transform: translateY(4px); box-shadow: 0 1px 0 #59616f; }
.browser { flex: 1; min-height: 0; display: flex; flex-direction: column; border-radius: 10px; overflow: hidden; background: #fff; box-shadow: 0 0 0 3px #14090a; }
.bar { display: flex; align-items: center; gap: 6px; padding: 8px 12px; background: #1c1214; }
.bar i { width: 10px; height: 10px; border-radius: 50%; background: #ff5f57; }
.bar i:nth-child(2) { background: #febc2e; }
.bar i:nth-child(3) { background: #28c840; }
.bar span { margin-left: 10px; font: 400 12px var(--mono); color: #ffcabc; }
.browser iframe { border: 0; width: 100%; height: min(64vh, 720px); background: #fff; }

/* ---------- responsive ---------- */
@media (max-width: 920px) {
  .machine { padding: 10px 10px 22px; border-radius: 22px 22px 8px 8px; }
  .body { grid-template-columns: 1fr; }
  .panel { position: static; height: auto; min-height: 0; }
  .tray { min-height: 170px; flex: none; }
  .cap { padding: 22px 10px 14px; }
  .cap::before, .cap::after { display: none; }
  .pack .nm { display: none; }
  .pack .win { height: 6.3cqw; }
  .pack .tag { font-size: 1.7cqw; }
  .plate { font-size: 1.7cqw; }
  .digits { font-size: 36px; }
  .browser iframe { height: 60vh; }
}
@media (max-height: 780px) and (min-width: 921px) {
  .key { height: 32px; font-size: 15px; }
  .panel { gap: 8px; padding: 10px; }
  .digits { font-size: 34px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
  .belt-track { animation: none; overflow-x: auto; }
}
