:root {
  color-scheme: light;
  --paper: #f2f2ef;
  --ink: #252525;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--paper);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button {
  font: inherit;
}

#cat-peel-stage {
  position: relative;
  width: 100%;
  height: 100%;
  min-height: 540px;
  overflow: hidden;
  background:
    radial-gradient(circle at 50% -20%, rgba(255, 255, 255, 0.94), transparent 58%),
    #f2f2ef;
  touch-action: none;
  user-select: none;
}

#cat-grid {
  position: absolute;
  inset: clamp(28px, 5vh, 62px) clamp(24px, 6vw, 96px) clamp(42px, 7vh, 76px);
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  grid-template-rows: repeat(3, minmax(0, 1fr));
  align-items: center;
  justify-items: center;
}

.cat-sticker {
  appearance: none;
  position: relative;
  width: clamp(122px, 14vw, 190px);
  aspect-ratio: 1;
  padding: 0;
  border: 0;
  outline: 0;
  background: transparent;
  cursor: pointer;
  transform: rotate(var(--rotation));
  transition: transform 180ms ease, filter 180ms ease, opacity 120ms ease;
  filter:
    drop-shadow(0 1px 0 rgba(0, 0, 0, 0.07))
    drop-shadow(0 2px 2px rgba(0, 0, 0, 0.08));
  -webkit-tap-highlight-color: transparent;
}

#cat-peel-stage.focused .cat-sticker:not(.selected) {
  opacity: 0.2;
  filter: none;
}

.cat-sticker:hover {
  transform: rotate(var(--rotation)) translateY(-2px);
  filter:
    drop-shadow(0 1px 0 rgba(0, 0, 0, 0.07))
    drop-shadow(0 5px 5px rgba(0, 0, 0, 0.11));
}

.cat-sticker.selected {
  pointer-events: none;
  opacity: 0;
}

.cat-sticker img {
  position: relative;
  z-index: 1;
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  pointer-events: none;
  -webkit-user-drag: none;
}

.cat-gloss {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  opacity: var(--shine-opacity, 0.13);
  background:
    radial-gradient(
      ellipse 38% 23% at var(--shine-x, 30%) var(--shine-y, 18%),
      rgba(255, 255, 255, 0.36) 0%,
      rgba(255, 255, 255, 0.14) 24%,
      rgba(255, 255, 255, 0.025) 54%,
      transparent 72%
    ),
    linear-gradient(
      118deg,
      transparent calc(var(--shine-band, 35%) - 14%),
      rgba(255, 255, 255, 0.015) calc(var(--shine-band, 35%) - 7%),
      rgba(255, 255, 255, 0.17) var(--shine-band, 35%),
      rgba(255, 255, 255, 0.025) calc(var(--shine-band, 35%) + 8%),
      transparent calc(var(--shine-band, 35%) + 17%)
    );
  mix-blend-mode: screen;
  mask: var(--cat-mask) center / contain no-repeat;
  -webkit-mask: var(--cat-mask) center / contain no-repeat;
  transition: opacity 160ms ease;
  will-change: background, opacity;
}

#peel-layer {
  position: absolute;
  z-index: 20;
  display: none;
  pointer-events: auto;
  cursor: grab;
  transform: translate(-50%, -50%);
  transform-origin: center;
  touch-action: none;
  transition:
    left 520ms cubic-bezier(0.2, 0.82, 0.2, 1),
    top 520ms cubic-bezier(0.2, 0.82, 0.2, 1),
    width 520ms cubic-bezier(0.2, 0.82, 0.2, 1),
    height 520ms cubic-bezier(0.2, 0.82, 0.2, 1),
    transform 520ms cubic-bezier(0.2, 0.82, 0.2, 1),
    filter 180ms ease;
  will-change: left, top, width, height, filter, transform;
}

#peel-layer.visible {
  display: block;
}

#peel-layer.zooming {
  pointer-events: none;
  cursor: default;
}

#peel-layer.dragging {
  cursor: grabbing;
  transition: filter 120ms ease;
}

#peel-canvas {
  display: block;
  width: 100%;
  height: 100%;
}

#peel-layer::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 45%;
  height: 45%;
  border-radius: 50%;
  background: rgba(20, 20, 20, calc(var(--peel, 0) * 0.12));
  filter: blur(calc(8px + var(--peel, 0) * 14px));
  transform:
    translate(
      calc(-50% + var(--shadow-x, 0px)),
      calc(-50% + var(--shadow-y, 5px))
    )
    scale(calc(1 + var(--peel, 0) * 0.35));
  z-index: -1;
  pointer-events: none;
}

#hint {
  position: absolute;
  left: 50%;
  bottom: 17px;
  z-index: 30;
  transform: translateX(-50%);
  padding: 7px 11px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.68);
  box-shadow: 0 1px 8px rgba(0, 0, 0, 0.05);
  color: rgba(25, 25, 25, 0.55);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.015em;
  backdrop-filter: blur(10px);
  pointer-events: none;
  transition: opacity 240ms ease;
  white-space: nowrap;
}

#hint.quiet {
  opacity: 0.24;
}

@media (max-width: 720px) {
  #cat-grid {
    inset: 24px 12px 48px;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    grid-template-rows: repeat(4, minmax(0, 1fr));
  }

  .cat-sticker {
    width: min(29vw, 142px);
  }

  #hint {
    bottom: 10px;
  }
}
