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%;
}

.mobile-back {
    position: absolute;
    top: 16px;
    left: 16px;
    width: 44px;
    height: 44px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.92);
    border: 1px solid rgba(0, 0, 0, 0.08);
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.12);
    color: #111;
    display: none;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    z-index: 25;
    -webkit-tap-highlight-color: transparent;
    transition: transform 0.2s, box-shadow 0.2s, background 0.2s;
}

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

.mobile-back:active {
    transform: scale(0.98);
}

.mobile-back svg {
    width: 22px;
    height: 22px;
}

/* 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;
}

.panel-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 36px;
    padding: 0 12px;
    border-radius: 10px;
    border: 1px solid rgba(0, 0, 0, 0.08);
    background: rgba(255, 255, 255, 0.95);
    color: #111;
    font-weight: 700;
    font-size: 13px;
    text-decoration: none;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.12);
    transition: transform 0.2s, box-shadow 0.2s;
}

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

.panel-link:active {
    transform: scale(0.98);
}

/* 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;
}

body.home-page .floating-card {
    position: absolute;
    top: 20px;
    left: 20px;
    width: 320px;
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border: 1px solid rgba(255, 255, 255, 0.6);
    border-radius: 16px;
    box-shadow:
        0 4px 6px -1px rgba(0, 0, 0, 0.05),
        0 12px 24px -4px rgba(0, 0, 0, 0.1),
        inset 0 0 0 1px rgba(255, 255, 255, 0.3);
    overflow: hidden;
    z-index: 100;
    transition: background 0.25s ease, transform 0.25s ease, box-shadow 0.25s ease;
    display: flex;
    flex-direction: column;
}

body.home-page .floating-card:hover {
    box-shadow:
        0 10px 15px -3px rgba(0, 0, 0, 0.08),
        0 20px 40px -4px rgba(0, 0, 0, 0.12),
        inset 0 0 0 1px rgba(255, 255, 255, 0.4);
    transform: translateY(-2px);
    background: rgba(255, 255, 255, 0.92);
}

body.home-page input[name="tabs"] {
    display: none;
}

body.home-page .tabs-header {
    display: flex;
    justify-content: space-around;
    align-items: center;
    background: rgba(0, 0, 0, 0.03);
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
    padding: 0;
    position: relative;
}

body.home-page .tab-btn {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 16px 0;
    cursor: pointer;
    color: #666;
    transition: color 0.2s ease, background 0.2s ease;
    position: relative;
    z-index: 2;
}

body.home-page .tab-btn:hover {
    color: #111;
    background: rgba(0, 0, 0, 0.02);
}

body.home-page .tab-btn svg {
    width: 20px;
    height: 20px;
    stroke-width: 2.5px;
}

body.home-page #tab-light:checked ~ .tabs-header label[for="tab-light"],
body.home-page #tab-materials:checked ~ .tabs-header label[for="tab-materials"],
body.home-page #tab-options:checked ~ .tabs-header label[for="tab-options"] {
    color: #007aff;
}

body.home-page .tab-indicator {
    position: absolute;
    bottom: 0;
    left: 0;
    height: 3px;
    width: 33.333%;
    background: #007aff;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border-radius: 3px 3px 0 0;
    z-index: 3;
}

body.home-page #tab-light:checked ~ .tabs-header .tab-indicator {
    transform: translateX(0%);
}

body.home-page #tab-materials:checked ~ .tabs-header .tab-indicator {
    transform: translateX(100%);
}

body.home-page #tab-options:checked ~ .tabs-header .tab-indicator {
    transform: translateX(200%);
}

body.home-page .tabs-content {
    position: relative;
    min-height: 260px;
}

body.home-page .content-section {
    display: none;
    padding: 20px;
    animation: homeFadeIn 0.18s ease-out;
}

@keyframes homeFadeIn {
    from { opacity: 0; transform: translateY(4px); }
    to { opacity: 1; transform: translateY(0); }
}

body.home-page #tab-light:checked ~ .tabs-content .section-light {
    display: block;
}

body.home-page #tab-materials:checked ~ .tabs-content .section-materials {
    display: block;
}

body.home-page #tab-options:checked ~ .tabs-content .section-options {
    display: block;
}

body.home-page .section-title {
    font-size: 14px;
    font-weight: 700;
    color: #1a1a1a;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 16px;
    padding-bottom: 8px;
    border-bottom: 1px solid rgba(0,0,0,0.06);
}

body.home-page .floating-card .control-group label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #666;
    margin-bottom: 8px;
}

body.home-page .floating-card .control-group label:has(input[type="checkbox"]),
body.home-page .floating-card .control-group label:has(input[type="radio"]) {
    display: flex;
    align-items: center;
    cursor: pointer;
    text-transform: none;
    font-size: 14px;
    font-weight: 500;
    color: #333;
    padding: 6px 0;
    margin-bottom: 0;
    transition: opacity 0.2s;
}

body.home-page .floating-card .control-group label:has(input[type="checkbox"]):hover,
body.home-page .floating-card .control-group label:has(input[type="radio"]):hover {
    opacity: 0.85;
}

body.home-page .home-links {
    display: flex;
    gap: 10px;
}

body.home-page .home-divider {
    border: 0;
    border-top: 1px solid rgba(0,0,0,0.12);
    margin: 12px 0;
}

/* Responsive - Mobile Zoom Out Effect */
@media (max-width: 768px) {
    body.home-page .floating-card {
        top: auto;
        left: 0;
        bottom: 0;
        width: 100%;
        border-radius: 20px 20px 0 0;
        border: none;
        border-top: 1px solid rgba(255,255,255,0.6);
        box-shadow: 0 -4px 20px rgba(0,0,0,0.1);
        max-height: 38vh;
        overflow-y: auto;
        transform: none;
    }

    body.home-page .floating-card:hover {
        transform: none;
    }

    body.home-page .tab-btn {
        padding: 14px 0;
    }

    /* 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;
    }

    .mobile-back {
        display: inline-flex;
    }

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