:root {
  --radius: 0px;
  --shadow: 0 20px 60px rgba(0, 0, 0, 0.18), 0 4px 16px rgba(0, 0, 0, 0.10);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  height: 100%;
  background: #818263;
  overflow: hidden;
}

body {
  touch-action: none;
}

.page {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.scene {
  width: min(92vw, 420px);
  perspective: 1600px;
  perspective-origin: 50% 48%;
}

.card-wrap {
  width: 100%;
  aspect-ratio: 5 / 7;
  display: grid;
  place-items: center;
}

.card {
  position: relative;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
  cursor: grab;
  user-select: none;
  -webkit-user-select: none;
  will-change: transform;
  transition: box-shadow 0.2s ease;
}

.card:active {
  cursor: grabbing;
}

.face {
  position: absolute;
  inset: 0;
  border-radius: var(--radius);
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  overflow: hidden;
  box-shadow: var(--shadow);
  background: #ffffff;
}

.back {
  transform: rotateY(180deg);
}

.card-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  display: block;
  pointer-events: none;
  border-radius: var(--radius);
}

/* Fade transition when front image changes */
.front {
  position: absolute;
  inset: 0;
}

#frontImg {
  transition: opacity 0.25s ease;
}

#frontImg.swap {
  opacity: 0;
}

@media (max-width: 480px) {
  .scene {
    width: min(96vw, 360px);
  }
}
