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

body {
    background: #000;
    color: #fff;
    font-family: 'Courier New', monospace;
    font-size: 11px;
    overflow: hidden;
    cursor: crosshair;
}

#canvas {
    width: 100vw;
    height: 100vh;
    display: block;
}

/* Footnotes positioned in bottom-left corner */
.footnotes {
    position: fixed;
    bottom: 20px;
    left: 20px;
    max-width: 320px;
    z-index: 100;
}

.current-relation {
    background: rgba(0, 0, 0, 0.85);
    padding: 12px 16px;
    border-radius: 4px;
    margin-bottom: 8px;
    border-left: 3px solid #444;
    opacity: 0;
    transition: opacity 0.3s ease;
    position: relative;
}

.current-relation.show {
    opacity: 1;
}

.current-relation .label {
    font-weight: bold;
    margin-bottom: 6px;
    font-size: 12px;
    color: #fff;
}

.current-relation .fluxus {
    font-style: italic;
    line-height: 1.4;
    font-size: 10px;
    color: #bbb;
}

.close-relation, .close-commentary {
    position: absolute;
    top: 4px;
    right: 8px;
    background: none;
    border: none;
    color: #666;
    cursor: pointer;
    font-size: 16px;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background-color 0.2s;
}

.close-relation:hover, .close-commentary:hover {
    background-color: rgba(255, 255, 255, 0.1);
    color: #999;
}

/* Commentary positioned in bottom-right corner */
.commentary {
    max-width: 320px;
    background: rgba(0, 0, 0, 0.85);
    padding: 12px 16px;
    border-radius: 4px;
    border-left: 3px solid #555;
    max-height: 200px;
    overflow-y: auto;
    z-index: 100;
    position: relative;
}

.commentary.hidden {
    display: none;
}

.commentary #commentary-text {
    line-height: 1.5;
    font-size: 10px;
    color: #ccc;
    padding-right: 20px; /* Make room for close button */
}

/* Stylish sliding drawer loading animation */
#loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 2000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    pointer-events: none;
}

#loading-overlay.active {
    opacity: 1;
    visibility: visible;
    pointer-events: all;
}

.loading-drawer {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 100%;
    transform: translateY(100%);
    transition: transform 0.4s cubic-bezier(0.23, 1, 0.32, 1);
}

.gray-drawer {
    background: #666666;
    z-index: 1;
}

.black-drawer {
    background: #000000;
    z-index: 2;
}

.loading-drawer.slide-in {
    transform: translateY(0);
}

.loading-content {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 3;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.loading-content.show {
    opacity: 1;
}

.loading-text {
    font-size: 14px;
    color: #ccc;
    font-style: italic;
    text-align: center;
    letter-spacing: 1px;
}

/* Animated dots for loading text */
.loading-text::after {
    content: '';
    animation: loading-dots 2s infinite;
}

@keyframes loading-dots {
    0% { content: '.'; }
    25% { content: '..'; }
    50% { content: '...'; }
    75% { content: '.'; }
    100% { content: '..'; }
}

/* Line styles */
.line {
    fill: none;
    stroke: #fff;
    vector-effect: non-scaling-stroke;
}

.line.hairline { stroke-width: 0.5; }
.line.thin { stroke-width: 1; }
.line.medium { stroke-width: 2; }
.line.bold { stroke-width: 3; }

.line.dashed { stroke-dasharray: 3,2; }
.line.dotted { stroke-dasharray: 1,1; }
.line.double { stroke-width: 1; }

/* Line animations */
@keyframes pulse {
    0%, 100% { stroke-opacity: 0.3; }
    50% { stroke-opacity: 1; }
}

@keyframes breathe {
    0%, 100% { stroke-width: inherit; }
    50% { stroke-width: calc(var(--base-width, 1px) * 1.5); }
}

@keyframes drift {
    0% { transform: translateX(0px); }
    50% { transform: translateX(2px); }
    100% { transform: translateX(0px); }
}

@keyframes jitter {
    0%, 100% { transform: translate(0px, 0px); }
    25% { transform: translate(1px, -1px); }
    75% { transform: translate(-1px, 1px); }
}

@keyframes twine {
    0% { stroke-dashoffset: 0; }
    100% { stroke-dashoffset: 10; }
}

.motion-pulse { animation: pulse 2s infinite; }
.motion-breathe { animation: breathe 3s infinite; }
.motion-drift { animation: drift 4s infinite; }
.motion-jitter { animation: jitter 0.5s infinite; }
.motion-twine { 
    stroke-dasharray: 4,2; 
    animation: twine 3s linear infinite;
}

.rhythm-slow .motion-pulse { animation-duration: 4s; }
.rhythm-slow .motion-breathe { animation-duration: 6s; }
.rhythm-slow .motion-drift { animation-duration: 8s; }
.rhythm-slow .motion-twine { animation-duration: 5s; }

.rhythm-fast .motion-pulse { animation-duration: 1s; }
.rhythm-fast .motion-breathe { animation-duration: 1.5s; }
.rhythm-fast .motion-drift { animation-duration: 2s; }
.rhythm-fast .motion-twine { animation-duration: 1.5s; }

.fading {
    transition: opacity 2s ease-out;
}

/* Responsive design for smaller screens */
@media (max-width: 768px) {
    .footnotes, .commentary {
        max-width: 280px;
    }
    
    .current-relation, .commentary {
        padding: 10px 12px;
    }
    
    body {
        font-size: 10px;
    }
    
    .loading-text {
        font-size: 12px;
    }
}
