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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
    min-height: 100vh;
    padding: 20px;
}

.moon-phases-container {
    max-width: 1400px;
    margin: 0 auto;
    background: white;
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    overflow: hidden;
}

header {
    background: linear-gradient(135deg, #3b82f6 0%, #6366f1 100%);
    color: white;
    padding: 30px;
    text-align: center;
}

header h1 {
    font-size: 2.2rem;
    font-weight: 700;
    margin-bottom: 10px;
}

header .subtitle {
    font-size: 1.1rem;
    opacity: 0.9;
}

main {
    padding: 30px;
}

.simulation-layout {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 30px;
    margin-bottom: 30px;
}

.animation-panel {
    background: #f8fafc;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.canvas-container {
    background: #0f172a;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.3);
    margin-bottom: 20px;
}

#moonCanvas {
    display: block;
    width: 100%;
    height: auto;
}

.phase-info {
    display: flex;
    justify-content: space-around;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 20px;
}

.info-item {
    background: white;
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 0.9rem;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    flex: 1;
    min-width: 140px;
    text-align: center;
}

.info-item span:first-child {
    font-weight: 600;
    color: #475569;
    margin-right: 6px;
    display: block;
    font-size: 0.85rem;
}

.info-item span:last-child {
    color: #3b82f6;
    font-weight: 700;
    font-size: 1.1rem;
}

.phase-icons {
    background: white;
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 20px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.phase-icons h4 {
    color: #1e293b;
    font-size: 1rem;
    margin-bottom: 12px;
    font-weight: 600;
}

.icons-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
}

.phase-icon {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 10px;
    border-radius: 6px;
    cursor: pointer;
    transition: background-color 0.2s;
}

.phase-icon:hover {
    background: #f1f5f9;
}

.moon-icon {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    position: relative;
    background: #1e293b;
}

.moon-icon.new-moon {
    background: #1e293b;
}

.moon-icon.first-quarter {
    background: linear-gradient(to right, #1e293b 50%, #f1f5f9 50%);
}

.moon-icon.full-moon {
    background: #f1f5f9;
    box-shadow: 0 0 10px rgba(241, 245, 249, 0.5);
}

.moon-icon.last-quarter {
    background: linear-gradient(to right, #f1f5f9 50%, #1e293b 50%);
}

.phase-icon span {
    font-size: 0.75rem;
    color: #475569;
    text-align: center;
}

.legend-section {
    background: white;
    border-radius: 8px;
    padding: 15px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.legend-section h4 {
    color: #1e293b;
    font-size: 1rem;
    margin-bottom: 12px;
    font-weight: 600;
}

.legend-items {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 0;
}

.legend-color {
    width: 30px;
    height: 6px;
    border-radius: 3px;
    flex-shrink: 0;
}

.legend-color.sun {
    background: #fbbf24;
}

.legend-color.earth {
    background: #3b82f6;
}

.legend-color.moon {
    background: #f1f5f9;
}

.legend-color.orbit {
    background: #475569;
    border: 1px dashed #475569;
}

.legend-color.sunlight {
    background: linear-gradient(to right, #fbbf24, transparent);
}

.legend-item span {
    font-size: 0.9rem;
    color: #475569;
}

.controls-panel {
    background: #f8fafc;
    border-radius: 12px;
    padding: 25px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    max-height: 700px;
    overflow-y: auto;
}

.controls-panel h3 {
    color: #1e293b;
    font-size: 1.5rem;
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 3px solid #3b82f6;
}

.control-group {
    margin-bottom: 25px;
}

.control-group h4 {
    color: #475569;
    font-size: 1.1rem;
    margin-bottom: 15px;
    font-weight: 600;
}

.control-group label {
    display: block;
    margin-bottom: 8px;
    color: #334155;
    font-size: 0.95rem;
}

.control-group label span:first-child {
    font-weight: 600;
}

.control-group label span:last-child {
    color: #3b82f6;
    font-weight: 700;
}

.control-group input[type="range"] {
    width: 100%;
    height: 8px;
    border-radius: 4px;
    background: #e2e8f0;
    outline: none;
    margin-bottom: 15px;
    -webkit-appearance: none;
}

.control-group input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #3b82f6;
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    transition: all 0.2s;
}

.control-group input[type="range"]::-webkit-slider-thumb:hover {
    background: #2563eb;
    transform: scale(1.1);
}

.control-group input[type="range"]::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #3b82f6;
    cursor: pointer;
    border: none;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    transition: all 0.2s;
}

.control-group input[type="range"]::-moz-range-thumb:hover {
    background: #2563eb;
    transform: scale(1.1);
}

.control-group select {
    width: 100%;
    padding: 10px 15px;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    background: white;
    color: #334155;
    font-size: 1rem;
    margin-bottom: 15px;
    cursor: pointer;
    transition: border-color 0.2s;
}

.control-group select:focus {
    outline: none;
    border-color: #3b82f6;
}

.checkbox-input {
    margin-right: 10px;
    cursor: pointer;
    width: 18px;
    height: 18px;
}

.checkbox-input:hover {
    transform: scale(1.05);
}

.button-group {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin-bottom: 25px;
}

.control-button {
    padding: 12px 20px;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.control-button.start {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: white;
}

.control-button.start:hover {
    background: linear-gradient(135deg, #059669 0%, #047857 100%);
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.control-button.pause {
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
    color: white;
}

.control-button.pause:hover {
    background: linear-gradient(135deg, #d97706 0%, #b45309 100%);
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.control-button.reset {
    background: linear-gradient(135deg, #6366f1 0%, #4f46e5 100%);
    color: white;
}

.control-button.reset:hover {
    background: linear-gradient(135deg, #4f46e5 0%, #4338ca 100%);
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.formulas-section {
    background: white;
    border-radius: 8px;
    padding: 20px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.formulas-section h3 {
    color: #1e293b;
    font-size: 1.2rem;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 2px solid #e2e8f0;
}

.formula-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.formula-item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 8px;
    background: #f8fafc;
    border-radius: 6px;
}

.formula-label {
    font-weight: 700;
    color: #3b82f6;
    min-width: 100px;
    font-size: 0.9rem;
}

.formula {
    color: #475569;
    font-family: 'Courier New', monospace;
    font-size: 0.95rem;
    line-height: 1.4;
}

.explanation {
    background: #f8fafc;
    border-radius: 12px;
    padding: 30px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.explanation h2 {
    color: #1e293b;
    font-size: 1.8rem;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 3px solid #3b82f6;
}

.explanation h3 {
    color: #334155;
    font-size: 1.4rem;
    margin-top: 25px;
    margin-bottom: 15px;
}

.explanation p {
    color: #475569;
    font-size: 1rem;
    line-height: 1.8;
    margin-bottom: 15px;
}

.explanation strong {
    color: #1e293b;
    font-weight: 600;
}

/* Responsive design */
@media (max-width: 1024px) {
    .simulation-layout {
        grid-template-columns: 1fr;
    }

    header h1 {
        font-size: 1.8rem;
    }

    header .subtitle {
        font-size: 1rem;
    }
}

@media (max-width: 768px) {
    body {
        padding: 10px;
    }

    main {
        padding: 20px;
    }

    header {
        padding: 20px;
    }

    header h1 {
        font-size: 1.5rem;
    }

    .phase-info {
        flex-direction: column;
    }

    .icons-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .button-group {
        grid-template-columns: 1fr;
    }

    .explanation h2 {
        font-size: 1.5rem;
    }

    .explanation h3 {
        font-size: 1.2rem;
    }

    .controls-panel {
        max-height: none;
    }
}
