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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
    color: #e2e8f0;
    line-height: 1.6;
    min-height: 100vh;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
}

header {
    text-align: center;
    padding: 3rem 0;
    border-bottom: 2px solid rgba(59, 130, 246, 0.3);
    margin-bottom: 3rem;
}

h1 {
    font-size: 3rem;
    background: linear-gradient(135deg, #60a5fa 0%, #a78bfa 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 0.5rem;
}

.subtitle {
    font-size: 1.2rem;
    color: rgba(255, 255, 255, 0.7);
}

section {
    background: rgba(30, 41, 59, 0.6);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(59, 130, 246, 0.2);
    border-radius: 16px;
    padding: 2.5rem;
    margin-bottom: 2rem;
    animation: slideIn 0.6s ease-out;
}

h2 {
    color: #60a5fa;
    font-size: 2rem;
    margin-bottom: 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

h2::before {
    content: '';
    width: 4px;
    height: 2rem;
    background: linear-gradient(135deg, #60a5fa 0%, #a78bfa 100%);
    border-radius: 2px;
}

h3 {
    color: #93c5fd;
    font-size: 1.5rem;
    margin-bottom: 1rem;
}

h4 {
    color: #a78bfa;
    font-size: 1.2rem;
    margin-bottom: 0.5rem;
}

h5 {
    color: #c4b5fd;
    font-size: 1rem;
    margin-bottom: 0.5rem;
}

p {
    color: rgba(255, 255, 255, 0.85);
    margin-bottom: 1rem;
}

strong {
    color: #fff;
}

code {
    display: block;
    color: #93c5fd;
    font-family: 'Courier New', monospace;
    font-size: 0.95rem;
    padding: 0.75rem;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 6px;
    margin-top: 0.5rem;
    border: 1px solid rgba(59, 130, 246, 0.2);
}

ul {
    margin-left: 1.5rem;
    margin-bottom: 1rem;
}

li {
    color: rgba(255, 255, 255, 0.85);
    margin-bottom: 0.5rem;
}

/* Intro Section */
.intro p {
    font-size: 1.1rem;
    line-height: 1.8;
}

.intro-image {
    margin-top: 2rem;
    text-align: center;
    padding: 2rem;
    background: rgba(15, 23, 42, 0.6);
    border-radius: 12px;
    border: 1px solid rgba(59, 130, 246, 0.3);
}

.diagram-image {
    max-width: 600px;
    width: 100%;
    height: auto;
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
    background: white;
    padding: 1rem;
}

.image-caption {
    margin-top: 1rem;
    font-size: 0.95rem;
    color: rgba(255, 255, 255, 0.7);
    font-style: italic;
}

.image-caption small {
    font-size: 0.85rem;
    color: rgba(255, 255, 255, 0.5);
}

/* Visualization Section */
.viz-description {
    font-size: 1.05rem;
    padding: 1rem;
    background: rgba(59, 130, 246, 0.1);
    border-left: 4px solid #60a5fa;
    border-radius: 8px;
    margin-bottom: 2rem;
}

.controls-panel {
    background: rgba(59, 130, 246, 0.1);
    padding: 2rem;
    border-radius: 12px;
    border: 2px solid rgba(59, 130, 246, 0.3);
    margin-bottom: 2rem;
}

.control-item {
    margin-bottom: 1.5rem;
}

.control-item label {
    display: block;
    color: #93c5fd;
    font-weight: 600;
    margin-bottom: 0.5rem;
    font-size: 1.1rem;
}

.control-item .hint {
    font-size: 0.85rem;
    color: #fbbf24;
    margin-top: 0.5rem;
    margin-bottom: 0;
    font-style: italic;
}

.control-item input[type="range"] {
    width: 100%;
    height: 8px;
    background: rgba(59, 130, 246, 0.2);
    border-radius: 4px;
    outline: none;
    cursor: pointer;
}

.control-item input[type="range"]::-webkit-slider-thumb {
    appearance: none;
    width: 20px;
    height: 20px;
    background: linear-gradient(135deg, #60a5fa 0%, #a78bfa 100%);
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(96, 165, 250, 0.5);
}

.control-item input[type="range"]::-moz-range-thumb {
    width: 20px;
    height: 20px;
    background: linear-gradient(135deg, #60a5fa 0%, #a78bfa 100%);
    border-radius: 50%;
    cursor: pointer;
    border: none;
    box-shadow: 0 2px 8px rgba(96, 165, 250, 0.5);
}

.button-group {
    display: flex;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.action-btn {
    padding: 0.75rem 2rem;
    font-size: 1.1rem;
    font-weight: 600;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    border: none;
}

.action-btn.primary {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: white;
    box-shadow: 0 4px 15px rgba(16, 185, 129, 0.3);
}

.action-btn.primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(16, 185, 129, 0.5);
}

.action-btn.secondary {
    background: rgba(100, 116, 139, 0.3);
    color: white;
    border: 1px solid rgba(148, 163, 184, 0.5);
}

.action-btn.secondary:hover {
    background: rgba(100, 116, 139, 0.5);
}

.stats-display {
    background: rgba(15, 23, 42, 0.8);
    padding: 1.5rem;
    border-radius: 12px;
    border: 1px solid rgba(59, 130, 246, 0.3);
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
}

.stats-display p {
    font-size: 1.1rem;
    margin: 0;
}

.stats-display strong {
    color: #10b981;
    font-size: 1.2rem;
}

.canvas-container {
    display: flex;
    justify-content: center;
    margin: 2rem 0;
    background: rgba(15, 23, 42, 0.4);
    border-radius: 12px;
    padding: 1rem;
}

#gradientCanvas {
    border-radius: 8px;
    max-width: 100%;
    height: auto;
}

.legend {
    display: flex;
    flex-wrap: wrap;
    gap: 2rem;
    justify-content: center;
    margin-top: 1.5rem;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.legend-color {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.legend-item span {
    color: rgba(255, 255, 255, 0.85);
    font-size: 0.95rem;
}

/* Math Section */
.math-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.5rem;
}

.math-card {
    background: rgba(15, 23, 42, 0.6);
    padding: 1.5rem;
    border-radius: 12px;
    border: 1px solid rgba(59, 130, 246, 0.3);
    transition: all 0.3s ease;
}

.math-card:hover {
    transform: translateY(-5px);
    border-color: rgba(59, 130, 246, 0.5);
    box-shadow: 0 8px 24px rgba(59, 130, 246, 0.2);
}

.math-card h3 {
    color: #60a5fa;
    font-size: 1.3rem;
    margin-bottom: 1rem;
}

.explanation {
    font-size: 0.9rem;
    color: rgba(255, 255, 255, 0.7);
    font-style: italic;
    margin-top: 0.5rem;
}

/* Algorithm Section */
.algorithm-steps {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
}

.algo-step {
    background: rgba(59, 130, 246, 0.1);
    padding: 1.5rem;
    border-radius: 12px;
    border: 1px solid rgba(59, 130, 246, 0.3);
    transition: all 0.3s ease;
    text-align: center;
}

.algo-step:hover {
    transform: translateY(-5px);
    border-color: rgba(59, 130, 246, 0.5);
    box-shadow: 0 8px 24px rgba(59, 130, 246, 0.2);
}

.step-number {
    width: 50px;
    height: 50px;
    background: linear-gradient(135deg, #60a5fa 0%, #a78bfa 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    font-weight: 700;
    margin: 0 auto 1rem auto;
    color: white;
}

.step-content h4 {
    margin-bottom: 0.75rem;
    text-align: center;
}

.step-content p {
    font-size: 0.95rem;
    color: rgba(255, 255, 255, 0.7);
    text-align: center;
    margin-bottom: 0.75rem;
}

.step-content code {
    font-size: 0.85rem;
}

/* Learning Rate Section */
.lr-comparison {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 2rem;
}

.lr-card {
    background: rgba(15, 23, 42, 0.6);
    padding: 2rem;
    border-radius: 12px;
    border: 2px solid rgba(100, 116, 139, 0.3);
    transition: all 0.3s ease;
}

.lr-card.optimal {
    border-color: rgba(16, 185, 129, 0.5);
    background: rgba(16, 185, 129, 0.1);
}

.lr-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
}

.lr-icon {
    font-size: 3rem;
    text-align: center;
    margin-bottom: 1rem;
}

.lr-icon.too-small {
    filter: grayscale(0.3);
}

.lr-icon.too-large {
    animation: shake 0.5s ease-in-out infinite;
}

.lr-card h4 {
    text-align: center;
    font-size: 1.4rem;
    margin-bottom: 1rem;
}

.lr-card p {
    text-align: center;
    font-size: 1.1rem;
    margin-bottom: 1rem;
}

.lr-card ul {
    list-style-position: inside;
    margin-left: 0;
}

.lr-visual {
    margin-top: 1.5rem;
    display: flex;
    justify-content: center;
}

.lr-visual svg {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 8px;
    padding: 10px;
}

.best-choice {
    text-align: center;
    color: #10b981;
    font-weight: 700;
    font-size: 1.1rem;
    margin-top: 1rem;
}

/* Types Section */
.types-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 2rem;
}

.type-card {
    background: rgba(15, 23, 42, 0.6);
    padding: 2rem;
    border-radius: 12px;
    border: 1px solid rgba(59, 130, 246, 0.3);
    transition: all 0.3s ease;
}

.type-card.highlighted {
    border-color: rgba(16, 185, 129, 0.5);
    background: rgba(16, 185, 129, 0.05);
}

.type-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 24px rgba(59, 130, 246, 0.2);
}

.type-icon {
    font-size: 3rem;
    text-align: center;
    margin-bottom: 1rem;
}

.type-desc {
    text-align: center;
    font-size: 1.05rem;
    margin-bottom: 1.5rem;
    color: #93c5fd;
}

.pros-cons {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin: 1.5rem 0;
}

.pros, .cons {
    padding: 1rem;
    border-radius: 8px;
}

.pros {
    background: rgba(16, 185, 129, 0.1);
    border: 1px solid rgba(16, 185, 129, 0.3);
}

.cons {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
}

.pros h5 {
    color: #10b981;
}

.cons h5 {
    color: #ef4444;
}

.pros ul li, .cons ul li {
    font-size: 0.9rem;
}

/* Advanced Section */
.section-intro {
    font-size: 1.05rem;
    padding: 1rem;
    background: rgba(139, 92, 246, 0.1);
    border-left: 4px solid #a78bfa;
    border-radius: 8px;
    margin-bottom: 2rem;
}

.optimizers-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
}

.optimizer-card {
    background: rgba(139, 92, 246, 0.1);
    padding: 1.5rem;
    border-radius: 12px;
    border: 1px solid rgba(139, 92, 246, 0.3);
    transition: all 0.3s ease;
}

.optimizer-card.featured {
    border-color: rgba(16, 185, 129, 0.5);
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.1) 0%, rgba(16, 185, 129, 0.1) 100%);
}

.optimizer-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 24px rgba(139, 92, 246, 0.3);
}

.optimizer-card h4 {
    color: #c4b5fd;
    font-size: 1.3rem;
    margin-bottom: 1rem;
}

.optimizer-card p {
    font-size: 0.95rem;
    margin-bottom: 1rem;
}

.optimizer-benefit {
    margin-top: 1rem;
    padding: 0.75rem;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 8px;
    border-left: 3px solid #10b981;
    color: #10b981;
    font-weight: 600;
    font-size: 0.9rem;
}

/* Practical Section */
.practical-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.5rem;
}

.practical-card {
    background: rgba(15, 23, 42, 0.6);
    padding: 2rem;
    border-radius: 12px;
    border: 1px solid rgba(59, 130, 246, 0.3);
    transition: all 0.3s ease;
}

.practical-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 24px rgba(59, 130, 246, 0.2);
}

.practical-icon {
    font-size: 3rem;
    text-align: center;
    margin-bottom: 1rem;
}

.practical-card h4 {
    text-align: center;
    margin-bottom: 1.5rem;
    font-size: 1.3rem;
}

.practical-card ul {
    margin-left: 1.5rem;
}

.practical-card li {
    margin-bottom: 0.75rem;
    font-size: 0.95rem;
}

/* Code Section */
.code-examples {
    display: grid;
    gap: 2rem;
}

.code-block {
    background: rgba(15, 23, 42, 0.8);
    padding: 1.5rem;
    border-radius: 12px;
    border: 1px solid rgba(59, 130, 246, 0.3);
}

.code-block h4 {
    color: #60a5fa;
    margin-bottom: 1rem;
}

.code-block pre {
    overflow-x: auto;
}

.code-block code {
    font-size: 0.9rem;
    line-height: 1.6;
    white-space: pre;
}

.code-block code.python {
    color: #93c5fd;
}

/* Summary Section */
.summary-content {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.5rem;
}

.summary-point {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    padding: 1.5rem;
    background: rgba(59, 130, 246, 0.1);
    border-radius: 12px;
    border: 1px solid rgba(59, 130, 246, 0.3);
    transition: all 0.3s ease;
}

.summary-point:hover {
    transform: translateX(10px);
    border-color: rgba(59, 130, 246, 0.5);
    box-shadow: 0 4px 16px rgba(59, 130, 246, 0.2);
}

.point-icon {
    font-size: 2rem;
    flex-shrink: 0;
}

.summary-point p {
    margin: 0;
    font-size: 1.05rem;
}

/* Footer */
footer {
    text-align: center;
    padding: 2rem;
    color: rgba(255, 255, 255, 0.5);
    border-top: 1px solid rgba(59, 130, 246, 0.2);
}

/* Animations */
@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes shake {
    0%, 100% {
        transform: translateX(0);
    }
    25% {
        transform: translateX(-5px);
    }
    75% {
        transform: translateX(5px);
    }
}

/* Responsive */
@media (max-width: 768px) {
    .container {
        padding: 1rem;
    }

    h1 {
        font-size: 2rem;
    }

    h2 {
        font-size: 1.5rem;
    }

    .math-grid,
    .algorithm-steps,
    .lr-comparison,
    .types-grid,
    .optimizers-grid,
    .practical-grid,
    .summary-content {
        grid-template-columns: 1fr;
    }

    .stats-display {
        grid-template-columns: 1fr;
    }

    .pros-cons {
        grid-template-columns: 1fr;
    }

    #gradientCanvas {
        width: 100%;
        height: auto;
    }

    .button-group {
        flex-direction: column;
    }
}
