body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    display: flex;
    justify-content: center;
    background-color: #f8f9fa;
    margin: 0;
    padding: 20px;
    box-sizing: border-box;
    min-height: 100vh;
    position: relative;
}

.back-btn {
    position: absolute;
    top: 20px;
    right: 20px;
    padding: 10px 20px;
    background-color: #2c3e50;
    color: white;
    text-decoration: none;
    border-radius: 6px;
    font-weight: bold;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
    transition: background-color 0.2s;
    z-index: 100;
}

.back-btn:hover {
    background-color: #34495e;
}

.main-wrapper {
    display: flex;
    gap: 30px;
    max-width: 1400px;
    width: 100%;
    align-items: flex-start;
    justify-content: center;
    flex-wrap: wrap;
    margin-top: 40px; /* Space for back button on smaller screens */
}

.pane {
    background: white;
    padding: 20px 40px;
    border-radius: 12px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
    text-align: center;
}

.left-pane {
    flex: 1 1 500px;
    max-width: 750px;
}

.right-pane {
    flex: 1 1 350px;
    max-width: 500px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    align-items: center;
}

h2, h3 {
    margin-top: 0;
    color: #333;
}

.formula-box {
    font-size: 1.5em;
    font-family: 'Courier New', Courier, monospace;
    background: #e9ecef;
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 20px;
    font-weight: bold;
    color: #2c3e50;
    word-break: break-all;
}

.warning-text {
    color: #d35400;
}

.calm-text {
    color: #27ae60;
}

canvas {
    border: 1px solid #ddd;
    border-radius: 4px;
    background-color: #fff;
    max-width: 100%;
    height: auto;
    touch-action: none; /* Helps prevent scrolling while interacting with canvas */
}

#fourierCanvas {
    cursor: crosshair;
}

.controls {
    display: flex;
    justify-content: center;
    gap: 40px;
    margin-top: 20px;
    flex-wrap: wrap;
}

.slider-group {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    max-width: 250px;
}

.slider-group label {
    margin-bottom: 8px;
    font-size: 1.1em;
}

/* Thicker touch-friendly slider */
input[type=range] {
    width: 100%;
    height: 30px;
    -webkit-appearance: none;
    margin: 10px 0;
    background: transparent;
}
input[type=range]:focus {
    outline: none;
}
input[type=range]::-webkit-slider-runnable-track {
    width: 100%;
    height: 10px;
    cursor: pointer;
    background: #bdc3c7;
    border-radius: 5px;
}
input[type=range]::-webkit-slider-thumb {
    height: 24px;
    width: 24px;
    border-radius: 50%;
    background: #2980b9;
    cursor: pointer;
    -webkit-appearance: none;
    margin-top: -7px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}
input[type=range]::-moz-range-track {
    width: 100%;
    height: 10px;
    cursor: pointer;
    background: #bdc3c7;
    border-radius: 5px;
}
input[type=range]::-moz-range-thumb {
    height: 24px;
    width: 24px;
    border-radius: 50%;
    background: #2980b9;
    cursor: pointer;
    box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}

.legend {
    margin-top: 20px;
    display: flex;
    justify-content: center;
    gap: 15px;
    font-size: 0.9em;
    flex-wrap: wrap;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 5px;
}

.legend-color {
    width: 15px;
    height: 15px;
    display: inline-block;
    border-radius: 3px;
}

.image-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    width: 100%;
}

.image-description {
    font-size: 0.9em;
    color: #555;
    max-width: 400px;
    line-height: 1.4;
}

/* Mobile adjustments */
@media (max-width: 768px) {
    .pane {
        padding: 15px 20px;
    }
    .formula-box {
        font-size: 1.1em;
        word-break: normal;
        white-space: nowrap;
        overflow-x: auto;
    }
    .back-btn {
        top: 15px;
        right: 15px;
        padding: 8px 15px;
        font-size: 0.9em;
    }
    .main-wrapper {
        margin-top: 50px;
    }
}
