:root {
    --primary-color: #6a0572;
    /* Deep Purple */
    --secondary-color: #ab83a1;
    /* Soft Lilac */
    --accent-color: #d4af37;
    /* Gold */
    --bg-color: #fce4ec;
    /* Light Pink */
    --text-color: #2c3e50;
    --page-bg: #fffbf0;
    /* Cream/Paper */
    --book-width: 420px;
    /* Slightly wider */
    --book-height: 580px;
    --anim-speed: 1s;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Lato', sans-serif;
    background: linear-gradient(135deg, #ff9a9e 0%, #fecfef 99%, #fecfef 100%);
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
}

/* Background Animation */
body::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: url('data:image/svg+xml;utf8,<svg width="40" height="40" viewBox="0 0 40 40" xmlns="http://www.w3.org/2000/svg"><text x="10" y="25" font-size="20">♥️</text></svg>'),
        url('data:image/svg+xml;utf8,<svg width="40" height="40" viewBox="0 0 40 40" xmlns="http://www.w3.org/2000/svg"><text x="10" y="25" font-size="20">♠️</text></svg>');
    opacity: 0.1;
    animation: floatBackground 20s linear infinite;
    z-index: -1;
}

@keyframes floatBackground {
    0% {
        background-position: 0 0;
    }

    100% {
        background-position: 100% 100%;
    }
}

/* 3D Scene */
#scene {
    width: var(--book-width);
    height: var(--book-height);
    perspective: 1500px;
    position: relative;
    transition: transform 1s;
}

#book {
    width: 100%;
    height: 100%;
    position: relative;
    transform-style: preserve-3d;
    transition: transform 1s;
}

/* Book Opening State */
body.book-open #scene {
    transform: translateX(50%);
}

body.book-open #book {
    transform: rotateY(0deg);
}

/* Pages */
.page {
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
    transform-origin: left;
    transform-style: preserve-3d;
    transition: transform var(--anim-speed) cubic-bezier(0.645, 0.045, 0.355, 1);
    background-color: var(--page-bg);
    box-shadow: inset 0 0 30px rgba(0, 0, 0, 0.1);
    border-radius: 5px 15px 15px 5px;
}

.page.flipped {
    transform: rotateY(-180deg);
}

/* Front and Back of Pages */
.front,
.back {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 30px;
    text-align: center;
    background-color: var(--page-bg);
    border: 1px solid #e0e0e0;
}

.back {
    transform: rotateY(180deg);
    border-radius: 15px 5px 5px 15px;
    background: linear-gradient(to right, #e3dac9, #fffbf0 20%);
}

.front {
    background: linear-gradient(to left, #e3dac9, #fffbf0 20%);
}

/* Cover Styling */
.cover .front {
    background: #4a148c;
    color: #fff;
    border: 2px solid #d4af37;
    border-radius: 5px 15px 15px 5px;
}

.cover .cover-content {
    border: 2px solid #d4af37;
    padding: 20px;
    height: 90%;
    width: 90%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

.cover h1 {
    font-family: 'Cinzel', serif;
    font-size: 2.5rem;
    margin-bottom: 10px;
    color: #d4af37;
}

.cover h2 {
    font-family: 'Dancing Script', cursive;
    font-size: 1.8rem;
    margin-bottom: 20px;
}

/* Typography */
h3 {
    font-family: 'Cinzel', serif;
    color: var(--primary-color);
    margin-bottom: 10px;
    font-size: 1.4rem;
}

p {
    font-size: 1rem;
    line-height: 1.5;
    margin-bottom: 10px;
    color: var(--text-color);
}

.instruction {
    font-style: italic;
    color: #888;
    font-size: 0.9rem;
    margin-top: 10px;
}

hr {
    border: 0;
    height: 1px;
    background: #ccc;
    width: 50%;
    margin: 15px auto;
}

/* Images */
.polaroid {
    background: white;
    padding: 10px 10px 30px 10px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
    transform: rotate(-3deg);
    max-width: 80%;
    margin-bottom: 15px;
    border: 1px solid #ddd;
}

.polaroid-small {
    background: white;
    padding: 5px 5px 20px 5px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    transform: rotate(2deg);
    max-width: 50%;
    margin-bottom: 10px;
    border: 1px solid #ddd;
}

/* Buttons */
button {
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 8px 16px;
    font-family: 'Cinzel', serif;
    font-size: 0.9rem;
    cursor: pointer;
    border-radius: 20px;
    transition: transform 0.2s, background 0.2s;
    margin-top: 10px;
}

button:hover {
    transform: scale(1.05);
    background: var(--secondary-color);
}

/* Minigames Containers */
.minigame-container {
    width: 100%;
    min-height: 150px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    background: rgba(255, 255, 255, 0.6);
    border-radius: 10px;
    padding: 10px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
}

/* Game 1: Rabbit */
.rabbit-choices {
    display: flex;
    gap: 10px;
}

/* Game 2: Memory */
.memory-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}

.memory-card {
    width: 50px;
    height: 70px;
    background: var(--primary-color);
    color: white;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 20px;
    cursor: pointer;
    border-radius: 5px;
    transform-style: preserve-3d;
    transition: transform 0.5s;
}

.memory-card.flipped {
    background: white;
    color: black;
    border: 2px solid var(--primary-color);
}

/* Game 3: Words */
.word-container {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    justify-content: center;
}

.word-piece {
    background: white;
    border: 1px solid var(--primary-color);
    padding: 5px 8px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 0.9rem;
}

/* Game 4: CM Mode */
.post {
    background: white;
    border: 1px solid #ddd;
    padding: 8px;
    margin-bottom: 8px;
    width: 100%;
    text-align: left;
    border-radius: 5px;
    font-size: 0.85rem;
}

.post-actions span {
    cursor: pointer;
    margin-right: 8px;
    font-size: 1rem;
}

/* Responsive */
@media (max-width: 850px) {
    :root {
        --book-width: 320px;
        --book-height: 500px;
    }

    body.book-open #scene {
        transform: translateX(0);
    }

    #scene {
        transform: scale(0.9);
    }
}