html,
body {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: #020617;
    font-family: 'Outfit', sans-serif;
    overscroll-behavior: none;
    touch-action: none; /* Disable browser defaults for panning */
}

/* ----------------------------------------------------------------
   #phet-stage  — The fixed-size "design canvas"
   ---------------------------------------------------------------- */
#phet-stage {
    position: absolute;
    top: 0;
    left: 0;
    width: 1280px;
    height: 720px;
    background: #020617;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform-origin: 0 0; /* Updated for custom pan/zoom math */
    box-shadow: 0 0 50px rgba(0, 0, 0, 0.5);
    touch-action: none;
}

nav {
    position: relative !important;
    background: rgba(15, 23, 42, 0.95) !important;
    backdrop-filter: blur(20px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1) !important;
    height: 65px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 30px;
    flex-shrink: 0;
    z-index: 100;
}

.nav-links {
    display: flex;
    list-style: none;
    gap: 30px;
    margin: 0;
    padding: 0;
}

.nav-links a {
    text-decoration: none;
    color: #94a3b8;
    font-weight: 500;
    transition: color 0.2s;
}

.nav-links a:hover {
    color: #f8fafc;
}

#sim-app {
    display: flex;
    flex: 1;
    min-height: 0;
    overflow: hidden;
    width: 100%;
}

.sim-container {
    flex: 1;
    display: flex;
}

.canvas-panel {
    background: #0f172a;
    overflow: hidden;
    cursor: default;
}

#simCanvas {
    width: 100%;
    height: 100%;
    display: block;
}

@media (max-width: 1024px) {
    .control-panel {
        width: 180px;
        padding: 0.5rem;
    }
    .section-header {
        font-size: 0.55rem;
    }
    label {
        font-size: 0.7rem;
    }
}

.control-panel {
    width: 210px;
    /* Reduced width */
    background: rgba(30, 41, 59, 0.7);
    /* Slightly more transparent */
    backdrop-filter: blur(25px);
    -webkit-backdrop-filter: blur(25px);
    border-left: 1px solid rgba(255, 255, 255, 0.08);
    padding: 1rem;
    /* Compact padding */
    overflow-y: auto;
    z-index: 10;
    color: #f8fafc;
    box-shadow: -5px 0 25px rgba(0, 0, 0, 0.3);
    display: flex;
    flex-direction: column;
}

.phet-box {
    background: rgba(51, 65, 85, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 12px;
    /* Smaller rounding */
    padding: 0.85rem;
    /* Compact padding */
    margin-bottom: 0.85rem;
    /* Reduced margin */
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    transition: transform 0.2s ease, box-shadow 0.2s ease, border 0.2s ease;
}

.phet-box:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.15);
}

.section-header {
    font-size: 0.65rem;
    /* Smaller font */
    margin-bottom: 0.75rem;
    color: #10b981;
    text-transform: uppercase;
    letter-spacing: 1.2px;
    font-weight: 700;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    padding-bottom: 0.5rem;
}

.btn-primary {
    background: #10b981;
    border: none;
    color: white;
    cursor: pointer;
    font-family: inherit;
    font-weight: 600;
    box-shadow: 0 4px 15px rgba(16, 185, 129, 0.3);
    transition: all 0.2s ease;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(16, 185, 129, 0.4);
    background: #059669;
}

.stat-line {
    display: flex;
    align-items: center;
}

.stat-label {
    font-size: 0.75rem;
    color: #94a3b8;
    font-weight: 500;
    text-transform: uppercase;
    margin-right: auto;
}

.val-display {
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 700;
}

/* Controls */
label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.8rem;
    /* Smaller font */
    margin-bottom: 8px;
    color: #cbd5e1;
    cursor: pointer;
    transition: color 0.2s;
}

label:hover {
    color: #f8fafc;
}

input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    background: transparent;
    margin: 4px 0 12px;
    /* Super compact margin */
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    height: 14px;
    /* Smaller thumb */
    width: 14px;
    border-radius: 50%;
    background: #10b981;
    cursor: pointer;
    margin-top: -5px;
    box-shadow: 0 0 10px rgba(16, 185, 129, 0.5);
    border: 2px solid white;
    transition: transform 0.1s;
}

input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.15);
}

input[type="range"]::-webkit-slider-runnable-track {
    width: 100%;
    height: 4px;
    /* Thinner track */
    cursor: pointer;
    background: #475569;
    border-radius: 3px;
    border: 1px solid rgba(0, 0, 0, 0.5);
}

input[type="radio"],
input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: #10b981;
    cursor: pointer;
}

.checkbox-group {
    display: flex;
    flex-direction: column;
}