body {
    background-color: #3e2723;
    background-image: url('shelf-background.png');
    font-family: 'Lora', serif;
    color: #f5f5f5;
    margin: 0;
    padding: 2rem;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    min-height: 100vh;
}

.bookshelf-container {
    text-align: center;
    width: 100%;
}

h1 {
    font-family: 'Playfair Display', serif;
    color: #d7ccc8;
    font-size: 3rem;
    margin-bottom: 2rem;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.5);
    border-bottom: 2px solid #a1887f;
    display: inline-block;
    padding-bottom: 0.5rem;
}

.bookshelf {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 40px 30px;
    padding: 20px;
    perspective: 1500px;
}

.book {
    width: 180px;
    height: 250px;
    position: relative;
    cursor: pointer;
    transform-style: preserve-3d;
    transition: transform 0.7s ease-in-out;
}

.book:hover {
    transform: rotateY(180deg);
}

.book-cover, .book-content {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden; /* Safari */
    border-radius: 2px 8px 8px 2px;
    box-shadow: 0 4px 8px rgba(0,0,0,0.3), inset -2px 0 5px rgba(0,0,0,0.2);
}

.book-cover {
    background-color: #5d4037;
    transform: rotateY(0deg);
    z-index: 2;
}

.book-cover img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 2px 8px 8px 2px;
}

.book-content {
    background-color: #efebe9;
    color: #4e342e;
    transform: rotateY(180deg);
    z-index: 1;
    padding: 20px;
    font-size: 0.8rem;
    overflow-y: auto;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
}

.book-content h3 {
    font-family: 'Playfair Display', serif;
    margin-top: 0;
    font-size: 1rem;
    border-bottom: 1px solid #bcaaa4;
    padding-bottom: 5px;
}

.book-content p {
    margin-top: 10px;
    font-style: italic;
}

.book-content::-webkit-scrollbar {
    width: 5px;
}

.book-content::-webkit-scrollbar-track {
    background: #d7ccc8;
}

.book-content::-webkit-scrollbar-thumb {
    background: #8d6e63;
}

/* For mobile: open on click */
.book.open {
    transform: rotateY(180deg);
}