:root {
    --primary-color: #005086;
    /* Synesthesia brand blue */
    --accent-color: #ffd400;
    /* Synesthesia brand yellow */
    --secondary-color: #2A2A2A;
    --background-color: #121212;
    --surface-color: #1E1E1E;
    --text-color: #E0E0E0;
    --user-bubble-color: #005086;
    --assistant-bubble-color: #2C2C2C;
}

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

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--background-color);
    color: var(--text-color);
    height: 100vh;
    /* Fallback */
    height: 100dvh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    /* Prevent scrollbars from canvas */
    position: relative;
}

#bg-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    /* Changed from -1 to 0 to be above body background */
}

.chat-container {
    width: 100%;
    max-width: 800px;
    width: 100%;
    max-width: 800px;
    height: 100vh;
    /* Fallback */
    height: 100dvh;
    /* Full screen on mobile */
    display: flex;
    flex-direction: column;
    background-color: rgba(30, 30, 30, 0.85);
    /* Glassmorphism */
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    /* Safari support */
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.1);
    z-index: 1;
    /* Ensure it's above the canvas */
    position: relative;
}

@media (min-width: 768px) {
    .chat-container {
        height: 90vh;
        border-radius: 12px;
        overflow: hidden;
    }
}

.chat-header {
    padding: 20px;
    background-color: rgba(30, 30, 30, 0.9);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    text-align: center;
    font-weight: 600;
    letter-spacing: 1px;
    text-transform: uppercase;
    display: flex;
    justify-content: center;
    align-items: center;
}

.logo-img {
    max-width: 250px;
    height: auto;
    filter: brightness(1.1);
    transition: filter 0.3s ease;
}

.logo-img:hover {
    filter: brightness(1.3);
}

.chat-messages {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.message {
    display: flex;
    max-width: 80%;
    animation: fadeIn 0.3s ease;
}

.message.assistant {
    align-self: flex-start;
}

.message.user {
    align-self: flex-end;
}

.bubble {
    padding: 12px 18px;
    border-radius: 18px;
    line-height: 1.5;
    font-size: 1rem;
}

.assistant .bubble {
    background-color: var(--assistant-bubble-color);
    border-bottom-left-radius: 4px;
}

.user .bubble {
    background-color: var(--user-bubble-color);
    color: white;
    border-bottom-right-radius: 4px;
}

.chat-input-area {
    padding: 20px;
    background-color: rgba(30, 30, 30, 0.9);
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    gap: 10px;
    align-items: center;
}

#user-input {
    flex: 1;
    padding: 15px;
    border-radius: 25px;
    border: 1px solid #444;
    background-color: rgba(42, 42, 42, 0.8);
    color: white;
    font-size: 1rem;
    outline: none;
    transition: border-color 0.2s, background-color 0.2s;
}

#user-input:focus {
    border-color: var(--primary-color);
    background-color: rgba(42, 42, 42, 1);
}

#upload-btn {
    background-color: transparent;
    border: 1px solid #444;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    color: #aaa;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: all 0.2s;
}

#upload-btn:hover {
    background-color: rgba(255, 255, 255, 0.1);
    color: white;
    border-color: #666;
    transform: scale(1.05);
}

#send-btn {
    background-color: var(--primary-color);
    border: none;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    color: white;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: transform 0.2s, background-color 0.2s;
    box-shadow: 0 4px 10px rgba(108, 99, 255, 0.3);
}

#send-btn:hover {
    transform: scale(1.05);
    background-color: #5a52d5;
}

#send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Scrollbar styling */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: #1E1E1E;
}

::-webkit-scrollbar-thumb {
    background: #444;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #555;
}

/* Typing Indicator */
.typing-indicator {
    display: flex;
    gap: 5px;
    padding: 10px 15px;
    background-color: var(--assistant-bubble-color);
    border-radius: 18px;
    border-bottom-left-radius: 4px;
    width: fit-content;
    margin-bottom: 15px;
    animation: fadeIn 0.3s ease;
}

.typing-dot {
    width: 8px;
    height: 8px;
    background-color: #aaa;
    border-radius: 50%;
    animation: typing 1.4s infinite ease-in-out both;
}

.typing-dot:nth-child(1) {
    animation-delay: -0.32s;
}

.typing-dot:nth-child(2) {
    animation-delay: -0.16s;
}

@keyframes typing {

    0%,
    80%,
    100% {
        transform: scale(0);
    }

    40% {
        transform: scale(1);
    }
}

/* Markdown Styles in Bubbles */
.bubble p {
    margin-bottom: 10px;
}

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

.bubble ul,
.bubble ol {
    margin-left: 20px;
    margin-bottom: 10px;
}

.bubble code {
    background-color: rgba(0, 0, 0, 0.3);
    padding: 2px 4px;
    border-radius: 4px;
    font-family: monospace;
}

.bubble pre {
    background-color: rgba(0, 0, 0, 0.3);
    padding: 10px;
    border-radius: 8px;
    overflow-x: auto;
    margin-bottom: 10px;
}

.bubble pre code {
    background-color: transparent;
    padding: 0;
}

.bubble strong {
    font-weight: 600;
    color: #fff;
}

/* Sci-Fi Dashboard Styles */
.dashboard-panel {
    position: fixed;
    top: 50%;
    left: 40px;
    transform: translateY(-50%);
    width: 280px;
    background: rgba(10, 15, 30, 0.65);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    border: 1px solid rgba(0, 80, 134, 0.3);
    border-left: 3px solid var(--accent-color);
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.5),
        inset 0 0 20px rgba(0, 80, 134, 0.1);
    padding: 20px;
    border-radius: 4px;
    z-index: 100;
    font-family: 'Courier New', Courier, monospace;
    /* Tech feel */
    color: var(--accent-color);
    transition: all 0.3s ease;
    display: none;
    /* Hidden by default, shown via JS when chat starts */
    opacity: 0;
    animation: slideIn 0.8s forwards;
}

@keyframes slideIn {
    to {
        opacity: 1;
        left: 40px;
    }

    from {
        opacity: 0;
        left: -200px;
    }
}

.dashboard-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(0, 80, 134, 0.5);
    padding-bottom: 10px;
    margin-bottom: 15px;
}

.dashboard-header h3 {
    font-size: 14px;
    letter-spacing: 2px;
    margin: 0;
    color: var(--primary-color);
    text-shadow: 0 0 5px rgba(0, 80, 134, 0.5);
}

.status-indicator {
    width: 8px;
    height: 8px;
    background-color: var(--accent-color);
    border-radius: 50%;
    box-shadow: 0 0 8px var(--accent-color);
    animation: blink 2s infinite;
}

@keyframes blink {
    0% {
        opacity: 0.4;
    }

    50% {
        opacity: 1;
    }

    100% {
        opacity: 0.4;
    }
}

.data-item {
    margin-bottom: 15px;
    opacity: 0.7;
    transition: all 0.5s ease;
    border-left: 2px solid transparent;
    padding-left: 8px;
}

.data-item.acquired {
    opacity: 1;
    border-left: 2px solid var(--accent-color);
    background: linear-gradient(90deg, rgba(0, 80, 134, 0.2) 0%, transparent 100%);
}

.data-item label {
    display: block;
    font-size: 10px;
    letter-spacing: 1px;
    color: #5a7d9a;
    margin-bottom: 4px;
    text-transform: uppercase;
}

.data-item .value {
    font-size: 13px;
    color: #fff;
    font-weight: 600;
    text-shadow: 0 0 2px rgba(255, 255, 255, 0.3);
}

.dashboard-footer {
    margin-top: 20px;
    border-top: 1px solid rgba(0, 80, 134, 0.5);
    padding-top: 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 10px;
    color: #5a7d9a;
}

.lines span {
    display: inline-block;
    width: 10px;
    height: 2px;
    background: #5a7d9a;
    margin-right: 2px;
}

/* Make chat container sensitive to dashboard presence on desktop */
@media (min-width: 1100px) {
    .chat-container {
        margin-left: 140px;
        /* Offset to balance layout */
    }
}

/* Hide dashboard on mobile */
@media (max-width: 900px) {
    .dashboard-panel {
        display: none !important;
    }

    .chat-container {
        margin-left: 0;
    }
}

a {
    color: var(--accent-color);
    text-decoration: none;
    transition: color 0.2s ease;
}

a:hover {
    color: #ffdf33;
    text-decoration: underline;
}

a:visited {
    color: #ccaa00;
}

.bubble a {
    color: var(--accent-color);
    font-weight: 500;
}

.bubble a:hover {
    color: #ffdf33;
}

/* End Game Buttons */
.end-game-options {
    display: flex;
    justify-content: center;
    gap: 20px;
    padding: 20px;
    animation: fadeIn 0.5s ease;
}

.primary-btn,
.secondary-btn {
    padding: 12px 24px;
    border-radius: 25px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    text-transform: uppercase;
    transition: all 0.3s ease;
    text-decoration: none;
    display: inline-block;
}

.primary-btn {
    background: var(--accent-color);
    color: var(--primary-color);
    border: none;
    box-shadow: 0 4px 15px rgba(255, 212, 0, 0.3);
}

.primary-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(255, 212, 0, 0.5);
    background: #ffe033;
}

.secondary-btn {
    background: transparent;
    color: #fff;
    border: 2px solid var(--accent-color);
}

.secondary-btn:hover {
    background: rgba(255, 212, 0, 0.1);
    transform: translateY(-2px);
    color: #fff;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Footer Styles */
.site-footer {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    padding: 10px 20px;
    background-color: rgba(0, 16, 32, 0.8);
    /* Semi-transparent background matching theme */
    backdrop-filter: blur(5px);
    color: rgba(255, 255, 255, 0.6);
    font-family: 'Inter', sans-serif;
    font-size: 0.75rem;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 100;
}

.footer-content {
    display: flex;
    align-items: center;
    gap: 10px;
}

.footer-link {
    color: rgba(255, 255, 255, 0.6);
    text-decoration: none;
    transition: color 0.2s ease;
}

.footer-link:hover {
    color: #ffd400;
    /* Yellow accent on hover */
    text-decoration: underline;
}

.footer-separator {
    color: rgba(255, 255, 255, 0.3);
}

/* Adjust chat container to not overlap with footer */
.chat-container {
    padding-bottom: 40px;
    /* Add some space for the footer */
}

@media (max-width: 600px) {
    .site-footer {
        padding: 5px;
        font-size: 0.6rem;
        /* prevent footer from covering input on small screens if keyboard is not up */
        z-index: 10;
    }

    .footer-content {
        flex-direction: column;
        gap: 2px;
        text-align: center;
    }

    .footer-separator {
        display: none;
    }
}