/* Global Styles */
:root {
    --background-dark: #1a022b;
    --background-medium: #1a022b;
    --background-light: #1a022b;
    --text-light: #f3e9d2;
    --text-medium: #d4af37;
    --text-dark: #333;
    --primary-color: #d4af37;
    --secondary-color: #8c1a11;
    --accent-color: #f0e68c;
}
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Palatino Linotype', 'Book Antiqua', Palatino, serif;
}

body {
    background: linear-gradient(135deg, var(--background-dark), var(--background-medium));
    color: var(--text-light);
    height: 100vh;
    font-size: 16px;
    overflow: auto;
}

/* Header */
.header {
    width: 100%;
    height: auto;
    max-height: 200px;
    background: var(--background-dark);
    text-align: center;
    padding: 10px;
}

/* Bookshelf Screen */
.bookshelf-screen {
    text-align: center;
    padding: 40px 20px;
    background: linear-gradient(135deg, var(--background-light), var(--background-medium));
    border-radius: 15px;
    box-shadow: 0 8px 15px rgba(0, 0, 0, 0.2);
    margin: 20px auto;
    max-width: 900px;
    color: var(--text-dark);
}

.section-title {
    font-size: 2.5rem;
    font-weight: bold;
    color: var(--primary-color);
    margin-bottom: 15px;
    text-shadow: 0 3px 6px rgba(0, 0, 0, 0.2);
}

.app-subtitle {
    font-size: 1.2rem;
    color: var(--text-dark);
    margin-bottom: 30px;
}

/* Bookshelf Styling */
.bookshelf {
    display: flex;
    justify-content: center;
    gap: 25px;
    flex-wrap: wrap;
    padding: 20px;
    overflow-y: auto;
}

/* Upload Book Button */
.upload-book {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 180px;
    height: 250px;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    border-radius: 15px;
    cursor: pointer;
    transition: transform 0.3s, box-shadow 0.3s;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
    color: var(--text-light);
}

.upload-book:hover {
    transform: scale(1.05);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.3);
}

.upload-icon {
    font-size: 4rem;
    margin-bottom: 10px;
    color: var(--text-light);
    transition: transform 0.3s ease;
}

.upload-book:hover .upload-icon {
    transform: rotate(360deg);
}

.upload-text {
    font-size: 1.2rem;
    font-weight: bold;
    text-align: center;
}

/* Book Cards */
.book {
    width: 200px;
    height: 300px;
    background: linear-gradient(135deg, var(--accent-color), var(--secondary-color));
    border-radius: 15px;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
    cursor: pointer;
    transition: transform 0.3s, box-shadow 0.3s;
    position: relative;
    overflow: hidden;
}

.book:hover {
    transform: translateY(-10px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.3);
}

.book-title {
    position: absolute;
    bottom: 10px;
    left: 10px;
    color: var(--text-light);
    font-size: 1.2rem;
    font-weight: bold;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
}

.hidden {
    display: none !important;
}

.app-title {
    font-size: 4rem;
    text-align: center;
    margin-bottom: 15px;
    font-weight: bold;
    color: var(--primary-color);
    text-shadow: 0 0 15px rgba(212, 175, 55, 0.7);
    position: relative;
    z-index: 1;
}

.app-subtitle {
    text-align: center;
    color: var(--text-medium);
    font-size: 1.3rem;
    margin-bottom: 40px;
    max-width: 700px;
    margin-left: auto;
    margin-right: auto;
    line-height: 1.6;
    font-weight: 400;
    position: relative;
    z-index: 1;
}

.bookshelf {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 35px;
    flex: 1;
    overflow-y: auto;
    padding: 25px;
    perspective: 1000px;
    position: relative;
    z-index: 0;
}

.book {
    width: 220px;
    height: 320px;
    position: relative;
    cursor: pointer;
    perspective: 1000px;
    margin: 20px;
    transition: transform 0.3s ease;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}

.book:hover {
    transform: scale(1.02);
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.7);
}

.book svg {
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
}

.book-page-svg {
    opacity: 0;
    z-index: 1;
    transition: opacity 0.5s ease;
}

.book:hover .book-page-svg {
    opacity: 1;
}

.book-cover-svg {
    transform-origin: 15% center;
    transition: transform 0.8s cubic-bezier(0.4, 0, 0.2, 1);
    transform: rotateY(-10deg);
    z-index: 2;
}

.book:hover .book-cover-svg {
    transform: rotateY(-100deg);
}

.book-spine {
    stroke-width: 1;
}

.book-cover {
    stroke-width: 1;
}

.book-page {
    fill: #fff;
    stroke: #ddd;
    stroke-width: 1;
}

.book-text {
    fill: #333;
    font-family: 'Palatino Linotype', 'Book Antiqua', Palatino, serif;
    font-size: 12px;
}

.book-title {
    font-size: 14px;
    font-weight: bold;
}

.spine-text {
    fill: #f3e9d2;
    font-family: 'Palatino Linotype', 'Book Antiqua', Palatino, serif;
    font-size: 12px;
    text-shadow: 1px 1px 1px rgba(0, 0, 0, 0.7);
}

.book-cover h3 {
    font-size: 1rem;
    text-align: center;
    color: #f3e9d2;
    text-shadow: 1px 1px 1px rgba(0, 0, 0, 0.7);
}

.upload-book {
    width: 220px;
    height: 320px;
    background: rgba(255, 255, 255, 0.1);
    border: 2px dashed var(--text-medium);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    transition: all 0.3s ease;
    border-radius: 10px;
    backdrop-filter: blur(5px);
}

.upload-book:hover {
    background: rgba(255, 255, 255, 0.15);
    border-color: var(--primary-color);
    transform: scale(1.02);
}

.upload-icon {
    font-size: 4.5rem;
    color: var(--text-medium);
    margin-bottom: 15px;
    transition: transform 0.3s ease;
}

.upload-book:hover .upload-icon {
    transform: scale(1.1);
}

.upload-book p {
    color: var(--text-medium);
    font-size: 1.2rem;
    font-weight: 500;
}

/* Processing Screen */
.processing-screen {
    height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    background-color: #0a0a0a;
}

.loading-container {
    width: 300px;
    height: 300px;
    position: relative;
}

.book-loading {
    width: 100px;
    height: 150px;
    position: absolute;
    top: 50%;
    left: 50%;
    margin-top: -75px;
    margin-left: -50px;
    perspective: 500px;
    transform-style: preserve-3d;
}

.book-loading .page {
    width: 100px;
    height: 150px;
    position: absolute;
    top: 0;
    left: 0;
    background-color: #f5f5f5;
    transform-origin: left center;
    border-radius: 0 5px 5px 0;
    animation: flip-page 2s infinite linear;
    box-shadow: 0 0 5px rgba(0, 0, 0, 0.5);
}

.book-loading .page:nth-child(1) {
    animation-delay: 0s;
    background-color: #f0f0f0;
}

.book-loading .page:nth-child(2) {
    animation-delay: 0.25s;
    background-color: #e8e8e8;
}

.book-loading .page:nth-child(3) {
    animation-delay: 0.5s;
    background-color: #e0e0e0;
}

.book-loading .page:nth-child(4) {
    animation-delay: 0.75s;
    background-color: #d8d8d8;
}

.book-loading .page:nth-child(5) {
    animation-delay: 1s;
    background-color: #d0d0d0;
}

.book-loading .cover {
    width: 100px;
    height: 150px;
    position: absolute;
    top: 0;
    left: 0;
    background-color: #8c1a11;
    z-index: 10;
    border-radius: 0 5px 5px 0;
    transform-origin: left center;
    transform: rotateY(0deg);
    box-shadow: 2px 2px 5px rgba(0, 0, 0, 0.5);
}

@keyframes flip-page {
    0% {
        transform: rotateY(0deg);
    }
    20% {
        transform: rotateY(-180deg);
    }
    100% {
        transform: rotateY(-180deg);
    }
}

.processing-status {
    margin-top: 30px;
    font-size: 1.5rem;
    text-align: center;
}

.progress-bar {
    width: 300px;
    height: 10px;
    background-color: #333;
    border-radius: 5px;
    margin-top: 20px;
    overflow: hidden;
}

.progress {
    height: 100%;
    background-color: #d4af37;
    width: 0%;
    border-radius: 5px;
    transition: width 0.5s ease;
}

/* Visual Novel Screen */
.vn-screen {
    width: 100vw;
    height: 100vh;
    position: relative;
    overflow: hidden;
}

.vn-background {
    width: 100%;
    height: 100%;
    background-color: #1a1a1a;
    background-size: cover;
    background-position: center;
    position: absolute;
    top: 0;
    left: 0;
    transition: background-image 1s ease;
}

.vn-character-container {
    width: 100%;
    height: 70%;
    position: absolute;
    bottom: 30%;
    display: flex;
    justify-content: center;
    align-items: flex-end;
}

.vn-character {
    height: 90%;
    opacity: 0;
    transition: opacity 0.5s ease;
    margin: 0 -50px;
}

.vn-character.active {
    opacity: 1;
}

.vn-textbox {
    width: 90%;
    max-width: 1000px;
    height: 25%;
    background-color: rgba(0, 0, 0, 0.7);
    border: 2px solid #d4af37;
    border-radius: 10px;
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    padding: 20px;
    color: white;
    overflow: hidden;
}

.vn-speaker {
    position: absolute;
    top: 0;
    left: 20px;
    background-color: #d4af37;
    color: #000;
    padding: 5px 20px;
    border-radius: 15px;
    font-weight: bold;
}

.vn-text {
    margin-top: 10px;
    font-size: 1.2rem;
    line-height: 1.5;
}

.vn-choices {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 20px;
}

.vn-choice {
    background-color: rgba(212, 175, 55, 0.2);
    border: 1px solid #d4af37;
    border-radius: 5px;
    padding: 8px 15px;
    color: white;
    cursor: pointer;
    transition: all 0.3s ease;
}

.vn-choice:hover {
    background-color: rgba(212, 175, 55, 0.4);
}

.vn-controls {
    position: absolute;
    top: 10px;
    right: 10px;
    display: flex;
    gap: 10px;
}

.vn-control-btn {
    width: 40px;
    height: 40px;
    background-color: rgba(0, 0, 0, 0.5);
    border: 1px solid #d4af37;
    border-radius: 50%;
    color: #d4af37;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    transition: all 0.3s ease;
}

.vn-control-btn:hover {
    background-color: rgba(0, 0, 0, 0.8);
}

.vn-continue {
    position: absolute;
    bottom: 10px;
    right: 10px;
    font-size: 1.5rem;
    color: #d4af37;
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0% {
        opacity: 0.2;
    }
    50% {
        opacity: 1;
    }
    100% {
        opacity: 0.2;
    }
}

/* Upload Modal */
.upload-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(0, 0, 0, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.upload-form {
    width: 90%;
    max-width: 500px;
    background-color: #241005;
    border: 2px solid #d4af37;
    border-radius: 10px;
    padding: 30px;
    position: relative;
}

.close-modal {
    position: absolute;
    top: 10px;
    right: 10px;
    font-size: 1.5rem;
    background: none;
    border: none;
    color: #d4af37;
    cursor: pointer;
}

.upload-form h2 {
    font-size: 1.8rem;
    margin-bottom: 20px;
    color: #d4af37;
    text-align: center;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: bold;
    color: #e0e0e0;
}

.form-group input {
    width: 100%;
    padding: 10px;
    border: 1px solid #666;
    background-color: #333;
    color: white;
    border-radius: 5px;
}

.file-upload {
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    width: 100%;
    height: 150px;
    border: 2px dashed #d4af37;
    border-radius: 5px;
    cursor: pointer;
    margin-bottom: 20px;
}

.file-upload p {
    color: #e0e0e0;
    margin-top: 10px;
}

.file-upload input {
    position: absolute;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
}

.submit-btn {
    width: 100%;
    padding: 12px;
    background-color: #d4af37;
    color: #000;
    border: none;
    border-radius: 5px;
    font-size: 1rem;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
}

.submit-btn:hover {
    background-color: #b38f1d;
}


/* Adjust the background image sizing and positioning */
.vn-background {
    background-size: cover;
    background-position: center center;
    background-repeat: no-repeat;
    transition: background-image 1s ease;
}

/* Style the character images */
.vn-character {
    height: 90%;
    width: auto;
    max-width: 300px;
    background-size: contain;
    background-position: bottom center;
    background-repeat: no-repeat;
    opacity: 0;
    transition: opacity 0.5s ease;
    margin: 0 -30px;
    position: relative;
}

.vn-character.active {
    opacity: 1;
}

/* Add loading animation for image generation */
@keyframes pulse-opacity {
    0% { opacity: 0.4; }
    50% { opacity: 0.8; }
    100% { opacity: 0.4; }
}

.vn-loading-image {
    animation: pulse-opacity 1.5s infinite;
    background-color: rgba(100, 100, 100, 0.3);
    border-radius: 10px;
}

/* Improve character container spacing */
.vn-character-container {
    width: 100%;
    height: 70%;
    position: absolute;
    bottom: 30%;
    display: flex;
    justify-content: center;
    align-items: flex-end;
    overflow: hidden;
}

/* Footer */
footer {
    text-align: center;
    padding: 10px;
    background: var(--background-dark);
    color: var(--text-light);
    font-size: 0.9rem;
    position: fixed;
    bottom: 0;
    width: 100%;
    box-shadow: 0 -2px 5px rgba(0, 0, 0, 0.2);
}

.footer-image-container {
    margin-top: 20px;
}

.footer-image {
    width: 100%;
    height: auto;
    max-height: 200px;
    display: block;
}