:root {
    --bg-color: #f5f5dc;
    --text-color: #000000;
    --font-size: 18px;
    --brightness: 100%;
}

.night-mode {
    --bg-color: #1a1a1a;
    --text-color: #e0e0e0;
}

* {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html, body {
    background-color: var(--bg-color);
    color: var(--text-color);
    font-size: var(--font-size);
    filter: brightness(var(--brightness));
    line-height: 1.6;
    margin: 0;
    padding: 0;
    font-family: 'Georgia', serif;
    transition: all 0.3s ease;
    height: auto;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeSpeed;
}

.container {
    max-width: 800px;
    margin: 0 auto;
    padding: 20px;
    background-color: rgba(255, 255, 255, 0.05);
    border-radius: 10px;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.1);
}

/* 页眉样式 - 已修改手机端适配 */
.site-header {
    background-color: rgba(0, 0, 0, 0.1);
    padding: 15px 0;
    margin-bottom: 20px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
    will-change: transform;
}

.header-container {
    max-width: 800px;
    margin: 0 auto;
    padding: 0 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
}

.site-title {
    font-size: 1.5em;
    font-weight: bold;
    margin: 0;
    text-align: center;
    width: 100%;
}

.site-nav {
    display: flex;
    gap: 20px;
    justify-content: center;
    width: 100%;
    margin-top: 10px;
}

.site-nav a {
    color: var(--text-color);
    text-decoration: none;
    transition: color 0.3s ease;
}

.site-nav a:hover {
    color: #4CAF50;
}

/* 页脚样式 */
.site-footer {
    background-color: rgba(0, 0, 0, 0.1);
    padding: 20px 0;
    margin-top: 20px;
    border-top: 1px solid rgba(0, 0, 0, 0.1);
    text-align: center;
}

.footer-container {
    max-width: 800px;
    margin: 0 auto;
    padding: 0 20px;
}

.footer-links {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin-bottom: 10px;
    flex-wrap: wrap;
}

.footer-links a {
    color: var(--text-color);
    text-decoration: none;
    transition: color 0.3s ease;
}

.footer-links a:hover {
    color: #4CAF50;
}

.copyright {
    font-size: 0.9em;
    opacity: 0.8;
}

.controls {
    background-color: rgba(0, 0, 0, 0.1);
    padding: 15px;
    border-radius: 10px;
    margin-bottom: 20px;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
    transform: translateZ(0);
}

.control-group {
    display: flex;
    align-items: center;
    gap: 5px;
}

button, select, input {
    padding: 8px 12px;
    border: 1px solid #ccc;
    border-radius: 5px;
    background-color: white;
    cursor: pointer;
    transition: all 0.2s ease;
    -webkit-appearance: none;
    touch-action: manipulation;
}

button:hover {
    background-color: #f0f0f0;
    transform: translateY(-2px);
}

.navigation {
    display: flex;
    justify-content: space-between;
    margin: 30px 0;
    padding: 15px;
    background-color: rgba(0, 0, 0, 0.05);
    border-radius: 10px;
    transform: translateZ(0);
}

.nav-btn {
    min-width: 120px;
    font-weight: bold;
}

.content {
    padding: 20px;
    line-height: 1.8;
    transform: translateZ(0);
}

.chapter-title {
    text-align: center;
    margin-bottom: 30px;
    font-size: 1.8em;
    border-bottom: 2px solid var(--text-color);
    padding-bottom: 10px;
    will-change: transform;
}

.indent {
    text-indent: 2em;
}

.dialogue {
    margin-left: 3em;
}

/* 括号内文字样式 */
.content :not(.chapter-title) :matches(p, span, div) {
    font-style: normal;
}

.content :not(.chapter-title) :matches(p, span, div)::before,
.content :not(.chapter-title) :matches(p, span, div)::after {
    font-style: normal;
}

.content p:not(.chapter-title) {
    position: relative;
}

.bracket-text {
    color: #808080 !important;
    font-style: italic !important;
}

.notification {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 15px 20px;
    background-color: #4CAF50;
    color: white;
    border-radius: 5px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
    opacity: 0;
    transition: opacity 0.3s ease;
    z-index: 1000;
    will-change: opacity;
}

.notification.show {
    opacity: 1;
}

.scroll-controls {
    display: flex;
    align-items: center;
    gap: 5px;
}

.scroll-speed-display {
    min-width: 30px;
    text-align: center;
    font-weight: bold;
}

.scroll-active {
    background-color: #4CAF50;
    color: white;
}

/* 性能优化：减少重绘和重排 */
.controls,
.navigation,
.content {
    will-change: transform;
    backface-visibility: hidden;
}

/* 手机端优化 - 已修改页眉适配 */
@media (max-width: 768px) {
    /* 页眉在手机端居中显示 */
    .header-container {
        flex-direction: column;
        align-items: center;
        text-align: center;
        gap: 10px;
    }
    
    .site-title {
        width: 100%;
        margin-bottom: 10px;
    }
    
    .site-nav {
        width: 100%;
        justify-content: center;
        gap: 15px;
    }
    
    .navigation {
        flex-direction: column;
        align-items: center;
        gap: 10px;
    }
    
    .nav-btn {
        width: 100%;
        max-width: 250px;
    }
    
    .container {
        padding: 10px;
    }
    
    .content {
        padding: 10px;
    }
    
    .controls {
        padding: 10px;
    }
    
    .chapter-title {
        font-size: 1.5em;
        margin-bottom: 20px;
    }
    
    /* 优化字体渲染 */
    body {
        -webkit-font-smoothing: antialiased;
        -moz-osx-font-smoothing: grayscale;
    }
    
    /* 减少动画复杂度 */
    button:hover {
        transform: none;
    }
}

/* 超小屏幕优化 */
@media (max-width: 480px) {
    :root {
        --font-size: 16px;
    }
    
    .site-title {
        font-size: 1.3em;
    }
    
    .site-nav {
        gap: 10px;
        flex-wrap: wrap;
    }
    
    .site-nav a {
        font-size: 0.9em;
    }
    
    .footer-links {
        gap: 10px;
    }
    
    .footer-links a {
        font-size: 0.9em;
    }
}

/* 打印样式优化 */
@media print {
    .controls,
    .navigation,
    .site-header,
    .site-footer {
        display: none;
    }
    
    .container {
        box-shadow: none;
        background: none;
    }
}