* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #0b1640;
  color: #f5f3ff;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}

#app {
  position: fixed;
  inset: 0;
  overflow: hidden;
  /* Requested look: dark blue at the top to dark purple at the bottom. */
  background: linear-gradient(180deg, #0b1640 0%, #1a1450 45%, #2c0f4f 100%);
}

#sky {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.moon {
  position: absolute;
  top: max(64px, env(safe-area-inset-top));
  right: 7%;
  width: min(22vw, 120px);
  aspect-ratio: 1;
  filter: drop-shadow(0 0 18px rgba(254, 243, 199, 0.45));
}

.star {
  position: absolute;
  border-radius: 50%;
  background: #fff;
  opacity: 0.8;
  animation: twinkle ease-in-out infinite alternate;
}

@keyframes twinkle {
  from {
    opacity: 0.25;
  }
  to {
    opacity: 1;
  }
}

#field {
  position: absolute;
  inset: 0;
  touch-action: none;
}

.item {
  position: absolute;
  left: 0;
  top: 0;
  padding: 0;
  margin: 0;
  border: 0;
  background: none;
  cursor: pointer;
  touch-action: none;
  will-change: transform;
}

.item svg,
.icon svg {
  display: block;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.item[data-kind="rainbowMouse"],
.item[data-kind="rainbowHat"] {
  filter: drop-shadow(0 0 8px rgba(255, 224, 102, 0.55));
}

.item.caught {
  pointer-events: none;
  animation: caught 0.3s ease-in forwards;
}

@keyframes caught {
  0%,
  45% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    scale: 0.4;
  }
}

.paw {
  position: absolute;
  bottom: -40px;
  width: 76px;
  margin-left: -38px;
  pointer-events: none;
  transform-origin: bottom center;
  animation: swipe 0.42s ease-out forwards;
  display: flex;
  flex-direction: column;
  align-items: center;
  filter: drop-shadow(0 0 6px rgba(196, 181, 253, 0.5));
}

.paw-hand {
  width: 76px;
  height: 68px;
  flex: none;
}

.paw-hand svg {
  display: block;
  width: 100%;
  height: 100%;
}

.paw-arm {
  flex: 1;
  width: 50px;
  margin-top: -14px;
  background: #050507;
  border-left: 2px solid #c4b5fd;
  border-right: 2px solid #c4b5fd;
}

@keyframes swipe {
  0% {
    transform: translateY(100%);
  }
  35% {
    transform: translateY(0);
  }
  65% {
    transform: translateY(0);
  }
  100% {
    transform: translateY(100%);
  }
}

.popup {
  position: absolute;
  transform: translate(-50%, -50%);
  font-size: 30px;
  font-weight: 800;
  pointer-events: none;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.6);
  animation: rise 0.8s ease-out forwards;
}

.popup.good,
b.good {
  color: #86efac;
}

.popup.big,
b.big {
  color: #fde68a;
}

.popup.bad,
b.bad {
  color: #fca5a5;
}

@keyframes rise {
  from {
    opacity: 1;
    transform: translate(-50%, -50%);
  }
  to {
    opacity: 0;
    transform: translate(-50%, -150%);
  }
}

#hud {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  justify-content: space-between;
  padding: max(12px, env(safe-area-inset-top)) 16px 0;
  pointer-events: none;
}

.stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 72px;
  padding: 6px 12px;
  border-radius: 14px;
  background: rgba(11, 22, 64, 0.55);
  border: 1px solid rgba(196, 181, 253, 0.25);
}

.stat .label {
  font-size: 12px;
  color: #c4b5fd;
}

.stat span:last-child {
  font-size: 26px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.screen {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(8, 6, 30, 0.55);
}

.screen[hidden] {
  display: none;
}

.card {
  width: min(420px, 100%);
  max-height: 100%;
  overflow: auto;
  padding: 22px 20px;
  border-radius: 20px;
  background: rgba(20, 16, 60, 0.92);
  border: 1px solid rgba(196, 181, 253, 0.3);
  text-align: center;
}

h1,
h2 {
  margin: 0 0 8px;
  font-size: 28px;
}

.lead {
  margin: 0 0 14px;
  color: #ddd6fe;
  line-height: 1.4;
}

.legend {
  list-style: none;
  margin: 0 0 18px;
  padding: 0;
  text-align: left;
}

.legend li {
  display: grid;
  grid-template-columns: 44px 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 4px 0;
}

.legend .icon {
  width: 44px;
  height: 44px;
}

.legend b {
  font-size: 20px;
}

#end[data-result="lost"] h2 {
  color: #fca5a5;
}

#end-best {
  color: #c4b5fd;
  margin: 0 0 16px;
}

.play {
  font: inherit;
  font-size: 20px;
  font-weight: 700;
  padding: 12px 36px;
  border: 0;
  border-radius: 999px;
  color: #1e1b4b;
  background: #fde68a;
  cursor: pointer;
}

.play:active {
  transform: scale(0.97);
}
