@font-face {
  font-family: "Press Start 2P";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("./fonts/PressStart2P.ttf") format("truetype");
}
@font-face {
  font-family: "VT323";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("./fonts/VT323.ttf") format("truetype");
}

:root {
  color-scheme: dark;
  --bg: #07080d;
  --cabinet: #12151f;
  --bezel: #1c2230;
  --line: #2a3144;
  --text: #d7ffe0;
  --dim: #7f8a7a;
  --phos: #5dff6a;
  --coin: #ff3d8a;
  --gold: #ffd36a;
  --hp: #39d0ff;
  --px: 4px;
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: "VT323", ui-monospace, monospace;
  font-size: 22px;
  line-height: 1.25;
}
body {
  background-image:
    radial-gradient(1200px 500px at 50% -10%, #142018 0%, transparent 60%),
    repeating-linear-gradient(90deg, #08090f 0 8px, #0a0b12 8px 16px);
}

.scan {
  pointer-events: none;
  position: fixed;
  inset: 0;
  z-index: 20;
  background: repeating-linear-gradient(
    to bottom,
    transparent 0 2px,
    rgba(0, 0, 0, 0.18) 2px 3px
  );
  mix-blend-mode: multiply;
}

.crt {
  max-width: 52rem;
  margin: 0 auto;
  padding: 18px 14px 40px;
}

.hud {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  padding: 0 4px;
}
.logo {
  font-family: "Press Start 2P", monospace;
  font-size: 11px;
  color: var(--phos);
  text-shadow: 0 0 8px #5dff6a88, 3px 3px 0 #000;
  letter-spacing: 2px;
}
.live {
  font-family: "Press Start 2P", monospace;
  font-size: 8px;
  color: var(--coin);
  animation: blink 1.2s steps(2, start) infinite;
}

.cabinet {
  position: relative;
  background: var(--cabinet);
  border: var(--px) solid #000;
  box-shadow:
    0 0 0 var(--px) var(--bezel),
    8px 8px 0 #000,
    inset 0 0 40px #0008;
  padding: 14px 14px 10px;
}

.stage {
  display: grid;
  grid-template-columns: 1.1fr 1fr;
  gap: 14px;
  align-items: stretch;
}

.sprite {
  margin: 0;
  background: #000;
  border: var(--px) solid var(--gold);
  box-shadow: 4px 4px 0 #000;
  position: relative;
  overflow: hidden;
  min-height: 180px;
}
.sprite img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  image-rendering: auto;
  filter: contrast(1.08) saturate(1.1);
}
.sprite figcaption {
  position: absolute;
  left: 8px;
  bottom: 8px;
  margin: 0;
  font-family: "Press Start 2P", monospace;
  font-size: 8px;
  color: #fff;
  background: #000c;
  padding: 6px 8px;
  border: 2px solid var(--phos);
}

.board { padding: 4px 2px 0; }
.kicker {
  margin: 0 0 8px;
  font-family: "Press Start 2P", monospace;
  font-size: 8px;
  color: var(--gold);
  letter-spacing: 2px;
}
h1 {
  margin: 0 0 8px;
  font-family: "Press Start 2P", monospace;
  font-size: 18px;
  line-height: 1.35;
  color: #f4fff6;
  text-shadow: 3px 3px 0 #000, 0 0 12px #5dff6a55;
}
.price {
  margin: 0 0 12px;
  color: var(--dim);
  font-size: 20px;
}

.hp {
  position: relative;
  height: 22px;
  background: #07080d;
  border: 3px solid #000;
  box-shadow: 3px 3px 0 var(--hp);
  margin: 0 0 14px;
  overflow: hidden;
}
.hp i {
  display: block;
  height: 100%;
  width: 0;
  background: repeating-linear-gradient(
    90deg,
    var(--phos) 0 10px,
    #2aa33a 10px 12px
  );
  box-shadow: 0 0 12px #5dff6a;
  transition: width .6s steps(16, end);
}
.hp span {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding-right: 8px;
  font-family: "Press Start 2P", monospace;
  font-size: 8px;
  color: #fff;
  text-shadow: 1px 1px 0 #000;
}

.stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 8px;
}
.stats div {
  background: #0b0d14;
  border: 2px solid var(--line);
  padding: 8px 6px;
  text-align: center;
}
.stats label {
  display: block;
  font-family: "Press Start 2P", monospace;
  font-size: 7px;
  color: var(--dim);
  margin-bottom: 4px;
}
.stats b {
  font-family: "Press Start 2P", monospace;
  font-size: 11px;
  color: var(--gold);
  font-weight: 400;
}
.stars {
  margin: 0;
  color: var(--phos);
  letter-spacing: 1px;
}

.ask {
  margin: 16px 0 12px;
  padding: 10px 12px;
  background: #0b0d14;
  border-left: 4px solid var(--phos);
  color: #c6d7c9;
  font-size: 22px;
}

.coins {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 10px;
}
.coins button, .custom button, .custom input {
  font-family: "Press Start 2P", monospace;
  font-size: 10px;
  border: 3px solid #000;
  background: var(--bezel);
  color: var(--text);
  padding: 10px 10px;
  box-shadow: 4px 4px 0 #000;
  cursor: pointer;
}
.coins button:hover, .custom button:hover { color: var(--phos); }
.coins button:active, .custom button:active {
  transform: translate(2px, 2px);
  box-shadow: 2px 2px 0 #000;
}

.custom { margin: 8px 0 4px; }
.custom label {
  display: block;
  font-family: "Press Start 2P", monospace;
  font-size: 8px;
  color: var(--dim);
  margin-bottom: 6px;
}
.custom .row { display: flex; gap: 8px; }
.custom input {
  width: 8.5rem;
  background: #07080d;
  color: var(--gold);
  outline: none;
  cursor: text;
}
.custom button {
  background: var(--coin);
  color: #fff;
  flex: 1;
}

.msg {
  min-height: 1.2em;
  margin: 8px 0;
  color: var(--gold);
  font-size: 20px;
}

.qrbox {
  margin: 12px 0;
  padding: 12px;
  text-align: center;
  background: #0b0d14;
  border: 3px solid #000;
  box-shadow: 4px 4px 0 var(--gold);
}
.qrbox img {
  display: block;
  margin: 8px auto;
  width: 180px;
  height: 180px;
  background: #fff;
  image-rendering: pixelated;
}
.qrbox code {
  display: block;
  font-family: "VT323", monospace;
  font-size: 16px;
  color: var(--dim);
  word-break: break-all;
  cursor: pointer;
}
.qr-hit {
  display: block;
  margin: 8px auto;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
}
.qr-hit img {
  display: block;
  margin: 0 auto;
  width: 180px;
  height: 180px;
  background: #fff;
  image-rendering: pixelated;
}
.ton-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  margin-top: 10px;
}
.ton-row button {
  font-family: "Press Start 2P", monospace;
  font-size: 8px;
  border: 3px solid #000;
  background: var(--bezel);
  color: var(--text);
  padding: 10px 8px;
  box-shadow: 4px 4px 0 #000;
  cursor: pointer;
}
.ton-row button:hover { color: var(--phos); }
.ton-row button:active {
  transform: translate(2px, 2px);
  box-shadow: 2px 2px 0 #000;
}
#ton-open {
  background: var(--phos);
  color: #05060a;
}

.ticker {
  overflow: hidden;
  white-space: nowrap;
  border-top: 3px solid #000;
  background: #05060a;
  margin: 10px -14px -10px;
  padding: 8px 0;
  color: var(--phos);
  font-family: "Press Start 2P", monospace;
  font-size: 8px;
}
.ticker span {
  display: inline-block;
  padding-left: 100%;
  animation: marquee 18s linear infinite;
}

.foot {
  margin: 16px 4px 0;
  color: #556055;
  font-size: 16px;
}

@keyframes blink { 50% { opacity: 0; } }
@keyframes marquee {
  0% { transform: translateX(0); }
  100% { transform: translateX(-100%); }
}

.rail {
  position: relative;
  height: 58px;
  margin: 6px 0 0;
}
.chip {
  position: absolute;
  left: var(--chip-x, 12%);
  bottom: 0;
  z-index: 6;
  width: 52px;
  height: 58px;
  transform: translateX(-50%);
  cursor: pointer;
  touch-action: manipulation;
  outline: none;
}
.chip:focus-visible {
  box-shadow: 0 0 0 2px var(--gold);
}
.chip-px {
  position: absolute;
  left: 2px;
  bottom: 2px;
  width: 16px;
  height: 16px;
  background: url("./chip.svg") no-repeat 0 0 / 64px 16px;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  transform: scale(3);
  transform-origin: bottom left;
  pointer-events: none;
}
.chip-flip .chip-px {
  left: auto;
  right: 2px;
  transform: scale(-3, 3);
  transform-origin: bottom right;
}
.chip-walk .chip-px { animation: chip-step 0.36s steps(2) infinite; }
.chip-beg .chip-px { background-position: -32px 0; }
.chip-cheer .chip-px,
.chip-pet .chip-px {
  background-position: -48px 0;
  animation: chip-hop 0.28s steps(2) infinite;
}
.chip-idle .chip-px { background-position: 0 0; animation: none; }

.chip-bubble {
  position: absolute;
  left: 50%;
  bottom: 52px;
  transform: translateX(-50%);
  font-family: "Press Start 2P", monospace;
  font-size: 7px;
  line-height: 1.3;
  color: #07080d;
  background: var(--gold);
  border: 3px solid #000;
  box-shadow: 3px 3px 0 #000;
  padding: 6px 7px 5px;
  white-space: nowrap;
  pointer-events: none;
}
.chip-bubble[hidden] { display: none; }

.chip-pop {
  position: absolute;
  left: 22px;
  top: 0;
  width: 7px;
  height: 6px;
  pointer-events: none;
  opacity: 0;
  background: var(--coin);
  clip-path: polygon(50% 100%, 0 35%, 20% 0, 50% 22%, 80% 0, 100% 35%);
}
.chip-hearts .chip-pop {
  animation: chip-heart 1.1s steps(5) forwards;
}

@keyframes chip-step {
  from { background-position: 0 0; }
  to { background-position: -32px 0; }
}
@keyframes chip-hop {
  0%, 100% { translate: 0 0; }
  50% { translate: 0 -5px; }
}
@keyframes chip-heart {
  0% { opacity: 1; translate: 0 8px; }
  100% { opacity: 0; translate: 0 -16px; }
}

@media (max-width: 720px) {
  .stage { grid-template-columns: 1fr; }
  h1 { font-size: 14px; }
  .stats { grid-template-columns: 1fr; }
  .custom .row { flex-direction: column; }
  .custom input { width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  .live { animation: none; }
  .ticker span { animation: none; padding-left: 8px; }
  .chip-walk .chip-px,
  .chip-cheer .chip-px,
  .chip-pet .chip-px { animation: none; }
  .hp i { transition: none; }
}
