:root {
    --bg-color: #1a1a1a;
    --text-color: #f0f0f0;
    --accent-color: #d4a373;
    --glass-bg: rgba(255, 255, 255, 0.1);
    --glass-border: rgba(255, 255, 255, 0.2);
    --shelf-height: 120px;
    --book-width: 30px;
    --book-height: 80px;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Outfit', sans-serif;
    color: var(--text-color);
    background-image: url('assets/images/background.webp');
    background-size: cover;
    background-position: center;
    background-attachment: fixed;
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
}

#game-container {
    width: 100%;
    max-width: 1200px;
    height: 100vh;
    display: flex;
    flex-direction: column;
    padding: 20px;
    background-color: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(5px);
}

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
}

.game-title {
    font-family: 'Playfair Display', serif;
    font-size: 3rem;
    color: var(--accent-color);
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
    letter-spacing: 2px;
}

.glass-panel {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    backdrop-filter: blur(10px);
    border-radius: 12px;
    padding: 15px 25px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

#stats-panel {
    display: flex;
    gap: 30px;
}

.stat-item {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.stat-item .label {
    font-size: 0.8rem;
    text-transform: uppercase;
    opacity: 0.7;
    margin-bottom: 4px;
}

.stat-item .value {
    font-size: 1.5rem;
    font-weight: 600;
}

#bookshelf-area {
    flex-grow: 1;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 40px;
    align-content: center;
    padding: 20px;
}

.shelf-container {
    position: relative;
    height: var(--shelf-height);
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    align-items: center;
    padding: 0 0px;
    cursor: pointer;
    transition: transform 0.2s;
    background-color: transparent;
}

.shelf-container:hover {
    transform: translateY(-5px);
}

.shelf-container.selected {
    outline: 3px solid var(--accent-color);
    outline-offset: 20px;
    border-radius: 6px;
}

.shelf-container.full {
    outline: 3px solid #ff4d4d;
    outline-offset: 15px;
    border-radius: 6px;
    box-shadow: 0 0 20px rgba(255, 77, 77, 0.3);
}

.shelf-image {
    position: absolute;
    bottom: -15px;
    left: 25%;
    width: 75%;
    height: 30px;
    background-image: url('assets/images/shelf.webp');
    background-repeat: no-repeat;
    background-size: 100% 100%;
    z-index: 1;
}

.books-stack {
    display: flex;
    align-items: flex-end;
    justify-content: center;
    gap: 2px;
    z-index: 2;
    width: 100%;
    margin-bottom: 10px;
}

.book {
    width: var(--book-width);
    height: var(--book-height);
    background-size: cover;
    background-position: center;
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.book.raised {
    transform: translateY(-8px);
}

.book.moving {
    pointer-events: none;
    z-index: 100;
}

footer {
    display: flex;
    justify-content: center;
    padding: 20px;
}

.controls {
    display: flex;
    gap: 15px;
}

.btn {
    background-color: var(--accent-color);
    color: #2b1f14;
    border: none;
    padding: 12px 24px;
    font-size: 1rem;
    font-weight: 600;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    text-transform: uppercase;
    font-family: 'Outfit', sans-serif;
}

.btn:hover {
    background-color: #e5b98f;
    transform: scale(1.05);
}

.btn.secondary {
    background-color: transparent;
    border: 2px solid var(--accent-color);
    color: var(--accent-color);
}

.btn.secondary:hover {
    background-color: var(--accent-color);
    color: #2b1f14;
}

/* Modal Styles */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    backdrop-filter: blur(8px);
}

.modal.hidden {
    display: none;
}

.modal-content {
    text-align: center;
    max-width: 500px;
    width: 90%;
}

.modal-content h2 {
    font-family: 'Playfair Display', serif;
    font-size: 2.5rem;
    margin-bottom: 20px;
    color: var(--accent-color);
}

.modal-content p,
.modal-content ul {
    margin-bottom: 30px;
    line-height: 1.6;
}

.modal-content ul {
    text-align: left;
    padding-left: 20px;
}

.modal-content li {
    margin-bottom: 10px;
}

/* Animations */
@keyframes bookEnter {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.book {
    animation: bookEnter 0.5s ease forwards;
}

/* Wizard Styles */
.wizard-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 150px;
    z-index: 50;
    pointer-events: none;
    filter: drop-shadow(0 0 10px rgba(212, 163, 115, 0.4));
}

#wizard-img {
    width: 100%;
    height: auto;
    display: block;
    animation: wizardFloat 4s ease-in-out infinite;
}

@keyframes wizardFloat {

    0%,
    100% {
        transform: translateY(0) rotate(-2deg);
    }

    50% {
        transform: translateY(-15px) rotate(2deg);
    }
}

@media (max-width: 768px) {
    .wizard-container {
        width: 100px;
        bottom: 10px;
        right: 10px;
        opacity: 0.8;
    }
}

/* Stats UI */
.icon-btn {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    transition: transform 0.2s;
    margin-right: 5px;
}

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

.stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
    margin: 20px 0;
}

.stats-box {
    background: rgba(255, 255, 255, 0.05);
    padding: 15px;
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.stats-val {
    font-size: 1.8rem;
    font-weight: 600;
    color: var(--accent-color);
}

.stats-label {
    font-size: 0.8rem;
    opacity: 0.7;
    margin-top: 5px;
}

.history-chart {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    height: 100px;
    margin: 20px 0;
    padding: 0 10px;
}

.chart-bar-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    flex: 1;
}

.chart-bar {
    width: 60%;
    background: var(--accent-color);
    border-radius: 4px 4px 0 0;
    min-height: 4px;
    transition: height 0.3s ease;
    opacity: 0.3;
}

.chart-bar.filled {
    opacity: 1;
}

.chart-label {
    font-size: 0.6rem;
    margin-top: 5px;
    opacity: 0.6;
}

.next-puzzle-container {
    background: rgba(212, 163, 115, 0.1);
    padding: 15px;
    border-radius: 12px;
    margin: 20px 0;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.countdown-value {
    font-family: monospace;
    font-size: 1.4rem;
    display: block;
    margin-top: 5px;
    color: var(--accent-color);
    font-weight: 600;
}

.mt-20 {
    margin-top: 20px;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
}

/* Responsive Adjustments */
@media (max-width: 900px) {
    :root {
        --shelf-height: 100px;
        --book-width: 25px;
        --book-height: 70px;
    }

    .game-title {
        font-size: 2.2rem;
    }

    #stats-panel {
        gap: 15px;
        padding: 10px 15px;
    }

    .stat-item .value {
        font-size: 1.2rem;
    }
}

@media (max-width: 600px) {
    :root {
        --shelf-height: 80px;
        --book-width: 18px;
        --book-height: 50px;
    }

    #game-container {
        padding: 10px;
    }

    header {
        flex-direction: column;
        gap: 15px;
        margin-bottom: 20px;
    }

    .game-title {
        font-size: 1.8rem;
    }

    #stats-panel {
        width: 100%;
        justify-content: space-around;
    }

    #bookshelf-area {
        grid-template-columns: repeat(2, 1fr);
        gap: 15px;
        padding: 10px;
    }

    .shelf-container.selected {
        outline-offset: 10px;
    }

    .shelf-image {
        height: 20px;
        bottom: -10px;
    }

    .modal-content h2 {
        font-size: 1.8rem;
    }

    .btn {
        padding: 10px 18px;
        font-size: 0.9rem;
    }

    .wizard-container {
        width: 80px;
    }
}

@media (max-width: 400px) {
    #bookshelf-area {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }

    :root {
        --book-width: 15px;
        --book-height: 40px;
    }
}