/* ========================================================
   ✿ KAWAII CLAW CATCHER ✿
   Aesthetic: Pastel arcade dreamscape
   ======================================================== */

*, *::before, *::after { box-sizing: border-box; }

:root {
  /* Pastel palette */
  --pink-50:  #fff1f7;
  --pink-100: #ffd9e8;
  --pink-200: #ffb3d1;
  --pink-300: #ff85b3;
  --pink-400: #f25e98;
  --pink-500: #d63a78;

  --cyan-100: #d6f6f7;
  --cyan-200: #a0e7e5;
  --cyan-300: #7fdfde;
  --cyan-400: #4ec9c7;

  --lav-100: #ece2ff;
  --lav-200: #c8a2ff;
  --lav-300: #a07bff;

  --butter: #fff4a3;
  --plum:   #5b3a7a;
  --plum-d: #3a2451;
  --cream:  #fff8ee;

  /* Original machine colors (preserved) */
  --brown: #5b3a7a;       /* re-tinted from #57280f to plum */
  --blue: var(--cyan-400);
  --dark-blue: #c8a2ff;   /* re-tinted control panel */
  --machine-color: var(--cyan-300);
  --machine-width: 160px;
  --m: 2;

  /* Atmosphere */
  --shadow-soft: 0 8px 24px rgba(91, 58, 122, 0.18);
  --shadow-pop:  0 12px 0 var(--pink-400), 0 14px 28px rgba(214, 58, 120, 0.35);
  --glow-pink:   0 0 24px rgba(255, 133, 179, 0.55);
  --glow-cyan:   0 0 24px rgba(127, 223, 222, 0.55);

  --font-display: 'Mochiy Pop One', 'M PLUS Rounded 1c', system-ui, sans-serif;
  --font-body:    'M PLUS Rounded 1c', system-ui, sans-serif;
  --font-script:  'Caveat', cursive;
}

html, body {
  margin: 0; padding: 0;
  min-height: 100vh;
  min-height: 100dvh;
  font-family: var(--font-body);
  color: var(--plum-d);
  overflow-x: hidden;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  /* prevent iOS double-tap zoom while still allowing page scroll on small screens */
  touch-action: manipulation;
}

body {
  background: var(--pink-50);
  /* prevent rubber-banding feeling on iOS */
  overscroll-behavior: none;
}

/* ========================================================
   BACKGROUND ATMOSPHERE
   ======================================================== */
.bg-layer {
  position: fixed; inset: 0;
  z-index: -10;
  pointer-events: none;
  overflow: hidden;
}
.bg-gradient {
  position: absolute; inset: -10%;
  background:
    radial-gradient(ellipse at 20% 10%, var(--pink-100) 0%, transparent 50%),
    radial-gradient(ellipse at 85% 15%, var(--lav-100) 0%, transparent 55%),
    radial-gradient(ellipse at 50% 90%, var(--cyan-100) 0%, transparent 55%),
    linear-gradient(180deg, #fff5fa 0%, #f0e7ff 50%, #e0f5f5 100%);
  animation: bgDrift 18s ease-in-out infinite alternate;
}
@keyframes bgDrift {
  0%   { transform: translate(0, 0) scale(1); }
  100% { transform: translate(-2%, 2%) scale(1.05); }
}
.bg-grid {
  position: absolute; inset: 0;
  background-image:
    linear-gradient(rgba(200, 162, 255, 0.08) 1px, transparent 1px),
    linear-gradient(90deg, rgba(200, 162, 255, 0.08) 1px, transparent 1px);
  background-size: 32px 32px;
  mask-image: radial-gradient(ellipse at center, black 30%, transparent 80%);
  -webkit-mask-image: radial-gradient(ellipse at center, black 30%, transparent 80%);
}

/* Petals & sparkles created via JS get positioned here */
.bg-petals, .bg-sparkles {
  position: absolute; inset: 0;
}
.petal {
  position: absolute;
  width: 14px; height: 14px;
  background: radial-gradient(circle at 30% 30%, #ffd9e8 0%, #ff85b3 100%);
  border-radius: 80% 0 80% 0;
  opacity: 0.85;
  filter: blur(0.3px) drop-shadow(0 2px 4px rgba(255, 133, 179, 0.4));
  animation: petalFall linear infinite;
}
@keyframes petalFall {
  0%   { transform: translate(0, -10vh) rotate(0deg); opacity: 0; }
  10%  { opacity: 0.9; }
  100% { transform: translate(40vw, 110vh) rotate(720deg); opacity: 0; }
}
.spark {
  position: absolute;
  width: 6px; height: 6px;
  background: white;
  border-radius: 50%;
  box-shadow:
    0 0 8px white,
    0 0 16px var(--pink-200);
  animation: sparkTwinkle ease-in-out infinite;
}
@keyframes sparkTwinkle {
  0%, 100% { opacity: 0; transform: scale(0.3); }
  50%      { opacity: 1; transform: scale(1.2); }
}

/* ========================================================
   HUD HEADER
   ======================================================== */
.hud {
  position: relative;
  z-index: 50;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 16px;
  padding: calc(env(safe-area-inset-top, 0px) + 14px)
           calc(env(safe-area-inset-right, 0px) + 22px)
           14px
           calc(env(safe-area-inset-left, 0px) + 22px);
  margin: 0;
}

.sound-toggle {
  width: 44px; height: 44px;
  border-radius: 50%;
  border: 3px solid var(--plum);
  background: white;
  box-shadow: 0 4px 0 var(--plum), 0 6px 14px rgba(91, 58, 122, 0.25);
  cursor: pointer;
  font-size: 20px;
  color: var(--plum);
  display: grid;
  place-items: center;
  position: relative;
  transition: transform 0.12s, box-shadow 0.12s;
}
.sound-toggle:active {
  transform: translateY(2px);
  box-shadow: 0 2px 0 var(--plum);
}
.sound-toggle .ico-off { display: none; color: var(--pink-400); }
.sound-toggle.muted .ico-on  { display: none; }
.sound-toggle.muted .ico-off { display: inline; }

.game-title {
  position: relative;
  margin: 0;
  text-align: center;
  font-family: var(--font-display);
  font-weight: 400;
  line-height: 1;
  letter-spacing: 0.02em;
}
.title-jp {
  display: block;
  font-size: clamp(14px, 2.4vw, 20px);
  color: var(--pink-400);
  margin-bottom: 4px;
  letter-spacing: 0.3em;
}
.title-en {
  display: block;
  font-size: clamp(22px, 4.5vw, 38px);
  color: var(--plum);
  text-shadow:
    2px 2px 0 var(--pink-200),
    4px 4px 0 var(--pink-300),
    6px 6px 16px rgba(214, 58, 120, 0.25);
}
.title-deco {
  position: absolute;
  top: 50%;
  font-size: clamp(20px, 4vw, 32px);
  color: var(--pink-300);
  animation: spin 8s linear infinite;
}
.title-deco.left  { left: -8%; transform: translateY(-50%); }
.title-deco.right { right: -8%; transform: translateY(-50%); animation-direction: reverse; }
@keyframes spin {
  from { transform: translateY(-50%) rotate(0deg); }
  to   { transform: translateY(-50%) rotate(360deg); }
}

.hud-stats {
  display: flex;
  gap: 8px;
  align-items: center;
}
.stat-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  background: white;
  border: 3px solid var(--plum);
  border-radius: 999px;
  box-shadow: 0 4px 0 var(--plum);
  font-family: var(--font-display);
  font-size: 14px;
  color: var(--plum-d);
  white-space: nowrap;
}
.stat-pill .stat-icon {
  color: var(--pink-400);
  font-size: 16px;
}
.mode-pill .stat-icon { color: var(--lav-300); }
.stat-pill.bump { animation: pillBump 0.4s ease; }
@keyframes pillBump {
  0%, 100% { transform: scale(1); }
  40%      { transform: scale(1.15) rotate(-3deg); }
}

/* ========================================================
   MAIN STAGE
   ======================================================== */
.stage {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 8px
           calc(env(safe-area-inset-right, 0px) + 16px)
           calc(env(safe-area-inset-bottom, 0px) + 60px)
           calc(env(safe-area-inset-left, 0px) + 16px);
}

/* ========================================================
   MASCOT SPEECH BUBBLE
   ======================================================== */
.mascot-bubble {
  position: absolute;
  top: 12px;
  right: max(20px, calc(50% - 280px));
  background: white;
  color: var(--plum-d);
  border: 3px solid var(--plum);
  border-radius: 18px;
  padding: 10px 14px;
  font-family: var(--font-script);
  font-size: 18px;
  font-weight: 700;
  max-width: 200px;
  box-shadow: 0 4px 0 var(--plum);
  z-index: 5;
  transform-origin: bottom right;
  animation: bubbleIn 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) backwards;
}
.mascot-bubble p { margin: 0; line-height: 1.2; }
.bubble-tail {
  position: absolute;
  bottom: -12px;
  right: 30px;
  width: 0; height: 0;
  border: 10px solid transparent;
  border-top-color: var(--plum);
}
.bubble-tail::after {
  content: '';
  position: absolute;
  top: -12px; left: -7px;
  width: 0; height: 0;
  border: 7px solid transparent;
  border-top-color: white;
}
@keyframes bubbleIn {
  0% { opacity: 0; transform: scale(0.5) rotate(-8deg); }
  100% { opacity: 1; transform: scale(1) rotate(-2deg); }
}
.mascot-bubble.pulse {
  animation: bubblePulse 0.4s ease;
}
@keyframes bubblePulse {
  0%, 100% { transform: rotate(-2deg) scale(1); }
  50%      { transform: rotate(-2deg) scale(1.06); }
}
@media (max-width: 720px) {
  .mascot-bubble { display: none; }
}

/* ========================================================
   CABINET FRAME
   ======================================================== */
.cabinet {
  position: relative;
  padding: 0 28px 24px;
  margin-top: 24px;
  background:
    linear-gradient(180deg, var(--pink-200) 0%, var(--pink-300) 100%);
  border: 5px solid var(--plum);
  border-radius: 32px;
  box-shadow:
    inset 0 4px 0 rgba(255,255,255,0.4),
    inset 0 -8px 0 rgba(91, 58, 122, 0.2),
    0 14px 0 var(--plum),
    0 22px 50px rgba(91, 58, 122, 0.35);
}
/* Cabinet body has cute pattern */
.cabinet::before {
  content: '';
  position: absolute;
  inset: 8px;
  border-radius: 24px;
  background-image:
    radial-gradient(circle at 20% 30%, rgba(255,255,255,0.5) 2px, transparent 3px),
    radial-gradient(circle at 70% 60%, rgba(255,255,255,0.5) 2px, transparent 3px),
    radial-gradient(circle at 40% 80%, rgba(255,255,255,0.5) 2px, transparent 3px);
  background-size: 60px 60px, 80px 80px, 70px 70px;
  pointer-events: none;
  opacity: 0.6;
}

/* Marquee top */
.marquee {
  position: relative;
  margin: 0 -28px 12px;
  padding: 12px 28px 14px;
  background:
    linear-gradient(180deg, var(--lav-200) 0%, var(--lav-300) 100%);
  border-radius: 28px 28px 8px 8px;
  border-bottom: 5px solid var(--plum);
  box-shadow: inset 0 4px 0 rgba(255,255,255,0.4);
  text-align: center;
}
.marquee-bulbs {
  position: absolute;
  top: 6px; left: 12px; right: 12px;
  display: flex;
  justify-content: space-between;
}
.marquee-bulbs span {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--butter);
  box-shadow: 0 0 8px var(--butter), 0 0 12px white;
  animation: bulbBlink 1s steps(1) infinite;
}
.marquee-bulbs span:nth-child(odd)  { animation-delay: 0s;   }
.marquee-bulbs span:nth-child(even) { animation-delay: 0.5s; }
@keyframes bulbBlink {
  0%, 50%   { opacity: 1; }
  50.01%, 100% { opacity: 0.25; }
}
.marquee-text {
  font-family: var(--font-display);
  font-size: clamp(16px, 3vw, 22px);
  color: white;
  text-shadow:
    2px 2px 0 var(--pink-400),
    -1px -1px 0 var(--plum),
    1px -1px 0 var(--plum),
    -1px 1px 0 var(--plum),
    1px 1px 0 var(--plum);
  letter-spacing: 0.05em;
  margin-top: 6px;
}
.marquee-text .m-jp {
  color: var(--butter);
  margin: 0 8px;
  font-size: 0.8em;
}

/* Side decorations */
.cabinet-deco {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  flex-direction: column;
  gap: 18px;
  font-size: 22px;
  pointer-events: none;
  z-index: 1;
}
.cabinet-deco.left  { left: 6px; }
.cabinet-deco.right { right: 6px; }
.deco-star { color: var(--butter); animation: bob 2.4s ease-in-out infinite; }
.deco-heart { color: white; animation: bob 2.4s ease-in-out infinite 0.3s; }
.cabinet-deco span:nth-child(3) { animation-delay: 0.6s; }
@keyframes bob {
  0%, 100% { transform: translateY(0) rotate(-6deg); }
  50%      { transform: translateY(-4px) rotate(6deg); }
}
@media (max-width: 480px) {
  .cabinet-deco { display: none; }
}

/* Coin slot at bottom */
.coin-slot {
  margin: 8px auto 0;
  width: fit-content;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 16px;
  background: var(--plum-d);
  border-radius: 12px;
  box-shadow: inset 0 2px 0 rgba(255,255,255,0.1), inset 0 -2px 0 rgba(0,0,0,0.3);
}
.coin-mouth {
  width: 32px; height: 6px;
  background: black;
  border-radius: 3px;
  box-shadow: inset 0 2px 4px rgba(0,0,0,0.8);
}
.coin-label {
  font-family: var(--font-display);
  font-size: 11px;
  color: var(--butter);
  letter-spacing: 0.15em;
  text-shadow: 0 0 6px var(--butter);
}

/* ========================================================
   ORIGINAL CLAW MACHINE (preserved structure, restyled)
   ======================================================== */
.wrapper {
  display: flex;
  justify-content: center;
  align-items: center;
  flex-direction: column;
  position: relative;
  z-index: 2;
}

.pix,
.pix::before,
.pix::after {
  width: calc(var(--w) * var(--m));
  height: calc(var(--h) * var(--m));
  image-rendering: pixelated;
  background-size: calc(var(--w) * var(--m)) calc(var(--h) * var(--m));
}
.pix::before, .pix::after {
  position: absolute;
  content: '';
}

.claw-machine {
  display: flex;
  flex-direction: column;
  border: 4px solid var(--plum);
  border-radius: 14px;
  overflow: hidden;
  position: relative;
  box-shadow:
    0 0 0 4px white,
    0 0 0 8px var(--plum),
    var(--shadow-soft);
}

.collection-box {
  --h: 32px;
  width: calc(var(--m) * var(--machine-width));
  margin: calc(var(--m) * var(--h) * -1 - 10px) 0 24px;
  display: flex;
  align-items: bottom;
  justify-content: start;
  position: relative;
  z-index: 3;
}
.collection-box .toy-wrapper {
  position: relative;
  width: calc(100% / 6);
  display: flex;
  align-items: end;
  justify-content: center;
}
.collection-box .toy-wrapper .toy::after {
  top: auto;
  bottom: 0;
}
.toy-wrapper.squeeze-in {
  width: 0;
  animation: squeeze-in forwards 0.4s;
  animation-delay: 1.4s;
}
@keyframes squeeze-in {
  0%   { width: 0; }
  100% { width: calc(100% / 6); }
}
@keyframes show-toy-2 {
  0%   { opacity: 0; transform: translateY(-100vh) rotate(-20deg); }
  60%  { transform: translateY(8px) rotate(8deg); }
  80%  { transform: translateY(-2px) rotate(-4deg); }
  100% { opacity: 1; transform: translateY(0) rotate(0); }
}
.toy-wrapper .toy {
  opacity: 0;
  transform: translateY(-100vh);
  animation: forwards show-toy-2 0.9s cubic-bezier(0.34, 1.56, 0.64, 1);
  animation-delay: 1s;
}

.claw-machine.show-overlay::after {
  content: '';
  position: absolute;
  width: 100%; height: 100%;
  left: 0; top: 0;
  background: radial-gradient(circle at center, rgba(255,255,255,0.4) 0%, var(--cyan-200) 100%);
  opacity: 0.7;
  z-index: 6;
  pointer-events: none;
  animation: overlayFlash 1s ease-out;
}
@keyframes overlayFlash {
  0%   { opacity: 0; }
  20%  { opacity: 0.85; }
  100% { opacity: 0.7; }
}

.box {
  position: relative;
  background:
    linear-gradient(180deg, #d6f6f7 0%, #a0e7e5 100%);
  --w: var(--machine-width);
  --h: 180px;
}
.box::before {
  background-color: var(--plum);
  top: calc(70px * var(--m));
  width: 100%;
  height: calc(var(--m) * 8px);
  z-index: 5;
}
.box::after {
  background-color: var(--cyan-300);
  top: calc(70px * var(--m));
  right: 0;
  width: calc(var(--m) * 8px);
  height: calc(var(--m) * 170px);
  z-index: 2;
}

.machine-top, .machine-bottom {
  position: absolute;
  width: 100%;
  --h: 70px;
  height: calc(var(--h) * var(--m));
}
.machine-top {
  top: 0;
  display: flex;
  align-items: center;
  z-index: 1;
}
.machine-top::after {
  content: '';
  top: 0; left: 0;
  width: 100%; height: 100%;
  background: linear-gradient(180deg, rgba(255,255,255,0.4) 0%, rgba(112, 247, 243, 0.45) 100%);
}
.machine-bottom {
  bottom: 0;
  background:
    linear-gradient(180deg, #fff8ee 0%, #ffeef5 100%);
}

.collection-point {
  position: absolute;
  bottom: 0;
  background-image: url(./images/IMG_1210.png);
  --w: 44px;
  --h: 24px;
  z-index: 0;
}

.rail { top: 0; left: 0; transition: 0.3s; border: solid var(--cyan-400); }
.rail.hori {
  --h: 5px;
  width: 100%;
  background-color: white;
  border-width: 2px 0;
}
.rail.vert {
  position: absolute;
  --h: 70px;
  --w: 5px;
  background-color: white;
  border-width: 0 2px;
}

.arm-joint {
  position: absolute;
  top: 0; left: 0;
  --w: 5px;
  --h: 5px;
  transition: 0.3s;
  z-index: -1;
}
.arm-joint::after {
  position: absolute;
  border: solid var(--cyan-400) 2px;
  background-color: white;
  --w: 10px;
  --h: 10px;
  top: calc(var(--m) * var(--h) * -0.25);
  left: calc(var(--m) * var(--w) * -0.25);
  border-radius: 2px;
}

.arm::after {
  position: absolute;
  --w: 13px;
  --h: 7px;
  bottom: calc(var(--m) * -1px);
  left: calc(var(--m) * -3px);
  background-image: url(./images/IMG_1211.png);
}
.arm.missed::after {
  background-image: url(./images/IMG_1212.png);
}
.arm.missed { animation: armShake 0.4s ease; }
@keyframes armShake {
  0%, 100% { transform: translateX(0); }
  25%      { transform: translateX(-3px); }
  75%      { transform: translateX(3px); }
}

.control {
  position: relative;
  --h: 60px;
  width: 100%;
  text-align: right;
  background: linear-gradient(180deg, var(--lav-200) 0%, var(--lav-300) 100%);
}

.cover {
  position: absolute;
  background-color: var(--cyan-300);
  --top-size: calc(var(--m) * 20px);
  --bottom-size: calc(var(--m) * 10px);
  z-index: 4;
}
.top {
  top: 0;
  width: 100%;
  height: calc(var(--m) * 16px);
}
.collection-arrow {
  position: absolute;
  left: calc(var(--m) * 21px);
  top: calc(var(--m) * 9px);
  --w: 8px;
  --h: 4px;
  background-image: url(./images/IMG_1213.png);
  filter: hue-rotate(-30deg) saturate(1.2);
}
.collection-arrow.active {
  animation: arrowPulse 0.8s ease-in-out infinite;
}
@keyframes arrowPulse {
  0%, 100% { transform: translateY(0); filter: hue-rotate(-30deg) saturate(1.2) brightness(1); }
  50%      { transform: translateY(-3px); filter: hue-rotate(-30deg) saturate(1.4) brightness(1.3); }
}
.bottom {
  bottom: 0;
  width: 100%;
  height: calc(var(--m) * 8px);
  background-color: var(--plum);
}
.left {
  bottom: 0; left: 0;
  height: calc(var(--m) * 170px);
  width: calc(var(--m) * 8px);
}
.right {
  top: 0; right: 0;
  height: 100%;
  width: calc(var(--m) * 116px);
}
.instruction {
  position: absolute;
  --w: 51px;
  --h: 12px;
  background-image: url(./images/IMG_1214.png);
  top: calc(var(--m) * 34px);
  right: calc(var(--m) * 11px);
  filter: hue-rotate(-20deg) saturate(1.2);
}

.arm {
  position: absolute;
  --w: 7px;
  --h: 28px;
  background-color: white;
  box-shadow: 0 0 0 2px var(--cyan-400);
  transition: 0.3s;
  margin-top: calc(var(--m) * -1px);
  margin-left: calc(var(--m) * -1px);
}
.claws {
  position: absolute;
  --w: 3px;
  --h: 10px;
  bottom: calc(var(--m) * -5px);
  left: calc(var(--m) * 2.5px);
}
.claws::before, .claws::after {
  top: 0;
  --w: 10px;
  --h: 16px;
  transition: 0.2s;
}
.claws::before {
  left: calc(var(--m) * -10px);
  background-image: url(./images/IMG_1215.png);
  --close-angle: 45deg;
  transform-origin: top right;
}
.claws::after {
  left: calc(var(--m) * 2.5px);
  background-image: url(./images/IMG_1216.png);
  --close-angle: -45deg;
  transform-origin: top left;
}
.arm.open .claws::before, .arm.open .claws::after {
  rotate: var(--close-angle);
}

.arm-joint::before {
  --w: 20px;
  --h: 16px;
  transform: scale(var(--scale));
  margin-left: -15px;
  margin-top: var(--shadow-pos);
  background-image: url(./images/IMG_1218.png);
  z-index: -1;
  opacity: 0.45;
}

button.hori-btn, button.vert-btn {
  position: relative;
  z-index: 5;
  --w: 24px;
  --h: 24px;
  margin: 12px 12px 0 0;
  border: 0;
  background-color: transparent;
  background-image: url(./images/IMG_1219.png);
  filter: hue-rotate(-30deg) saturate(1.5) drop-shadow(0 2px 0 var(--plum));
  cursor: pointer;
}

.claw-machine, .claw-machine * {
  user-select: none;
  -webkit-user-select: none;
  -moz-user-select: none;
  -webkit-touch-callout: none;
}

.hori-btn { transform: rotate(90deg); }

.active {
  animation: pulse infinite 0.9s ease-in-out;
  pointer-events: all;
}
@keyframes pulse {
  0%, 100% { filter: hue-rotate(-30deg) saturate(1.5) brightness(1) drop-shadow(0 2px 0 var(--plum)); }
  50%      { filter: hue-rotate(-30deg) saturate(1.5) brightness(1.5) drop-shadow(0 2px 0 var(--plum)) drop-shadow(0 0 8px var(--butter)); }
}

/* ========================================================
   TOY (preserved + idle bobble + collected display)
   ======================================================== */
.toy.display {
  transform: scale(3);
  animation: forwards show-toy-1 0.8s;
  animation-delay: 1s;
}
.toy {
  position: absolute;
  transition: transform 1s, left 0.3s, top 0.3s;
  --m: 2;
  --w: 20px;
  --h: 27px;
  transform: rotate(var(--rotate-angle, 0deg));
  pointer-events: none;
  /* Idle bobble inherited via animation */
}
.toy:not(.grabbed):not(.selected):not(.display) {
  animation: idleBob 3s ease-in-out infinite;
}
@keyframes idleBob {
  0%, 100% { transform: rotate(var(--rotate-angle, 0deg)) translateY(0); }
  50%      { transform: rotate(var(--rotate-angle, 0deg)) translateY(-2px); }
}
.toy::after { content: ''; }

.toy.bear::after {
  --w: 24px; --h: 30px;
  top: calc(var(--m) * -2px);
  left: calc(var(--m) * -2px);
  background-image: url(./images/IMG_1220.png);
}
.toy.bear.grabbed::after { background-image: url(./images/IMG_1221.png); }
.toy-wrapper .toy.bear::after { background-image: url(./images/IMG_1222.png); }

.toy.bunny { --w: 20px; --h: 29px; }
.toy.bunny::after {
  --w: 24px; --h: 32px;
  top: calc(var(--m) * -2px);
  left: calc(var(--m) * -2px);
  background-image: url(./images/IMG_1223.png);
}
.toy.bunny.grabbed::after { background-image: url(./images/IMG_1224.png); }
.toy-wrapper .toy.bunny::after { background-image: url(./images/IMG_1225.png); }

.toy.golem::after {
  --w: 26px; --h: 30px;
  top: calc(var(--m) * -1px);
  left: calc(var(--m) * -3px);
  background-image: url(./images/IMG_1226.png);
}
.toy.golem.grabbed::after { background-image: url(./images/IMG_1227.png); }
.toy-wrapper .toy.golem::after { background-image: url(./images/IMG_1228.png); }

.toy.cucumber { --w: 16px; --h: 28px; }
.toy.cucumber::after {
  --w: 16px; --h: 30px;
  top: calc(var(--m) * 1px);
  left: 0;
  background-image: url(./images/IMG_1229.png);
}
.toy.cucumber.grabbed::after { background-image: url(./images/IMG_1230.png); }
.toy-wrapper .toy.cucumber::after { background-image: url(./images/IMG_1231.png); }

.toy.penguin { --w: 24px; --h: 22px; }
.toy.penguin::after {
  --w: 26px; --h: 24px;
  top: calc(var(--m) * -1px);
  left: calc(var(--m) * -1px);
  background-image: url(./images/IMG_1232.png);
}
.toy.penguin.grabbed::after { background-image: url(./images/IMG_1233.png); }
.toy-wrapper .toy.penguin::after { background-image: url(./images/IMG_1234.png); }

.toy.robot { --w: 20px; --h: 30px; }
.toy.robot::after {
  --w: 24px; --h: 32px;
  top: calc(var(--m) * -1px);
  left: calc(var(--m) * -2px);
  background-image: url(./images/IMG_1235.png);
}
.toy.robot.grabbed::after { background-image: url(./images/IMG_1236.png); }
.toy-wrapper .toy.robot::after { background-image: url(./images/IMG_1237.png); }

.toy.selected { pointer-events: all; cursor: pointer; animation: selectedGlow 0.8s ease-in-out infinite; }
@keyframes selectedGlow {
  0%, 100% { filter: drop-shadow(0 0 4px var(--butter)) drop-shadow(0 0 8px var(--pink-200)); }
  50%      { filter: drop-shadow(0 0 8px var(--butter)) drop-shadow(0 0 16px var(--pink-300)); }
}

@keyframes show-toy-1 {
  0%   { opacity: 1; transform: scale(3) translateY(0); }
  30%  { opacity: 0; }
  100% { opacity: 0; transform: scale(1) translateY(-100vh); }
}

.control .collection-point {
  filter: brightness(0.85) hue-rotate(-15deg);
  bottom: calc(var(--m) * 8px);
}

/* ========================================================
   PARTICLES
   ======================================================== */
.particle-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 7;
  overflow: visible;
}
.particle {
  position: absolute;
  pointer-events: none;
  font-size: 14px;
  will-change: transform, opacity;
}
.particle.heart  { color: var(--pink-400); }
.particle.star   { color: var(--butter); }
.particle.sparkle { color: white; text-shadow: 0 0 8px var(--cyan-200); }

@keyframes particleBurst {
  0%   { transform: translate(0,0) scale(0.4); opacity: 0; }
  20%  { opacity: 1; }
  100% { transform: translate(var(--dx), var(--dy)) scale(1); opacity: 0; }
}

/* Confetti from celebration */
.confetto {
  position: fixed;
  top: 0;
  width: 12px;
  height: 12px;
  background: hsl( calc(360 * var(--rand)), 90%, 75%);
  border-radius: var(--shape, 50%);
  pointer-events: none;
  z-index: 9999;
  box-shadow: 0 0 6px hsla( calc(360 * var(--rand)), 90%, 80%, 0.6);
}

/* ========================================================
   MODE BUTTONS
   ======================================================== */
.mode-buttons {
  display: flex;
  gap: 12px;
  margin: 28px auto 0;
  justify-content: center;
  align-items: stretch;
  flex-wrap: wrap;
  padding: 0 8px;
}
.mode-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 12px 20px;
  min-width: 130px;
  font-family: var(--font-display);
  font-size: 16px;
  border: 4px solid var(--plum);
  border-radius: 18px;
  background: white;
  color: var(--plum-d);
  cursor: pointer;
  box-shadow: 0 6px 0 var(--plum), 0 8px 18px rgba(91, 58, 122, 0.25);
  transition: transform 0.12s, box-shadow 0.12s, background 0.2s;
}
.mode-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 0 var(--plum), 0 10px 22px rgba(91, 58, 122, 0.3);
}
.mode-btn:active {
  transform: translateY(4px);
  box-shadow: 0 2px 0 var(--plum);
}
.mode-btn.active {
  background: linear-gradient(180deg, var(--butter) 0%, #ffd56b 100%);
  transform: translateY(0);
}
.mode-btn .mb-emoji { font-size: 22px; line-height: 1; margin-bottom: 4px; }
.mode-btn .mb-label { font-size: 15px; }
.mode-btn .mb-sub   { font-size: 11px; color: var(--pink-500); font-family: var(--font-body); font-weight: 700; opacity: 0.85; }

/* ========================================================
   TIMER
   ======================================================== */
.timer-wrapper {
  position: fixed;
  top: 80px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 100;
  font-family: var(--font-display);
}
.timer-inner {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  background: var(--plum-d);
  color: var(--butter);
  border: 3px solid var(--butter);
  border-radius: 14px;
  font-size: 22px;
  letter-spacing: 0.05em;
  text-shadow: 0 0 6px var(--butter);
  box-shadow: 0 0 0 3px var(--plum), 0 6px 0 var(--plum), 0 8px 16px rgba(91, 58, 122, 0.35);
}
.timer-icon { font-size: 18px; }
.timer-wrapper.warn .timer-inner {
  animation: timerWarn 0.6s ease-in-out infinite;
}
@keyframes timerWarn {
  0%, 100% { background: var(--plum-d); }
  50%      { background: var(--pink-500); }
}

/* ========================================================
   SCOREBOARD
   ======================================================== */
#scoreboard {
  background: white;
  color: var(--plum-d);
  padding: 18px 28px;
  border: 4px solid var(--plum);
  border-radius: 22px;
  text-align: center;
  box-shadow: 0 6px 0 var(--plum), 0 10px 24px rgba(91, 58, 122, 0.3);
  font-family: var(--font-display);
  margin-top: 12px;
  z-index: 10000;
}
#scoreboard h3 {
  margin: 0 0 12px;
  color: var(--pink-400);
  font-size: 18px;
  letter-spacing: 0.05em;
}
#score-list {
  margin: 0;
  padding: 0 0 0 4px;
  list-style: none;
  counter-reset: rank;
}
#score-list li {
  counter-increment: rank;
  margin: 6px 0;
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
#score-list li::before {
  content: counter(rank);
  display: inline-grid;
  place-items: center;
  width: 24px; height: 24px;
  border-radius: 50%;
  background: var(--pink-200);
  color: var(--plum-d);
  font-size: 13px;
  font-family: var(--font-display);
}
#score-list li:nth-child(1)::before { background: var(--butter); }
#score-list li:nth-child(2)::before { background: var(--cyan-200); }
#score-list li:nth-child(3)::before { background: var(--lav-200); }

/* ========================================================
   WIN OVERLAY
   ======================================================== */
#winOverlay {
  position: fixed;
  inset: 0;
  background: radial-gradient(circle at center, rgba(255, 217, 232, 0.85) 0%, rgba(200, 162, 255, 0.85) 100%);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: grid;
  place-items: center;
  z-index: 9999;
  animation: overlayFade 0.5s ease;
}
@keyframes overlayFade {
  from { opacity: 0; }
  to   { opacity: 1; }
}
.win-content {
  position: relative;
  text-align: center;
  padding: 36px 48px;
  max-width: 480px;
}
.win-burst {
  position: absolute;
  inset: -20px;
  background:
    radial-gradient(circle at center, rgba(255,255,255,0.8) 0%, transparent 70%),
    conic-gradient(from 0deg, var(--pink-200), var(--butter), var(--cyan-200), var(--lav-200), var(--pink-200));
  border-radius: 50%;
  filter: blur(20px);
  z-index: -1;
  animation: burstSpin 8s linear infinite;
  opacity: 0.7;
}
@keyframes burstSpin {
  to { transform: rotate(360deg); }
}
.win-title {
  display: flex;
  justify-content: center;
  gap: 4px;
  font-family: var(--font-display);
  font-size: clamp(40px, 9vw, 72px);
  margin: 0 0 8px;
  color: white;
  text-shadow:
    3px 3px 0 var(--pink-400),
    6px 6px 0 var(--lav-300),
    8px 8px 20px rgba(91, 58, 122, 0.4);
}
.win-title span {
  display: inline-block;
  animation: letterPop 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) backwards;
}
.win-title span:nth-child(1) { animation-delay: 0.0s; }
.win-title span:nth-child(2) { animation-delay: 0.08s; }
.win-title span:nth-child(3) { animation-delay: 0.16s; }
.win-title span:nth-child(4) { animation-delay: 0.24s; }
.win-title span:nth-child(5) { animation-delay: 0.32s; }
.win-title span:nth-child(6) { animation-delay: 0.40s; }
.win-title span:nth-child(7) { animation-delay: 0.48s; }
.win-title span:nth-child(8) { animation-delay: 0.56s; }
@keyframes letterPop {
  0%   { opacity: 0; transform: translateY(40px) scale(0.3) rotate(-20deg); }
  100% { opacity: 1; transform: translateY(0) scale(1) rotate(0); }
}
.win-jp {
  font-family: var(--font-display);
  color: var(--pink-400);
  font-size: clamp(18px, 3vw, 28px);
  margin: 0 0 16px;
  letter-spacing: 0.1em;
  animation: fadeUp 0.6s ease 0.7s backwards;
}
.win-stats {
  background: white;
  border: 4px solid var(--plum);
  border-radius: 18px;
  padding: 12px 20px;
  margin: 0 auto 20px;
  display: inline-block;
  box-shadow: 0 4px 0 var(--plum);
  animation: fadeUp 0.6s ease 0.9s backwards;
}
.win-stats p { margin: 0; font-size: 16px; color: var(--plum-d); }
.win-stats strong { color: var(--pink-500); font-family: var(--font-display); }
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0); }
}
.replay-btn {
  font-family: var(--font-display);
  padding: 14px 28px;
  font-size: 18px;
  background: linear-gradient(180deg, var(--pink-200) 0%, var(--pink-300) 100%);
  color: white;
  border: 4px solid var(--plum);
  border-radius: 18px;
  cursor: pointer;
  box-shadow: 0 6px 0 var(--plum), 0 8px 18px rgba(91, 58, 122, 0.3);
  text-shadow: -1px -1px 0 var(--plum), 1px -1px 0 var(--plum), -1px 1px 0 var(--plum), 1px 1px 0 var(--plum);
  letter-spacing: 0.05em;
  animation: fadeUp 0.6s ease 1.1s backwards;
}
.replay-btn:hover { transform: translateY(-2px); box-shadow: 0 8px 0 var(--plum), 0 10px 22px rgba(91, 58, 122, 0.35); }
.replay-btn:active { transform: translateY(4px); box-shadow: 0 2px 0 var(--plum); }

/* ========================================================
   UTILITIES
   ======================================================== */
.hidden {
  opacity: 0;
  height: 0;
  overflow: hidden;
  pointer-events: none;
  display: none;
}

/* Screen shake */
.shake { animation: screenShake 0.4s ease; }
@keyframes screenShake {
  0%, 100% { transform: translate(0,0); }
  20%      { transform: translate(-4px, 2px) rotate(-0.4deg); }
  40%      { transform: translate(4px, -2px) rotate(0.4deg); }
  60%      { transform: translate(-3px, 1px) rotate(-0.2deg); }
  80%      { transform: translate(3px, -1px) rotate(0.2deg); }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ========================================================
   RESPONSIVE
   ======================================================== */
@media (max-width: 600px) {
  .hud { grid-template-columns: auto 1fr auto; padding: 10px 12px; gap: 8px; }
  .game-title .title-deco { display: none; }
  .stat-pill { font-size: 12px; padding: 6px 10px; }
  .mode-btn { min-width: 100px; padding: 10px 14px; }
  .mode-btn .mb-label { font-size: 13px; }
  .mode-btn .mb-sub { font-size: 10px; }
  .cabinet { padding: 0 12px 18px; border-width: 4px; }
  .marquee { margin: 0 -12px 10px; padding: 10px 12px 12px; }
  .timer-wrapper { top: 64px; }
  .timer-inner { font-size: 18px; padding: 8px 14px; }
}

/* ========================================================
   FOOTER
   ======================================================== */
.footer-credit {
  position: fixed;
  bottom: 6px;
  left: 50%;
  transform: translateX(-50%);
  font-family: var(--font-body);
  font-size: 11px;
  color: var(--plum);
  opacity: 0.6;
  z-index: 1;
}
