* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: 'Inter', sans-serif;
    background-color: #000000;
    color: #ffffff;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    overflow-x: hidden; /* Prevents horizontal scrolling bugs */
}

/* --- Top Navigation --- */
.top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    background: rgba(10, 10, 10, 0.8);
    border-bottom: 1px solid #1a1a1a;
    backdrop-filter: blur(10px);
    z-index: 10;
    /* Allows text to wrap neatly on very narrow screens */
    flex-wrap: wrap; 
    gap: 0.5rem;
}

.back-link {
    color: #888888;
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    transition: color 0.2s;
    white-space: nowrap;
}

.back-link:hover { color: #ffffff; }

.sim-title {
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: #3b82f6;
    font-size: 0.9rem;
    text-align: right;
}

/* --- Mobile-First Layout (Default) --- */
.sim-container {
    display: flex;
    flex-direction: column; /* Forces vertical stacking on mobile */
    flex: 1;
    width: 100%;
}

.canvas-wrapper {
    width: 100%;
    /* Locks the canvas to take up the top portion of the phone screen */
    height: 45vh; 
    min-height: 280px;
    position: relative;
    background: radial-gradient(circle at center, #0a101f 0%, #000000 100%);
    border-bottom: 1px solid #1a1a1a;
}

canvas {
    width: 100%;
    height: 100%;
    display: block;
}

.control-panel {
    width: 100%;
    background: #050505;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

/* --- UI Elements --- */
h3 {
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: #666666;
    border-bottom: 1px solid #1a1a1a;
    padding-bottom: 0.5rem;
}

.control-group {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.control-group label {
    font-size: 0.95rem;
    font-weight: 500;
    display: flex;
    justify-content: space-between;
}

/* Premium Sliders */
input[type=range] {
    -webkit-appearance: none;
    width: 100%;
    background: transparent;
    padding: 10px 0;
}

input[type=range]::-webkit-slider-runnable-track {
    width: 100%;
    height: 4px;
    background: #1a1a1a;
    border-radius: 2px;
}

input[type=range]::-webkit-slider-thumb {
    -webkit-appearance: none;
    height: 22px; /* Slightly larger for easier mobile tapping */
    width: 22px;
    border-radius: 50%;
    background: #ffffff;
    margin-top: -9px;
    cursor: pointer;
    box-shadow: 0 0 10px rgba(255,255,255,0.2);
}

/* Live Readouts */
.readout-panel {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-top: auto;
}

.readout-item {
    background: #0a0a0a;
    padding: 1rem;
    border-radius: 12px;
    border: 1px solid #1a1a1a;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.readout-item span:first-child {
    font-size: 0.8rem;
    color: #888888;
}

.formula {
    font-family: monospace;
    font-size: 0.9rem;
    color: #cccccc;
}

.value {
    font-size: 1.5rem;
    font-weight: 700;
    text-align: right;
}

.x-val { color: #3b82f6; } 
.y-val { color: #f59e0b; } 

/* --- Desktop Layout Overrides --- */
@media (min-width: 800px) {
    body {
        height: 100vh;
        overflow: hidden; /* Locks scrolling on desktop */
    }
    
    .sim-container {
        flex-direction: row; /* Switches to side-by-side */
        height: calc(100vh - 70px);
    }

    .canvas-wrapper {
        flex: 1; /* Takes up all remaining width */
        height: 100%;
        border-bottom: none;
    }

    .control-panel {
        width: 380px; /* Locks panel width */
        height: 100%;
        border-left: 1px solid #1a1a1a;
        overflow-y: auto;
        padding: 2.5rem 2rem;
    }

    .sim-title {
        font-size: 1rem;
    }
}
