body {
    margin: 0;
    overflow: hidden;
    background-color: #000000;
    color: #ffffff;
    font-family: "Courier New", Courier, monospace;
}

canvas {
    display: block;
    position: fixed;
    top: 0;
    left: 0;
    z-index: -1;
}

#info {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    z-index: 1;
    color: rgba(255, 255, 255, 0.8);
    animation: fadeIn 5s ease-in-out;
    transition: opacity 0.5s ease-in-out;
}

#info h1 {
    font-size: 3rem;
    margin: 0;
    letter-spacing: 0.5rem;
    text-transform: uppercase;
}

#narrative-container {
    position: absolute;
    bottom: 5%;
    left: 50%;
    transform: translateX(-50%);
    width: 80%;
    text-align: center;
    z-index: 1;
    pointer-events: none;
    transition: opacity 0.5s ease-in-out;
}

.narrative-text {
    font-size: 1.2rem;
    color: rgba(255, 255, 255, 0.7);
    opacity: 0;
    transition: opacity 2s ease-in-out;
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    white-space: nowrap;
}

#chat-icon {
    position: absolute;
    top: 20px;
    left: 20px;
    width: 29px;
    height: 29px;
    cursor: pointer;
    z-index: 100;
    animation: pulse-rotate 10s linear infinite;
}

@keyframes pulse-rotate {
    0% {
        transform: scale(1) rotate(0deg);
    }
    50% {
        transform: scale(1.2) rotate(180deg);
    }
    100% {
        transform: scale(1) rotate(360deg);
    }
}

#chat-icon img {
    width: 100%;
    height: 100%;
    filter: invert(1);
    opacity: 1;
}

#chat-window {
    position: absolute;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(0, 0, 0, 0.3);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 99;
    transition: opacity 0.5s ease-in-out;
    opacity: 1;
}

#chat-window.hidden {
    opacity: 0;
    pointer-events: none;
}

#chat-window:not(.hidden) ~ #info {
    opacity: 0;
    pointer-events: none;
}

#chat-window:not(.hidden) ~ #narrative-container {
    opacity: 0;
    pointer-events: none;
}

#chat-header {
    position: absolute;
    top: 20px;
    width: 100%;
    text-align: center;
    font-size: 1.5rem;
    color: rgba(255, 255, 255, 0.5);
}

#chat-messages {
    width: 80%;
    max-width: 900px;
    height: 70%;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    padding: 20px;
    border: none;
    scroll-behavior: smooth;
}

.message {
    margin-bottom: 10px;
    padding: 8px 12px;
    border-radius: 15px;
    max-width: 85%;
    line-height: 1.4;
    word-wrap: break-word;
    word-break: break-word;
    font-family: "Courier New", Courier, monospace;
    font-size: 14px;
    letter-spacing: 0.3px;
    backdrop-filter: blur(5px);
    white-space: pre-wrap;
    overflow-wrap: break-word;
}

/* Markdown content styling */
.message h1,
.message h2,
.message h3,
.message h4,
.message h5,
.message h6 {
    margin: 12px 0 6px 0;
    color: rgba(255, 255, 255, 0.95);
    line-height: 1.3;
    font-weight: bold;
}

.message h1 {
    font-size: 1.8em;
}
.message h2 {
    font-size: 1.6em;
}
.message h3 {
    font-size: 1.4em;
}
.message h4 {
    font-size: 1.2em;
}
.message h5 {
    font-size: 1.1em;
}
.message h6 {
    font-size: 1em;
}

.message p {
    margin: 4px 0;
    line-height: 1.4;
}

.message p:first-child {
    margin-top: 0;
}

.message p:last-child {
    margin-bottom: 0;
}

.message ul,
.message ol {
    margin: 10px 0;
    padding-left: 24px;
}

.message li {
    margin: 4px 0;
    line-height: 1.5;
}

.message blockquote {
    border-left: 4px solid rgba(255, 255, 255, 0.4);
    margin: 12px 0;
    padding-left: 16px;
    font-style: italic;
    color: rgba(255, 255, 255, 0.85);
    background-color: rgba(255, 255, 255, 0.02);
    border-radius: 0 8px 8px 0;
}

.message code {
    background-color: rgba(255, 255, 255, 0.15);
    color: #ffeb3b;
    padding: 2px 6px;
    border-radius: 4px;
    font-family: "Monaco", "Menlo", "Ubuntu Mono", monospace;
    font-size: 0.9em;
}

.message pre {
    background-color: rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.1);
    padding: 12px;
    border-radius: 8px;
    overflow-x: auto;
    margin: 12px 0;
    position: relative;
}

.message pre code {
    background-color: transparent;
    padding: 0;
    color: #f8f8f2;
}

.message table {
    border-collapse: collapse;
    width: 100%;
    margin: 12px 0;
    background-color: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    overflow: hidden;
}

.message table th,
.message table td {
    border: 1px solid rgba(255, 255, 255, 0.15);
    padding: 10px 12px;
    text-align: left;
}

.message table th {
    background-color: rgba(255, 255, 255, 0.1);
    font-weight: bold;
    color: rgba(255, 255, 255, 0.95);
}

.message table tr:nth-child(even) {
    background-color: rgba(255, 255, 255, 0.02);
}

.message strong,
.message b {
    color: rgba(255, 255, 255, 0.95);
    font-weight: bold;
}

.message em,
.message i {
    color: rgba(255, 255, 255, 0.9);
    font-style: italic;
}

.message a {
    color: #64b5f6;
    text-decoration: underline;
    transition: color 0.2s ease;
}

.message a:hover {
    color: #90caf9;
}

.message hr {
    border: none;
    height: 1px;
    background-color: rgba(255, 255, 255, 0.2);
    margin: 16px 0;
}

/* Math expressions */
.message .katex {
    color: #81c784;
}

.message .katex-display {
    margin: 12px 0;
    text-align: center;
}

/* Mermaid diagrams */
.message .mermaid {
    background-color: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    padding: 16px;
    margin: 12px 0;
    text-align: center;
}

/* Chart containers */
.message .chart-container {
    background-color: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    padding: 16px;
    margin: 12px 0;
    height: 300px;
    position: relative;
}

/* Code syntax highlighting adjustments for dark theme */
.message pre[class*="language-"] {
    background-color: rgba(0, 0, 0, 0.4);
}

.message .token.comment,
.message .token.prolog,
.message .token.doctype,
.message .token.cdata {
    color: #999;
}

.message .token.punctuation {
    color: #ccc;
}

.message .token.property,
.message .token.tag,
.message .token.boolean,
.message .token.number,
.message .token.constant,
.message .token.symbol,
.message .token.deleted {
    color: #f07178;
}

.message .token.selector,
.message .token.attr-name,
.message .token.string,
.message .token.char,
.message .token.builtin,
.message .token.inserted {
    color: #c3e88d;
}

.message .token.operator,
.message .token.entity,
.message .token.url,
.language-css .token.string,
.style .token.string {
    color: #89ddff;
}

.message .token.atrule,
.message .token.attr-value,
.message .token.keyword {
    color: #c792ea;
}

.message .token.function,
.message .token.class-name {
    color: #82aaff;
}

.message .token.regex,
.message .token.important,
.message .token.variable {
    color: #f78c6c;
}

.user-message {
    background-color: rgba(255, 255, 255, 0.15);
    align-self: flex-end;
    text-align: right;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.ai-message {
    background-color: rgba(40, 40, 40, 0.75);
    align-self: flex-start;
    text-align: left;
    color: rgba(255, 255, 255, 0.95);
    border: 1px solid rgba(255, 255, 255, 0.05);
}

#chat-input-container {
    position: absolute;
    bottom: 5%;
    width: 80%;
    max-width: 900px;
    display: flex;
    border: none;
    padding: 0;
}

#chat-input {
    flex-grow: 1;
    background-color: transparent;
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: white;
    padding: 8px;
    border-radius: 5px;
    margin-right: 10px;
}

#chat-send, #chat-clear {
    background-color: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    padding: 8px 15px;
    border-radius: 5px;
    cursor: pointer;
    margin-left: 10px;
}

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



