@import url('https://fonts.googleapis.com/css2?family=Press+Start+2P&family=Orbitron:wght@400;700;900&family=Roboto+Mono:wght@300;400;700&display=swap');

:root {
    --primary-color: #00ffcc; /* 赛博青色 */
    --secondary-color: #ff00ff; /* 赛博粉色 */
    --background-color: #1a0e2a; /* 深邃紫黑 */
    --text-color: #e0e0e0;
    --glow-color: rgba(0, 255, 204, 0.8);
    --title-font: 'Orbitron', 'Press Start 2P', sans-serif; /* 标题用Orbitron或像素风 */
    --body-font: 'Roboto Mono', monospace; /* 正文用等宽 */
}

body {
    background-color: var(--background-color);
    color: var(--text-color);
    font-family: var(--body-font);
    margin: 0;
    padding: 0; /* Base padding, can be overridden by media queries */
    overflow-x: hidden; /* 防止横向滚动 */
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    perspective: 1000px; /* 为3D翻页效果准备 */
    background-image:
        linear-gradient(45deg, rgba(255,0,255,0.1) 25%, transparent 25%, transparent 75%, rgba(255,0,255,0.1) 75%),
        linear-gradient(45deg, rgba(255,0,255,0.1) 25%, transparent 25%, transparent 75%, rgba(255,0,255,0.1) 75%),
        linear-gradient(to bottom, rgba(26, 14, 42, 0.95), rgba(40, 10, 60, 0.98));
    background-size: 60px 60px, 60px 60px, 100% 100%;
    background-position: 0 0, 30px 30px, 0 0;
    animation: backgroundShift 20s linear infinite;
}

@keyframes backgroundShift {
    0% { background-position: 0 0, 30px 30px, 0 0; }
    100% { background-position: 60px 60px, 90px 90px, 0 0; }
}

.container {
    width: 90%;
    max-width: 800px;
    background-color: rgba(10, 5, 20, 0.85);
    border: 2px solid var(--primary-color);
    box-shadow: 0 0 25px var(--glow-color), 0 0 10px var(--secondary-color) inset;
    padding: 30px;
    margin: 20px auto; /* Ensure centering if body align-items is changed */
    border-radius: 10px;
    text-align: center;
    animation: fadeIn 1s ease-out;
    position: relative; /* For page flip */
    transform-style: preserve-3d; /* For page flip */
    box-sizing: border-box; /* Ensure padding and border are included in width/height */
}

h1, h2 {
    font-family: var(--title-font);
    color: var(--primary-color);
    text-shadow:
        0 0 5px var(--glow-color),
        0 0 10px var(--glow-color),
        0 0 15px var(--glow-color),
        0 0 20px var(--secondary-color),
        2px 2px 2px #000;
    animation: flicker 3s infinite alternate, titlePop 0.5s ease-out;
    letter-spacing: 2px;
    margin-bottom: 20px;
    word-wrap: break-word; /* Ensure long titles wrap */
}

h1 {
    font-size: 2.8em; /* 夸张字体 */
    font-weight: 900;
}

h2 {
    font-size: 2em;
    font-weight: 700;
}

p {
    font-size: 1.1em;
    line-height: 1.8;
    text-align: left;
    margin-bottom: 1.5em;
    color: #ccc; /* 稍暗的正文颜色，突出标题 */
    word-wrap: break-word;
}

p strong { /* 强调文本 */
    color: var(--primary-color);
    font-weight: bold;
    text-shadow: 0 0 3px var(--glow-color);
}

.button {
    font-family: var(--title-font);
    background-color: transparent;
    color: var(--primary-color);
    border: 2px solid var(--primary-color);
    padding: 15px 30px;
    font-size: 1.2em;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.3s ease;
    border-radius: 5px;
    box-shadow: 0 0 10px var(--glow-color);
    margin: 10px;
    display: inline-block;
    box-sizing: border-box;
}

.button:hover, .button:focus {
    background-color: var(--primary-color);
    color: var(--background-color);
    box-shadow: 0 0 20px var(--glow-color), 0 0 30px var(--secondary-color);
    transform: translateY(-3px) scale(1.05);
}

.nav-buttons {
    margin-top: 40px;
    display: flex;
    justify-content: space-between; /* For PC layout */
    align-items: center; /* For PC layout */
    flex-wrap: wrap; /* Allow buttons to wrap on medium screens if needed before full stacking */
}

/* 特效 */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(20px) scale(0.95); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes titlePop {
    0% { transform: scale(0.5); opacity: 0; }
    70% { transform: scale(1.1); }
    100% { transform: scale(1); opacity: 1; }
}

@keyframes flicker {
    0%, 100% { text-shadow: 0 0 5px var(--glow-color), 0 0 10px var(--glow-color), 0 0 15px var(--secondary-color), 2px 2px 2px #000; opacity: 1; }
    50% { text-shadow: 0 0 3px var(--glow-color), 0 0 8px var(--secondary-color), 2px 2px 2px #000; opacity: 0.85; }
}

/* 翻页动画 - 基本淡入淡出 */
.page-content {
    animation: pageEnter 0.7s cubic-bezier(0.250, 0.460, 0.450, 0.940) both;
}

.page-exit {
    animation: pageExit 0.5s cubic-bezier(0.550, 0.085, 0.680, 0.530) both;
}

@keyframes pageEnter {
    0% {
        opacity: 0;
        transform: translateX(100px) scale(0.9);
    }
    100% {
        opacity: 1;
        transform: translateX(0) scale(1);
    }
}

@keyframes pageExit {
    0% {
        opacity: 1;
        transform: translateX(0) scale(1);
    }
    100% {
        opacity: 0;
        transform: translateX(-100px) scale(0.9);
    }
}

/* 封面专属 */
.cover-title {
    font-size: 4em; /* 巨大标题 */
    margin-bottom: 30px;
}
.cover-subtitle {
    font-size: 1.5em;
    color: var(--secondary-color);
    margin-bottom: 40px;
    font-family: var(--body-font);
    font-style: italic;
}

/* 章节内容容器 */
#chapter-text-container {
    text-align: justify; /* 两端对齐，更有书的感觉 */
    max-height: 60vh; /* 如果内容过多，出现滚动条 */
    overflow-y: auto;
    padding-right: 15px; /* 为滚动条留出空间 */
    scrollbar-width: thin;
    scrollbar-color: var(--primary-color) var(--background-color);
}

#chapter-text-container::-webkit-scrollbar {
    width: 8px;
}
#chapter-text-container::-webkit-scrollbar-track {
    background: rgba(255,255,255,0.1);
    border-radius: 4px;
}
#chapter-text-container::-webkit-scrollbar-thumb {
    background-color: var(--primary-color);
    border-radius: 4px;
    border: 2px solid var(--background-color);
}
#chapter-text-container p:first-of-type {
    margin-top: 0;
}


/* ========================================== */
/*            RESPONSIVE STYLES               */
/* ========================================== */

/* Medium screens / Tablets (e.g., up to 1024px) */
@media (max-width: 1024px) {
    h1 {
        font-size: 2.5em;
    }
    h2 {
        font-size: 1.8em;
    }
    .cover-title {
        font-size: 3.5em;
    }
    .cover-subtitle {
        font-size: 1.3em;
    }
    p {
        font-size: 1.05em;
    }
}


/* Mobile & Smaller Tablets (up to 768px) */
@media (max-width: 768px) {
    body {
        padding: 15px 0; /* Add some vertical padding on body for mobile */
        /* If content overflows vertically, allow scrolling from top */
        justify-content: flex-start;
        /* align-items: center; will still center the container horizontally */
    }

    .container {
        width: 90%;
        padding: 20px;
        margin-top: 20px; /* Ensure space from top */
        margin-bottom: 20px; /* Ensure space at bottom */
    }

    h1 {
        font-size: 2em;
        letter-spacing: 1.5px;
    }

    h2 {
        font-size: 1.6em;
    }

    p {
        font-size: 0.95em;
        line-height: 1.7;
        text-align: left; /* Keep left align for readability on mobile */
    }
    #chapter-text-container p { /* Paragraphs inside chapter text container */
         text-align: justify; /* Keep justified for book feel if desired */
    }


    .button {
        font-size: 1em;
        padding: 12px 20px;
        display: block; /* Make buttons stack */
        width: 100%;    /* Full width of their parent (e.g. .container or .nav-buttons) */
        max-width: 320px; /* Max width for buttons for better aesthetics */
        margin-left: auto; /* Center the button if its parent is wider */
        margin-right: auto;
        margin-top: 15px;
        margin-bottom: 15px;
    }
    .button:first-child {
         margin-top: 20px; /* Ensure first button has enough top margin */
    }
     .button:last-child {
         margin-bottom: 0;
    }


    .button:hover, .button:focus {
        transform: translateY(-2px) scale(1.03); /* Less dramatic hover on mobile */
    }

    .nav-buttons {
        margin-top: 30px;
        flex-direction: column; /* Stack nav buttons */
        align-items: center; /* Center buttons in the column */
        gap: 15px; /* Space between stacked buttons */
    }
    .nav-buttons .button {
        width: 80%; /* Nav buttons can be a bit wider, still respecting max-width */
        margin: 0; /* gap property handles spacing */
    }


    .cover-title {
        font-size: 2.5em;
        margin-bottom: 20px;
    }

    .cover-subtitle {
        font-size: 1.1em;
        margin-bottom: 25px;
    }

    #chapter-text-container {
        max-height: 60vh; /* Adjust if needed, vh is good for responsiveness */
        padding-right: 10px; /* Smaller padding for scrollbar */
    }

    #chapter-text-container::-webkit-scrollbar {
        width: 6px;
    }
    #chapter-text-container::-webkit-scrollbar-thumb {
        border: 1px solid var(--background-color);
    }
}

/* Smaller Mobile Phones (e.g., up to 480px) */
@media (max-width: 480px) {
    .container {
        width: 95%; /* Use more screen width */
        padding: 15px;
    }

    h1 {
        font-size: 1.8em;
        letter-spacing: 1px;
    }
    .cover-title {
        font-size: 2.2em;
    }

    h2 {
        font-size: 1.4em;
    }
    .cover-subtitle {
        font-size: 1em;
    }

    p {
        font-size: 0.9em;
        line-height: 1.6;
    }

    .button {
        font-size: 0.95em;
        padding: 10px 18px;
        /* width: 90%; Max-width from 768px query still applies */
    }
    .nav-buttons {
        margin-top: 25px;
        gap: 10px; /* Smaller gap for smaller screens */
    }
    .nav-buttons .button {
        width: 90%; /* Can make nav buttons wider on very small screens */
    }


    #chapter-text-container {
        max-height: 55vh; /* Potentially reduce height to show more surrounding UI */
    }
}