body, html {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    font-family: 'Inter', 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    user-select: none;
    background-color: #f5f5f7;
    color: #333;
}

#simulation-container {
    position: relative;
    width: 100%;
    height: 100%;
    background-color: #f0f0f0;
}

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

/* Modern Panel Style */
.panel {
    position: absolute;
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    padding: 20px;
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.08);
    font-size: 14px;
    border: 1px solid rgba(255, 255, 255, 0.4);
    z-index: 10;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.panel:hover {
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.12);
}

.top-left-panel {
    top: 20px;
    left: 20px;
    width: 240px;
}

.right-panel {
    top: 50%;
    right: 20px;
    left: auto;
    transform: translateY(-50%);
    width: 300px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.right-panel.materials-collapsed {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.materials-close {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    border: 1px solid rgba(0, 0, 0, 0.08);
    background: rgba(255, 255, 255, 0.95);
    color: #111;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 1;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.12);
    transition: transform 0.2s, box-shadow 0.2s;
}

.materials-close:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 24px rgba(0, 0, 0, 0.16);
}

.materials-close:active {
    transform: scale(0.98);
}

.bottom-left-panel {
    bottom: 20px;
    left: 20px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 15px;
}

/* Material Controls */
.material-box {
    background: rgba(255, 255, 255, 0.5);
    padding: 15px;
    border-radius: 12px;
    border: 1px solid rgba(0,0,0,0.05);
}

.material-box h3 {
    margin: 0 0 12px 0;
    font-size: 15px;
    font-weight: 600;
    color: #1a1a1a;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

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

.control-group label {
    display: block;
    margin-bottom: 6px;
    font-weight: 500;
    color: #555;
    font-size: 13px;
}

/* Custom Select */
select {
    width: 100%;
    padding: 8px 12px;
    border-radius: 8px;
    border: 1px solid #ddd;
    background-color: #fff;
    font-family: inherit;
    font-size: 14px;
    outline: none;
    cursor: pointer;
    transition: border-color 0.2s;
    appearance: none;
    background-image: url("data:image/svg+xml;charset=US-ASCII,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%22292.4%22%20height%3D%22292.4%22%3E%3Cpath%20fill%3D%22%23333%22%20d%3D%22M287%2069.4a17.6%2017.6%200%200%200-13-5.4H18.4c-5%200-9.3%201.8-12.9%205.4A17.6%2017.6%200%200%200%200%2082.2c0%205%201.8%209.3%205.4%2012.9l128%20127.9c3.6%203.6%207.8%205.4%2012.8%205.4s9.2-1.8%2012.8-5.4L287%2095c3.5-3.5%205.4-7.8%205.4-12.8%200-5-1.9-9.2-5.5-12.8z%22%2F%3E%3C%2Fsvg%3E");
    background-repeat: no-repeat;
    background-position: right 12px top 50%;
    background-size: 10px auto;
}

select:focus {
    border-color: #007aff;
    box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.1);
}

/* Custom Sliders */
.input-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

input[type="range"] {
    -webkit-appearance: none;
    width: 100%;
    height: 6px;
    background: #e0e0e0;
    border-radius: 3px;
    outline: none;
    transition: background 0.2s;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    background: #fff;
    border: 2px solid #007aff;
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    transition: transform 0.1s;
}

input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.1);
}

input[type="range"]:active::-webkit-slider-thumb {
    background: #007aff;
}

input[type="number"] {
    width: 65px;
    padding: 6px;
    border: 1px solid #ddd;
    border-radius: 6px;
    text-align: center;
    font-family: inherit;
    font-weight: 500;
}

input[type="number"]:focus {
    border-color: #007aff;
    outline: none;
}

/* Color Slider Special */
.color-slider {
    background: linear-gradient(to right, #9400D3, #4B0082, #0000FF, #00FF00, #FFFF00, #FF7F00, #FF0000) !important;
    height: 8px !important;
}

.color-slider::-webkit-slider-thumb {
    border-color: #333 !important;
    width: 20px !important;
    height: 20px !important;
    background: transparent !important;
    border: 3px solid #fff !important;
    box-shadow: 0 0 0 1px rgba(0,0,0,0.5) !important;
}

/* Checkboxes */
.panel label input[type="checkbox"], 
.panel label input[type="radio"] {
    margin-right: 8px;
    accent-color: #007aff;
    transform: scale(1.1);
}

.panel label {
    cursor: pointer;
    display: flex;
    align-items: center;
}

/* FAB Reset Button */
.fab-btn {
    position: absolute;
    bottom: 30px;
    right: 30px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: #007aff;
    color: white;
    border: none;
    font-size: 24px;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(0, 122, 255, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 20;
    transition: transform 0.2s, background 0.2s, box-shadow 0.2s;
}

.fab-btn:hover {
    background: #0066d6;
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 122, 255, 0.5);
}

.fab-btn:active {
    transform: scale(0.95);
}

.materials-toggle {
    position: absolute;
    top: 20px;
    right: 20px;
    height: 40px;
    padding: 0 14px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid rgba(0, 0, 0, 0.08);
    color: #111;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    z-index: 20;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.12);
    transition: transform 0.2s, box-shadow 0.2s, background 0.2s;
}

.materials-toggle[hidden] {
    display: none;
}

.materials-toggle:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 24px rgba(0, 0, 0, 0.16);
}

.materials-toggle:active {
    transform: scale(0.98);
}

.materials-toggle__icon {
    width: 24px;
    height: 24px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: #007aff;
    color: #fff;
    font-size: 16px;
    line-height: 1;
}

.materials-toggle__text {
    font-size: 14px;
    font-weight: 600;
    letter-spacing: 0.2px;
}

.install-prompt {
    position: fixed;
    inset: 0;
    display: grid;
    place-items: center;
    background: rgba(0, 0, 0, 0.35);
    z-index: 50;
    padding: 16px;
}

.install-prompt[hidden] {
    display: none;
}

.install-prompt__content {
    width: min(360px, 100%);
    background: rgba(255, 255, 255, 0.92);
    border: 1px solid rgba(255, 255, 255, 0.5);
    border-radius: 18px;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    box-shadow: 0 18px 55px rgba(0, 0, 0, 0.18);
    padding: 18px;
}

.install-prompt__title {
    font-size: 16px;
    font-weight: 700;
    color: #111;
    margin-bottom: 14px;
}

.install-prompt__actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

.install-prompt__primary,
.install-prompt__secondary {
    height: 38px;
    padding: 0 14px;
    border-radius: 10px;
    border: none;
    cursor: pointer;
    font-weight: 600;
    font-size: 14px;
}

.install-prompt__primary {
    background: #007aff;
    color: #fff;
}

.install-prompt__secondary {
    background: rgba(0, 0, 0, 0.08);
    color: #111;
}

/* Responsive - Mobile Zoom Out Effect */
@media (max-width: 768px) {
    /* Scale down panels to simulate "Zoom Out" and clear up space */
    .top-left-panel {
        transform: scale(0.75);
        transform-origin: top left;
        top: 10px;
        left: 10px;
        width: 240px; /* Keep original width, let scale reduce it */
    }

    .right-panel {
        top: auto;
        bottom: 5px;
        right: 5px;
        left: auto;
        transform: scale(0.75);
        transform-origin: bottom right;
        width: 280px;
    }

    .materials-toggle {
        top: auto;
        right: 10px;
        bottom: 10px;
        transform-origin: bottom right;
    }

    .bottom-left-panel {
        transform: scale(0.75);
        transform-origin: bottom left;
        bottom: 5px;
        left: 5px;
    }

    .fab-btn {
        transform: scale(0.8);
        transform-origin: top left;
        top: 15px;
        left: 200px;
        bottom: auto;
        right: auto;
    }

    /* Adjust font readability if needed */
    .panel {
        font-weight: 500; /* Slightly bolder to compensate for size */
    }
}
