:root {
    --primary-red: #8b1e1e;
    --ancient-gold: #c5a059;
    --parchment: #f4ecd8;
    --ink-black: #1a1a1a;
    --wood-brown: #3e2723;
    --border-color: #5d4037;
}

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

body {
    font-family: "Noto Serif SC", "SimSun", "STSong", serif;
    background-color: var(--wood-brown);
    background-image: url('https://www.transparenttextures.com/patterns/dark-wood.png');
    /* Subtle wood texture */
    color: var(--ink-black);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    overflow-x: hidden;
    overflow-y: auto;
    padding: 20px;
}

.game-wrapper {
    position: relative;
    padding: 15px;
    background-color: var(--parchment);
    background-image: url('https://www.transparenttextures.com/patterns/paper.png');
    /* Paper texture */
    border: 8px double var(--border-color);
    box-shadow: 0 0 30px rgba(0, 0, 0, 0.5), inset 0 0 100px rgba(139, 30, 30, 0.05);
    border-radius: 4px;
    width: min(95vw, 860px);
    /* Ensure it expands but doesn't overflow */
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.header {
    width: 100%;
    text-align: center;
    margin-bottom: 15px;
    border-bottom: 2px solid var(--border-color);
    padding-bottom: 10px;
}

.header h1 {
    font-size: clamp(1.2rem, 5vw, 2.2rem);
    /* Dynamic font size */
    color: var(--primary-red);
    text-shadow: 1px 1px 0px var(--ancient-gold);
    letter-spacing: 4px;
}

#ruffle-container {
    width: 100%;
    /* Take up all available space in the wrapper */
    aspect-ratio: 4 / 3;
    background: transparent;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
}

ruffle-player {
    --splash-screen-background: var(--ink-black);
    width: 100% !important;
    height: 100% !important;
    display: block;
}

footer {
    margin-top: 20px;
    font-family: "SimSun", serif;
    color: var(--parchment);
    text-shadow: 1px 1px 2px #000;
    opacity: 0.8;
    text-align: center;
}

/* Responsive adjustments */
@media (max-width: 600px) {
    body {
        padding: 10px;
    }

    .game-wrapper {
        padding: 8px;
        border-width: 4px;
    }

    .header h1 {
        letter-spacing: 2px;
    }
}

/* Footer Link */
footer a {
    color: var(--parchment);
    text-decoration: underline;
    cursor: pointer;
    margin-left: 5px;
    transition: color 0.3s ease;
}

footer a:hover {
    color: var(--ancient-gold);
}

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

.modal.active {
    display: flex;
}

.modal-content {
    position: relative;
    background-color: var(--parchment);
    background-image: url('https://www.transparenttextures.com/patterns/paper.png');
    padding: 30px;
    border: 6px double var(--border-color);
    width: min(90%, 500px);
    border-radius: 4px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.7);
    animation: modal-appear 0.4s cubic-bezier(0.18, 0.89, 0.32, 1.28);
}

@keyframes modal-appear {
    from {
        transform: scale(0.8);
        opacity: 0;
    }

    to {
        transform: scale(1);
        opacity: 1;
    }
}

.close-button {
    position: absolute;
    right: 15px;
    top: 10px;
    color: var(--primary-red);
    font-size: 32px;
    font-weight: bold;
    cursor: pointer;
    line-height: 1;
    transition: transform 0.2s ease;
}

.close-button:hover {
    color: var(--ancient-gold);
    transform: rotate(90deg);
}

.modal h2 {
    color: var(--primary-red);
    border-bottom: 2px solid var(--border-color);
    padding-bottom: 12px;
    margin-bottom: 20px;
    font-size: 1.6rem;
    text-align: center;
}

.modal-body p {
    margin-bottom: 15px;
    line-height: 1.8;
    color: var(--wood-brown);
    font-size: 1.05rem;
    text-align: justify;
}