/* Champs claw machine. Tokens follow the Champs design system (ds/colors.css). */

.cm {
  --ink: #0a0a0a;
  --paper: #ffffff;
  --lime: #ccff00;
  --magenta: #ff00cc;
  --cyan: #00ffff;
  --hot: #ff0033;
  --orange: #ff6600;
  --led: #ff6a00;
  --led-dim: #3a1400;
  --bulb-off: #4a3b00;
  --bulb-on: #fff27a;
  --chase: 1.4s;
  --ease-pop: cubic-bezier(0.2, 0.9, 0.25, 1);

  width: min(720px, 100%);
  margin: 0 auto;
  font-family: Inter, system-ui, sans-serif;
  color: var(--ink);
}

.cm-svg {
  display: block;
  width: 100%;
  height: auto;
  user-select: none;
  -webkit-user-select: none;
}

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

.cm-bulb {
  fill: var(--bulb-off);
  stroke: var(--ink);
  stroke-width: 2;
  animation: cm-chase var(--chase) steps(1, end) infinite;
  animation-delay: calc(var(--i) * var(--chase) / -8);
}

@keyframes cm-chase {
  0%, 62% { fill: var(--bulb-off); }
  63%, 100% { fill: var(--bulb-on); filter: drop-shadow(0 0 5px var(--bulb-on)); }
}

.cm[data-mode='play'] { --chase: 0.9s; }
.cm[data-mode='play'] .cm-bulb:nth-child(odd) { --bulb-on: var(--lime); }

.cm[data-mode='win'] .cm-bulb,
.cm[data-mode='win3'] .cm-bulb {
  animation: cm-flash 0.24s steps(1, end) infinite;
  animation-delay: calc(var(--i) * 0.03s);
}
.cm[data-mode='win3'] .cm-bulb:nth-child(3n) { --bulb-on: var(--magenta); }
.cm[data-mode='win3'] .cm-bulb:nth-child(3n + 1) { --bulb-on: var(--cyan); }
.cm[data-mode='win3'] .cm-bulb:nth-child(3n + 2) { --bulb-on: var(--lime); }

@keyframes cm-flash {
  0%, 49% { fill: var(--bulb-on); filter: drop-shadow(0 0 7px var(--bulb-on)); }
  50%, 100% { fill: var(--bulb-off); }
}

.cm[data-mode='jam'] .cm-bulb { animation: cm-jam 0.6s steps(1, end) infinite; }
@keyframes cm-jam {
  0%, 49% { fill: var(--hot); }
  50%, 100% { fill: var(--bulb-off); }
}

/* ------------------------------------------------------------------- LED */

.cm-led {
  font-family: 'Press Start 2P', ui-monospace, monospace;
  font-size: 15px;
  letter-spacing: 1px;
  fill: var(--led);
}
.cm-led-blink { animation: cm-blink 0.8s steps(1, end) infinite; }
.cm-led-hot { fill: var(--hot); }
.cm-led-win { animation: cm-rainbow 0.5s steps(1, end) infinite; }

@keyframes cm-blink {
  0%, 59% { opacity: 1; }
  60%, 100% { opacity: 0.15; }
}
@keyframes cm-rainbow {
  0% { fill: var(--lime); }
  25% { fill: var(--magenta); }
  50% { fill: var(--cyan); }
  75% { fill: #fff27a; }
}

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

.cm-strip {
  fill: var(--lime);
  stroke: var(--ink);
  stroke-width: 3;
  opacity: 0.35;
  animation: cm-strip 1.8s ease-in-out infinite;
  animation-delay: calc(var(--i) * -0.3s);
}
@keyframes cm-strip {
  0%, 100% { opacity: 0.3; }
  50% { opacity: 1; filter: drop-shadow(0 0 6px var(--lime)); }
}
.cm[data-mode='win3'] .cm-strip { fill: var(--magenta); animation-duration: 0.4s; }

.cm-neon-top { fill: var(--magenta); opacity: 0.75; }
.cm[data-mode='play'] .cm-neon-top { fill: var(--lime); }
.cm-floor-glow { transition: opacity 400ms; }
.cm[data-mode='win3'] .cm-floor-glow { animation: cm-glow 0.3s steps(2, end) infinite; }
@keyframes cm-glow { 50% { opacity: 0.2; } }

.cm-carriage-lamp,
.cm-claw-lamp { fill: var(--hot); }
.cm[data-mode='play'] .cm-carriage-lamp,
.cm[data-mode='play'] .cm-claw-lamp { fill: var(--lime); animation: cm-blink 0.5s steps(1, end) infinite; }

.cm-aim-shadow { fill: #0a0a0a; opacity: 0.28; }
.cm-aim-ring {
  fill: none;
  stroke: var(--lime);
  stroke-width: 4;
  stroke-dasharray: 10 7;
  filter: drop-shadow(0 0 4px var(--lime));
  animation: cm-ring 0.9s linear infinite;
}
@keyframes cm-ring { to { stroke-dashoffset: -34; } }

.cm-prize-sign {
  font-family: 'Press Start 2P', ui-monospace, monospace;
  font-size: 11px;
  fill: var(--lime);
  animation: cm-sign 1.2s steps(1, end) infinite;
}
@keyframes cm-sign {
  0%, 69% { opacity: 1; }
  70%, 100% { opacity: 0.5; }
}

.cm.cm-coin-in .cm-svg { animation: cm-shake 0.3s steps(3, end); }
.cm.cm-flash .cm-svg { animation: cm-bright 0.14s steps(2, end) 5; }
@keyframes cm-bright { 50% { filter: brightness(1.35) saturate(1.3); } }
@keyframes cm-shake {
  33% { transform: translate(1px, -1px); }
  66% { transform: translate(-1px, 1px); }
}

/* ------------------------------------------------------------ control panel */

.cm-panel {
  margin-top: 8px;
  border: 5px solid var(--ink);
  border-radius: 6px 6px 18px 18px;
  background:
    repeating-linear-gradient(135deg, transparent 0 14px, rgba(10, 10, 10, 0.05) 14px 28px),
    linear-gradient(180deg, #f6f6f6, #d4d4d4);
  padding: 18px 20px;
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  align-items: center;
  gap: 18px;
}

.cm button { font: inherit; cursor: pointer; }
.cm button:focus-visible { outline: 4px solid var(--lime); outline-offset: 3px; }

/* prize door */
.cm-door { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.cm-door-label { font: 700 10px/1 Inter, sans-serif; letter-spacing: 0.2em; }
.cm-door-frame {
  position: relative;
  width: 86px;
  height: 64px;
  border: 4px solid var(--ink);
  border-radius: 10px;
  background: #111;
  overflow: hidden;
  box-shadow: inset 0 6px 0 rgba(0, 0, 0, 0.6);
}
.cm-door-flap {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, #ffffff, #bfc5cb);
  border-bottom: 4px solid var(--ink);
  transform-origin: 50% 0;
  transition: transform 240ms var(--ease-pop);
}
.cm-door.is-open .cm-door-flap { transform: perspective(160px) rotateX(-78deg); }
.cm-door-out { position: absolute; inset: 0; }

.cm-pod {
  position: absolute;
  bottom: 6px;
  left: 50%;
  width: 30px;
  height: 30px;
  margin-left: -15px;
  border-radius: 50%;
  border: 3px solid var(--ink);
  background: linear-gradient(180deg, var(--top, var(--lime)) 0 46%, var(--ink) 46% 54%, var(--shell, #111) 54%);
  opacity: 0;
}
.cm-door.is-open .cm-pod { animation: cm-pod 900ms var(--ease-pop) forwards; }
.cm-pod-1 { animation-delay: 120ms !important; --dx: -22px; }
.cm-pod-2 { animation-delay: 240ms !important; --dx: 22px; }
.cm-pod[data-type='capMag'] { --top: #111; --shell: var(--magenta); }
.cm-pod[data-type='capCyan'] { --top: var(--cyan); --shell: #111; }
.cm-pod[data-type='capBlue'] { --top: #111; --shell: #0066ff; }
.cm-pod[data-type='capPurp'] { --top: var(--lime); --shell: #111; }
.cm-pod[data-type='capClear'] { --top: #111; --shell: var(--lime); }
@keyframes cm-pod {
  0% { opacity: 1; transform: translate(0, -60px) rotate(0); }
  55% { transform: translate(var(--dx, 0), 0) rotate(200deg); }
  75% { transform: translate(var(--dx, 0), -8px) rotate(260deg); }
  100% { opacity: 1; transform: translate(var(--dx, 0), 0) rotate(300deg); }
}

/* joystick */
.cm-stick-wrap {
  display: grid;
  grid-template-columns: 44px 78px 44px;
  grid-template-rows: 40px auto 40px;
  grid-template-areas: '. up .' 'left stick right' '. down .';
  align-items: center;
  justify-items: center;
  gap: 6px 10px;
  justify-content: center;
}
.cm-n-up { grid-area: up; }
.cm-n-down { grid-area: down; }
.cm-n-left { grid-area: left; }
.cm-n-right { grid-area: right; }
.cm-stick { grid-area: stick; }
.cm-nudge {
  width: 44px;
  height: 40px;
  border: 4px solid var(--ink);
  border-radius: 12px;
  background: var(--paper);
  box-shadow: 3px 3px 0 var(--ink);
  font-size: 16px;
  touch-action: none;
  transition: transform 80ms, box-shadow 80ms;
}
.cm-nudge:active { transform: translate(3px, 3px); box-shadow: 0 0 0 var(--ink); background: var(--lime); }

.cm-stick { position: relative; width: 78px; height: 86px; touch-action: none; cursor: grab; }
.cm-stick:active { cursor: grabbing; }
.cm-stick-base {
  position: absolute;
  left: 4px;
  right: 4px;
  bottom: 0;
  height: 26px;
  border-radius: 50%;
  background: radial-gradient(ellipse at 50% 35%, #3a3a3a, #0a0a0a 70%);
  border: 4px solid var(--ink);
}
.cm-stick { --tilt: 0deg; --push: 0; }
.cm-stick-shaft {
  position: absolute;
  left: 50%;
  bottom: 12px;
  width: 10px;
  height: 52px;
  margin-left: -5px;
  border-radius: 5px;
  background: linear-gradient(90deg, #f6f8fa, #8c949c 60%, #dde2e7);
  border: 3px solid var(--ink);
  transform-origin: 50% 100%;
  transform: rotate(var(--tilt, 0deg)) scaleY(calc(1 - var(--push, 0) * 0.22));
  transition: transform 90ms ease-out;
}
.cm-stick-ball {
  position: absolute;
  left: 50%;
  top: -30px;
  width: 38px;
  height: 38px;
  margin-left: -19px;
  border-radius: 50%;
  border: 4px solid var(--ink);
  background: radial-gradient(circle at 34% 30%, #ffffff 0 12%, var(--lime) 30%, #7a9900 100%);
}

/* coin */
.cm-coin { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.cm-credits {
  font: 12px/1 'Press Start 2P', ui-monospace, monospace;
  color: var(--led);
  background: #1a0600;
  border: 3px solid var(--ink);
  border-radius: 6px;
  padding: 7px 9px;
  text-shadow: 0 0 6px var(--led);
  white-space: nowrap;
}
.cm-slot {
  position: relative;
  width: 58px;
  height: 36px;
  border: 4px solid var(--ink);
  border-radius: 8px;
  background: linear-gradient(180deg, #e9edf0, #9aa2a9);
  overflow: hidden;
}
.cm-slot::after {
  content: '';
  position: absolute;
  left: 50%;
  top: 7px;
  width: 6px;
  height: 16px;
  margin-left: -3px;
  border-radius: 2px;
  background: var(--ink);
  box-shadow: 0 0 8px var(--orange);
}
.cm-coin-piece {
  position: absolute;
  left: 50%;
  top: -30px;
  width: 22px;
  height: 22px;
  margin-left: -11px;
  border-radius: 50%;
  border: 3px solid var(--ink);
  background: radial-gradient(circle at 35% 30%, #fff6b0, #f5c400 55%, #b58a00);
  opacity: 0;
  z-index: 1;
}
.cm.cm-coin-in .cm-coin-piece { animation: cm-coin 600ms var(--ease-pop); }
.cm.cm-coin-return .cm-coin-piece { animation: cm-coin-back 800ms var(--ease-pop); }
@keyframes cm-coin-back {
  0% { opacity: 1; transform: translateY(46px) scaleX(0.2); }
  45% { opacity: 1; transform: translateY(-14px) scaleX(1) rotate(-20deg); }
  70% { transform: translateY(0) rotate(12deg); }
  100% { opacity: 1; transform: translateY(0) rotate(0); }
}
@keyframes cm-coin {
  0% { opacity: 1; transform: translateY(0) scaleX(1); }
  60% { opacity: 1; transform: translateY(34px) scaleX(0.35); }
  100% { opacity: 0; transform: translateY(46px) scaleX(0.2); }
}
.cm-coin-btn {
  border: 4px solid var(--ink);
  border-radius: 999px;
  background: var(--lime);
  box-shadow: 4px 4px 0 var(--ink);
  padding: 9px 14px;
  font-weight: 800;
  font-size: 12px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  transition: transform 80ms, box-shadow 80ms;
}
.cm-coin-btn:hover { transform: translate(-1px, -1px); box-shadow: 5px 5px 0 var(--ink); }
.cm-coin-btn:active { transform: translate(4px, 4px); box-shadow: 0 0 0 var(--ink); }
.cm-coin-btn:disabled { opacity: 0.55; cursor: progress; }

/* drop + quick grab */
.cm-go { display: flex; flex-direction: column; align-items: center; gap: 16px; }
.cm-quick {
  min-height: 40px;
  border: 4px solid var(--ink);
  border-radius: 999px;
  background: var(--cyan);
  box-shadow: 4px 4px 0 var(--ink);
  padding: 8px 14px;
  font-weight: 800;
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  white-space: nowrap;
  animation: cm-quick-in 300ms var(--ease-pop);
}
.cm-quick b { font-family: 'Archivo Black', Impact, sans-serif; font-size: 13px; }
.cm-quick:hover { transform: translate(-1px, -1px); box-shadow: 5px 5px 0 var(--ink); }
.cm-quick:active { transform: translate(4px, 4px); box-shadow: 0 0 0 var(--ink); }
@keyframes cm-quick-in { from { opacity: 0; transform: translateY(6px); } }

/* drop button: a red arcade dome */
.cm-drop {
  width: 108px;
  height: 108px;
  border-radius: 50%;
  border: 6px solid var(--ink);
  background:
    radial-gradient(circle at 36% 28%, rgba(255, 255, 255, 0.85) 0 10%, transparent 26%),
    radial-gradient(circle at 50% 60%, #ff3355, var(--hot) 55%, #99001f 100%);
  box-shadow: 0 9px 0 #5c0013, 0 9px 0 6px var(--ink);
  color: var(--paper);
  font-family: 'Archivo Black', Impact, sans-serif;
  font-size: 19px;
  letter-spacing: 0.04em;
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.35);
  transition: transform 90ms, box-shadow 90ms, filter 200ms;
}
.cm-drop:not(:disabled) { animation: cm-dome 1.1s ease-in-out infinite; }
.cm-drop:not(:disabled):hover { filter: brightness(1.08); }
.cm-drop.is-pressed,
.cm-drop:not(:disabled):active {
  transform: translateY(7px);
  box-shadow: 0 2px 0 #5c0013, 0 2px 0 6px var(--ink);
  animation: none;
}
.cm-drop:disabled { filter: grayscale(0.55) brightness(0.8); cursor: not-allowed; }
@keyframes cm-dome {
  50% { filter: brightness(1.18) drop-shadow(0 0 12px rgba(255, 0, 51, 0.6)); }
}

.cm-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-top: 10px;
  font: 600 11px/1.3 Inter, sans-serif;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #4a4a4a;
}
.cm-mute {
  min-height: 40px;
  border: 3px solid var(--ink);
  border-radius: 999px;
  background: var(--paper);
  padding: 8px 14px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
.cm-mute[aria-pressed='true'] { background: var(--lime); }

.cm-shelf {
  margin-top: 14px;
  border: 4px solid var(--ink);
  border-radius: 14px;
  background: var(--ink);
  color: var(--paper);
  padding: 12px 14px 14px;
}
.cm-shelf-head { margin: 0 0 10px; font: 600 12px/1 Inter, sans-serif; letter-spacing: 0.14em; text-transform: uppercase; color: #c8c8c8; }
.cm-shelf-head b { color: var(--lime); margin-right: 6px; }
.cm-shelf-row {
  list-style: none;
  margin: 0;
  padding: 0 0 4px;
  display: flex;
  gap: 10px;
  overflow-x: auto;
  scrollbar-width: thin;
}
.cm-shelf-cap {
  flex: none;
  min-width: 58px;
  height: 58px;
  border-radius: 50%;
  border: 3px solid var(--paper);
  background: linear-gradient(180deg, var(--lime) 0 46%, var(--ink) 46% 54%, #1c1c1c 54%);
  display: grid;
  place-items: center;
  font: 11px/1 'Archivo Black', Impact, sans-serif;
  color: var(--paper);
  text-shadow: 0 1px 0 var(--ink), 0 -1px 0 var(--ink), 1px 0 0 var(--ink), -1px 0 0 var(--ink);
  animation: cm-shelf-in 420ms var(--ease-pop) both;
  animation-delay: var(--d);
}
.cm-shelf-cap.is-multi-2 { border-color: var(--cyan); }
.cm-shelf-cap.is-multi-3 { border-color: var(--magenta); box-shadow: 0 0 10px var(--magenta); }
@keyframes cm-shelf-in { from { opacity: 0; transform: translateY(-16px) scale(0.6); } }

.cm-sr {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* ------------------------------------------------------------------ phones */

@media (max-width: 560px) {
  .cm-panel {
    grid-template-columns: 1fr 1fr;
    grid-template-areas: 'stick drop' 'door coin';
    padding: 14px;
    gap: 14px;
  }
  .cm-stick-wrap { grid-area: stick; }
  .cm-go { grid-area: drop; }
  .cm-drop { justify-self: center; width: 96px; height: 96px; }
  .cm-door { grid-area: door; }
  .cm-coin { grid-area: coin; }
  .cm-nudge { width: 40px; height: 40px; }
  .cm-stick-wrap { grid-template-columns: 40px 70px 40px; }
  .cm-credits { font-size: 10px; padding: 6px 7px; }
  .cm-foot { flex-direction: column; align-items: flex-start; }
}

@media (max-width: 400px) {
  .cm-panel {
    grid-template-columns: auto auto;
    justify-content: space-around;
    grid-template-areas: 'stick stick' 'drop coin' 'door door';
  }
  .cm-door { flex-direction: row; }
}

@media (prefers-reduced-motion: reduce) {
  .cm-aim-ring,
  .cm-quick,
  .cm-shelf-cap,
  .cm-bulb,
  .cm-strip,
  .cm-drop,
  .cm-prize-sign,
  .cm-led-blink,
  .cm-led-win,
  .cm .cm-svg { animation: none !important; }
  .cm-bulb:nth-child(3n) { fill: var(--bulb-on); }
  .cm-door.is-open .cm-pod { animation-duration: 1ms; }
}
