:root {
    --bg-paper: #f4f1e8;
    --ink-black: #2b2b2b;
    --seal-red: #b22222;
    --jade-green: #2e8b57;
    --royal-gold: #daa520;
    --comic-font: "Comic Sans MS", "Chalkboard SE", sans-serif;
    --classic-font: "KaiTi", "SimKai", "STKaiti", "Georgia", serif;
    --code-bg: #f0f0f0;
}

body {
    background-color: #dedede;
    background-image: url("data:image/svg+xml,%3Csvg width='100' height='100' viewBox='0 0 100 100' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M11 18c3.866 0 7-3.134 7-7s-3.134-7-7-7-7 3.134-7 7 3.134 7 7 7zm48 25c3.866 0 7-3.134 7-7s-3.134-7-7-7-7 3.134-7 7 3.134 7 7 7zm-43-7c1.657 0 3-1.343 3-3s-1.343-3-3-3-3 1.343-3 3 1.343 3 3 3zm63 31c1.657 0 3-1.343 3-3s-1.343-3-3-3-3 1.343-3 3 1.343 3 3 3zM34 90c1.657 0 3-1.343 3-3s-1.343-3-3-3-3 1.343-3 3 1.343 3 3 3zm56-76c1.657 0 3-1.343 3-3s-1.343-3-3-3-3 1.343-3 3 1.343 3 3 3zM12 86c2.21 0 4-1.79 4-4s-1.79-4-4-4-4 1.79-4 4 1.79 4 4 4zm28-65c2.21 0 4-1.79 4-4s-1.79-4-4-4-4 1.79-4 4 1.79 4 4 4zm23-11c2.21 0 4-1.79 4-4s-1.79-4-4-4-4 1.79-4 4 1.79 4 4 4zm-6 60c2.21 0 4-1.79 4-4s-1.79-4-4-4-4 1.79-4 4 1.79 4 4 4zm29 22c2.21 0 4-1.79 4-4s-1.79-4-4-4-4 1.79-4 4 1.79 4 4 4zM32 63c2.21 0 4-1.79 4-4s-1.79-4-4-4-4 1.79-4 4 1.79 4 4 4zm57-13c2.21 0 4-1.79 4-4s-1.79-4-4-4-4 1.79-4 4 1.79 4 4 4zm-9-21c1.105 0 2-.895 2-2s-.895-2-2-2-2 .895-2 2 .895 2 2 2zM60 91c1.105 0 2-.895 2-2s-.895-2-2-2-2 .895-2 2 .895 2 2 2zM35 41c1.105 0 2-.895 2-2s-.895-2-2-2-2 .895-2 2 .895 2 2 2zM12 60c1.105 0 2-.895 2-2s-.895-2-2-2-2 .895-2 2 .895 2 2 2z' fill='%239C92AC' fill-opacity='0.1' fill-rule='evenodd'/%3E%3C/svg%3E");
    font-family: var(--classic-font);
    color: var(--ink-black);
    margin: 0;
    padding: 20px;
    line-height: 1.6;
}

.container {
    max-width: 900px;
    margin: 0 auto;
    background-color: var(--bg-paper);
    padding: 40px;
    box-shadow: 0 0 20px rgba(0,0,0,0.1);
    border: 1px solid #d4d1c8;
    position: relative;
    border-radius: 4px;
}

/* Decorative border simulating a book or scroll */
.container::before {
    content: "";
    position: absolute;
    top: 5px; left: 5px; right: 5px; bottom: 5px;
    border: 2px solid var(--ink-black);
    pointer-events: none;
    opacity: 0.1;
}

h1, h2, h3 {
    font-weight: bold;
    text-align: center;
    margin-top: 30px;
}

h1 {
    font-size: 2.5em;
    color: var(--seal-red);
    text-shadow: 1px 1px 0 rgba(0,0,0,0.1);
    border-bottom: 3px double var(--ink-black);
    padding-bottom: 10px;
    margin-bottom: 30px;
}

.chapter-title {
    font-size: 1.8em;
    color: var(--ink-black);
    margin-bottom: 20px;
    border-left: 5px solid var(--seal-red);
    padding-left: 15px;
    text-align: left;
}

/* Comic Panels */
.comic-panel {
    background: #fff;
    border: 3px solid var(--ink-black);
    margin: 20px 0;
    padding: 20px;
    position: relative;
    box-shadow: 5px 5px 0 rgba(0,0,0,0.2);
    display: flex;
    flex-direction: column;
    align-items: center;
}

.comic-panel.dialogue-row {
    flex-direction: row;
    align-items: flex-start;
    gap: 20px;
}

.character-avatar {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    border: 3px solid var(--ink-black);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    overflow: hidden;
    background-color: #fff;
    box-shadow: 2px 2px 5px rgba(0,0,0,0.2);
}

.character-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.speech-bubble {
    background: #fff;
    border: 2px solid var(--ink-black);
    border-radius: 15px;
    padding: 15px;
    position: relative;
    font-family: var(--comic-font);
    font-size: 1.1em;
    flex-grow: 1;
}

.speech-bubble::after {
    content: '';
    position: absolute;
    border-style: solid;
    border-width: 10px 10px 10px 0;
    border-color: transparent var(--ink-black) transparent transparent;
    display: block;
    width: 0;
    z-index: 1;
    left: -12px;
    top: 20px;
}

.speech-bubble.right::after {
    border-width: 10px 0 10px 10px;
    border-color: transparent transparent transparent var(--ink-black);
    right: -12px;
    left: auto;
}

/* Code Blocks */
pre {
    background-color: var(--code-bg);
    border: 1px solid #ccc;
    padding: 15px;
    border-radius: 5px;
    overflow-x: auto;
    font-family: 'Consolas', 'Monaco', monospace;
    position: relative;
}

pre::before {
    content: "📜 御书房秘籍";
    position: absolute;
    top: 0;
    right: 0;
    background: var(--jade-green);
    color: white;
    font-size: 0.8em;
    padding: 2px 8px;
    border-bottom-left-radius: 5px;
}

code {
    font-family: 'Consolas', 'Monaco', monospace;
    color: #d63384;
}

/* Interactive Elements */
.interactive-box {
    border: 2px dashed var(--royal-gold);
    background-color: #fffdf5;
    padding: 20px;
    margin: 20px 0;
    border-radius: 8px;
}

.btn-seal {
    background-color: var(--seal-red);
    color: white;
    border: none;
    padding: 10px 20px;
    font-family: var(--classic-font);
    font-size: 1.2em;
    cursor: pointer;
    border-radius: 4px;
    transition: transform 0.1s;
    box-shadow: 0 4px 0 #800000;
}

.btn-seal:active {
    transform: translateY(4px);
    box-shadow: none;
}

.answer-area {
    display: none;
    margin-top: 15px;
    padding: 15px;
    background-color: #e8f5e9;
    border: 1px solid #c8e6c9;
    border-radius: 4px;
}

.answer-area.visible {
    display: block;
    animation: fadeIn 0.5s;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Navigation */
.nav-buttons {
    display: flex;
    justify-content: space-between;
    margin-top: 50px;
    border-top: 1px solid #ccc;
    padding-top: 20px;
}

.nav-link {
    text-decoration: none;
    color: var(--ink-black);
    font-weight: bold;
    display: flex;
    align-items: center;
    gap: 10px;
}

.nav-link:hover {
    color: var(--seal-red);
}

/* Unit Map (Index Page) */
.unit-card {
    border: 1px solid var(--ink-black);
    margin-bottom: 20px;
    background: #fff;
    transition: transform 0.2s;
}

.unit-card:hover {
    transform: scale(1.02);
    box-shadow: 0 10px 20px rgba(0,0,0,0.1);
}

.unit-header {
    background: var(--ink-black);
    color: white;
    padding: 10px 15px;
    font-size: 1.2em;
    display: flex;
    justify-content: space-between;
}

.unit-content {
    padding: 15px;
}

.chapter-list {
    list-style: none;
    padding: 0;
}

.chapter-list li {
    margin: 8px 0;
    padding-bottom: 8px;
    border-bottom: 1px dashed #eee;
}

.chapter-list a {
    text-decoration: none;
    color: #333;
    display: block;
}

.chapter-list a:hover {
    color: var(--seal-red);
}

.quiz-badge {
    background: var(--royal-gold);
    color: #000;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.8em;
    margin-left: 10px;
}
