body { 
    margin: 0; 
    background: #333; 
    font-family: sans-serif; 
    display: flex; 
    height: 100dvh; 
    overflow: hidden; 
}
#container { 
    flex-grow: 1; 
    height: 100%; 
    position: relative; 
    overflow: hidden;
    display: flex; 
    flex-direction: row; 
}
#hud { 
    position: relative;
    background: #2a2a2a;
    border-right: 1px solid #444;
    flex-shrink: 0; 
    width: 220px; 
    height: 100%;
    z-index: 10;
}
#three-container {
    flex-grow: 1;
    position: relative;
    overflow: hidden;
    width: 100%;
    background: #333;
}
#three-canvas {
    display: block;
    width: 100%;
    height: 100%;
    outline: none;
}
#controls {
    width: 340px; 
    height: 100%; 
    background: #222; 
    border-left: 1px solid #444;
    padding: 20px; 
    box-sizing: border-box; 
    display: flex; 
    flex-direction: column;
    gap: 15px; 
    overflow-y: auto; 
    color: #eee;
    flex-shrink: 0;
    z-index: 20;
    padding-bottom: max(20px, env(safe-area-inset-bottom));
}
h2 { 
    margin: 0 0 10px 0; 
    font-size: 18px; 
    color: #fff; 
    border-bottom: 1px solid #555; 
    padding-bottom: 5px; 
}
.control-group { 
    display: flex; 
    flex-direction: column; 
    gap: 8px; 
    margin-bottom: 10px; 
}
.btn-row { 
    display: flex; 
    gap: 8px; 
    width: 100%; 
}
.label { 
    font-size: 12px; 
    color: #aaa; 
    font-weight: bold; 
}
hr { 
    width: 100%; 
    border: 0; 
    border-top: 1px solid #444; 
    margin: 5px 0; 
}
button {
    padding: 8px; 
    cursor: pointer; 
    background: #555; 
    color: white;
    border: 1px solid #777; 
    border-radius: 4px; 
    flex: 1; 
    font-size: 13px;
    transition: background 0.2s;
}
button:hover { background: #777; }
button:disabled { background: #333; color: #666; cursor: not-allowed; border-color: #444; }
button.apply { background: #4466aa; border-color: #5577cc; }
button.apply:hover { background: #5577cc; }
button.primary { background: #448844; border-color: #55aa55; }
button.primary:hover { background: #55aa55; }
button.stop { background: #aa5544; border-color: #cc7755; }
button.stop:hover { background: #cc7755; }
button.red { background: #884444; border-color: #aa5555; }
button.red:hover { background: #aa5555; }
input[type="text"], textarea {
    padding: 8px; 
    border-radius: 4px; 
    border: 1px solid #555;
    background: #111; 
    color: #fff; 
    width: 100%; 
    box-sizing: border-box; 
    font-family: monospace;
}
input[type="text"]:focus, textarea:focus { outline: none; border-color: #888; }
textarea { resize: vertical; min-height: 80px; line-height: 1.4; }
.blocked { animation: shake 0.3s; background-color: #aa4444 !important; }
@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25%, 75% { transform: translateX(-5px); }
    50% { transform: translateX(5px); }
}
@media (max-width: 768px) and (orientation: portrait) {
    body { flex-direction: column; }
    #container {
        width: 100%;
        height: 60%; 
        flex-direction: column; 
        border-bottom: 1px solid #444;
    }
    #hud { 
        width: 100%;
        height: 120px; 
        border-right: none;
        border-bottom: 1px solid #444;
    }
    #three-container {
        width: 100%;
        flex-grow: 1; 
    }
    #controls {
        width: 100%;
        height: 40%; 
        border-left: none;
        border-top: 1px solid #444;
        padding: 10px 15px;
        padding-bottom: max(20px, env(safe-area-inset-bottom) + 10px);
    }
    h2 { font-size: 16px; margin-bottom: 5px; }
    button { padding: 12px; font-size: 14px; }
    .control-group { gap: 5px; margin-bottom: 5px; }
    textarea { min-height: 60px; }
}
@media (max-width: 900px) and (orientation: landscape) {
    #controls { width: 280px; padding: 10px; }
    button { font-size: 11px; padding: 6px; }
    h2 { font-size: 16px; }
    #hud { width: 180px; }
}