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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    overflow-x: hidden;
    background: linear-gradient(135deg, #1a1a1a 0%, #000000 100%);
    min-height: 100vh;
}

/* Fixed canvas background */
.graph-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    opacity: 0.2;
}

#mathCanvas {
    width: 100%;
    height: 100%;
    display: block;
}

/* Hero Section */
.hero-section {
    text-align: center;
    padding: 3rem 2rem 2rem;
    /* animation: fadeInUp 1s ease-out; */
}

.hero-section h1 {
    margin: 0;
    font-weight: 800;
    color: white;
    font-size: 3.5rem;
    text-shadow: 0 4px 8px rgba(0, 0, 0, 0.8);
}

.hero-section p {
    margin: 1rem 0 0;
    color: white;
    font-size: 1.3rem;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.6);
}

/* Main Content */
.content-section {
    max-width: 1400px;
    margin: 2rem auto;
    padding: 0 2rem;
}

.section-title {
    text-align: center;
    font-weight: 700;
    font-size: 2.2rem;
    color: white;
    margin-bottom: 3rem;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.8);
    /* animation: fadeInUp 1.2s ease-out; */
}

/* Trees Container */
.trees-container {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    grid-template-rows: repeat(2, 1fr);
    gap: 3rem;
    justify-items: center;
    max-width: 800px;
    margin: 0 auto;
}

/* Individual Tree Container */
.tree-container {
    background: rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(10px);
    border-radius: 20px;
    padding: 2rem 1.5rem;
    border: 2px solid rgba(255, 255, 255, 0.1);
    min-height: 500px;
    width: 100%;
    max-width: 350px;
    transition: all 0.3s ease;
    position: relative;
    overflow: visible;
}

.tree-container:hover {
    transform: translateY(-5px);
    border-color: rgba(255, 255, 255, 0.3);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
}

.tree-title {
    text-align: center;
    color: white;
    font-size: 1.8rem;
    font-weight: 700;
    margin-bottom: 2rem;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.6);
    cursor: pointer;
    position: relative;
}

/* Collapse indicator for mobile */
.collapse-indicator {
    display: none;
    position: absolute;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    font-size: 1.5rem;
    transition: transform 0.3s ease;
}

.tree-title.collapsed .collapse-indicator {
    transform: translateY(-50%) rotate(180deg);
}

/* Tree content wrapper for collapse functionality */
.tree-content {
    transition: max-height 0.3s ease-out, opacity 0.3s ease-out;
    overflow: hidden;
}

.tree-content.collapsed {
    max-height: 0;
    opacity: 0;
}

/* Tree Structure */
.tree {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
}

/* Tree Nodes */
.tree-node {
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.15) 0%, rgba(255, 255, 255, 0.05) 100%);
    color: white;
    padding: 0.8rem 1.2rem;
    border-radius: 25px;
    margin: 0.5rem 0;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
    position: relative;
    z-index: 2;
    font-weight: 600;
    font-size: 0.95rem;
    text-align: center;
    min-width: 140px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    text-decoration: none;
    display: block;
    backdrop-filter: blur(10px);
}

.tree-node:hover {
    transform: scale(1.1) translateY(-3px);
    box-shadow: 0 8px 25px rgba(255, 255, 255, 0.2);
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.25) 0%, rgba(255, 255, 255, 0.15) 100%);
    border-color: rgba(255, 255, 255, 0.5);
}

.tree-node.root {
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.25) 0%, rgba(255, 255, 255, 0.15) 100%);
    font-size: 1.1rem;
    padding: 1rem 1.5rem;
    font-weight: 700;
    min-width: 160px;
    margin-bottom: 1.5rem;
    border: 2px solid rgba(255, 255, 255, 0.4);
}

.tree-node.root:hover {
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.35) 0%, rgba(255, 255, 255, 0.25) 100%);
    box-shadow: 0 8px 25px rgba(255, 255, 255, 0.25);
    border-color: rgba(255, 255, 255, 0.6);
}

/* Connection Lines */
.tree-line {
    width: 2px;
    height: 20px;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.3), rgba(255, 255, 255, 0.1));
    margin: -5px 0;
    z-index: 1;
}

/* Branching Lines for Multiple Children */
.branch-container {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
}

.branch-line {
    width: 2px;
    height: 15px;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.3), rgba(255, 255, 255, 0.1));
}

.horizontal-connector {
    height: 2px;
    background: linear-gradient(90deg, rgba(255, 255, 255, 0.1), rgba(255, 255, 255, 0.3), rgba(255, 255, 255, 0.1));
    width: 80%;
    margin: -1px 0;
}

/* Precalculus Tree - More Detailed */
.precalc-branches {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    width: 100%;
    margin-top: 1rem;
}

.precalc-node {
    font-size: 0.8rem;
    padding: 0.6rem 0.8rem;
    min-width: 100px;
}

/* Animations */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(50px);
    }

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

@keyframes float {
    0% {
        transform: translateY(100vh) rotate(0deg);
        opacity: 0;
    }

    10% {
        opacity: 1;
    }

    90% {
        opacity: 1;
    }

    100% {
        transform: translateY(-100px) rotate(360deg);
        opacity: 0;
    }
}

/* Floating particles */
.particle {
    position: fixed;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    pointer-events: none;
    animation: float 6s infinite linear;
}

/* Mobile Responsive */
@media screen and (max-width: 768px) {
    .hero-section {
        padding: 2rem 1rem;
    }

    .hero-section h1 {
        font-size: 2.5rem;
    }

    .hero-section p {
        font-size: 1.1rem;
    }

    .content-section {
        padding: 0 1rem;
    }

    .trees-container {
        grid-template-columns: 1fr;
        grid-template-rows: auto;
        gap: 2rem;
        max-width: none;
    }

    .tree-container {
        max-width: 100%;
        min-height: auto;
        padding: 1.5rem 1rem;
    }

    .tree-title {
        font-size: 1.6rem;
        margin-bottom: 1rem;
        padding-right: 2rem;
    }

    .collapse-indicator {
        display: block;
    }

    .tree-content {
        max-height: 1000px;
        /* Large enough for full content */
    }

    .tree-content.collapsed {
        max-height: 0;
        opacity: 0;
        padding: 0;
    }

    .precalc-branches {
        grid-template-columns: 1fr;
        gap: 0.5rem;
    }

    /* Reduce spacing on mobile when collapsed */
    .tree-container.collapsed {
        min-height: auto;
        padding-bottom: 1rem;
    }
}

@media screen and (max-width: 480px) {
    .hero-section h1 {
        font-size: 2rem;
    }

    .section-title {
        font-size: 1.8rem;
    }

    .tree-node {
        font-size: 0.85rem;
        padding: 0.7rem 1rem;
    }

    .precalc-node {
        font-size: 0.75rem;
        padding: 0.5rem 0.7rem;
    }

    .tree-title {
        font-size: 1.4rem;
    }
}
