.flip-clock {
  text-align: center;
  perspective: 400px;
  margin: 20px auto;
}

.flip-clock *,
.flip-clock *:before,
.flip-clock *:after {
  box-sizing: border-box;
}

.card {
  display: block;
  position: relative;
  padding-bottom: 0.72em;
  font-size: 9vw;
  line-height: 0.95;
}

.card__top,
.card__bottom,
.card__back::before,
.card__back::after {
  display: block;
  height: 0.72em;
  color: #ccc;
  background: #222;
  padding: 0.25em 0.25em;
  border-radius: 0.15em 0.15em 0 0;
  backface-visibility: hidden;
  transform-style: preserve-3d;
  width: auto;
  min-width: 2.2em;
  transform: translateZ(0);
}

.card__bottom {
  color: #FFF;
  position: absolute;
  top: 50%;
  left: 0;
  border-top: solid 1px #000;
  background: #393939;
  border-radius: 0 0 0.15em 0.15em;
  pointer-events: none;
  overflow: hidden;
}

.card__bottom::after {
  display: block;
  margin-top: -0.72em;
}

.card__top,
.card__bottom {
  text-align: center;
}

.card__back::before,
.card__bottom::after {
  content: attr(data-value);
}

.card__back {
  position: absolute;
  top: 0;
  height: 100%;
  left: 0%;
  pointer-events: none;
}

.card__back::before {
  position: relative;
  z-index: -1;
  overflow: hidden;
}

.flip .card__back::before {
  animation: flipTop 0.3s cubic-bezier(.37, .01, .94, .35);
  animation-fill-mode: both;
  transform-origin: center bottom;
}

.flip .card__back .card__bottom {
  transform-origin: center top;
  animation-fill-mode: both;
  animation: flipBottom 0.6s cubic-bezier(.15, .45, .28, 1);
}

@keyframes flipTop {
  0% {
    transform: rotateX(0deg);
    z-index: 2;
  }

  0%,
  99% {
    opacity: 0.99;
  }

  100% {
    transform: rotateX(-90deg);
    opacity: 0;
  }
}

@keyframes flipBottom {

  0%,
  50% {
    z-index: -1;
    transform: rotateX(90deg);
    opacity: 0;
  }

  51% {
    opacity: 0.99;
  }

  100% {
    opacity: 0.99;
    transform: rotateX(0deg);
    z-index: 5;
  }
}

.flip-clock__slot {
  font-size: 2vw;
}

/* From Uiverse.io by augustin_4687 – converted to vanilla CSS and hover-based behavior */

.button {
  --stone-50: #fafaf9;
  --stone-800: #292524;
  --yellow-300: #fde047;
  --yellow-400: #facc15;
  --yellow-500: #eab308;
  --black-25: rgba(0, 0, 0, 0.25);

  position: relative;
  display: block;
  width: 4rem;
  height: 4rem;
  cursor: pointer;
}

/* Main button */
.button>button {
  cursor: pointer;
  display: inline-block;
  height: 100%;
  width: 100%;
  appearance: none;
  border: 2px solid var(--stone-800);
  border-radius: 0.25rem;
  background-color: var(--yellow-400);
  outline: 2px solid transparent;
  outline-offset: 2px;
  transition: background-color 0.2s;
}

.button>button:hover {
  background-color: var(--yellow-300);
}

/* Originally :active → now on :hover */
.button>button:hover {
  outline-color: var(--stone-800);
}

.button>button:focus-visible {
  outline-color: var(--stone-800);
  outline-style: dashed;
}

/* Second span: the inner animated surface */
.button>span:nth-child(2) {
  position: absolute;
  inset: 3px;
  pointer-events: none;
  background-color: var(--yellow-400);
  border-bottom: 2px solid var(--black-25);
  transition: transform 75ms;
}

.button>span:nth-child(2)::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image: radial-gradient(rgb(255 255 255 / 80%) 20%, transparent 20%),
    radial-gradient(rgb(255 255 255 / 100%) 20%, transparent 20%);
  background-position: 0 0, 4px 4px;
  background-size: 8px 8px;
  mix-blend-mode: hard-light;
  opacity: 0.5;
  animation: dots 0.5s infinite linear;
}

/* Third span: little pixel blocks */
.button>span:nth-child(3) {
  position: absolute;
  pointer-events: none;
  inset: 0;
}

.button>span:nth-child(3)::before {
  content: "";
  width: 0.375rem;
  height: 0.375rem;
  position: absolute;
  top: 0.25rem;
  left: 0.25rem;
  background-color: var(--stone-800);
  border-radius: 0.125rem;
  box-shadow:
    3.125em 0 var(--stone-800),
    0 3.125em var(--stone-800),
    3.125em 3.125em var(--stone-800);
}

/* Fourth span: shadow pattern */
.button>span:nth-child(4) {
  position: absolute;
  pointer-events: none;
  inset: 0;
  filter: drop-shadow(0.25em 0.25em 0 rgba(0, 0, 0, 0.2));
  transition: all 75ms;
}

.button>span:nth-child(4)::after {
  content: "";
  width: 0.25rem;
  height: 0.25rem;
  position: absolute;
  top: 0.875rem;
  left: 1rem;
  border-radius: 0.0625px;
  background-color: var(--stone-800);
  box-shadow:
    0.75em 2em var(--stone-800),
    1em 2em var(--stone-800),
    0.75em 1.75em var(--stone-800),
    1em 1.75em var(--stone-800),
    0.75em 1.25em var(--stone-800),
    1em 1.25em var(--stone-800),
    0.75em 1em var(--stone-800),
    1em 1em var(--stone-800),
    1em 0.75em var(--stone-800),
    1.5em 0.75em var(--stone-800),
    1.25em 0.75em var(--stone-800),
    1.25em -0.25em var(--stone-800),
    1.5em 0em var(--stone-800),
    1.25em 0.5em var(--stone-800),
    1.5em 0.5em var(--stone-800),
    1.25em 0.25em var(--stone-800),
    1.5em 0.25em var(--stone-800),
    1.25em 0 var(--stone-800),
    1em -0.25em var(--stone-800),
    0.75em -0.25em var(--stone-800),
    0.5em -0.25em var(--stone-800),
    0.25em -0.25em var(--stone-800),
    0.25em 0 var(--stone-800),
    0 0.25em var(--stone-800),
    0 0.5em var(--stone-800),
    0.25em 0.25em var(--stone-800),
    0.25em 0.5em var(--stone-800);
}

/* Fifth span: bottom highlight layer */
.button>span:nth-child(5) {
  position: absolute;
  background-color: var(--yellow-400);
  border: 2px solid var(--stone-800);
  border-radius: 0.75rem;
  pointer-events: none;
  z-index: -1;
  inset: 0.5rem 1.5rem;
  box-shadow:
    7px 0 0 0 var(--stone-800),
    inset 0 2px 0 0 var(--yellow-300),
    inset 0 -2px 0 0 var(--yellow-500);
  transition: all 0ms cubic-bezier(0, 0.5, 0.4, 1);
}

/* Originally button:active ~ span(5) → now button:hover ~ span(5) */
.button>button:hover~span:nth-child(5) {
  transform: translateY(-200%);
  transition-duration: 200ms;
  opacity: 0;
}

/* Hover shadow depth adjustment */
.button>button:hover~span:nth-child(4) {
  filter: drop-shadow(0.125em 0.125em 0 rgba(0, 0, 0, 0.2));
}

/* Animation for dotted highlight */
@keyframes dots {
  0% {
    background-position: 0 0, 4px 4px;
  }

  100% {
    background-position: 8px 0, 12px 4px;
  }
}

/* Dark mode adjustments */
@media (prefers-color-scheme: dark) {

  .button>button:hover,
  .button>button:focus-visible {
    outline-color: var(--yellow-400);
  }
}