/* Jackpurr - retro-arcade slot cabinet for the Playgram hub.
   Palette, type and component rules follow the TOKEHUNT arcade spec. */

:root {
  --bg: #020617;
  --panel: #0c1e3e;
  --surface: #172554;
  --text: #f8fafc;
  --muted: #94a3b8;
  --link: #38bdf8;
  --primary: #38bdf8;
  --success: #a3e635;
  --error: #ef4444;
  --warning: #facc15;
  --border: #1e3a8a;
  --live: #ff2a2a;
  --mythic: #a44dff;

  --display: "Press Start 2P", "Silkscreen", ui-monospace, monospace;
  --body: "VT323", "Silkscreen", ui-monospace, monospace;

  --safeT: env(safe-area-inset-top, 0px);
  --safeB: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: var(--body);
  font-size: 1.0625rem;
  line-height: 1.35;
  -webkit-font-smoothing: none;
  -moz-osx-font-smoothing: grayscale;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
  overscroll-behavior: none;
  touch-action: manipulation;
}

h1, h2, h3 {
  font-family: var(--display);
  line-height: 1.15;
  word-spacing: -0.05em;
  font-weight: 400;
}

button { font: inherit; color: inherit; cursor: pointer; }

.hidden { display: none !important; }

/* ------------------------------------------------------------- cabinet */

#cabinet {
  position: relative;
  height: 100%;
  display: flex;
  flex-direction: column;
  gap: clamp(6px, 1.4vh, 12px);
  padding: calc(var(--safeT) + 8px) 12px calc(var(--safeB) + 10px);
  background:
    radial-gradient(120% 70% at 50% -10%, rgba(56, 189, 248, .16), transparent 62%),
    radial-gradient(90% 55% at 50% 108%, rgba(163, 230, 53, .12), transparent 60%),
    var(--bg);
}

/* ------------------------------------------------------------- marquee */

#marquee {
  position: relative;
  flex: 0 0 auto;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 10px;
  padding: clamp(8px, 1.6vh, 14px) 14px;
  background: linear-gradient(180deg, #123063, var(--panel) 60%);
  border: 1px solid var(--border);
  border-radius: .75rem;
  box-shadow:
    inset 0 1px 0 rgba(125, 211, 252, .35),
    0 0 26px rgba(56, 189, 248, .18);
}

#marquee h1 {
  grid-column: 2;
  text-align: center;
  font-size: clamp(1.05rem, 5.4vw, 1.7rem);
  letter-spacing: .02em;
}
#marquee h1 b { color: var(--text); font-weight: 400; }
#marquee h1 i {
  font-style: normal;
  color: var(--primary);
  background: linear-gradient(100deg, var(--primary) 40%, #fff 50%, var(--primary) 60%);
  background-size: 260% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  animation: shine 3.6s linear infinite;
}
@keyframes shine { from { background-position: 160% 0; } to { background-position: -60% 0; } }

#tagline {
  grid-column: 2;
  text-align: center;
  color: var(--muted);
  font-size: .95rem;
  letter-spacing: .18em;
  margin-top: 3px;
}

/* LED status dots */
.led {
  width: 12px; height: 12px;
  border-radius: 50%;
  background: #14264d;
  border: 1px solid #24408a;
  box-shadow: inset 0 0 4px #000;
}
.led.on   { background: var(--success); border-color: #cdff6b; box-shadow: 0 0 12px var(--success); animation: blink .5s steps(1) infinite; }
.led.warn { background: var(--warning); border-color: #ffe98a; box-shadow: 0 0 12px var(--warning); animation: blink .32s steps(1) infinite; }
.led.bad  { background: var(--live);    border-color: #ff9a9a; box-shadow: 0 0 12px var(--live);    animation: blink .24s steps(1) infinite; }
@keyframes blink { 50% { opacity: .28; } }

/* ------------------------------------------------------------- machine */

#machine {
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  grid-template-columns: 1fr clamp(48px, 15vw, 76px);
  gap: 10px;
  align-items: stretch;
}

#reelbox { position: relative; min-width: 0; display: flex; }

#reelFrame {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  border: 1px solid var(--border);
  border-radius: .75rem;
  background: linear-gradient(180deg, #04102a, #061634 55%, #04102a);
  box-shadow:
    inset 0 1px 0 rgba(125, 211, 252, .28),
    inset 0 0 44px rgba(2, 6, 23, .95),
    0 0 30px rgba(56, 189, 248, .14);
  overflow: hidden;
}

#reels { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }

/* centre payline */
#payline {
  position: absolute; left: 0; right: 0;
  top: 50%; transform: translateY(-50%);
  height: 33.3333%;
  border-top: 1px solid rgba(56, 189, 248, .38);
  border-bottom: 1px solid rgba(56, 189, 248, .38);
  background: linear-gradient(90deg, rgba(56, 189, 248, .06), rgba(56, 189, 248, .02), rgba(56, 189, 248, .06));
  pointer-events: none;
  transition: border-color .18s, box-shadow .18s, background .18s;
}
#payline i {
  position: absolute; top: 50%; width: 9px; height: 9px;
  transform: translateY(-50%) rotate(45deg);
  background: var(--primary);
  box-shadow: 0 0 10px var(--primary);
}
#payline i:first-child { left: -5px; }
#payline i:last-child  { right: -5px; }

#payline.won {
  border-color: var(--success);
  background: linear-gradient(90deg, rgba(163, 230, 53, .18), rgba(163, 230, 53, .05), rgba(163, 230, 53, .18));
  box-shadow: 0 0 26px rgba(163, 230, 53, .5), inset 0 0 30px rgba(163, 230, 53, .16);
  animation: paylinePulse .46s steps(1) infinite;
}
#payline.won i { background: var(--success); box-shadow: 0 0 14px var(--success); }
#payline.jackpot {
  border-color: var(--mythic);
  background: linear-gradient(90deg, rgba(164, 77, 255, .26), rgba(164, 77, 255, .08), rgba(164, 77, 255, .26));
  box-shadow: 0 0 34px rgba(164, 77, 255, .65), inset 0 0 34px rgba(164, 77, 255, .2);
}
#payline.jackpot i { background: var(--mythic); box-shadow: 0 0 16px var(--mythic); }
@keyframes paylinePulse { 50% { opacity: .45; } }

/* live lottie cells that take over once a reel settles */
#cells {
  position: absolute; left: 0; right: 0;
  top: 50%; transform: translateY(-50%);
  height: 33.3333%;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  pointer-events: none;
}
#cells .cell { position: relative; opacity: 0; transition: opacity .12s linear; }
#cells .cell.live { opacity: 1; }
#cells .cell canvas, #cells .cell svg { display: block; width: 100%; height: 100%; }
#cells .cell.hit::after {
  content: "";
  position: absolute; inset: 6%;
  border-radius: 14px;
  box-shadow: 0 0 22px 4px rgba(163, 230, 53, .55), inset 0 0 18px rgba(163, 230, 53, .3);
  animation: hitAura .6s ease-in-out infinite alternate;
}
#cells .cell.hit.mythic::after {
  box-shadow: 0 0 30px 6px rgba(164, 77, 255, .7), inset 0 0 22px rgba(164, 77, 255, .38);
}
@keyframes hitAura { from { opacity: .35; } to { opacity: 1; } }

/* CRT glass + reel glow */
#glass {
  position: absolute; inset: 0; pointer-events: none;
  background:
    linear-gradient(180deg, rgba(2, 6, 23, .92), rgba(2, 6, 23, 0) 22%, rgba(2, 6, 23, 0) 78%, rgba(2, 6, 23, .92)),
    linear-gradient(105deg, rgba(255, 255, 255, .07) 0 18%, transparent 34%);
}
#reelGlow {
  position: absolute; inset: 0; pointer-events: none; opacity: 0;
  transition: opacity .25s;
  background: radial-gradient(70% 55% at 50% 50%, rgba(163, 230, 53, .3), transparent 70%);
}
#reelGlow.on { opacity: 1; }
#reelGlow.mythic { background: radial-gradient(70% 55% at 50% 50%, rgba(164, 77, 255, .38), transparent 70%); }

/* win banner */
/* sits low, over the vignetted bottom row, so it never masks the payline art */
#winBanner {
  position: absolute; left: 50%; bottom: 3%;
  transform: translateX(-50%);
  padding: 8px 14px;
  font-family: var(--display);
  font-size: clamp(.62rem, 3.1vw, .9rem);
  color: #04240a;
  background: var(--success);
  border-radius: .5rem;
  box-shadow: 0 0 26px rgba(163, 230, 53, .7);
  animation: bannerPop .34s cubic-bezier(.2, 1.6, .4, 1);
  white-space: nowrap;
  z-index: 6;
}
#winBanner.mythic { background: var(--mythic); color: #fff; box-shadow: 0 0 32px rgba(164, 77, 255, .85); }
@keyframes bannerPop { from { transform: translateX(-50%) scale(.5); opacity: 0; } }

/* -------------------------------------------------------------- handle */

#handleRig { position: relative; touch-action: none; cursor: grab; }
#handleRig.pulling { cursor: grabbing; }

#handleTrack {
  position: absolute; left: 50%; top: 6%; bottom: 6%;
  width: 12px; transform: translateX(-50%);
  border-radius: 8px;
  background: linear-gradient(180deg, #0a1a38, #050e22);
  border: 1px solid var(--border);
  box-shadow: inset 0 0 10px #000;
  overflow: hidden;
}
#handleTrack i {
  position: absolute; inset: 0;
  background: repeating-linear-gradient(180deg, rgba(56, 189, 248, .1) 0 1px, transparent 1px 12px);
}

#handleMount {
  position: absolute; left: 50%; top: 4%;
  width: 30px; height: 18px; transform: translateX(-50%);
  border-radius: 6px 6px 3px 3px;
  background: linear-gradient(180deg, #2b4c8f, #12224a);
  border: 1px solid var(--border);
  box-shadow: inset 0 1px 0 rgba(148, 197, 255, .5);
}

#handleShaft {
  position: absolute; left: 50%;
  width: 9px; transform: translateX(-50%);
  border-radius: 5px;
  background: linear-gradient(90deg, #6b7f9e, #d8e6ff 42%, #6b7f9e);
  box-shadow: 0 0 8px rgba(0, 0, 0, .6);
}

#handleBall {
  position: absolute; left: 50%;
  width: clamp(34px, 11vw, 50px); aspect-ratio: 1;
  transform: translate(-50%, 0);
  border-radius: 50%;
  background: radial-gradient(circle at 34% 28%, #ffd9d9 0 8%, var(--live) 42%, #7d0000 100%);
  box-shadow: 0 0 18px rgba(255, 42, 42, .55), inset -4px -6px 12px rgba(0, 0, 0, .55);
  border: 1px solid #ff6b6b;
}
#handleBall span {
  position: absolute; left: 26%; top: 18%;
  width: 22%; height: 16%;
  border-radius: 50%;
  background: rgba(255, 255, 255, .8);
  filter: blur(1px);
}

#handleHint {
  position: absolute; left: 50%; bottom: 1%;
  transform: translateX(-50%);
  font-family: var(--display);
  font-size: .5rem;
  color: var(--muted);
  letter-spacing: .1em;
  animation: hintBob 1.6s ease-in-out infinite;
  white-space: nowrap;
}
@keyframes hintBob { 50% { transform: translate(-50%, 4px); } }
#handleRig.armed #handleHint { color: var(--success); animation: none; }
#handleRig.busy { opacity: .45; pointer-events: none; }

/* -------------------------------------------------------------- meters */

#meters {
  flex: 0 0 auto;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}
.meter {
  padding: 6px 8px 5px;
  text-align: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: .75rem;
  box-shadow: inset 0 1px 0 rgba(125, 211, 252, .22);
}
.meter small {
  display: block;
  font-family: var(--display);
  font-size: .46rem;
  color: var(--muted);
  letter-spacing: .1em;
}
.meter strong {
  display: block;
  font-size: clamp(1.3rem, 6vw, 1.9rem);
  font-weight: 400;
  color: var(--primary);
  text-shadow: 0 0 12px rgba(56, 189, 248, .55);
  line-height: 1.1;
}
.meter.win strong { color: var(--success); text-shadow: 0 0 12px rgba(163, 230, 53, .55); }
.meter.flash { animation: meterFlash .3s steps(1) 4; }
@keyframes meterFlash { 50% { background: #24406f; } }

/* ------------------------------------------------------------ controls */

#controls { flex: 0 0 auto; display: flex; flex-direction: column; gap: 8px; }

#betRow { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }

.betBtn {
  font-family: var(--display);
  font-size: .68rem;
  padding: 10px 0 11px;
  color: var(--muted);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: .75rem;
  box-shadow: inset 0 -3px 0 rgba(2, 6, 23, .7);
  transition: transform .06s, box-shadow .06s, color .12s, background .12s;
}
.betBtn:active { transform: translateY(2px); box-shadow: inset 0 -1px 0 rgba(2, 6, 23, .7); }
.betBtn.on {
  color: #04101d;
  background: var(--primary);
  border-color: #7dd3fc;
  box-shadow: inset 0 -3px 0 #0c76a8, 0 0 16px rgba(56, 189, 248, .5);
}

/* chunky arcade CTA with a slow diagonal shine */
.primaryBtn {
  position: relative;
  overflow: hidden;
  font-family: var(--display);
  font-size: clamp(.74rem, 3.6vw, 1rem);
  padding: 16px 0 18px;
  color: #04240a;
  background: var(--success);
  border: 1px solid #cdff6b;
  border-radius: .75rem;
  box-shadow: 0 6px 0 #4d7a05, 0 10px 20px rgba(0, 0, 0, .5), inset 0 2px 0 rgba(255, 255, 255, .45);
  transition: transform .06s, box-shadow .06s, filter .15s;
}
.primaryBtn::after {
  content: "";
  position: absolute; top: -60%; left: -35%;
  width: 30%; height: 220%;
  transform: rotate(18deg);
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .55), transparent);
  animation: sweep 3.4s ease-in-out infinite;
}
@keyframes sweep { 0%, 62% { left: -40%; } 100% { left: 130%; } }
.primaryBtn:active { transform: translateY(4px); box-shadow: 0 2px 0 #4d7a05, 0 4px 10px rgba(0, 0, 0, .5), inset 0 2px 0 rgba(255, 255, 255, .45); }
.primaryBtn:disabled { filter: grayscale(.7) brightness(.62); box-shadow: 0 6px 0 #2b3f13; cursor: default; }
.primaryBtn:disabled::after { display: none; }
.primaryBtn.small { font-size: .7rem; padding: 12px 0 14px; width: 100%; margin-top: 12px; }

#utilRow { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.ghostBtn {
  font-family: var(--display);
  font-size: .44rem;
  padding: 9px 2px 10px;
  color: var(--link);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: .6rem;
  letter-spacing: .04em;
  box-shadow: inset 0 -2px 0 rgba(2, 6, 23, .7);
  transition: transform .06s, color .12s;
}
.ghostBtn:active { transform: translateY(2px); }
.ghostBtn[aria-pressed="false"] { color: var(--muted); }

/* --------------------------------------------------------------- sheet */

.sheet {
  position: absolute; inset: 0; z-index: 20;
  display: flex; align-items: center; justify-content: center;
  padding: calc(var(--safeT) + 16px) 16px calc(var(--safeB) + 16px);
  background: rgba(2, 6, 23, .9);
  -webkit-backdrop-filter: blur(3px);
  backdrop-filter: blur(3px);
}
.sheetPanel {
  width: 100%; max-width: 380px;
  max-height: 100%;
  overflow-y: auto;
  padding: 20px 18px 18px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: .75rem;
  box-shadow: inset 0 1px 0 rgba(125, 211, 252, .3), 0 0 40px rgba(56, 189, 248, .18);
}
.sheetPanel h2 {
  font-size: clamp(.9rem, 4vw, 1.15rem);
  color: var(--primary);
  text-align: center;
  text-shadow: 0 0 14px rgba(56, 189, 248, .6);
}
.sheetPanel h3 {
  font-size: .66rem;
  color: var(--success);
  margin: 18px 0 8px;
  letter-spacing: .06em;
}
.sheetSub { text-align: center; color: var(--muted); font-size: .95rem; letter-spacing: .12em; margin: 8px 0 14px; }
.sheetNote { color: var(--muted); font-size: .95rem; margin-top: 12px; }
.sheetNote b { color: var(--link); }

#payList { list-style: none; display: flex; flex-direction: column; gap: 6px; }
#payList li {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 7px 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: .5rem;
}
#payList .combo { display: flex; gap: 3px; }
#payList .combo canvas { width: 26px; height: 26px; display: block; }
#payList .name { font-size: 1rem; color: var(--text); letter-spacing: .06em; }
#payList .name em { font-style: normal; color: var(--muted); }
#payList .pay { font-family: var(--display); font-size: .68rem; color: var(--success); }
#payList li.top { border-color: var(--mythic); box-shadow: 0 0 16px rgba(164, 77, 255, .3); }
#payList li.top .pay { color: var(--mythic); }

#mathList { display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; }
#mathList dt { color: var(--muted); font-size: 1rem; }
#mathList dd { color: var(--primary); font-size: 1rem; text-align: right; }

/* ---------------------------------------------------------------- boot */

.bootPanel { text-align: center; }
.bootCat { font-size: 46px; animation: hintBob 1.2s ease-in-out infinite; }
.bootBar {
  height: 12px; margin: 16px 0 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
}
.bootBar i {
  display: block; height: 100%; width: 0;
  background: linear-gradient(90deg, var(--primary), var(--success));
  box-shadow: 0 0 14px rgba(56, 189, 248, .7);
  transition: width .2s;
}
#bootMsg { color: var(--muted); font-size: 1rem; letter-spacing: .12em; }

/* --------------------------------------------------------- CRT overlay */

#scanlines {
  position: absolute; inset: 0; z-index: 40;
  pointer-events: none;
  background: repeating-linear-gradient(180deg, rgba(0, 0, 0, .22) 0 1px, transparent 1px 3px);
  mix-blend-mode: multiply;
  opacity: .55;
}

/* offscreen lottie stage */
#stage { position: fixed; left: -9999px; top: -9999px; width: 1px; height: 1px; overflow: hidden; }

/* shake on a losing spin */
#cabinet.shake { animation: shake .34s ease-in-out; }
@keyframes shake {
  20% { transform: translateX(-4px); }
  45% { transform: translateX(4px); }
  70% { transform: translateX(-2px); }
}

/* short viewports: trim the vertical furniture */
@media (max-height: 620px) {
  #tagline { display: none; }
  #utilRow .ghostBtn { font-size: .4rem; padding: 7px 2px 8px; }
  .primaryBtn { padding: 12px 0 14px; }
}

@media (prefers-reduced-motion: reduce) {
  #marquee h1 i, .primaryBtn::after, .bootCat, #handleHint,
  #payline.won, #cells .cell.hit::after, .led.on, .led.warn, .led.bad { animation: none; }
}
