.perspective {
    perspective: 1000px;
    perspective-origin: 50% -50px;
    height: 200px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
  }
  
  .house {
    width: 100px;
    height: 100px;
    position: relative;
    transform-style: preserve-3d;
    animation: rotate 10s infinite linear;
  }
  
  .face {
    position: absolute;
    width: 100px;
    height: 100px;
    background-color: rgba(255, 255, 255, 0.8);
    border: 1px solid #000;
  }
  
  .roof {
    position: absolute;
    width: 100px;
    height: 70.71px; /* Calculated for 45-degree roof */
    background-color: #8B4513;
    transform-origin: bottom;
  }
  
  .front { transform: translateZ(50px); }
  .back { transform: translateZ(-50px) rotateY(180deg); }
  .left { transform: translateX(-50px) rotateY(-90deg); }
  .right { transform: translateX(50px) rotateY(90deg); }
  .top { transform: translateY(-50px) rotateX(90deg); }
  .bottom { transform: translateY(50px) rotateX(-90deg); }
  
  .roof.front {
    transform: translateY(-70px) translateZ(50px) rotateX(45deg);
  }
  .roof.back {
    transform: translateY(-70px) translateZ(-50px) rotateX(-45deg);
  }
  
  .face.front { background-color: #f0f0f0; }
  .face.back { background-color: #e0e0e0; }
  .face.left { background-color: #d0d0d0; }
  .face.right { background-color: #c0c0c0; }
  .face.top { background-color: #b0b0b0; }
  .face.bottom { background-color: #a0a0a0; }
  
  /* Add a door */
  .face.front::after {
    content: '';
    position: absolute;
    width: 30px;
    height: 50px;
    bottom: 0;
    left: 35px;
    background-color: #8B4513;
  }
  
  /* Add windows */
  .face.front::before,
  .face.left::before,
  .face.right::before {
    content: '';
    position: absolute;
    width: 20px;
    height: 20px;
    top: 15px;
    left: 15px;
    background-color: #87CEEB;
    border: 1px solid #000;
  }
  
  @keyframes rotate {
    from { transform: rotateY(0); }
    to { transform: rotateY(360deg); }
  }
  
  /* Media query for portrait/mobile devices */
  @media (max-width: 768px), (orientation: portrait) {
    .perspective {
      perspective-origin: 50% -25px;
      height: 100px;
    }
  
    .house {
      width: 50px;
      height: 50px;
    }
  
    .face {
      width: 50px;
      height: 50px;
    }
  
    .roof {
      width: 50px;
      height: 35.36px; /* Half of the original roof height */
    }
  
    .front { transform: translateZ(25px); }
    .back { transform: translateZ(-25px) rotateY(180deg); }
    .left { transform: translateX(-25px) rotateY(-90deg); }
    .right { transform: translateX(25px) rotateY(90deg); }
    .top { transform: translateY(-25px) rotateX(90deg); }
    .bottom { transform: translateY(25px) rotateX(-90deg); }
  
    .roof.front {
      transform: translateY(-35px) translateZ(25px) rotateX(45deg);
    }
    .roof.back {
      transform: translateY(-35px) translateZ(-25px) rotateX(-45deg);
    }
  
    /* Adjust door size */
    .face.front::after {
      width: 15px;
      height: 25px;
      left: 17.5px;
    }
  
    /* Adjust window size */
    .face.front::before,
    .face.left::before,
    .face.right::before {
      width: 10px;
      height: 10px;
      top: 7.5px;
      left: 7.5px;
    }
  }