:root {
    --c-bronze: #8b5a2b;
    --c-gold: #d4af37;
    --theme-color: #f59e0b;
    --theme-glow: rgba(245, 158, 11, 0.6);
    --theme-bg-tint: rgba(0, 0, 0, 0.4);
}

/* Theme Modifiers */
.theme-add { --theme-color: #f59e0b; --theme-glow: rgba(245, 158, 11, 0.6); --theme-bg-tint: rgba(245, 158, 11, 0.05); }
.theme-sub { --theme-color: #06b6d4; --theme-glow: rgba(6, 182, 212, 0.6); --theme-bg-tint: rgba(6, 182, 212, 0.05); }
.theme-mul { --theme-color: #ef4444; --theme-glow: rgba(239, 68, 68, 0.6); --theme-bg-tint: rgba(239, 68, 68, 0.05); }
.theme-div { --theme-color: #a855f7; --theme-glow: rgba(168, 85, 247, 0.6); --theme-bg-tint: rgba(168, 85, 247, 0.05); }

body {
    background: url('assets/beijing.jpeg') no-repeat center center fixed;
    background-size: 100% 100%;
    margin: 0; padding: 0;
    font-family: 'Noto Serif SC', serif;
    transition: background-color 1s ease;
}

body::before {
    content: ''; position: fixed; inset: 0;
    background: radial-gradient(circle, var(--theme-bg-tint) 0%, rgba(0,0,0,0.85) 100%);
    pointer-events: none; z-index: 1;
    transition: background 1s ease;
}

#starfire-canvas { position: fixed; inset: 0; pointer-events: none; z-index: 2; }

/* Discovery Scroll (Thematic Agent Output) */
#spirit-scroll {
    background-color: #f3e5ab;
    box-shadow: 0 20px 60px rgba(0,0,0,0.9), inset 0 0 100px rgba(139, 90, 43, 0.3);
    border-radius: 4px;
}
.scroll-inner::-webkit-scrollbar { display: none; }
.scroll-entry {
    animation: brush-fade 1s forwards;
    opacity: 0;
    transform: translateY(10px);
    border-left: 2px solid rgba(139, 90, 43, 0.5);
    padding-left: 10px;
}
@keyframes brush-fade {
    to { opacity: 1; transform: translateY(0); }
}

/* Resonance Threads */
.resonance-line {
    fill: none;
    stroke: var(--theme-color);
    stroke-width: 2;
    stroke-dasharray: 10 5;
    filter: drop-shadow(0 0 8px var(--theme-color));
    opacity: 0.3;
    animation: flow 20s linear infinite;
    transition: stroke 1s ease, filter 1s ease;
}
@keyframes flow {
    from { stroke-dashoffset: 200; }
    to { stroke-dashoffset: 0; }
}

/* 3D Wheel CSS */
.gear-container { margin: 20px 0; padding: 40px 0; }
.wheel-3d-wrapper { perspective: 1200px; width: 150px; height: 250px; display: flex; align-items: center; justify-content: center; }
.wheel-3d { position: relative; width: 120px; height: 180px; transform-style: preserve-3d; transition: transform 0.1s linear; }
.wheel-face {
    position: absolute; width: 120px; height: 180px; backface-visibility: hidden;
    display: flex; align-items: center; justify-content: center;
    font-size: 100px; font-weight: bold;
    color: var(--theme-color);
    text-shadow: 0 0 20px var(--theme-glow);
    background: linear-gradient(135deg, #3d2b1f 0%, #1a110a 100%);
    border: 3px solid rgba(212, 175, 55, 0.3);
    box-shadow: inset 0 0 50px rgba(0,0,0,0.9);
    border-radius: 8px;
    transition: color 1s ease, text-shadow 1s ease;
}

/* Controls */
.gear-btn {
    position: relative; width: 50px; height: 40px;
    background: rgba(26, 17, 10, 0.8); border: 1.5px solid var(--c-gold);
    color: var(--c-gold); font-size: 24px; cursor: pointer; border-radius: 8px;
    transition: 0.2s; display: flex; align-items: center; justify-content: center;
    z-index: 50; box-shadow: 0 0 10px rgba(245, 158, 11, 0.3);
}
.gear-btn:hover { background: var(--c-gold); color: #1a110a; }

.op-btn {
    width: 70px; height: 70px; border-radius: 50%;
    background: rgba(26, 17, 10, 0.8); border: 2px solid var(--theme-color);
    color: var(--theme-color); font-size: 32px; cursor: pointer;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    display: flex; align-items: center; justify-content: center;
    box-shadow: 0 0 10px var(--theme-glow);
}
.op-btn.active { background: var(--theme-color); color: #1a110a; transform: scale(1.15); box-shadow: 0 0 40px var(--theme-glow); }

#centralOpLabel, #leftOpLabel, #rightOpLabel {
    color: var(--theme-color);
    text-shadow: 0 0 15px var(--theme-glow);
    transition: all 1s ease;
}

.truth-hub {
    margin-top: 10px; padding: 20px 40px; border: 3px solid var(--theme-color);
    background: rgba(0,0,0,0.6); border-radius: 16px;
    box-shadow: 0 0 40px var(--theme-glow), inset 0 0 20px var(--theme-glow);
    display: flex; align-items: center; justify-content: center; min-width: 180px;
    transition: border 1s ease, box-shadow 1s ease;
}
#resultValue { font-size: 110px; color: var(--theme-color); font-weight: 800; font-family: 'Ma Shan Zheng', cursive; text-shadow: 0 0 30px var(--theme-glow); transition: color 1s ease, text-shadow 1s ease; }

/* Beasts */
.beast-area { min-height: 200px; }
.beast-wrapper {
    filter: drop-shadow(0 0 10px var(--theme-glow));
    animation: beast-float 3.5s infinite ease-in-out;
}
@keyframes beast-float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-10px); } }

/* Spiritual Guide - Teacher Styling */
.teacher-frame {
    border: 1px solid rgba(212, 175, 55, 0.2);
    background: rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(4px);
    animation: spiritual-float 6s infinite ease-in-out;
}
.teacher-frame:hover {
    border-color: rgba(212, 175, 55, 0.6);
    box-shadow: 0 0 50px rgba(212, 175, 55, 0.3);
}
@keyframes spiritual-float {
    0%, 100% { transform: translateY(0) rotate(-1deg); }
    50% { transform: translateY(-15px) rotate(1deg); }
}

/* Footer */
footer {
    width: 100%;
    padding: 20px 0;
    margin-top: 20px;
    text-align: center;
}
.footer-branded {
    text-shadow: 0 0 10px var(--theme-glow);
    background: rgba(0,0,0,0.6); 
    padding: 6px 20px; 
    border-radius: 99px; 
    display: inline-block;
    border: 1px solid var(--theme-glow);
}
@media (max-width: 1024px) {
    #spirit-scroll { display: none !important; }
    #teacher-container { display: none !important; } /* Hide teacher on tablet to avoid overlap */
    .beast-area { min-height: 40px; }
    .lab-card { flex-direction: column !important; gap: 40px !important; padding: 20px !important; scale: 0.9; }
    .gear-container { padding: 0 !important; }
    .truth-hub { scale: 0.8; margin: 10px 0; }
}

@media (max-width: 640px) {
    h1 { font-size: 2.2rem !important; }
    .wheel-3d-wrapper { scale: 0.75; height: 160px; }
    .truth-hub { scale: 0.7; }
    #ai-text { font-size: 0.9rem !important; padding: 10px; }
    .beast-area { transform: scale(0.6); max-height: 150px; overflow: hidden; }
}

@media (max-width: 400px) {
    .lab-card { scale: 0.8; }
    .wheel-3d-wrapper { scale: 0.65; }
    .truth-hub { scale: 0.6; }
    .op-btn { width: 50px; height: 50px; font-size: 20px; }
    #centralOpLabel { font-size: 0.9rem !important; }
}
