:root {
    --bg-color: #050505;
    --text-color: #ffffff;
    --accent-color: #00f2ff;
}

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

html {
    height: 100%;
    overscroll-behavior: none;
}

body {
    background-color: var(--bg-color);
    color: var(--text-color);
    font-family: 'Outfit', sans-serif;
    overflow: hidden;
    touch-action: none;
    height: 100vh;
    /* Fallback */
    height: 100dvh;
    width: 100vw;
    display: flex;
    justify-content: center;
    align-items: center;
    overscroll-behavior: none;
}

#canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
}

.ui-controls {
    position: absolute;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 100;
    display: flex;
    gap: 15px;
    background: rgba(255, 255, 255, 0.05);
    padding: 10px 20px;
    border-radius: 30px;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    pointer-events: auto;
    touch-action: manipulation;
    user-select: none;
    -webkit-user-select: none;
}

.mode-btn {
    background: transparent;
    border: none;
    color: rgba(255, 255, 255, 0.4);
    cursor: pointer;
    padding: 10px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.mode-btn:hover {
    color: #ffffff;
    background: rgba(255, 255, 255, 0.1);
    transform: scale(1.1);
}

.mode-btn svg {
    width: 20px;
    height: 20px;
    filter: drop-shadow(0 0 2px rgba(0, 0, 0, 0.5));
}

.mode-btn.active {
    background: rgba(255, 255, 255, 0.15);
    color: #00f2ff;
    box-shadow: 0 0 15px rgba(0, 242, 255, 0.3);
}

.mode-btn.active svg {
    filter: drop-shadow(0 0 5px #00f2ff);
}

/* Fourier Controls */
.controls-panel {
    position: absolute;
    bottom: 100px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(10, 20, 30, 0.8);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    padding: 20px;
    border-radius: 20px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    gap: 20px;
    align-items: center;
    z-index: 100;
    transition: opacity 0.3s, transform 0.3s;
    color: #fff;
    font-size: 14px;
}

.controls-panel.hidden {
    opacity: 0;
    pointer-events: none;
    transform: translateX(-50%) translateY(20px);
}

.control-group {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.control-group label {
    font-size: 12px;
    color: #00f2ff;
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* Custom Select */
select {
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #fff;
    padding: 5px 10px;
    border-radius: 5px;
    outline: none;
    font-family: inherit;
}

/* Custom Slider */
input[type=range] {
    -webkit-appearance: none;
    width: 150px;
    background: transparent;
}

input[type=range]::-webkit-slider-thumb {
    -webkit-appearance: none;
    height: 16px;
    width: 16px;
    border-radius: 50%;
    background: #00f2ff;
    cursor: pointer;
    margin-top: -6px;
    box-shadow: 0 0 10px rgba(0, 242, 255, 0.5);
}

input[type=range]::-webkit-slider-runnable-track {
    width: 100%;
    height: 4px;
    cursor: pointer;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 2px;
}

.panel-header {
    width: 100%;
    text-align: center;
    font-weight: 700;
    color: #fff;
    margin-bottom: 10px;
    font-size: 12px;
    letter-spacing: 2px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    padding-bottom: 5px;
    position: absolute;
    top: 10px;
    left: 0;
}

.controls-panel {
    /* Updates to accommodate header */
    padding-top: 40px;
    flex-wrap: wrap;
    justify-content: center;
    min-width: 320px;
}

.button-row {
    display: flex;
    gap: 8px;
    margin-bottom: 5px;
}

.fault-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: rgba(255, 255, 255, 0.7);
    padding: 6px 12px;
    border-radius: 4px;
    font-family: 'Outfit', sans-serif;
    font-size: 11px;
    text-transform: uppercase;
    cursor: pointer;
    flex: 1;
    transition: all 0.2s;
}

.fault-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
}

/* Healthy Button Active */
.fault-btn[data-fault="healthy"].active {
    background: #00ff9d;
    color: #000;
    border-color: #00ff9d;
    box-shadow: 0 0 10px rgba(0, 255, 157, 0.3);
    font-weight: 700;
}

/* Fault Buttons Active (Generic Red/Amber) */
.fault-btn:not([data-fault="healthy"]).active {
    background: #ff4800;
    color: #fff;
    border-color: #ff4800;
    box-shadow: 0 0 10px rgba(255, 72, 0, 0.3);
    font-weight: 700;
}